The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: AzraelUK on April 09, 2008, 04:37:07 PM

Title: Console output
Post by: AzraelUK on April 09, 2008, 04:37:07 PM
How does one go about outputting data to the console?

I've just written my first programming in MASM assembly language. Here it is:
.386
.model flat, stdcall
.code
start:
    mov eax, 1
    mov ebx, 1
fib:
    mov ecx, eax
    mov eax, ebx
    add ecx, ebx
    jmp fib
end start


There's probably some crazy crazy bitwise way of speeding this up, but I think I'll leave that to the pros :wink.

So, how would I output the number? Preferably, I'd be able to add a \r at the end, to stop console spam.
Title: Re: Console output
Post by: BogdanOntanu on April 09, 2008, 05:06:30 PM
Check this:

http://www.masm32.com/board/index.php?topic=9020.msg65380#msg65380

You will also need to convert your numbers to strings first before performing string output.

MASM32 package has a series of function for this conversion but it is also a good exercise for the student to make a number to ASCII conversion routine.

However your program is incorrect because it will never stop ...
Title: Re: Console output
Post by: AzraelUK on April 09, 2008, 05:20:19 PM
Well, my plan was to get the output sorted, and then have some simple input to stop when any key is pressed :)
Title: Re: Console output
Post by: herge on April 09, 2008, 07:18:40 PM
 Hi AzraelUK:

Try the inkey macro.

; INKEY.ASM 3:08 PM 4/9/2008

    include \masm32\include\masm32rt.inc
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start