The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Ajax on May 09, 2007, 09:32:34 PM

Title: Explanation of a Program for a noob
Post by: Ajax on May 09, 2007, 09:32:34 PM
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
Title: Re: Explanation of a Program for a noob
Post by: hutch-- on May 09, 2007, 11:25:56 PM
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
Title: Re: Explanation of a Program for a noob
Post by: Ajax on May 10, 2007, 12:28:23 AM
Thanks that really helped me alot but what does the 10 and 13 mean at the end of the strings.
Title: Re: Explanation of a Program for a noob
Post by: hutch-- on May 10, 2007, 01:00:47 AM
The ascii characters for a carrage return (13) and the line feed (10).
Title: Re: Explanation of a Program for a noob
Post by: dsouza123 on May 10, 2007, 01:05:19 AM
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.