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.
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 ...
Well, my plan was to get the output sorted, and then have some simple input to stop when any key is pressed :)
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