I am writing a program in x86 assembly for FreeDOS. I am trying to stick with 16 bit registers so it will work on older hardware.
The program will create a framed box on the screen and I am pushing a structure with the values for the box on the stack to a routine. I would like to know if I can store this stack value in a label. I am currently using si and that works fine but if I can not use si then I have use for other things. I know I can push it onto the stack to save it but if I don't have to the would be great.
I have the following structure defined.
struc BOX_FRAME
.TopX: resb 1
.TopY: resb 1
.BottomX: resb 1
.BottomY: resb 1
.Color: resb 1
endstruc
and this label defined in my data section
section data
window:
istruc BOX_FRAME
at BOX_FRAME.TopX, db 0
at BOX_FRAME.TopY, db 0
at BOX_FRAME.BottomX, db 0
at BOX_FRAME.BottomY, db 0
at BOX_FRAME.Color, db 0
iend
I am passing this on the stack using this
mov ax, data
mov ds, ax
mov [window+BOX_FRAME.TopX], byte 4
mov [window+BOX_FRAME.TopY], byte 4
mov [window+BOX_FRAME.BottomX], byte 25
mov [window+BOX_FRAME.BottomY], byte 10
mov [window+BOX_FRAME.Color], byte COLOR_YELLOW
or [window+BOX_FRAME.Color], byte COLOR_BLUE
push window
call drawWindow
in drawWindow I have this
drawWindow:
.init:
push bp
mov bp, sp
mov si, word [bp+4]
I have the following single-line macros defined
%define x1 byte [si+BOX_FRAME.TopX]
%define y1 byte [si+BOX_FRAME.TopY]
%define x2 byte [si+BOX_FRAME.BottomX]
%define y2 byte [si+BOX_FRAME.BottomY]
%define color byte [si+BOX_FRAME.Color]
Here is an example of how the single-line macros are used.
mdraw_corner x1, y1, BORDER_TOPLEFT
mdraw_corner is a multi-line macro
Using si works just fine but I am wondering if I can use a label instead. if so, how would I use it to address a value in the structure.
For example If I have a label defined
section bss
.draw_struct resw 1
I am attaching what it currently looks like when it runs, for your enjoyment and aww.
thanks much,
Tyson