Coordinate structure
A program demonstrating the use of a POINT structure with coordinates for storing and printing coordinate data.
Program source code
title .model small .stack 100h POINT struc aValue dw ? bValue dw ? cValue dw ? POINT ends data segment public points POINT <> fmtout db "A: [%d]\nB: [%d]\nC: [%d]\n\0" data ends code segment public ; Start of the code segment assume ds:data, cs:code include Handyfar.inc ; Include the file with functions main proc ; Start of the main procedure call SetDataSegment ; Call the SetDataSegment procedure lea si, ds:[points] ; Load the address of the points variable into the si register mov word ptr[si].aValue, 22 ; Copy the value 22 into the aValue field of the points structure mov word ptr[si].bValue, 33 ; Copy the value 33 into the bValue field of the points structure mov word ptr[si].cValue, 44 ; Copy the value 44 into the cValue field of the points structure push word ptr[si].cValue ; 4th: save the cValue variable value on the stack push word ptr[si].bValue ; 3rd: save the bValue variable value on the stack push word ptr[si].aValue ; 2nd: save the aValue variable value on the stack lea ax, ds:[fmtout] ; 1st: load the address of the fmtout format string into ax call PrintFormatString ; Call the PrintFormatString procedure add sp, 6 ; Align the stack xor al, al ; Clear the al register call ExitProcess ; Call the ExitProcess procedure main endp ; End of the main procedure code ends ; End of the code segment end main ; End of file. The main procedure is the entry point
A: [22]
B: [33]
C: [44]
Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".