file listing
Posted: Sun Oct 22, 2006 10:50 am
hi all,
i'm trying to implement a simple "ls" command in my real mode os ( it should print the filenames without dot extension, only the first 8 chars). but when i type in ls, i see my floppy drive working, then an empty line gets printed and after that my command line appears again.
heres my code for loading and (trying) to print a list of files in the root dir (its all FAT12)
and here are my vars used
i'm not sure if im doing the correct things .. pointed si to 0x7C0:500 (where i hope i loaded my root dir correctly )
Thank you for your time
joke
i'm trying to implement a simple "ls" command in my real mode os ( it should print the filenames without dot extension, only the first 8 chars). but when i type in ls, i see my floppy drive working, then an empty line gets printed and after that my command line appears again.
heres my code for loading and (trying) to print a list of files in the root dir (its all FAT12)
Code: Select all
fat_read:
xor cx,cx
xor dx,dx
mov ax,0x0020
mul word [Frootent]
div word [Fbps]
mov cx,ax
xor ax,ax
mov al, byte [Ffats]
mul word [Fspfat]
inc ax
mov word [datasect],ax
call read_root
call write_root
ret
read_root:
cmp cx,0
je finished_reading
push ax
push bx
push cx
call lbachs
mov ah,0x02
mov al,0x01
mov ch,byte [ABStrack]
mov cl,byte [ABSsector]
mov dh,byte [ABShead]
xor dl,dl
mov bx,0x500
int 13h
pop cx
pop bx
pop ax
dec cx
jmp read_root
finished_reading:
ret
write_root:
mov ax, 0xE0
mov bx,0x500
mov si,[es:bx]
mov cx,8
printloop:
push ax
mov ax,0E0Ah
int 10h
xor ax,ax
call printing
pop ax
dec ax
cmp ax,0
je finished_write
jmp printloop
finished_file:
push ax
mov ax,0E0Ah
int 10h
pop ax
cmp ax,0
je finished_write
dec ax
mov cx,8
add si,0x20
jmp printloop
finished_write:
jmp mainloop
lbachs:
xor dx,dx
div word [Fspt]
inc dl
mov byte [ABSsector],dl
xor dx,dx
div word [Fheads]
mov byte [ABShead],dl
mov byte [ABStrack],al
ret
printing:
lodsb
cmp cx,0
je fileprintover
cmp al,0x00
je mainloop
mov ah,0Eh
mov bh,0Fh
xor bl,bl
int 10h
jmp printing
fileprintover:
ret
Code: Select all
Fbps dw 0x200
Fspc db 0x01
Freserved db 0x01
Ffats db 0x02
Frootent dw 0x00E0
Ftotalsec dw 0x0B40
Fspfat dw 0x0009
Fspt dw 0x0012
Fheads dw 0x0002
drive db 0
ABStrack db 0
ABShead db 0
ABSsector db 0
datasect dw 0
Thank you for your time
joke