Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .stack 256
- .data
- str1 db 'Shirt$'
- str2 db 'Pants$'
- str3 db 'Socks$'
- strarray dw offset str1, offset str2, offset str3
- .code
- start:
- ; Setup the DS register to point at .data
- mov ax, @data
- mov ds, ax
- ; TYPE operator returns the size of an element in strarray.
- ; 2 in this case since we defined strarray with elements
- ; of type word (DW)
- ; Get the pointer stored in 3rd element of strarray to DX
- mov dx, strarray[2*(TYPE strarray)]
- ; Print the string using DOS function call
- mov ah, 9h
- int 21h
- ; ALternatively you can access the array element through
- ; a register like BX, SI, DI
- ; Get the offset of the 2nd element into BX
- mov bx, 1*(TYPE strarray)
- ; Get the pointer stored in 2nd element of strarray to DX
- mov dx, strarray[bx]
- ; Print the string using DOS function call
- mov ah, 9h
- int 21h
- ; Exit program
- mov ax, 4C00h
- int 21h
- end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement