News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Console output

Started by AzraelUK, April 09, 2008, 04:37:07 PM

Previous topic - Next topic

AzraelUK

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.

BogdanOntanu

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 ...
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

AzraelUK

Well, my plan was to get the output sorted, and then have some simple input to stop when any key is pressed :)

herge

 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


// Herge born  Brussels, Belgium May 22, 1907
// Died March 3, 1983
// Cartoonist of Tintin and Snowy