Search code examples
assemblyx86masm32

x86 assembly- Simple arithmetic program not working, MASM32 on xp


I have a simple program that adds 1+1 until it reaches a million, and then it prints "Done!" to the console. But when it runs, it does nothing. Here is the code:

.386
.model flat, stdcall
option casemap :none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
.data
          main dd 0
          msg  db "Done!", 0
.code      
start:      
_loop:    mov eax, 1 
          mov main, eax
          cmp main, 1000000
          jz _next
          jmp _loop
_next:    invoke StdOut, addr msg
          invoke ExitProcess, 0
end start

It doesn't do anything when I run it. I don't see why. I currently run it through cmd, by clicking and dragging it to the prompt and pressing enter. And also, is MASM32 the easiest assembler to learn, or are there better and easier ones out there? If so, could someone post the ones that are better? Thanks. I just need somewhere to start learning x86 assembly.

Thanks in advance,

Progrmr


Solution

  • Your program doesn't increment anything. You probably want an add instruction in there somewhere.