News:

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

Explanation of a Program for a noob

Started by Ajax, May 09, 2007, 09:32:34 PM

Previous topic - Next topic

Ajax

hi im  a new member and was wondering if anyone can expalin to me what the program parts do to me.  I know that what it does, I just need help on knowing what each part is. 

include \masm32\include\masm32rt.inc

.data
    var dd 65

.code


start:

main proc

mov eax, var
print str$(eax)," is the original number",13,10

mov edx,10
add var,edx
print str$(edx)," is added to it",13,10

mov eax, var
print str$(eax)," is the final number.",13,10,13,10

ret

main endp

end start

hutch--

Try this commented version of your test piece.


; include all of the normal masm32 include file and libraries

include \masm32\include\masm32rt.inc

.data
    var dd 65   ; initialised 32 bit variable

.code           ; begin the code section


start:          ; starting label and code entry point

main proc       ; start of simple procedure

mov eax, var    ; copy content of "var" into EAX register

; display EAX to the console.

print str$(eax)," is the original number",13,10

mov edx,10      ; copy the immediate 10 into register EDX
add var,edx     ; add EDX to var

; display EDX to the console

print str$(edx)," is added to it",13,10

mov eax, var    ; copy content of "var" into EAX register again

; display EAX to the console again.

print str$(eax)," is the final number.",13,10,13,10

;; ret          ; incorrectly used RETURN, terminate an EXE with ExitProcess

exit            ; macro that uses ExitProcess.

main endp

end start
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Ajax

Thanks that really helped me alot but what does the 10 and 13 mean at the end of the strings.

hutch--

The ascii characters for a carrage return (13) and the line feed (10).
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dsouza123

13,10

Ascii characters 13 and 10 are Carriage Return and Line feed
two characters that end a line of text in Windows (also in DOS).

They cause the next thing to be printed to be at the start of the next line.

In hexadecimal they are 0Dh,0Ah.