Thanks. Bill S.
Code: Select all
;dsecs.asm nasm -f bin dsecs.asm -o dsecs.bin
bits 16
org 0x7C00 ; add 0x7C00 to label addresses
mov ax, 0 ; set up segments
mov ds, ax
mov es, ax
mov ss, ax ; setup stack
mov sp, 0x7C00 ; stack grows downwards from 0x7C00
mov ah,0x15
mov dl,0x80 ;bit 7 = hd
int 0x13 ;returns #sectors in cx:dx
push dx
mov dx,cx ;operate on cx as dx
xor cx,cx ;cx counts to 1
mov bx,i2xt ;point to table
getcxdx:
rol dx,4 ;put hi hex digit on r. side
and dl,0x0f ;get digit, put it in al
mov al,dl ;index into table
xlat ;table result in al
mov ah,0xe
int 0x10 ;write
rol dx,4 ;put next hex digit on r. side
and dl,0x0f
mov al,dl ;index into table
xlat ;table result in al
mov ah,0xe
int 0x10 ;write
rol dx,4 ;put next hex digit on r. side
and dl,0x0f ;get digit
mov al,dl ;index into table
xlat ;table result in al
mov ah,0xe
int 0x10 ;write
rol dl,4 ;put next hex digit on r. side
and dl,0x0f
mov al,dl ;index into table
xlat ;table result in al
mov ah,0xe
int 0x10 ;write
cmp cx,0
jne crlf
inc cx
pop dx
jmp getcxdx
crlf:
mov al,0xd ;go to left end
mov ah,0xe ;
int 0x10 ;write
mov al,0xa ;go to next line
mov ah,0xe ;
int 0x10 ;write
i2xt db '0123456789ABCDEF'