; Sample Standalone program
; RETURN BIOS DISK PARAMETER TABLE ADDRESS
; ¸ ERDOGAN TAN (29/12/2000)

;ÄÄÄÄÄÄÄÄÄÄ CODE_SEG_1  ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

CODE_SEG_1	segment para public
		assume  CS:CODE_SEG_1, DS:CODE_SEG_1, SS:CODE_SEG_1, ES:CODE_SEG_1

		org	100h

proc_start	proc	far

start:
                push cs
                pop ds

repeat_dparam_read:
                mov si, offset Press_Any_Key
                call proc_print_msg

                xor ah, ah              ; "Press any key to continue"
                int 16h

                call proc_clear_screen

                mov si, offset Drive_No
                mov cx, 4
get_bios_dpt_address:
                mov dl, byte ptr [SI]
                mov al, dl
                call proc_hex
                mov word ptr [Str_Drive_No], ax

                push si
                push cx

                mov ah, 8
                int 13h
                jnc short pass_dparam_error_msg

                mov al, ah
                call proc_hex
                mov word ptr [Register_AX], ax
                mov si, offset Error_Msg
                call proc_print_msg

                jmp short pass_print_dpt_address

pass_dparam_error_msg:
                mov ax, di
                push ax
                xchg ah, al
                call proc_hex
                mov word ptr [DPT_Offset], ax
                pop ax
                call proc_hex
                mov word ptr [DPT_Offset]+2, ax

                mov ax, es
                push ax
                xchg ah, al
                call proc_hex
                mov word ptr [DPT_Segment], ax
                pop ax
                call proc_hex
                mov word ptr [DPT_Segment]+2, ax

                mov si, offset DPT_Info
                call proc_print_msg

                mov si, offset Press_Any_Key
                call proc_print_msg

pass_print_dpt_address:

                xor ah, ah              ; "Press any key to continue"
                int 16h

                call proc_clear_screen

                pop cx
                pop si
                inc si
                loop get_bios_dpt_address

                int 20h

proc_clear_screen:
                mov ah, 0Fh 
                int 10h
                mov ah, 0
                int 10h

                retn

proc_hex:
               db 0D4h, 10h             ; AAM 
                                        ; output : AH = AL / 10h
                                        ;          AL = AL mod 10h
               or ax, '00'

               xchg ah, al

               cmp al, '9'
               jna short pass_cc_al
               add al, 7
pass_cc_al:
               cmp ah, '9'
               jna short end_of_proc_hex
               add ah, 7
end_of_proc_hex:
               retn

proc_print_msg  proc near

loc_print:
                lodsb                           ; Load byte at DS:SI to AL
		and     AL,AL            
                je      short end_of_print      ; If AL = 00h then return
		mov     AH,0Eh                  
		mov     BX,07h             
                int     10h                     
		jmp     short loc_print           
end_of_print:
                retn

proc_print_msg  endp

DPT_Info:
                db 7
                db "BIOS DISK PARAMETER TABLE of Drive: "
Str_Drive_No:   dw 3030
                db 'h'
                db 0Dh, 0Ah, 0Dh, 0Ah
                db 'Segment : '
DPT_Segment:    dd 30303030h
                db 'h'
                db 0Dh, 0Ah
                db 'Offset  : '
DPT_Offset:     dd 30303030h
                db 'h'
                db 0Dh, 0Ah, 0
Error_Msg:
                db 0Dh, 0Ah
                db 7
                db "Transaction failed !"
                db 0Dh, 0Ah
                db "Error Code: "
Register_AX:    dw 3030h
                db 'h'
                db 0Dh, 0Ah, 0
Press_Any_Key:
                db 0Dh, 0Ah 
                db "Press any key to continue ..."
                db 0Dh, 0Ah, 0

Drive_No:       db  0, 1, 80h, 81h

proc_start	endp

CODE_SEG_1	ends

		end	start

