转自 comp.os.vxworks
Boot Sector Disassembly
seg_a segment byte public
assume cs:seg_a, ds:seg_a
org 0
ata0bs01 proc far
0000:7C00 start:
0000:7C00 EB 3C jmp short Start
; now data because: after jmp/ret
0000:7C02 90 db 90h
0000:7C03 57 49 4E 44 52 49 56 52 db 'WINDRIVR'
0000:7C0B 00 02 08 01 00 db 00h, 02h, 08h
0000:7C0E 01 00 db 01h, 00h
0000:7C10 02 00 db 02h, 00h
0000:7C12 02 20 7A F8 db 02h, 20h, 7Ah,0F8h, 0Ch
0000:7C16 0C 00 db 0Ch, 00h
0000:7C18 20 00 02 00 db 20h, 00h, 02h,
00h
0000:7C1C 20 00 db 20h, 00h
0000:7C1E 00 00 00 00 00 00 00 00 db 00h, 00h, 00h, 00h, 00h, 00h, 00h,
00h
0000:7C26 29 05 17 0C 0B db 29h, 05h, 17h, 0Ch, 0Bh
0000:7C2B 0013[00] db 19 dup (0)
0000:7C3E Start:
0000:7C3E 8C C8 mov AX,CS
0000:7C40 8E D8 mov DS,AX
0000:7C42 8E C0 mov ES,AX
0000:7C44 FC cld ; Clear
direction
0000:7C45 FA cli ; Disable
interrupts
0000:7C46 8E D0 mov SS,AX
0000:7C48 BC 7BFE mov SP,7BFEh
0000:7C4B FB sti ; Enable
interrupts
0000:7C4C ,BE 7DD4 mov SI,d_7DD4_e ; 'VxLd 1.2
', 0
0000:7C4F E8 00EB call OutputString
0000:7C52 33 DB xor BX,BX ; Zero
register
0000:7C54 8B C3 mov AX,BX
0000:7C56 A0 7C10 mov AL,ds:d_7C10_e ; (=02)
0000:7C59 F7 26 7C16 mul word ptr ds:d_7C16_e ; (=0) dx:ax=
data * ax
0000:7C5D 8B 0E 7C0E mov CX,ds:d_7C0E_e ; (=01 00)
0000:7C61 03 0E 7C1C add CX,ds:d_7C1C_e ; (=20 00)
0000:7C65 13 16 7C1E adc DX,ds:d_7C1E_e ; (=00 00)
0000:7C69 89 0E 7B03 mov ds:d_7B03_e,CX ; (=0)
0000:7C6D 89 16 7B05 mov ds:d_7B05_e,DX ; (=0)
0000:7C71 03 C8 add CX,AX
0000:7C73 13 D3 adc DX,BX
0000:7C75 89 0E 7B07 mov ds:d_7B07_e,CX ; (=0)
0000:7C79 89 16 7B09 mov ds:d_7B09_e,DX ; (=0)
0000:7C7D 89 0E 7B0B mov ds:d_7B0B_e,CX ; (=0)
0000:7C81 89 16 7B0D mov ds:d_7B0D_e,DX ; (=0)
0000:7C85 52 push DX
0000:7C86 B8 0020 mov AX,20h
0000:7C89 F7 26 7C11 mul word ptr ds:d_7C11_e ; (=00
02)dx:ax=data*ax
0000:7C8D 8B 36 7C0B mov SI,ds:d_7C0B_e ; (=00 02)
0000:7C91 03 C6 add AX,SI
0000:7C93 48 dec AX
0000:7C94 F7 F6 div SI ;ax,dx
rem=dx:ax/reg
0000:7C96 01 06 7B0B add ds:d_7B0B_e,AX ; (=0)
0000:7C9A 11 1E 7B0D adc ds:d_7B0D_e,BX ; (=0)
0000:7C9E A3 7B0F mov ds:d_7B0F_e,AX ; (=0)
0000:7CA1 91 xchg CX,AX
0000:7CA2 5A pop DX
0000:7CA3 ,BB 7E00 mov BX,d_7E00_e ; Note: Load
Address
0000:7CA6 E8 00AE call LoadBootrom
0000:7CA9 73 03 jnc l_00AE ; Jump if
carry=0
0000:7CAB E9 0083 jmp ReadErrorExit
0000:7CAE l_00AE:
0000:7CAE ,BE 7DEC mov SI,d_7DEC_e ; (=0)
0000:7CB1 FC cld ; Clear
direction
0000:7CB2 8B 0E 7C11 mov CX,ds:d_7C11_e ; (=0)
0000:7CB6 ,BF 7E00 mov DI,d_7E00_e ; (=0)
0000:7CB9 l_00B9:
0000:7CB9 51 push CX
0000:7CBA 56 push SI
0000:7CBB 57 push DI
0000:7CBC B9 000B mov CX,0Bh
0000:7CBF F3/ A6 repe cmpsb; Rep zf=1+cx >0 Cmp [si] to
es:[di]
0000:7CC1 5F pop DI
0000:7CC2 5E pop SI
0000:7CC3 59 pop CX
0000:7CC4 74 0A jz l_00D0 ; Jump if
zero
0000:7CC6 83 C7 20 add DI,20h
0000:7CC9 E2 EE loop l_00B9 ; Loop if cx
> 00000:7CCB BE 7DE9 mov SI,7DE9h ;
'No BOOTROM SYS', 0
0000:7CCE EB 64 jmp short ErrorExit
0000:7CD0 l_00D0:
0000:7CD0 8B 45 1C mov AX,[DI+1Ch]
0000:7CD3 8B 55 1E mov DX,[DI+1Eh]
0000:7CD6 F7 36 7C0B div word ptr ds:d_7C0B_e
;ax,dxrem=dx:ax/data
0000:7CDA D1 E8 shr AX,1 ; Shift
w/zeros fill
0000:7CDC D1 E8 shr AX,1 ; Shift
w/zeros fill
0000:7CDE 40 inc AX
0000:7CDF A3 7B11 mov ds:d_7B11_e,AX ; (=0)
0000:7CE2 A1 7C0B mov AX,ds:d_7C0B_e ; (=0)
0000:7CE5 D1 E8 shr AX,1 ; Shift
w/zeros fill
0000:7CE7 D1 E8 shr AX,1 ; Shift
w/zeros fill
0000:7CE9 A3 7B13 mov ds:d_7B13_e,AX ; (=0)
0000:7CEC 8B 45 1A mov AX,[DI+1Ah]
0000:7CEF 48 dec AX
0000:7CF0 48 dec AX
0000:7CF1 33 C9 xor CX,CX ; Zero
register
0000:7CF3 8A 0E 7C0D mov CL,ds:d_7C0D_e ; (=0)
0000:7CF7 F7 E1 mul CX ; dx:ax = reg
* ax
0000:7CF9 03 06 7B0B add AX,ds:d_7B0B_e ; (=0)
0000:7CFD 13 16 7B0D adc DX,ds:d_7B0D_e ; (=0)
0000:7D01 ,BB 0800 mov BX,d_0800_e ; (=0)
0000:7D04 l_0104:
0000:7D04 ,8E C3 mov ES,BX
0000:7D06 33 DB xor BX,BX ; Zero
register
0000:7D08 B1 04 mov CL,4
0000:7D0A 50 push AX
0000:7D0B 52 push DX
0000:7D0C E8 0048 call LoadBootrom
0000:7D0F 5A pop DX
0000:7D10 58 pop AX
0000:7D11 72 1E jc ReadErrorExit ; Jump if
carry Set
0000:7D13 ,BE 7DF8 mov SI,d_7DF8_e ; '.',0
0000:7D16 E8 0024 call OutputString
0000:7D19 FF 0E 7B11 dec word ptr ds:d_7B11_e ; (=0)
0000:7D1D 74 0E jz GoodExit ; Jump if
zero
0000:7D1F 83 C0 04 add AX,4
0000:7D22 83 D2 00 adc DX,0
0000:7D25 8C C3 mov BX,ES
0000:7D27 03 1E 7B13 add BX,ds:d_7B13_e ; (=0)
0000:7D2B EB D7 jmp short l_0104
0000:7D2D GoodExit:
0000:7D2D FF 2E 7D39 jmp dword ptr ds:d_7D39_e ; (=0)
0000:7D31 ReadErrorExit:
;
xref 0000:7CAB
0000:7D31 ,BE 7DDE mov SI,d_7DDE_e ; 'Read
error', 0
0000:7D34 ErrorExit:
0000:7D34 E8 0006 call OutputString
0000:7D37 l_0137:
0000:7D37 EB FE jmp short l_0137
0000:7D39 00 00 00 08 db 0, 0, 0, 8 ;
Address 0x0000-8000
ata0bs01 endp
;==========================================================================
; SUBROUTINE
;
; Called from: 0000:7C4F, 0116, 0134
;==========================================================================
0000:7D3D OutputString proc near
0000:7D3D 53 push BX
0000:7D3E 50 push AX
0000:7D3F 80 3E 7DD3 00 cmp byte ptr ds:d_7DD3_e,0 ; (=0)
0000:7D44 75 0E jne l_0154 ; Jump if not
equal
0000:7D46 l_0146:
0000:7D46 ,AC lodsb ; String [si]
to al
0000:7D47 0A C0 or AL,AL ; Zero ?
0000:7D49 74 09 jz l_0154 ; Jump if
zero
0000:7D4B B4 0E mov AH,0Eh
0000:7D4D BB 0007 mov BX,7
0000:7D50 CD 10 int 10h ; Video display
ah=functn 0Eh
; write char al, teletype mode
0000:7D52 EB F2 jmp short l_0146
0000:7D54 l_0154:
0000:7D54 58 pop AX
0000:7D55 5B pop BX
0000:7D56 C3 retn
OutputString endp
;==========================================================================
; SUBROUTINE
;
; Called from: 0000:7CA6, 010C
;
;==========================================================================
0000:7D57 LoadBootrom proc near
0000:7D57 B5 02 mov CH,2
0000:7D59 57 push DI
0000:7D5A 88 0E 7B00 mov ds:d_7B00_e,CL ; (=0)
0000:7D5E 8B F0 mov SI,AX
0000:7D60 8B FA mov DI,DX
0000:7D62 89 1E 7B01 mov ds:d_7B01_e,BX ; (=0)
0000:7D66 l_0166:
0000:7D66 8B C6 mov AX,SI
0000:7D68 8B D7 mov DX,DI
0000:7D6A 8B 1E 7C18 mov BX,ds:d_7C18_e ; (=0)
0000:7D6E F7 F3 div BX ; ax,dx
rem=dx:ax/reg
0000:7D70 42 inc DX
0000:7D71 43 inc BX
0000:7D72 l_0172:
0000:7D72 ,52 push DX
0000:7D73 02 D1 add DL,CL
0000:7D75 3B D3 cmp DX,BX
0000:7D77 5A pop DX
0000:7D78 76 04 jbe l_017E ; Jump if
below or =
0000:7D7A FE C9 dec CL
0000:7D7C EB F4 jmp short l_0172
0000:7D7E l_017E:
0000:7D7E 8B DA mov BX,DX
0000:7D80 51 push CX
0000:7D81 99 cwd ; Word to double
word
0000:7D82 F7 36 7C1A div word ptr ds:d_7C1A_e
;ax,dxrem=dx:ax/data
0000:7D86 86 E0 xchg AH,AL
0000:7D88 B1 06 mov CL,6
0000:7D8A D2 E0 shl AL,CL ; Shift
w/zeros fill
0000:7D8C 91 xchg CX,AX
0000:7D8D 0A CB or CL,BL
0000:7D8F 8A F2 mov DH,DL
0000:7D91 58 pop AX
0000:7D92 B7 05 mov BH,5
0000:7D94 l_0194:
0000:7D94 53 push BX
0000:7D95 50 push AX
0000:7D96 8B 1E 7B01 mov BX,ds:d_7B01_e ; (=0)
0000:7D9A 8A 16 7DD2 mov DL,ds:d_7DD2_e ; (=0)
0000:7D9E 50 push AX
0000:7D9F CD 13 int 13h ; Disk
dl=drive a ah=func 02h
; read sectors to memory es:bx
; al=#,ch=cyl,cl=sectr,dh=head
0000:7DA1 58 pop AX
0000:7DA2 32 E4 xor AH,AH ; Zero
register
0000:7DA4 72 1F jc l_01C5 ; Jump if
carry Set
0000:7DA6 59 pop CX
0000:7DA7 5B pop BX
0000:7DA8 03 F0 add SI,AX
0000:7DAA 83 D7 00 adc DI,0
0000:7DAD 28 06 7B00 sub ds:d_7B00_e,AL ; (=0)
0000:7DB1 F7 26 7C0B mul word ptr ds:d_7C0B_e ; dx:ax = data
* ax
0000:7DB5 01 06 7B01 add ds:d_7B01_e,AX ; (=0)
0000:7DB9 8A 0E 7B00 mov CL,ds:d_7B00_e ; (=0)
0000:7DBD 80 F9 00 cmp CL,0
0000:7DC0 77 A4 ja l_0166 ; Jump if
above
0000:7DC2 F8 clc ; Clear carry
flag
0000:7DC3 l_01C3:
0000:7DC3 ,5F pop DI
0000:7DC4 C3 retn
0000:7DC5 l_01C5:
0000:7DC5 33 C0 xor AX,AX ; Zero
register
0000:7DC7 CD 13 int 13h ; Disk dl=drive a
ah=func 00h
; reset disk, al=return status
0000:7DC9 58 pop AX
0000:7DCA 5B pop BX
0000:7DCB FE CF dec BH
0000:7DCD 75 C5 jnz l_0194 ; Jump if not
zero
0000:7DCF F9 stc ; Set carry
flag
0000:7DD0 EB F1 jmp short l_01C3
LoadBootrom endp
0000:7DD2 80 00 db 80h, 00h
l_7DD4:
0000:7DD4 56 78 4C 64 20 31 2E db 'VxLd 1.2 ', 0
0000:7DDB 32 20 00
l_7DDE:
0000:7DDE 52 65 61 64 20 65 db 'Read error', 0
0000:7DE4 72 72 6F 72 00
l_7DE9:
0000:7DE9 4E 6F 20 42 4F 4F db 'No BOOTROM SYS', 0
0000:7DEF 54 52 4F 4D 20 53
0000:7DF5 59 53 00
l_7DF8:
0000:7DF8 2E 00 db 2Eh, 00h,
0000:7DFA 00 00 00 DF db 00h, 00h,
00h,0DFh
0000:7DFE 55 AA db 55h,0AAh
0000:7E00 0200[00] db 512 dup (0)
seg_a ends
____________________ CROSS REFERENCE - KEY ENTRY POINTS ___________________
seg:off type label
---- ---- ---- --------------------------------
0000:7C00 far start
__________________ Interrupt Usage Synopsis __________________
Interrupt 10h : Video display ah=functn xxh
Interrupt 10h : ah=0Eh write char al, teletype mode
Interrupt 13h : Disk dl=drive # ah=func xxh
Interrupt 13h : ah=00h reset disk, al=return status
Interrupt 13h : ah=02h read sectors to memory es:bx