📄 ub.asm
字号:
push es
pop ds ; DS:ESI = ptr to read data
push 0000h
pop es ; ES = 0000 with 4GB access
; ES:EDI = ptr to final source buffer
rep movs es:byte ptr [edi],ds:byte ptr [esi]
pop ds
pop es
pop si ; DS:SI = ptr to BPB information
mov dword ptr ds:[si+80h],edi; update ptr to source buffer
popad
jmp short i19_10 ; continue..
i19_03_00:
jmp i19_03 ; read error..
i19_09:
mov ecx,ds:dword ptr [di+80h]; ptr to end of file+1
sub ecx,ptr_to_source_buffer; ECX = file size in bytes
shr ecx,15 ; ECX = file size in unit of 32k
; BIOS ROM file is read from floppy diskette and is stored
; in 1m:0000 onwards depending on size of the file
; all the scratch data area which has been used for reading the diskette is
; NOT needed anymore and can NOW be re-used for scratch data area for
; somethingelse..
;---------------------------------------;
cli
; ECX = file size in unit of 32k
; start operating on flash..
pushad
check_point_ini 0f5h ; ======== F5
call disable_internal_cache ; disable internal cache
popad
call flash_program ; detect, erase, program flash
jc i19_15 ; error..display and halt
; successful..generate cpu reset..
; make sure floppy goes off after flash programming
mov dx,3f2h ; DIGITAL OUTPUT REGISTER PORT
mov al,0ch ; turn of MOTOR
out dx,al
;---------------------------------------;
; CS:SI = ptr to message/beep codes..
; enable GateA20..
call display_on_port ; display program successful
mov al,60h
out 64h,al
call ib_free
mov al,75h ; disable kb, set sys bit
out 60h,al
call ib_free
in al,60h
mov bl,cgroup:boot_block_flag; get boot block flag
test bl,02h ; destroy CMOS checksum ?
jz no_csum_destroy ; no
mov ax,0c08eh ; destroy CMOS checksum
call cmos_data_out
no_csum_destroy:
test bl,01h ; reboot ?
jnz halt ; no
; reboot after successful flash programming
call restore_cpuid ; restore EDX
;;;; jmp far F000:FFF0
db 0eah ; goto ROM
dw 0fff0h
dw 0f000h
halt:
mov al,0fh
out 61h,al
jmp short halt
i19_15:
jmp display_blink_halt
;---------------------------------------;
;*****************************************************************;
;*****************************************************************;
;** **;
;** (C)Copyright 1985-1996, American Megatrends Inc. **;
;** **;
;** All Rights Reserved. **;
;** **;
;** 6145-F, Northbelt Parkway, Norcross, **;
;** **;
;** Georgia - 30071, USA. Phone-(770)-246-8600. **;
;** **;
;*****************************************************************;
;*****************************************************************;
;-----------------------------------------------;
; READ_1_CLUSTER ROUTINE ;
; ;
; this routine reads the asked cluster form the;
; file ;
; input : ;
; ax cluster# ;
; bp #of sectors/cluster ;
; ds:di ptr to scratch area ;
; es:bx pointer to read buffer ;
; output: ;
; nc ok ;
; cy error ;
; ;
; register destroyed..AX BX CX DX ;
;-----------------------------------------------;
read_1_cluster proc near
push bp ; BP = #of sectors per cluster
call find_sec_hd_cyl_cluster ; find start sector#, head#, cyl# for
; the cluster concerned
r_c_03:
; CH,CL = cyl#, start sector#..
; DH,DL = head#, drive#..
; BP = #of sectors yet to be read..
mov ax,0201h ; read 1 sector at a time
int 13h ; read the sectors
jc r_c_01 ; error..CY already..
r_c_skip:
mov ax,[di+0bh] ; #of bytes per sector
add bx,ax ; update buffer address
jnz r_c_02
inc byte ptr [di+02h] ; update file size in unit of 64k
mov ax,es
add ax,1000h
mov es,ax
r_c_02:
dec bp ; all sectors in the cluster read ?
jz r_c_00 ; yes..
; find next sector, hd#, cyl# of the next sector in that cluster..
push si
mov si,di
call find_next_sector_hd_cyl ; next sector#, hd#, cyl# of that cluster
pop si
jmp short r_c_03 ; read next sector fo cluster
r_c_00:
; successful reading of cluster..
clc ; NC..
r_c_01:
pop bp ; restore #of sectors per cluster
ret
read_1_cluster endp
;---------------------------------------;
; FIND_SEC_HD_CYL_CLUSTER ;
; this routine finds the sector#, head#,
; cyl# for the given cluster# ;
; input : ;
; ax cluster# ;
; ds:di pointer to scratch storage
; output: ;
; cl bit 5-0 sector# ;
; bit 7-6 high 2-bits of ;
; 10-bit cyl# ;
; ch low 8-bits of 10-bit cyl#
; dh head# ;
; dl hard disk# ;
;---------------------------------------;
find_sec_hd_cyl_cluster proc near
dec ax
dec ax ; subtract 02 from cluster#
mov dl,[di+0dh] ; multiply by #of sectors/cluster
xor dh,dh
mul dx
add ax,[di] ; add starting abs sector# of data area
push si
mov si,di ; DS:SI ptr to scratch area
call find_sector_head_cyl ; find sector#, head#, cyl#, disk#
pop si
ret
find_sec_hd_cyl_cluster endp
;---------------------------------------;
; FIND_NEXT_SECTOR_HD_CYL ;
; this routine finds the sector#, head#,
; cyl# of the next sector ;
; input : ;
; cl bit 5-0 present sector#;
; bit 7-6 high 2-bits of ;
; 10-bit cyl# ;
; ch low 8-bits of 10-bit cyl#
; dh present head# ;
; ds:si ptr to scratch area ;
; output: ;
; cl bit 5-0 next sector# ;
; bit 7-6 high 2-bits of ;
; 10-bit cyl# ;
; ch low 8-bits of 10-bit cyl#
; dh head# ;
; register destroyed..AX CX DH ;
;---------------------------------------;
find_next_sector_hd_cyl proc near
mov al,cl
and al,3fh ; AL = sector# of previous sector
xchg cl,ch
shr ch,6 ; CX = 10-bit cyl# of previous sector
inc al ; next sector#
cmp al,[si+18h] ; sector crosses boundary ?
jbe r_10 ; no..
; sector crosses boundary..
mov al,1 ; sector#
inc dh ; increment head#
cmp dh,[si+1ah] ; head crosses boundary ?
jb r_10 ; no..
mov dh,00 ; yes..new head#..
inc cx ; new cyl#
r_10:
; AL = sector# of the next sector ..
; DH = head# of the next sector ..
; CX = cyl# of the next sector ..
xchg cl,ch ; CH = low 8-bits of 10-bit cyl#
shl cl,6 ; CL = bit 7-6 high 2bit of 10bit cyl#
or cl,al ; bit 5-0 sector#
ret
find_next_sector_hd_cyl endp
;---------------------------------------;
; FIND_SECTOR_HEAD_CYL ;
; this routine finds the corresponding ;
; sector#, head#, cyl# for a given ;
; absolute sector# ;
; input : ;
; ax absolute sector# ;
; ds:si ptr to bpb informn ;
; output: ;
; cl bit 5-0 sector# ;
; bit 7-6 high 2-bits of ;
; 10-bit cyl# ;
; ch low 8-bits of 10-bits cyl#
; dh head# ;
; dl drive# ;
; register destroyed..AX CX DX ;
;---------------------------------------;
find_sector_head_cyl proc near
xor dx,dx
div word ptr [si+18h] ; divide by #of sectors/track
inc dl
mov cl,dl ; CL = sector# (1-based)
xor dx,dx
div word ptr [si+1ah] ; divide by #of heads
mov dh,dl ; DH = head# (0-based)
mov ch,al ; CH = low 8-bits of 10-bit cyl#
shl ah,6
or cl,ah ; CL = bit 7-6 high 2bits of 10bit cyl#
; bit 5-0 sector#
mov dl,drive_number ; DL = drive#
ret
find_sector_head_cyl endp
;---------------------------------------;
; FIND_STORE_CLUSTER_NOS ;
; this routine finds the cluster#s of ;
; the file and stores them serially ;
; input : ;
; ax starting cluster# ;
; ds:di ptr to area where the ;
; cluster#s are to be stored
; es:0000 contain FAT sectors ;
; output: ;
; none ;
; register destroyed..AX BX CX DX DI ;
;---------------------------------------;
find_store_cluster_nos proc near
push es
push ds
push es
push ds
pop es
pop ds ; exchange DS and ES
fcn_00:
; 12-bit FAT..
mov cx,ax ; save last cluster#
mov bx,3
mul bx
shr ax,1 ; multiply cluster# by 1.5
; AX = offset into the FAT pointing to the entry that maps the cluster just
; used..that entry contains the next cluster# of the file..
; CX = last cluster# being used..
mov bx,ax
mov ax,[bx] ; get the content of the entry in FAT
test cl,1 ; last cluster# even/odd ?
jz fcn_02 ; last cluster# even..keep low 12-bits
shr ax,04h ; last cluster# odd..keep high 12-bits
fcn_02:
and ax,0fffh ; AX = next cluster#
stosw ; store next cluster#
cmp ax,0ff8h ; end of file ?
jb fcn_00 ; no..
pop ds
pop es
mov word ptr [di-02h],end_of_cluster; mark end of file cluster
; with FFFF
dummy_ret:: ; (CORE0211+)
ret
find_store_cluster_nos endp
;---------------------------------------;
;*****************************************************************;
;*****************************************************************;
;** **;
;** (C)Copyright 1985-1996, American Megatrends Inc. **;
;** **;
;** All Rights Reserved. **;
;** **;
;** 6145-F, Northbelt Parkway, Norcross, **;
;** **;
;** Georgia - 30071, USA. Phone-(770)-246-8600. **;
;** **;
;*****************************************************************;
;*****************************************************************;
;-----------------------------------------------------------------------;
public _UB_ENDS
_UB_ENDS label byte ; marks end of module
;---------------------------------------;
_text ends
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -