Issues with general purpose registers
Hey everyone! I've wrote a simple Assembly script to print a list of numbers from 0-6 in the console. But once I'm still learning to use the language, for a better practice, I focused on using nothing but registers to hold data, using the eax register as the list range, and the ebx register as an indexer. Such usage seemed to be ok to me. But after assembling and linking the code, I tried to run the .exe file and got a totally different output. Here's the source-code: main PROC LOCAL n:DWORD mov eax, 6 ; Works if eax is replaced for the "n" variable mov ebx, 0 COMPARE: cmp ebx, eax ; Works if eax is replaced for the "n" variable jl FNC jg BREAK FNC: print str$(ebx) print chr$(13, 10) jmp INCECX INCECX: inc ebx jmp COMPARE BREAK: ret main ENDP The logically expected output was: 0 1 2 3 4 5 6 But instead the code is generating multiple different outputs: - Using eax as indexer: - Output: 0 1 2 - Using ecx as indexer - Output: 0 - Using edx as indexer - Output: 0 1 2 3 4 5 6 7 8 ... and so on As much as my knowledge allows me to assume, these registers are for general purpose, so I find a lot strage that these aren't holding values correctlly. I'm using MASM v6.14.8444 and MASM Incremental Linker v5.12.8078 I'd be thankful if you could help me on this. Thanks.