RosettaCodeData/Task/Enumerations/8086-Assembly/enumerations-2.8086

14 lines
573 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
mov ax,seg DaysOfTheWeek
mov ds,ax
mov si,offset DaysOfTheWeek
mov bx,2 ;desired enumeration of 2 = Tuesday
add bx,bx ;double bx since this is a table of words
mov ax,[bx+si] ;load the address of the string "Tuesday" into ax
mov si,ax ;we can't load indirectly from AX, so move it into SI. We don't need the old value of SI anymore
mov al,[si] ;load the byte at [SI] (in this case, the "T" in Tuesday.)
ret
DaysOfTheWeek word Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday
;each is a pointer to a string containing the text you would expect.