I'm trying to display an array using Borland Turbo Assembler 5 (similar to MASM syntax as far as I know) for MS-DOS, the first string prints but remaining ones don't. Any advice on best way to accomplish this with 8086 compatible MS-DOS assembly?
; TEST.COM:
stdin equ 0 ; standard input handle
stdout equ 1 ; standard output handle
stderr equ 2 ; standard error handle
cr equ 0dh ; ASCII carriage return
lf equ 0ah ; ASCII linefeed
escape equ 1Bh ; escape
fg_black equ escape,'[30m'
fg_red equ escape,'[31m'
_TEXT segment word public 'CODE'
org 100h
assume cs:_TEXT,ds:_TEXT,es:_TEXT,ss:_TEXT
main proc near
mov bx,dir_array
mov ah,9
dirloop:
lea dx,[bx]
int 21h
add bx,2
cmp bx,offset dir_array+dir_array_size
jl dirloop
mov ax,4C00h
int 21h
main endp
msg1 db cr,lf
db 'DOS FindFirst API Test',cr,lf
dir_array dw dos_dir,int21_3E_dir,test_dir1,test_dir2,test_dir3
end1 db '$'
dir_array_size equ $-dir_array
end2 db '$'
dos_dir db 'C:\DOS',cr,lf,'$'
int21_3E_dir db "C:\DOS\INT21_3E",cr,lf,'$'
test_dir1 db "C:\DOS\INT21_3E\TEST1",cr,lf,'$'
test_dir2 db "C:\DOS\INT21_3E\TEST2",cr,lf,'$'
test_dir3 db "C:\DOS\INT21_3E\TEST3",cr,lf,'$'
test_file1 db "C:\DOS\INT21_3E\ARC.TXT",0
test_file2 db "C:\DOS\INT21_3E\RONLY.TXT",0
test_file3 db "C:\DOS\INT21_3E\SYSTEM.TXT",0
test_file4 db "C:\DOS\INT21_3E\HIDDEN.TXT",0
msg1_len equ $-msg1
_TEXT ends
end main
Checking with turbo debugger I can see "bx" is being assigned the value dos_dir but I was hoping it would specify the address of dir_array.
The first string is at 13E:
Output:



[bx]you're reading from beyond the end of your array, and you exit the loop before reading the first element in the array.