Slide 4.7: INCLUDE directive
Slide 4.9: Instructions
Home

.CODE, .DATA, .STACK, and PROC Directives


Assembly programs are organized around segments, which are usually named code, data, and stack: The code segment contains one or more procedures, with one designated as the startup procedure. PROC identifies the beginning of a procedure, e.g.,
   main PROC
where the procedure name is main, which is also the startup procedure.



WriteString (textbook page 124)
It writes a null-terminated string to standard output. When calling it, place the string's offset in EDX register. The hexadecimal bytes 0Dh and 0Ah are end-of-line characters.

.data book BYTE "MASM Assembler", 0 .code mov edx, OFFSET book call WriteString


.data hexVal DWORD ? .code call ReadHex mov hexVal, eax
ReadHex (textbook page 121)
It reads a 32-bit hexadecimal integer from standard input, terminated by the Enter key, and returns the value in EAX register.

WriteHex (textbook pages 123 – 124)
It writes a 32-bit unsigned integer to standard output in 8-digit hexadecimal format. Leading zeros are inserted if necessary. Before calling it, place the integer in EAX register.

.data X DWORD 50000h .code mov eax, X call WriteHex