|
楼主 |
发表于 2007-11-16 13:29:48
|
显示全部楼层
7.1.6.6.c. The key parts of the decompression routine 4 b2 O+ n, V7 j
C.解压例程的关键部分5 i) X3 K/ ?& q
Address Assembly Code' T1 x9 ^2 x% q5 g4 ^) V" k9 E5 o9 C% _
2000:E512 Decompress_System_BIOS proc near ; CODE XREF: 0002E3DC0 x" _' L' K$ Q7 k! B/ K4 M8 ~, a. @
.........
& K9 [% x' E" S U2000:E555 mov bx, 02 U( z/ R7 G6 [" T8 b! P2 N3 j
2000:E558 mov es, bx
8 n6 N$ K5 l0 H* B2000:E55A assume es:nothing6 ^; \/ b& u7 v' M* T0 @- I2 g
2000:E55A mov word ptr es:7004h, 0FFFFh
/ D0 P: U. Q0 ?' b! |2000:E561 xor al, al
' \9 S2 r n& U) q9 x2000:E563: V7 R: d; k4 V
2000:E563 ; System_BIOS Decompression started here' l- r( k7 ~8 R9 B4 A! I
2000:E563 mov bx, 1000h. o) M5 w- N! z7 }# \+ }+ P
2000:E566 mov es, bx ; es = src_seg
1 U! \# {5 h- x1 G v# h2000:E568 assume es:_1000h* I+ l2 M. b) R. M* c" J! a
2000:E568 xor bx, bx ; bx = src_offset
1 `7 s# N4 y! b) ]2000:E56A call Decompress ; on ret, CF=1 if error occured
6 l( a0 z" G& l v& m$ P* t5 N( ?2000:E56D jb short sysbios_decomp_error& n m0 y- H: e; [/ C7 W
2000:E56F test ecx, 0FFFF0000h ; compressed component size more than 64KB?
+ ]8 J) ?( z$ _( V2000:E576 jz short sysbios_decomp_error ; jmp if compressed component size <= 64KB* }8 I, z7 z2 ?
2000:E578 mov bx, 2000h! C9 z$ {' S3 j1 t3 H
2000:E57B mov es, bx ; proceed2next cmprssd componnt (in next segment)
, [* ]6 w- D: K2 S2000:E57D assume es:_2000h
( a9 Y; y% r* g- u5 @5 p! U3 K8 |% C2000:E57D mov bx, 1 ; bx = index to be added to previous src_offset in cx9 Q2 o6 `. g! E2 Z/ r% P& j
2000:E580 jmp short repeat_decompress ; decompress remaining component (1st pass jmp taken)
* \; y7 N2 h( f: n0 E& v3 ~2000:E582 ; ---------------------------------------------------------------------------
* Y7 S# E$ F% q' |/ b1 K2000:E582 sysbios_decomp_error: ; CODE XREF: Decompress_System_BIOS+5B/ W( G$ D0 j H& W/ N. o! R& @
2000:E582 ; Decompress_System_BIOS+64
z- R t& Z, {8 k; z+ I2000:E582 rcl al, 1
- ?8 H2 }& o5 @5 b7 z2000:E584 mov bx, 2000h! o! }) w# A8 \ M$ G6 F' g
2000:E587 mov es, bx' ]4 f' T3 R3 [! O% H T# {
2000:E589 xor bx, bx
" u5 a; E2 K/ L; B7 u" c2000:E58B call Decompress
5 Y; \( V) O1 u2000:E58E rcl al, 1
0 y I2 F' i/ L- F! z2000:E590 cmp al, 3! K) @$ h# Y+ a6 n
2000:E592 jnz short decompress_successfull$ |( i3 E w" c* a
2000:E594 mov ax, 1000h
5 U& n7 }5 T% P! e2000:E597 stc" t t9 d/ P) b0 R4 i( ]2 J
2000:E598 retn, y, r# y) U9 y2 S; ]1 G) G
2000:E599 ; ---------------------------------------------------------------------------
I; O9 T/ Y. I& P2000:E599 decompress_successfull: ; CODE XREF: Decompress_System_BIOS+80
# v9 H3 P# `. ]/ k% |' ^2000:E599 or al, al* o* w5 k" o* [8 X& N% P4 _
2000:E59B jnz short sys_bios_dcomprss_done
! F! }7 i/ ~& Z( \1 W( J2000:E59D repeat_decompress: ; CODE XREF: Decompress_System_BIOS+6E
3 ]7 D& E& ]1 o2000:E59D ; Decompress_System_BIOS+99$ v* X4 R/ h6 [
2000:E59D add bx, cx ; bx = point to next compressed component
8 x+ ?. q0 M' q# L$ J2000:E59F call Decompress% V8 ~ F4 ?5 H
2000:E5A2 jb short sys_bios_dcomprss_done ; 1st pass jmp taken (original.tmp)7 H% P- h. z( Y
2000:E5A4 test ecx, 0FFFF0000h" g, I3 d3 c" {" g" r
2000:E5AB jz short repeat_decompress
# v/ t1 e/ G8 o$ ^2000:E5AD sys_bios_dcomprss_done: ; CODE XREF: Decompress_System_BIOS+89
- B& V5 z8 @1 g! A+ `3 z+ |, D2000:E5AD ; Decompress_System_BIOS+90
. Z: M Z. g! h6 i6 T; ^2000:E5AD call Decmprss_Sysbios_Extension/ f" M) I# ?0 _ k' d$ q
2000:E5B0 jz _sysbios_chksum_error
. Q6 \8 Q j4 H* M2000:E5B4 mov ax, 5000h
/ p5 B* r* i7 N2000:E5B7 clc0 F# R1 \. e. p* J0 ]
2000:E5B8 retn
1 p: X) n$ R6 N! [/ M2000:E5B8 Decompress_System_BIOS endp1 b; n/ O' j' H1 n% W
________________________________________
% p i* R8 P' e' p6 ?0 }2000:E5B9 --- Decompress ---
% ~- d! t# v( c, e/ E' _! y2000:E5B9 in: es = component_seg' B. J, o' c; t0 {
2000:E5B9 bx = component_offset
$ J8 ~5 l6 C9 w- D8 b2000:E5B9 out: ecx = overall_compressed_component_length
$ b# k/ ?; j* t9 J2000:E5B9 edx = original_component_size7 O* Q/ {$ T' Q6 v1 ]4 z
2000:E5B9 CF, set if failed, cleared if success
9 O, x# ~4 U: ^1 E/ U7 E: q2000:E5B9 ; --------------- S U B R O U T I N E ---------------------------------------
6 z! g3 W% X9 A1 H8 x; m2000:E5B9 Decompress proc near ; CODE XREF: Decmprss_Sysbios_Extension:not_awdext
3 D& ^. w& l x! J; d7 n& _" j2000:E5B9 ; Decmprss_Sysbios_Extension:not_awdext2 ..." K* v: G) `5 j/ w8 v5 c6 ]& g
2000:E5B9 cmp dword ptr es:[bx+0Fh], 40000000h ; is extension component?7 |) A( T# y% N
2000:E5C2 jnz short not_xtension_component ; 1st pass jmp taken
% W% ?- I4 u( [6 ]2000:E5C4 mov si, 0
7 m5 E4 n4 @1 K2 O2000:E5C7 mov ds, si
; d7 \# ]% r( Z/ ^+ ^2000:E5C9 assume ds:nothing
' `) Z8 r2 n2 r( S2000:E5C9 mov ds:7000h, bx
?4 d, H2 t% C. e$ O4 n2000:E5CD mov si, es, i: r. k; ]% M2 a$ l" w
2000:E5CF mov ds:7002h, si
! L4 a6 _, b/ H, R7 f7 K2000:E5D3 lea si, ds:7789h
) j) Z: b4 V0 ]2 r9 d% K2000:E5D7 mov ds:7004h, si1 y( ]" S0 k9 a1 ~
2000:E5DB movzx ecx, byte ptr es:[bx]
+ k5 s6 V/ s4 }0 I+ b+ K: q2000:E5E0 add ecx, es:[bx+7]
! J, A% [+ l( j2000:E5E5 add ecx, 3 C9 D/ I7 s5 i7 [* v4 U
2000:E5E9 retn- |7 G# ]2 v$ q/ O. F9 R2 q S8 _
2000:E5EA ; ---------------------------------------------------------------------------
% A' j4 q% z$ k& j2000:E5EA not_xtension_component: ; CODE XREF: Decompress+92 c, L D( M+ _- v i) O6 l4 ?' j X
2000:E5EA mov dx, 3000h ; dx = scratchpad_seg for decompression4 M5 ]" b0 @/ a) l1 Z4 w, K& O! }
2000:E5ED push ax
& B/ g* B6 w+ I- \2000:E5EE push es
( A1 `3 B! q% \2000:E5EF call Find_BBSS ; on ret, si contains offset right after BBSS sign
, p* {6 n" B9 W& P) j+ D1 d2000:E5F2 pop es$ h2 P( S( _3 U
2000:E5F3 assume es:nothing
2 }5 V$ m+ [9 G3 M, Q/ n2000:E5F3 push es
* b* t: T: X* |3 c2000:E5F4 mov ax, es! z$ |5 A, N8 {
2000:E5F6 shr ax, 0Ch
- y1 R3 k/ s6 m% H2000:E5F9 mov es, ax, C, ^% i/ C2 M; B6 P! o
2000:E5FB assume es:nothing9 P: w. J# Z7 _% Z4 U
2000:E5FB mov ax, cs:[si+0Eh]2 [3 @/ d4 `: ^! L3 u" l* u9 D
2000:E5FF call ax ; call decompression engine at 2000:7789h7 U! G x6 q" N$ c
2000:E601 pop es( ? O+ _2 ~ ?% `+ P3 W2 H9 r
2000:E602 assume es:nothing0 `1 p. f1 R% U8 G l
2000:E602 pop ax
2 [/ S7 }# w- v# e8 V0 ^2000:E603 retn# N7 n0 \' I; D7 r# Y+ o
2000:E603 Decompress endp$ u C" s& v7 A6 N) ]
________________________________________: {. ~7 c0 c! c2 `4 ?/ L. U0 g" Y
2000:7789 --- Decomprssion_Ngine ---
) O* W2 i. l' G; ?/ r5 j2000:7789 in: dx = scratch-pad_segment_for_decompression8 G/ Y0 _( I5 ^$ D
2000:7789 es = (compressed_segment_addr>>0xC) [hi_word of src phy addr]
5 s% t# Z3 ^7 }+ g& P1 Z. z1 I2000:7789 bx = compressed_offset_addr
E* D$ P' R1 V2000:7789& b; F/ l x" ]4 w! D
2000:7789 out: ecx = overall_compressed_component_length" z! e( W4 G8 j% `+ c" [
2000:7789 edx = original_file_size6 O8 g1 c1 P/ X A1 v0 ~# Y; f; H
2000:7789 ; --------------- S U B R O U T I N E ---------------------------------------- L6 ?" t5 X D9 P# F1 G
2000:7789 Decompression_Ngine proc near! {$ D) F' r! d: _% e) {
2000:7789 push eax' _( U6 o: X8 S/ e Q [
2000:778B push bx* Z1 G, v: O- Q& `, y# T6 C
2000:778C push es, ~$ @) S8 S! v, R
2000:778D mov ds, dx. K2 Y5 P i, r: i/ x" W& e
2000:778F push ds6 |6 ]/ m3 q3 y+ c* v" c
2000:7790 pop es
! e3 P9 K/ V; V2 c9 q, e2000:7791 xor di, di3 d4 g! o( x) d7 x e3 A
2000:7793 mov cx, 4000h2 a4 L" P4 R4 A+ i; O
2000:7796 xor ax, ax* ^8 n4 U, z1 q. P7 E& z* d# d# c2 ^
2000:7798 rep stosw ; zero-init 32KB starting at Scratchpad_Seg:0000h d- I% F( M! @, R) i8 ~$ L
2000:779A pop es9 u/ {) v, r( ^' U" E" I
2000:779B push es- ?- s5 E; M2 L) C' f/ Q0 S) g9 r
2000:779C# C, q# q# D1 A) |
2000:779C ;Setup GDT to be used to get src bytes (Fetch_Byte) later0 A; I _$ ]" @- I: t e
2000:779C mov word ptr ds:100h, es ; ds:100h = compressed_seg_addr>>0xC
; X1 K! |: @! ]! _3 X2 W+ L1 J2000:779C ; 1st pass ds:100h = 1; o. A2 |" r: T( C4 \ d: z
2000:77A0 mov ds:102h, bx ; ds:102h = compressed_offset_addr0 f' f. I" _; H1 s6 ?- Z# V
2000:77A0 ; 1st pass bx = 0
% G5 D h, W' {% O2000:77A4 xor ecx, ecx
, Q: q/ t3 g. e7 r2000:77A7 mov ds:57A8h, ecx
8 U, {8 K2 \/ ?/ I3 a' o5 e1 n2000:77AC mov ds:57ACh, ecx; ?4 d) q# }; ~" b) u- G4 T' g5 B' C
2000:77B1 lea cx, ds:57A8h
$ T, v1 E+ y+ n5 j* G+ d9 _: H. I2000:77B5 ror ecx, 46 g# R. L- {2 O1 k4 @/ e% E0 y
2000:77B9 mov ax, ds
0 k9 e7 ^+ C# c/ m4 l6 x# G2000:77BB add cx, ax! ~! @5 g8 N; c' I; ]8 C
2000:77BD rol ecx, 4- x" b% G7 c# x3 n& N: s& I9 I1 F. W
2000:77C1 mov word ptr ds:57A2h, 18h; s& M7 D2 J, r4 {8 [8 A8 |& G8 [
2000:77C7 mov ds:57A4h, ecx; D0 e1 l4 w) `
2000:77CC mov dword ptr ds:57B0h, 0FFFFh, r/ w( k2 P+ E% I3 D% m( R! }
2000:77D5 mov ax, es
$ l, w" f Z8 p e2000:77D7 movzx ecx, ah ; es = hi_word addr of desc_base
, c: M; Z& z) k2000:77DB ror ecx, 8 ; ecx = base_24_31 << 24
' w, y3 A# N" |7 H* a$ C- ~2000:77DF mov cl, al
/ g2 E8 k- |' ~0 H: v0 t" z2000:77E1 or ecx, 8F9300h0 D9 {7 ~" Y1 S! n
2000:77E8 mov ds:57B4h, ecx4 f2 j( R8 u1 N# @/ ~/ m
2000:77ED mov dword ptr ds:57B8h, 0FFFFh' U' i( o6 O! y6 U8 _5 L
2000:77F6 mov dword ptr ds:57BCh, 8F9300h
- h. }$ V# ?0 e4 [4 y c+ j2000:77FF push gs1 i. J* X$ V- |) N
2000:7801 mov di, 0
( O" s; z9 H7 @" ~; a( [2000:7804 mov gs, di
' y& E. [( G$ \* d+ Q1 z2000:7806 assume gs:nothing1 h5 t( v: a4 a) F4 t
2000:7806 mov di, 6000h! X. [% S. _/ l$ J1 k# s* `* d8 ?
2000:7809 mov word ptr gs:[di], 7789h
6 e' S" e" G' h) Q2000:780E
- n. q. B1 y# `1 U4 F& ^2000:780E ;check LZH header
, c3 a' F% N+ r2 B3 S4 u. i3 E2000:780E add bx, 12h ; LZH-header decomp_seg_addr_hi_byte index
9 r8 Q6 J7 b9 O% D6 y7 e$ @- M) L2000:7811 call Fetch_Byte. f! H$ U x& A7 T
2000:7814 sub bx, 12h ; restore bx to point to first byte, i6 V4 ^4 D9 H8 I F
2000:7817 cmp al, 40h ; '@' ; is extension component?
. g) ]6 l! F/ K @; h2000:7817 ; at 1st: al equ 50h (original.tmp); I: | k4 y$ ]. d G& t- v
2000:7817 ; at 2nd: al equ 41h (awardext.rom)$ T, v S% e, m% I
2000:7819 jnz short not_extension_component ; 1st-pass jmp taken
* d6 H+ [, ]" s1 `# Z% x- O6 W2000:781B add bx, 11h
. @# R; t, {7 ]2000:781E call Fetch_Byte ; fetch "dest_seg_addr" lo_byte% k) _* d- ?. R+ U6 B
2000:7821 sub bx, 11h ; restore bx to point to first byte3 H* {0 n1 `2 q: X- y
2000:7824 or al, al ; if extension component, jmp taken; ?3 r9 W2 c) F( \5 o+ k
2000:7826 jnz short extension_component
" x* Z) O9 O. C2000:7828 cmp dword ptr gs:[di+4], 0
3 o# r7 M( s0 g: n8 y$ C; C- B/ s2000:782E jnz short not_extension_component
# O) }* `/ p$ \+ ?2000:7830 extension_component: ; CODE XREF: Decompression_Ngine+9D8 {2 l1 o: @2 e- ^
2000:7830 movzx dx, al ; dl = "dest_seg_addr" lo_byte1 K* I, k' {% E+ D5 N- W
2000:7833 inc bx ; bx = LZH_hdr_chksum byte index: C. u2 D( p+ I' B4 @- q3 ?
2000:7834 call Fetch_Byte
: m, i4 F! E$ C; b' f/ i2000:7837 sub al, dl ; LZH_hdr_chksum = LZH_hdr_chksum - "dest_seg_addr"_lo_byte
" J; ]( v2 z% n( \6 F1 i) G2 Q2000:7839 call Patch_Byte ; store new checksum
& i9 T; m8 G$ `2000:783C dec bx ; restore bx
c& q7 m1 e; L2000:783D xor al, al ; al = 00h
* c0 p$ y$ @7 K2 a( n, |* j2000:783F add bx, 11h ; bx = "dest_seg_addr"_lo_byte index
5 s7 S$ C( P- i, c/ q4 v( W- B2000:7842 call Patch_Byte ; patch "dest_seg_addr"_lo_byte to 00h
! [8 m \. {/ x& d+ Y6 s5 |2000:7845 sub bx, 11h: V W. d8 z" c1 [$ `+ Z8 C( C
2000:7848 inc dx ; dx = "dest_seg_addr"_lo_byte + 1
1 _/ Y. _: G2 p% O2000:7849 shl dx, 2 ; dx = 4*("dest_seg_addr"_lo_byte + 1)! j; [' N- r- B. `5 j0 A
2000:784C add di, dx ; di = 6000h + dx -- look above!8 q p* @. o( o# p* `) g8 y
2000:784E mov gs:[di], bx ; 0000:[di] = compressed_offset_addr
7 H* @* ]* {) V, G6 d2000:7851 mov cx, es
- H: e z' A" D2000:7853 mov gs:[di+2], cx ; 0000:[di+2] = compressed_seg_addr>>0xC (hi_word of src phy addr), o/ X" P# y `0 D
2000:7857 call Fetch_Byte ; al = LZH_hdr_len
. B2 G. [. Z5 Y& o4 ?+ k2000:785A movzx ecx, al ; ecx = LZH_hdr_len2 X. x ?0 y; a% t+ G! `: @
2000:785E add bx, 7
+ |1 h3 C. S2 c, M& a2 M" R2000:7861 call Fetch_Dword ; eax = compressed_file_size& B6 e- `6 ^2 X* t3 W
2000:7864 sub bx, 7. T" X r6 x$ l' Y( `8 T! @0 B0 x
2000:7867 add ecx, eax ; ecx = LZH_header_len + compressed_file_size. [3 K+ Q) V" k8 o% a, u
2000:786A add ecx, 3 ; ecx = total_compressed_component_size" u, Y! ~6 C2 x p' m! N
2000:786E pop gs3 m& A, ?0 x' l ?1 O7 g; J) S
2000:7870 assume gs:nothing4 M: g" z) \( l
2000:7870 jmp exit% y8 i7 ]( @$ V+ C; A
2000:7873 ; ---------------------------------------------------------------------------
) c ^+ o5 d; e: m1 C( { S2000:7873 not_extension_component: ; CODE XREF: Decompression_Ngine+90
/ S( _1 d" b! Q! `4 F( \2000:7873 ; Decompression_Ngine+A5
, ]7 y% {! o. Q8 E1 W2000:7873 pop gs
. l L8 [& v0 E9 \2000:7875 call Make_CRC16_Table
& R/ [$ f# g) E: j* U2000:7878 call Read_Header ; fetch header component to scratchpad_seg, on error CF=1
9 ~* _" l. t9 f. s8 D2000:787B jb exit ; ret with error code set6 h& `" Y5 R1 N4 {1 [7 y/ A
2000:787F mov ax, ds:108h ; mov ax, decomprss_seg_addr b- z! ~. J1 m
2000:7882 mov ds:104h, ax ; mov nu_decomprss_seg_addr, ax
# ~0 U! `# `& s8 H2000:7885 mov ax, ds:10Ah ; mov ax, decomprss_offst_addr
; _- @6 m( @$ K4 E- P2000:7888 mov ds:106h, ax ; mov nu_decomprss_offst_addr, ax: t9 o) ?" p7 i! y; \; C
2000:788B mov ecx, ds:310h ; ecx = compressed_component_size
1 X$ _1 X8 S2 f g& |5 v2000:7890 xor eax, eax- G' D5 E4 P/ e( `3 O3 y( ]9 a, t
2000:7893 mov al, ds:571Ch ; al = LZH_hdr_len
" J. @) p% V3 J0 V- O3 s2000:7896 add ecx, eax ; ecx = compressed_cmpnnt_size + LZH_hdr_len
' N; g5 }5 G& A) G1 `1 V2000:7899 add ecx, 3 ; ecx = compressed_cmpnnt_size + LZH_hdr_len +
+ @1 J! P2 P% B( e2000:7899 ; sizeof(EOF_byte) + sizeof(LZH_hdr_len_byte) +
6 M' @0 j6 |5 D2000:7899 ; sizeof(LZH_hdr_8bit_chk_sum)
) A1 ?0 K4 ]# x# u1 D: j6 g2000:7899 ; i.e. ecx = overall_component_len& y5 B* ^0 M" e/ @
2000:789D mov edx, ds:314h ; mov edx, original_file_size
& F* w, k, @4 z. q- R* Y4 p+ S. l# l* w+ g2000:78A2 push edx) t! X! `. c1 \ q. S
2000:78A4 push ecx& i. \* L5 r8 q! \2 o, z( `
2000:78A6 push bx
6 a% e4 n `4 y# W2000:78A7 add bx, 5 ; point to LZH ID byte
8 \/ W' _* p& E4 w2000:78AA call Fetch_Byte
" \$ M! n8 K' N; j, h2000:78AD pop bx
& z2 Y' y4 P% j& C. W2000:78AE cmp al, '0' ; is '-lh0-'?+ u$ `8 `! j% q5 l9 U( q* i
2000:78B0 jnz short decompress_part# ?- r) [* H4 v3 F4 i# P
2000:78B2 push ds
( I0 u3 ~" o# m; M) A3 r2000:78B3 push si9 z+ Y# Y6 P& {% I. G
2000:78B4 push bx c$ o# ^7 ]$ x! U: ?
2000:78B5 mov di, ds:10Ah0 I( K' }: m& h
2000:78B9 movzx ax, byte ptr ds:571Ch4 ~" s5 W( |0 t+ M+ V- T* T f
2000:78BE add ax, 28 i8 m6 |, u: e) H5 g: ^8 _# \
2000:78C1 add bx, ax
( S" \# U6 Q5 m9 d; i2000:78C3 mov cx, ds:310h
' ^$ S. x1 D' \" Q2000:78C7 mov ax, ds:108h" j; t' c! Q9 o3 f
2000:78CA mov es, ax
* b* \! `! ^- k, W7 m2000:78CC add cx, 3 ~4 P" t& H0 W1 V& Y, |
2000:78CF shr cx, 2! s7 D9 {& _, f; s" |
2000:78D2 next_dword: ; CODE XREF: Decompression_Ngine+151 {: A, Z U3 h; K3 `9 G
2000:78D2 call Fetch_Dword
" H) Q1 V/ G; Q3 }2 @' B2000:78D5 add bx, 41 c* A {& {& p$ P0 w
2000:78D8 stosd& V) V2 E+ v4 F5 L/ q% @
2000:78DA loop next_dword
7 L3 B* K6 E! y- `' u; M2000:78DC pop bx
" X. ?/ i, @3 z. W1 X- G1 d: T2000:78DD pop si
8 A" \. S2 \: W) t* p6 \: U2000:78DE pop ds
1 |* Y0 ~7 j3 ]$ r: L# c2000:78DF jmp short LZH_hdr_OK
; O8 ?0 N9 t+ V& R. ` Z) Q. M2000:78E1 ; ---------------------------------------------------------------------------0 Q2 O$ C- c! N0 n+ Z4 C4 E1 U' q
2000:78E1 decompress_part: ; CODE XREF: Decompression_Ngine+1279 s( i" e U" B0 G
2000:78E1 push word ptr ds:104h ; save destination seg addr
% y" B5 m% X1 v( Q7 x2000:78E5 push word ptr ds:106h ; save destination offset addr
$ E0 }7 M# J2 r2000:78E9 push large [dword ptr ds:314h]7 ]9 ^- D' B9 v2 K) |
2000:78EE call Lzh_Expand ; Lzh_Expand capable of handling compressed
3 O' J5 ^. b2 L3 D# M4 y, t& q2000:78EE ; component bigger than 64KB (1 segment)3 i) ]# }2 V$ s. s7 N0 V, p/ r
2000:78F1 pop dword ptr ds:314h
& t& Y1 }2 Q" Q& F/ ^6 y+ W0 L2 j2000:78F6 pop word ptr ds:106h
4 i6 {, \- ^' p6 w" M: N2000:78FA pop word ptr ds:104h1 @3 V( c9 X9 q" Y
2000:78FE LZH_hdr_OK: ; CODE XREF: Decompression_Ngine+156% S4 s% K7 c$ ?& q. T! |% K5 K& }
2000:78FE call Zero_Init ; zero init 32KB of scratchpad_seg0 x' Z* [ Q) n/ u* |0 J8 E# C# p8 g% o
2000:7901 pop ecx% U% q, [( J t$ |; ]) ]
2000:7903 pop edx* ?7 b+ Y7 U, _% e
2000:7905 clc
9 f: c4 g z2 [6 k6 @& J* c3 K2000:7906 exit: ; CODE XREF: Decompression_Ngine+E7! f+ N; A& @6 l6 `' R0 w
2000:7906 ; Decompression_Ngine+F2# c, E, c: d) G! z) K; Z2 U# {
2000:7906 pop es* s) L8 ]* W' n" V
2000:7907 pop bx
# d$ r+ O8 r0 \' C0 u0 f. \2000:7908 pop eax
9 Q. _! t! U3 u% P2000:790A retn; f `& `5 |! L7 F1 r
2000:790A Decompression_Ngine endp
- Q* V/ X, g2 a4 E+ ^, @________________________________________; l; B# t- s- o6 P) v
# [2 x# I5 ~% v6 d# n( }
2000:790B --- Make_CRC16_Table ---
- j H( b% \& e/ ]+ y3 `4 p2000:790B 1st pass, the base address for DS is 3_0000h' M1 T) C" d" p
2000:790B in: ds = scratch_pad_segment for CRC table
' r0 o: m3 U' I* M3 \: M2000:790B out: ds:10Ch - ds:11Bh = CRC-16 table
$ C" T" a3 \" O8 J3 \+ e& G2000:790B ; --------------- S U B R O U T I N E ---------------------------------------. _$ i; N% U- O3 [
2000:790B Make_CRC16_Table proc near ; CODE XREF: Decompression_Ngine+EC7 O% {" b& g" F" m" _
2000:790B 51 push cx
* s2 }4 \, J) Z$ O2000:790C 53 push bx
9 A( ~/ B/ |# Z8 o9 d2000:790D 50 push ax
; D! @* {! u! z! o2000:790E 56 push si* m; A' T# Z- J; h. B
2000:790F BE 0C 01 mov si, 10Ch
+ H5 P0 V8 b; C: B! r8 x: l2000:7912 B9 00 01 mov cx, 100h) `6 M+ m- b3 u% ?- h5 N* F, }
2000:7915 next_byte: ; CODE XREF: Make_CRC16_Table+2B" X/ s! k; r3 |4 J
2000:7915 B8 00 01 mov ax, 100h
0 ?* M' [# p1 j; u0 y- {' T4 U2000:7918 2B C1 sub ax, cx
: R' M. _7 M! c* A2000:791A 50 push ax
$ C1 F0 q& Q8 t2000:791B BB 00 00 mov bx, 06 `) z1 n* {7 A$ I/ w$ X; ]& M9 t
2000:791E is_bit: ; CODE XREF: Make_CRC16_Table+25
s# X. z k, q# }% w6 q+ g2000:791E A9 01 00 test ax, 16 y0 t( Y* Z6 B9 o5 m) b
2000:7921 74 07 jz short not_bit
8 I0 S4 H; h2 h1 Y2000:7923 D1 E8 shr ax, 13 P7 V% v+ m$ Y. C
2000:7925 35 01 A0 xor ax, 0A001h ; CRC poly" P9 t+ D+ n1 r9 B: ^" b
2000:7928 EB 02 jmp short point_to_next_byte
* _& y0 ~- c+ x9 S$ K4 \2000:792A ; ---------------------------------------------------------------------------
K; f6 m; }! D# Z/ w2000:792A not_bit: ; CODE XREF: Make_CRC16_Table+166 W! {+ y0 Q' ?4 X
2000:792A D1 E8 shr ax, 1
* j. ?! R) v3 V$ [3 k2 O2000:792C point_to_next_byte: ; CODE XREF: Make_CRC16_Table+1D4 W4 N0 m3 I, E% D; h6 j
2000:792C 43 inc bx3 |! E9 s7 C5 G0 `
2000:792D 83 FB 08 cmp bx, 8
/ _) E$ ]) o2 \2 C: h9 k2000:7930 72 EC jb short is_bit' k& J4 z9 G$ C& a9 [5 `8 g, ?
2000:7932 5B pop bx
* F/ C# F5 m: m5 T2000:7933 89 00 mov [bx+si], ax' W7 V/ l7 K# `! c! c9 ^5 v
2000:7935 46 inc si, U" r Y. ~% `$ E( m# |% d, L! E5 q
2000:7936 E2 DD loop next_byte# r$ D0 N- e# U* g b; j2 _% `
2000:7938 5E pop si# y1 R/ K L3 _. ?
2000:7939 58 pop ax9 [0 i2 u' L) S, M; w" ^
2000:793A 5B pop bx
1 u1 E d% @" d3 \- U2000:793B 59 pop cx- w9 D# K$ g, N+ h/ ^4 ^/ U! ]! f: t. ]
2000:793C C3 retn+ Y: [0 H: \2 A1 r7 T" G
2000:793C Make_CRC16_Table endp1 y. O7 E& k! N( @- Z+ g; |
________________________________________* H b1 o/ `' n0 c
# y( L+ s) S4 u* E- p7 W* l4 K
2000:79E8 --- Read_Header ---2 x _" e! U# o5 Q, l
2000:79E8 in: ds = scratchpad_segment
D9 O: Q! D: l2 M( U' a# ]: _7 ]2000:79E8 ds:102h = LZH_hdr_byte_index& H& W: s5 n: p" L9 p: S
2000:79E8
- V& n1 ~ S0 O+ X" b( G, o% J2000:79E8 out: ds:102h = LZH_hdr_byte_index
3 ]2 \' p8 ~' h2000:79E8 ds:108h = componnt_decomprrsion_seg_addr; ]; s, e/ L$ ~. U, q9 V8 y: K
2000:79E8 ds:10Ah = componnt_decomprrsion_offset_addr. w# S, I/ X2 h" x P2 ?- V5 U) n' R
2000:79E8 ds:310h = uncompressed_componnt_size
! b. x# [6 w- g$ y: o8 T2000:79E8 ds:314h = component_seg:offset_decompression_addr
9 q4 }7 Y. P+ E2000:79E8 ds:571Ch = LZH_hdr_len
, Y M; S$ P; W7 O C2000:79E8 ds:571Dh = LZH_hdr_chksum: I. `9 o. s! p* ~
2000:79E8 ds:571Eh = LZH crc16 val
) P! Y u: E% ^: N2000:79E8 ds:0 - ds:LZH_hdr_len = copy of current component LZH hdr
! ?. R4 c6 ?7 q' W/ Z0 }2000:79E8 ; --------------- S U B R O U T I N E ---------------------------------------
8 F6 [/ \# O" H* o/ p0 d2000:79E8 Read_Header proc near ; CODE XREF: Decompression_Ngine+EF# k8 c: d' |+ W2 y# V+ m
2000:79E8 60 pusha6 h5 ~ r) R2 b7 r/ g
2000:79E9 06 push es
- a; ^' ?- c) p8 Q2000:79EA 8B 1E 02 01 mov bx, ds:102h
# H% b2 k3 ^7 q. D2000:79EE E8 DA 00 call Fetch_Byte
: W" w& x2 X2 j6 C; G% |1 A9 r+ D; M2000:79F1 FF 06 02 01 inc word ptr ds:102h9 @! [2 B" j3 p. S
2000:79F5 A2 1C 57 mov ds:571Ch, al
0 V, x( E" S9 n! @2000:79F8 07 pop es- Q) E, V+ B' G9 G
2000:79F9 80 3E 1C 57 00 cmp byte ptr ds:571Ch, 0+ V+ U7 c4 h" u% G
2000:79FE 75 04 jnz short read_LZH_hdr_ok7 |# K! f0 B% u1 z
2000:7A00 error: ; CODE XREF: Read_Header+38; n; E" ^4 Y5 B- M/ q9 }9 a) M5 K/ Y
2000:7A00 ; Read_Header+71 ...
3 ] z5 j' W) W1 F2000:7A00 F9 stc
' Q- L) s% J) V$ j+ B, U6 m2 }2000:7A01 E9 86 00 jmp exit
2 W$ m& s5 K" f; U% g2000:7A04 ; ---------------------------------------------------------------------------- p7 f, T0 u7 \. U9 K4 ~ R& ]
2000:7A04 read_LZH_hdr_ok: ; CODE XREF: Read_Header+16% u7 G; i. Z& F% |
2000:7A04 06 push es6 `/ U# C% T, b/ I" P8 b
2000:7A05 8B 1E 02 01 mov bx, ds:102h! _& W+ R I! f( E- n0 l- z( x
2000:7A09 E8 BF 00 call Fetch_Byte ; read LZH_hdr_chksum byte
2 Z* |# D g0 e0 U8 N2000:7A0C FF 06 02 01 inc word ptr ds:102h& d# r; c h) I( \, A( I+ g. Z
2000:7A10 A2 1D 57 mov ds:571Dh, al ; 1st pass: 3000:571D = LZH_hdr_chksum9 c0 d( x* D2 l$ w
2000:7A13 07 pop es
& V, ]+ I; S- J1 ^% }$ _) u2000:7A14 E8 26 FF call Calc_LZH_hdr_CRC16 ; fetch compressed component value to RAM,* a9 R6 K% H2 Q7 F( x( ]2 J) g
2000:7A14 ; then calc its CRC16 checksum3 r- D6 ^4 a1 n% e
2000:7A17 E8 88 FF call CalcHdrSum / W4 X8 {/ K3 n7 B5 }6 k' M: n+ ~, U3 `6 Y
2000:7A1A 3A 06 1D 57 cmp al, ds:571Dh ; is the stored LZH_hdr 8-bit chksum match the one that read?4 G4 R' p( o) H: h
2000:7A1E 74 02 jz short LZH_hdr_8bit_chksum_ok
7 T1 q. J! b9 F2000:7A20 EB DE jmp short error* P3 H% h, p; t
2000:7A22 ; ---------------------------------------------------------------------------7 @0 f. [3 [" c
2000:7A22 LZH_hdr_8bit_chksum_ok: ; CODE XREF: Read_Header+363 h" B2 a+ v( o
2000:7A22 BB 05 00 mov bx, 5; E) C Q: {1 B( }# L
2000:7A25 B9 04 00 mov cx, 4 ; bx+cx = compressed_component_size_index (Dword)
4 V8 T+ C% u: L9 D8 |( V2000:7A28 E8 99 FF call GetFromHeader# f# y5 x: u( k( o% Z$ D/ x5 i2 h
2000:7A2B 66 A3 10 03 mov ds:310h, eax5 I9 \' }: c# p* V$ \+ }
2000:7A2F BB 09 00 mov bx, 9 x1 H m' U2 p1 ~! w- e
2000:7A32 B9 04 00 mov cx, 4 ; bx+cx = original file size (Dword)
8 H2 z9 `' b8 `2 ~8 [/ o. q/ m2000:7A35 E8 8C FF call GetFromHeader, r/ }: M5 m+ J) }
2000:7A38 66 A3 14 03 mov ds:314h, eax& x# p0 g# N4 x: ~
2000:7A3C BB 0D 00 mov bx, 0Dh
1 n' c* Q! S2 j5 C ?2000:7A3F B9 02 00 mov cx, 2 ; bx+cx = decompression_component_offset addr (Word)! y, p9 Q3 P1 s$ _5 P
2000:7A42 E8 7F FF call GetFromHeader
. r1 _# D9 y- ~. H x) w4 z4 h; _2000:7A45 A3 0A 01 mov ds:10Ah, ax5 b! H! }6 B9 \3 U+ m8 Z! j
2000:7A48 BB 0F 00 mov bx, 0Fh. G2 c' d- y2 @# s) I4 P9 u0 D: {
2000:7A4B B9 02 00 mov cx, 2 ; bx+cx = decompression_component_segment addr (Word)
3 b7 {. I+ ? C: t2000:7A4E E8 73 FF call GetFromHeader- a, s# V- ? h
2000:7A51 A3 08 01 mov ds:108h, ax
, c2 J q7 m$ d% {; H; z0 ], ]3 p2000:7A54 80 3E 11 00 20 cmp byte ptr ds:11h, 20h ; ' ' ; is LZH level 1 file attribute?$ Q+ @ m& t* [
2000:7A59 75 A5 jnz short error0 j6 A6 j& t, v: e. _* v
2000:7A5B 80 3E 12 00 01 cmp byte ptr ds:12h, 1 ; is LZH level 1 ?
- O1 u& x0 w$ _2000:7A60 75 9E jnz short error* Q( h9 w' a3 ^- y6 @
2000:7A62 0F B6 1E 1C 57 movzx bx, byte ptr ds:571Ch ; bx = lzh_hdr_len$ \3 ?: Q% o7 V3 J" v
2000:7A67 83 EB 05 sub bx, 5 ; bx = CRC16_byte_index
' s+ Q* A) G! r2 ]# e; N+ B1 X! j' [2000:7A6A B9 02 00 mov cx, 2
8 z1 M2 O; a \% w& F2000:7A6D E8 54 FF call GetFromHeader ; read CRC16 value
7 ]3 w( X2 X; ^# F1 J8 k8 l/ X2000:7A70 A3 1E 57 mov ds:571Eh, ax ; ds:571Eh = CRC16_val
3 [2 m; \9 s5 f1 @$ E3 r6 ]2000:7A73 BB 13 00 mov bx, 13h ; bx = filename_len byte index8 Z: B+ i7 @4 ~/ p
2000:7A76 8A 9F 00 00 mov bl, [bx+0] ; bl = filename_len$ t5 \# t! I0 I I
2000:7A7A B8 14 00 mov ax, 14h0 x2 t2 R5 b9 a$ H7 J0 y7 J
2000:7A7D 03 D8 add bx, ax ; bx = CRC16_byte_index
? ~& v+ e1 Q1 |9 h: X1 q2000:7A7F C6 87 00 00 24 mov byte ptr [bx+0], 24h ; '$'7 S+ A- B6 M5 T& u
2000:7A84 C6 87 01 00 00 mov byte ptr [bx+1], 0# M$ i5 f9 W" Y( V; j; v7 N2 \% \
2000:7A89 F8 clc
- l* f; v) q: F7 r4 F" z2000:7A8A exit: ; CODE XREF: Read_Header+19
1 [% U! c& U: u1 |! m1 A2000:7A8A 61 popa5 v0 C3 V, f0 e+ d
2000:7A8B C3 retn3 o' v$ P7 b- @' e( x1 O
2000:7A8B Read_Header endp
. X6 M4 Z5 e# c1 @8 X( `________________________________________1 Q' i/ C. x3 h/ O" `- V) ~. S W
+ r0 g% T8 ~- _/ M" j
2000:793D Calc_LZH_hdr_CRC16 proc near ; CODE XREF: Read_Header+2C
8 F: r* t& W2 t: {; p$ X3 A1 m2000:793D 50 push ax4 A. m2 d) f( e0 M
2000:793E 53 push bx
/ B+ m. \8 {# O# R3 N" L$ t2000:793F 51 push cx
! Q; H$ P: c q3 e# i- D( r2000:7940 52 push dx2 @6 y& N, n7 i3 Z0 y
2000:7941 0F B6 0E 1C 57 movzx cx, byte ptr ds:571Ch" W/ D( o5 T1 F$ l- v Q1 k
2000:7946 06 push es
2 n( B- ^! Q) O3 z2000:7947 56 push si+ F' X! J6 }) n* t h
2000:7948 8B 1E 02 01 mov bx, ds:102h# ?) {; V: m: ~
2000:794C BE 00 00 mov si, 0
. _. `7 F( i& t1 Z7 T2000:794F next_byte: ; CODE XREF: Calc_LZH_hdr_CRC16+19' U+ U9 {0 x& N! a" y+ a8 u8 p! l
2000:794F E8 79 01 call Fetch_Byte
; n# h2 Y: k4 p6 W1 `2000:7952 88 04 mov [si], al) z& u P& G9 z5 ?" H9 _1 j# o
2000:7954 43 inc bx- Y) p8 \2 U D: I2 T% }
2000:7955 46 inc si
1 a! m. n& j( ]% O+ |1 j9 _2000:7956 E2 F7 loop next_byte2 I$ r3 o( C8 X4 m3 {4 i* h
2000:7958 8B C3 mov ax, bx! p; k3 c. ?3 l8 V6 C. L
2000:795A 2B 06 02 01 sub ax, ds:102h& Z; I/ ]$ ^5 P7 n' e
2000:795E 89 1E 02 01 mov ds:102h, bx, U" \$ z- e) f' O8 U! j
2000:7962 5E pop si2 m, `6 @- O8 i T6 R. `/ B; @" E
2000:7963 07 pop es5 m- X- T1 b' ^, E2 F8 F- U
2000:7964 A2 1C 57 mov ds:571Ch, al; R5 W- Y/ z$ N5 X
2000:7967 8B C8 mov cx, ax$ e' j7 Q$ J# a Q" o* o; i* ]! p
2000:7969 01 06 14 03 add ds:314h, ax$ x) k3 u* Y; w. o8 s
2000:796D 41 inc cx
- C0 s; m3 j" C) |7 X# q# U- s2000:796E BB 00 00 mov bx, 04 ? l6 n" ]+ a) F) [
2000:7971 next_CRC_byte: ; CODE XREF: Calc_LZH_hdr_CRC16+5E$ E* N" E ]: `# O; X+ }" R& U
2000:7971 0F B6 07 movzx ax, byte ptr [bx]
% d3 E- t. r! @& a' w2000:7974 49 dec cx
0 W1 X1 [6 F* y2000:7975 E3 26 jcxz short exit" Q/ |& y5 B' ]$ S! D
2000:7977 50 push ax/ z1 T; ~1 j; ^4 m( Y( ^
2000:7978 53 push bx U9 P8 f4 [3 g/ f$ j
2000:7979 56 push si. R0 |3 ?% r4 M+ ` {
2000:797A 8B F0 mov si, ax0 B3 H( J$ M0 N' s, ^2 X% g6 @7 S
2000:797C A1 0C 03 mov ax, ds:30Ch$ d: L8 {6 O+ m* q2 z, k
2000:797F 33 C6 xor ax, si1 C" ^6 x9 F' F8 H* v
2000:7981 25 FF 00 and ax, 0FFh: N/ P! c- r8 N W5 o
2000:7984 8B F0 mov si, ax
4 n% c! B( o4 F5 E) t2000:7986 D1 E6 shl si, 14 m5 J( G! ~0 r
2000:7988 8B 9C 0C 01 mov bx, [si+10Ch]' \4 u+ f+ D5 p4 T5 \
2000:798C A1 0C 03 mov ax, ds:30Ch5 m/ y* b* c8 T2 i; u3 q1 q' O- l
2000:798F C1 E8 08 shr ax, 8
) D; c s6 B2 m$ D1 L& x7 @2000:7992 33 C3 xor ax, bx
/ q+ I; I. T/ C' p$ g; U2000:7994 A3 0C 03 mov ds:30Ch, ax
2 c! M) L( Z. G+ G! [2000:7997 5E pop si
1 q" ^! j6 X* N9 ~' W2000:7998 5B pop bx
" n( y( D# R' N! X8 d2000:7999 58 pop ax, r; Y( O% G* E7 R4 n
2000:799A 43 inc bx0 v1 u' ~0 N" S& {5 n. p: Z0 L
2000:799B EB D4 jmp short next_CRC_byte, I- T( [/ q9 L; e6 y. h/ i2 u
2000:799D ; ---------------------------------------------------------------------------
; W8 n5 y# E7 a( }0 O1 v, [! g2000:799D exit: ; CODE XREF: Calc_LZH_hdr_CRC16+383 i& I6 v; t1 k7 v z, c A6 y
2000:799D 5A pop dx
/ t% H2 l$ f' W( Z& t. E, \2000:799E 59 pop cx. z( s" |5 U0 \2 v8 T
2000:799F 5B pop bx
$ S# `0 H7 k3 ?; B" G2000:79A0 58 pop ax
) Q, Z/ k2 J8 A. M2000:79A1 C3 retn+ X) V" ~% o7 `' [
2000:79A1 Calc_LZH_hdr_CRC16 endp
8 t' C' K, ^& X7 b" X" Y U9 B- j7 Y________________________________________9 [8 G Q. P8 h2 d4 h
# n7 f8 G& Z2 S" X/ ^0 M# I5 c2000:79A2 CalcHdrSum proc near ; CODE XREF: Read_Header+2F
. b- v! ~0 R; k( Q2000:79A2 53 push bx
* e: y1 Y, S; Q. z' o( D2000:79A3 51 push cx
* V9 w5 L0 }1 Z! Y2000:79A4 52 push dx; @) m$ x9 R/ T" P3 i/ ]
2000:79A5 B8 00 00 mov ax, 0" n/ { V/ W# `2 [3 S" Y, e
2000:79A8 0F B6 0E 1C 57 movzx cx, byte ptr ds:571Ch4 u( a0 S8 o4 u0 s
2000:79AD loc_2000_79AD: ; CODE XREF: CalcHdrSum+19 j$ h7 _6 Y n8 l$ v! ~% f
2000:79AD 0F B6 1E 1C 57 movzx bx, byte ptr ds:571Ch6 u% y3 D1 T8 K7 @
2000:79B2 2B D9 sub bx, cx0 r/ R8 }% U5 s
2000:79B4 0F B6 97 00 00 movzx dx, byte ptr [bx+0]$ P& r2 s# `/ }1 y0 e
2000:79B9 03 C2 add ax, dx
) p0 w; T7 k5 p; K. P2000:79BB E2 F0 loop loc_2000_79AD5 Q+ E- X! d- X! f0 ^8 P
2000:79BD 5A pop dx8 {7 c) j( }, t* L4 Y8 |( H
2000:79BE 59 pop cx
3 k; w- s; e! b) ^6 N2000:79BF 5B pop bx
) f! L) M6 U# B o2 ~2000:79C0 25 FF 00 and ax, 0FFh* {+ _4 i. C5 e. N/ Z
2000:79C3 C3 retn
( U- |2 ~/ h- A$ c, z2000:79C3 CalcHdrSum endp
$ ?/ f7 M9 B% J5 N. |2 `________________________________________
, Z; Q1 E. _ F5 _3 C/ c9 R$ u4 i! E2 J! A& F
2000:79C4 --- GetFromHeader ---: ]3 t: I- H6 f
2000:79C4 in: bx = byte_index of the "component" to read
2 t& \$ n4 ~5 n3 d/ g0 |2000:79C4 cx = length of "component" to read7 w) k5 i- X+ S! W F1 d( a. V7 K
2000:79C4
, A8 U, j: O2 x, W- k8 P- U2000:79C4 out: eax = dword_read
, J' E0 j0 a7 S& R7 T2000:79C4 ; --------------- S U B R O U T I N E ---------------------------------------
6 G+ m/ e( c. K8 B" t: G8 I2000:79C4 GetFromHeader proc near ; XREF: Read_Header+40
. b1 c5 S# d: H+ s1 G! R. ~2000:79C4 ; Read_Header+4D ...7 K0 _! Y' ? T( @& f/ G
2000:79C4 53 push bx2 L7 k9 v8 ]% Y! t C" Y
2000:79C5 66 52 push edx
8 J f* t& q& z* `( H: w Z2000:79C7 56 push si
+ @" Y) |, g! m: l2 o2 F3 _, o# E4 Y2000:79C8 66 33 C0 xor eax, eax8 l$ U6 {0 q7 O. E6 ~
2000:79CB 4B dec bx
# T- {4 x' O# Y2000:79CC 41 inc cx! h+ k1 h) c8 x
2000:79CD next_byte: ; CODE XREF: GetFromHeader+1D+ }4 z% b; z! V& E9 X* W5 ]
2000:79CD 49 dec cx
! Z d- ?, `$ g* F2000:79CE E3 13 jcxz short exit) W. @) [" G6 |) \7 {' a, Q
2000:79D0 66 C1 E0 08 shl eax, 8: f% `% h0 h S# t
2000:79D4 8B F3 mov si, bx8 Z N1 P5 w' c
2000:79D6 03 F1 add si, cx
4 L0 W2 N9 |4 i. x# A6 Z. C2000:79D8 66 0F B6 94 00 00 movzx edx, byte ptr [si+0]
$ f, B3 i. n, v$ j# I* B/ G2000:79DE 66 03 C2 add eax, edx
! L9 |+ p! r( o' k# L6 E" U! C2000:79E1 EB EA jmp short next_byte
8 ]& L, K$ {# [; z* F8 U2000:79E3 ; ---------------------------------------------------------------------------
0 R' |0 [7 A6 c. }4 v9 u2000:79E3 exit: ; CODE XREF: GetFromHeader+A) u) d6 _. Z) V j" G( N4 K: U
2000:79E3 5E pop si) n% l; x2 J6 L2 q8 r
2000:79E4 66 5A pop edx% b4 K, O1 G. b- V: R# N
2000:79E6 5B pop bx k, B- S2 t- [: Y' j# k
2000:79E7 C3 retn# u9 P( y2 F7 r
2000:79E7 GetFromHeader endp
) N$ R' y% A- _3 A. b% W看完这些彻底的线索,我们成功的构建映射了bios解压部分:
- M, x9 R0 g3 K9 W. J) CStarting address of decompressed BIOS component in RAM Compressed Size Decompressed Size Decompression State (by Bootblock code) Component description1 L3 y% R7 c3 `' h( R8 }( @% q
4100:0000h 3A85h 57C0h Decompressed to RAM beginning at address in column one. awardext.rom, this is a "helper module" for original.tmp! O$ s9 q3 Y; c, n- v7 C
4001:0000h 5CDCh A000h Not decompressed yet cpucode.bin, this is the CPU microcode
* o) ]6 f7 I5 r. O: _& O6 `/ O4003:0000h DFAh 21A6h Not decompressed yet acpitbl.bin, this is the ACPI table
1 v I# _. `9 |3 H: y3 h4002:0000h 35Ah 2D3Ch Not decompressed yet iwillbmp.bmp, this is the EPA logo
& g3 Z Q8 u9 D# o. V/ J3 Y4027:0000h A38h FECh Not decompressed yet nnoprom.bin, explanation N/A c9 l# e& I8 \: F
4007:0000h 1493h 2280h Not decompressed yet antivir.bin, this is BIOS antivirus code+ K: E; l! k7 w& r8 X, ?6 ?
4028:0000h F63Ah 14380h Not decompressed yet ROSUPD.bin, seems to be custom Logo display procedure
2 w0 V- w9 z/ H3 ]- _: a5000:0000h 15509h 20000h Decompressed to RAM beginning at address in column one. original.tmp, the system BIOS+ \3 D2 v6 i7 t( k
注意:绿色覆盖的解压地址被另外的方法处理:
9 U5 a+ Y- J0 `1 T! w) z* p8 q5 ZA. 上面解释的部分不是真正的被解压区域。只是某种真正解压区域的占有区域,稍后由original.tmp处理。结论是:在bootblock中只有original.tmp和awardext.rom被Decompress_System_Bios解压缩。如果你想改变这个,那么试着计算被解压代码的大小总和,他不会合适的!
! _9 J9 N9 \8 L/ l7 [- k* wB. 所有的这些被解压段地址部分被Decompression_Ngine procedure变换到4000h,就像你看到的在例程里面地址2000:7842h。6 i9 m9 Z6 o) e
C. “(被解压)开始地址。。。”中的40xxh 实际上是一个ID,工作如下:40(高字节)是ID,标示它是一个扩展bios,将要在稍后的original.tmp执行时被解压缩。Xx是一个id,在original.tmp用到,标示要被解压缩的部分。这些在下面的original.tmp中会详细解释。+ E' e7 k2 r4 T7 p/ I& e
D. 所有的这些部分都要在original.tmp执行时被解压缩。解压结果被放在地址4000:0000h,但是不会在同一时刻。有一些(也许所有的)部分也要从那个地址重新定向,在另外的部分在那个地址被解压缩后保留他们的内容。这些在下面的original.tmp中会详细解释。! j o4 F0 Z" ^+ V9 q% ?- j
7.1.6.7. Shadow the BIOS code
6 l5 V, w) s8 k) o% @/ Z% o7.Shadow bios代码。假设解压例程成功的完成了,上面的例程接着拷贝被解压得system bios(original.tmp),从RAM中的5000:0000h - 6000:FFFFh到E_0000h - F_FFFFh。完成如下:
j/ I6 f% A- }6 t- h) F0 S1 P9 R1)重新编程北桥shadow RAM控制寄存器,使能只写到地址E_0000h - F_FFFFh,促进写操作这个地址范围到DRAM(没有到bios rom芯片)。6 _, k, I$ ?0 V
2)进行一个字符串拷贝操作,拷贝被解压了的system bios(original.tmp),从5000:0000h - 6000:FFFFh到E_0000h - F_FFFFh。& |" x* X3 |0 v5 e
3)重新编程北桥shadow RAM控制寄存器,使能只读到地址E_0000h - F_FFFFh ,促进读操作这个地址范围到DRAM(没有到bios rom芯片)。这个也是对system bios 代码写保护
' {/ ?# m. K% {7.1.6.8. Enable the microprocessor cache then jump into the decompressed system BIOS
* U$ y+ O' r7 H6 b( @ 8.使能微处理高速缓存,然后跳转到压缩的system bios。这一步是普通bootblock代码执行路径的最后一步。使能处理器高速缓存后,代就会跳转到RAM地址F000:F80Dh中的写保护的system bios(original.tmp),如上面看到的代码。这个跳转的目的地址好像在不同的award bios中都一样。2 F! U( o( |$ d; a- D
现在我要呈现在跳转到解压缩的original.tmp之前,压缩的和解压的bios部分的内存地图。这个很重要,因为这会在等会的分析解压缩了的original.tmp方便我们。现在我们不得不注意,所有的代码都在RAM中之行,在没有代码在bios rom芯片中执行了。5 N2 B' Q' D& f- ~
Address Range in RAM Decompression State (by Bootblock code) Description& j8 D \9 G7 n3 i/ x$ E
0000:6000h - 0000:6xxxh N/A This area contains the header of the extension component (component other than original.tmp and awardext.rom) fetched from the compressed BIOS at 8000:0000h - 9000:FFFFh (previously BIOS component at FFFC_0000h - FFFD_FFFFh in the BIOS chip). Note that this is fetched here by part of the bootblock in segment 2000h. ) [, o5 w# a- ^
1000:0000h - 2000:5531h Compressed This area contains the compressed original.tmp. It's part of the copy of the last 128KB of the BIOS (previously BIOS component at E000:0000h - F000:FFFFh in the BIOS chip). This code is shadowed here by the bootblock in BIOS ROM chip.
) G. L% c0 ^# D$ N* P2000:5532h - 2000:5FFFh Pure Binary (non-executable) This area contains only padding bytes.
. @% n$ {+ Z0 B/ Y) w0 l6 \0 S2000:6000h - 2000:FFFFh Pure binary (executable) This area contains the bootblock code. It's part of the copy of the last 128KB of the BIOS (previously BIOS component at E000:0000h - F000:FFFFh in the BIOS ROM chip). This code is shadowed here by the bootblock in BIOS ROM chip. This is where our code currently executing (the "copy" of bootblock in segment 2000h).
0 _& a1 A% B# f/ x7 R* g4100:0000h - 4100:57C0h Decompressed This area contains the decompressed awardext.rom. Note that the decompression process is accomplished by part of the bootblock code in segment 2000h.
6 x! F1 T2 z C! m) Q* j$ T: U8 W5000:0000h - 6000:FFFFh Decompressed This area contains the decompressed original.tmp. Note that the decompression process is accomplished by part of the bootblock code in segment 2000h.
% ?/ a* M( z7 p# D1 w* C9 _8000:0000h - 9000:FFFFh Compressed This area contains the copy of the first/lower 128KB of the BIOS (previously BIOS component at FFFC_0000h - FFFD_0000h in the BIOS chip). This code is copied here by the bootblock code in segment 2000h./ g$ g" _4 ?; d( q p
E000:0000h - F000:FFFFh Decompressed This area contains copy of the decompressed original.tmp, which is copied here by the bootblock code in segment 2000h.3 g! ~) @, E9 `+ l
) L) }: Y. }: e 最后要注意:这里解释的booblock只涉及到了normal Bootblock code execution path ,意思是没有解释一旦original.tmp崩溃时的bootblock POST。有时间的话,我将要涉及到。所有的bootblock如上,我们将要开始研究original.tmp。
4 A! r/ F7 d. m! s) v- W7.2. System BIOS a.k.a Original.tmp/ u) T6 q0 q3 z% S, b. L
我们刚进行了上面的bootblock,我要高亮晦涩的代码执行路径。所以,现在,你正在看我的bios的解压了的original.tmp的反汇编代码。
% c! T8 E4 p& B$ V w: c. f7.2.1. Entry point from "Bootblock in RAM"
; t% e1 `9 Z3 Q$ G IAddress Hex Mnemonic3 F; @# I5 N6 {3 r
F000:F80D This code is jumped into by the bootblock code 2 B5 s6 f! k2 `
F000:F80D if everything went OK
( P1 P# x( m k- o' wF000:F80D E9 02 F6 jmp sysbios_entry_point ; 8 Y. I$ J: l0 b
这里是在重新定位和写保护system bios后,bootblock跳转的地方。; l* e% f# z, Q7 q g6 {! F& ^7 z$ W
7.2.2. The awardext.rom and Extension BIOS Components (lower 128KB bios-code) Relocation Routine
' D9 |0 s7 l; Q/ `# QAddress Assembly Code3 M) X: _1 ]4 f l0 t/ z
F000:EE12 sysbios_entry_point: ; CODE XREF: F000:F80D
8 `) c0 W9 y/ d$ Z E$ x1 `F000:EE12 mov ax, 0
6 u4 Q) u+ N E7 ~F000:EE15 mov ss, ax ; ss = 0000h: C3 `9 p, J q
F000:EE17 mov sp, 1000h ; setup stack at 0:1000h n9 k2 I& ]& J" m$ D
F000:EE1A call setup_stack ; Call Procedure6 E' A, T1 M" R% s* C K# v
F000:EE1D call init_DRAM_shadowRW ; Call Procedure
- ^7 K: \2 r/ [& T% i5 j2 ]6 o/ C! a% B8 KF000:EE20 mov si, 5000h ; ds=5000h (look at copy_mem_word), r* s f- M0 Q$ b* K% ^
F000:EE23 mov di, 0E000h ; es=E000h (look at copy_mem_word), W6 \" \- ^, [% I, Z
F000:EE26 mov cx, 8000h ; copy 64KByte4 x5 q9 Z- S( W# u2 r1 H5 j7 T. _! @
F000:EE29 call copy_mem_word ; copy E000h segment routine, i.e.* b: K9 ^* `4 N S. e* V; [
F000:EE29 ; copy 64Kbyte from 5000:0h to E000:0h
2 {! c0 [% n. \3 W1 v4 k lF000:EE2C call j_init_DRAM_shadowR ; Call Procedure+ i9 i2 }& b+ D* n# W
F000:EE2F mov si, 4100h ; ds = XGroup segment decompressed, i.e.3 w" R2 d U& {- P
F000:EE2F ; at this point 4100h
4 b0 x9 R- i+ D P$ xF000:EE32 mov di, 6000h ; es = new XGroup segment2 n7 \# U- E$ X9 a3 X: ]; u
F000:EE35 mov cx, 8000h ; copy 64KByte/ P% F* D7 o" e4 N
F000:EE38 call copy_mem_word ; copy XGroup segment , i.e.
$ ^! k/ s+ d# C; f6 YF000:EE38 ; 64Kbyte from 4100:0h to 6000:0h
" r9 m+ K" O# [3 p: C) EF000:EE3B call Enter_UnrealMode ; jump below in UnrealMode
# A0 g* Z n- r4 y2 }* {: o: YF000:EE3E Begin_in_UnrealMode
, i% Z4 g6 X* B; bF000:EE3E mov ax, ds7 k' _( p; N" `$ _# P7 R
F000:EE40 mov es, ax ; es = ds (3rd entry in GDT)
2 o: a/ A; i: ^7 n" r# P/ ~F000:EE40 ; base_addr=0000 0000h;limit 4GB4 J: T; f+ o- A5 F1 ?2 P* e
F000:EE42 assume es:nothing) v/ Y* z7 G$ V# s. X3 F N
F000:EE42 mov esi, 80000h ; mov esi,(POST_Cmprssed_Temp_Seg shl 4)
! {8 s; A) |# |3 T, { uF000:EE42 ; relocate lower 128KB bios code
; O+ o8 X, h7 a' V! {* `$ |. H7 WF000:EE48 mov edi, 160000h
% [. ^9 O/ A" g/ A8 d+ gF000:EE4E mov ecx, 8000h$ R3 O, C$ t5 p0 h( g1 a, ~
F000:EE54 cld ; Clear Direction Flag
' U. Y' o; x- E. |F000:EE55 rep movs dword ptr es:[edi], dword ptr [esi] ; move
8 R# N& C: \3 _1 k2 dF000:EE55 ; 128k data to 160000h (phy addr)
a, a, P( r# p* d; l$ VF000:EE59 call Leave_UnrealMode ; Call Procedure
% I6 P/ t) R& v3 k% ?: G8 ]& ?F000:EE59 End_in_UnrealMode
; R, w# A0 j8 s0 V7 N; u& g6 h( ^: yF000:EE5C mov byte ptr [bp+214h], 0 ; mov byte ptr 3 F- g+ N& g9 C: q% F) z
F000:EE5C ; POST_SPEED[bp],Normal_Boot) y% C( p* P: E4 d3 }( B# H
F000:EE61 mov si, 626Bh ; offset 626Bh (E000h POST tests)
* F( i# i0 K' u/ G7 ZF000:EE64 push 0E000h ; segment E000h
; ^5 `2 k; T+ R v7 mF000:EE67 push si ; next instruction offset (626Bh)" P* d' A# G+ @
F000:EE68 retf ; jmp to E000:626Bh
) ?0 J2 K- @& U" u* G/ P; V, g________________________________________
1 |+ z# {2 o' r T
( z9 t- D1 I& M4 PF000:7440 Enter_UnrealMode proc near ; CODE XREF: F000:EE3B9 z+ P8 P) x9 l- Y. M1 A+ C) A* e
F000:7440 mov ax, cs( v ~/ O( \) G4 A" B q( V' R
F000:7442 mov ds, ax ; ds = cs
E! y! L, ~1 f& z6 g, `F000:7444 assume ds:F000
- d4 \! M! ~, r% Y0 ?F000:7444 lgdt qword ptr GDTR_F000_5504 ; Load Global Descriptor Table Register0 F' G3 } h8 F |' j
F000:7449 mov eax, cr0
* u( z$ _& A k( p; IF000:744C or al, 1 ; Logical Inclusive OR
$ t: `8 g9 n# Y' i) tF000:744E mov cr0, eax
* j1 I$ e6 S! g. K$ d8 gF000:7451 mov ax, 10h- w0 Q6 M& I p/ B6 T1 }+ ^
F000:7454 mov ds, ax ; ds = 10h (3rd entry in GDT)
7 W! X2 |$ Y% u! E! H5 d! N1 WF000:7456 assume ds:nothing# q% {3 T* ] r3 J# B9 L2 N' d
F000:7456 mov ss, ax ; ss = 10h (3rd entry in GDT)( _/ n1 _& u9 U8 l; Z8 n+ S
F000:7458 assume ss:nothing7 r$ K5 a% v+ n, }* V3 ?
F000:7458 retn ; Return Near from Procedure0 O" C% X/ V; s6 [
F000:7458 Enter_UnrealMode endp- v( ]4 m q) X, C, {9 Q" ^0 p: U
________________________________________. ~. Y9 l0 P( x. g; h5 U
( K* E7 Z, g# C" R0 G% Q/ i
F000:5504 GDTR_F000_5504 dw 30h ; DATA XREF: Enter_PMode+40 c% ^+ F, N7 n% P4 b
F000:5504 ; GDT limit (6 valid desc)2 q9 e7 r4 p" V4 n# T8 z Q
F000:5506 dd 0F550Ah ; GDT phy addr (below): [* b! i4 ?: }) n
F000:550A dq 0 ; null desc) D4 i+ m$ V$ m& z2 v" Z! A' B4 W
F000:5512 dq 9F0F0000FFFFh ; code desc (08h)
/ f# z. M6 z+ I. `- c$ u5 {F000:5512 ; base_addr=F0000h;seg_limit=64KB;code,execute/ReadOnly
/ v$ Q1 o1 M& PF000:5512 ; conforming,accessed;granularity=1Byte;16-bit segment;( j6 P" R5 y0 T `) w! G+ z1 \
F000:5512 ; segment present,code,DPL=0
9 O& }# t: r$ ?F000:551A dq 8F93000000FFFFh ; data desc (10h)
/ V# e8 f! S: @ ^" }0 \4 c- b5 WF000:551A ; base_addr=0000 0000h;seg_limit=4GB;data,R/W,accessed;
2 U* j+ w5 A: b7 a* l1 f% oF000:551A ; granularity=4KB;16-bit segment; segment present,0 D; B" O' C, v( h' q4 X% f0 X
F000:551A ; data,DPL=0
9 @/ ^: V0 |2 a/ W& ^3 Q: DF000:5522 dq 0FF0093FF0000FFFFh ; data desc 18h
# L) X% {" C: ]3 M: L1 yF000:5522 ; base_addr=FFFF0000h;seg_limit=64KB;data,R/W,accessed;! }# A0 }2 C3 C: F" I: q
F000:5522 ; 16-bit segment,granularity = 1 byte;+ D- p: h$ `" {! y- ?
F000:5522 ; segment present, data, DPL=0./ H8 b p- c3 Q
F000:552A dq 0FF0093FF8000FFFFh ; data desc 20h
. l* } d0 T: g2 GF000:552A ; base_addr=FFFF8000h;seg_limit=64KB;data,R/W,accessed;. M$ w/ V% b' x; _. q6 a& D5 q% P
F000:552A ; 16-bit segment,granularity = 1 byte;
% S( J; Y4 ^9 g; M8 n/ \9 pF000:552A ; segment present, data, DPL=0.: R# D4 M: s* A
F000:5532 dq 930F0000FFFFh ; data desc 28h9 U& S8 R ^7 I1 V) @1 ~2 U3 Z
F000:5532 ; base_addr=F0000h;seg_limit=64KB;data,R/W,accessed;9 y. p0 t& X2 L4 s' {# t' w
F000:5532 ; 16-bit segment,granularity = 1 byte;
( f* W! K( |' r; B( C" m* f9 \F000:5532 ; segment present, data, DPL=0.
/ p9 o2 W5 K# v7 k4 t" s" A________________________________________
8 g- T5 i3 t. g9 J3 ^/ J- t注意:上面的代码执行以后,这个内存地图就再改变了一次。但是这个时候,只对于压缩BIOS扩展,比如低128KB的bios代码和解压缩了的awardext.rom,在上面bootblock解释到的内存地图部分的被覆盖了。# a% m6 Z6 b4 X1 g4 O$ o9 W
New Address Range in RAM Decompression State Description5 `* \* n. {5 \6 i; y, V
6000:0000h - 6000:57C0h Decompressed This is the relocated awardext.rom/ w/ P: t& ?& n
160000h - 17FFFFh Compressed This is the relocated compressed "BIOS extension", including the compressed awardext.rom. (i.e. this is the copy of FFFC0000h - FFFDFFFF in the BIOS rom chip. & m. l4 a$ X5 [1 s' s W6 r6 d, i
/ e( B+ S# _ G1 B: k1 K% }: ^+ g/ y
7.2.3. Call to the POST routine a.k.a "POST jump table execution" - [5 `/ z7 \9 H3 A0 G! Q# X
Address Assembly Code/ F4 {4 l7 q+ i6 \- v
E000:626B The last of the these POST routines starts the EISA/ISA6 Y' V) N! _- i
E000:626B section of POST and thus this call should never return.! {3 X; F# U9 k' l- L/ f' g% j: P
E000:626B If it does, we issue a POST code and halt.
/ R1 w( R: J/ U4 y" qE000:626B
' ]% m: {; s' T1 e' }4 e/ c% WE000:626B This routine called from F000:EE68h5 O; `$ c4 i9 [% @
E000:626B
8 q4 O' @$ D3 w3 a6 I7 J+ }E000:626B sysbios_entry_point_contd a.k.a NORMAL_POST_TESTS
4 w& w% X0 @. ]5 v* e" w7 T: }E000:626B mov cx, 3 ; mov cx,STD_POST_CODE O6 m/ c/ G! B( L& ?
E000:626E mov di, 61C2h ; mov di,offset STD_POST_TESTS
j# v# b( i2 ]% {/ `E000:6271 call RAM_POST_tests ; this won't return in normal condition
9 E8 Z0 j2 B2 V1 v8 W! C7 G- O# pE000:6274 jmp short Halt_System ; Jump
9 H! V, b9 L& I% Y+ o. V________________________________________3 g( i/ h5 v/ `; \: s
5 G( S( N7 j! o. X, i4 G
E000:6276 ; --------------- S U B R O U T I N E ---------------------------------------! J2 t7 |1 I' ^2 q" c$ B
E000:6276 8 q' C+ u9 ?" e& g
E000:6276 RAM_POST_tests proc near ; CODE XREF: last_E000_POST+D2 {/ Z2 B7 \& F/ [
E000:6276 ; last_E000_POST+18 ...& z" b ^$ F+ D. B3 g
E000:6276 mov al, cl ; cl = 38 L) b+ {+ x4 l; W/ {2 M! G
E000:6278 out 80h, al ; manufacture's diagnostic checkpoint
" P8 v+ z4 s- D% p3 N% }, IE000:627A push 0F000h1 S6 G& t4 n+ Z# B: k" s
E000:627D pop fs ; fs = F000h4 D3 Q3 K: q5 X. C; \; e: h+ D
E000:627F 4 V: a& Y* ^& E3 \, g5 v( a, [
E000:627F ;This is the beginning of the call into E000 segment 2 v4 a# k9 @% ?1 n6 P1 H# W
E000:627F ;POST function table& Y# r6 @! x7 y( F) X/ E! U7 m' b6 j
E000:627F assume fs:F000
2 i6 P6 e* x5 l/ C& B% QE000:627F mov ax, cs:[di] ; in the beginning :4 v6 P& R8 q2 t
E000:627F ; di = 61C2h ; ax = cs:[di] = 154Eh- I* }2 l# Y5 ]: K1 F
E000:627F ; called from E000:2489 w/ di=61FCh (dummy)
" K1 C0 W" y# F2 F# a. w- c& [E000:6282 inc di ; Increment by 1
7 \4 j& L$ M0 ^6 T( [E000:6283 inc di ; di = di + 2
W9 {2 k- C: V% C9 T/ PE000:6284 or ax, ax ; Logical Inclusive OR1 d3 f8 {4 t" ?: E) h
E000:6286 jz RAM_post_return ; RAM Post Error3 i R5 K- j) j9 m8 ]4 h* N
E000:6288 push di ; save di5 x E( K1 Q% w z4 f/ u9 g
E000:6289 push cx ; save cx2 s& x/ K4 P0 |! C8 \8 ]
E000:628A call ax ; call 154Eh (relative call addr)
9 K; j% D- D) ]E000:628A ; ,one of this call
1 u' G4 W8 M6 C( fE000:628A ; won't return in normal condition% J& Q( G0 f ~& i0 J
E000:628C pop cx ; restore all
' {& f1 W/ }' K. v! o0 sE000:628D pop di
! \4 A! Q2 |( j! ]E000:628E jb RAM_post_return ; Jump if Below (CF=1)
; a) g% F& k0 N# Z9 JE000:6290 inc cx ; Increment by 1
' P$ s1 H5 _5 g# v& EE000:6291 jmp short RAM_POST_tests ; Jump
4 s& ?2 R8 g. A5 }$ uE000:6293 ; ---------------------------------------------------------------------------5 P* G9 `. s0 ]- |" |- ?. I
E000:6293 ( ?3 \5 X, K" R4 N
E000:6293 RAM_post_return: ; CODE XREF: RAM_POST_tests+10
% k; ^. P' W; h) T) jE000:6293 ; RAM_POST_tests+18
N4 R" L) {1 ^& xE000:6293 retn ; Return Near from Procedure/ |/ N! _ d! W, k0 L' q7 Q% {3 s
E000:6293 RAM_POST_tests endp
5 S& Y* Q* D7 C' O. n! F) {. Z________________________________________2 ]' L1 t2 g8 _' f/ d- A5 H; u# K
- D6 Z7 ~/ O% A, z! uE000:61C2 E0_POST_TESTS_TABLE:7 ~+ E: G: I7 s, [5 L
E000:61C2 dw 154Eh ; Restore boot flag
0 K$ ^4 P B% k4 G1 z1 N' PE000:61C4 dw 156Fh ; Chk_Mem_Refrsh_Toggle* W: G9 `: v# K! i* i
E000:61C6 dw 1571h ; keyboard (and its controller) POST
$ v$ u L q0 R+ t2 _" U" wE000:61C8 dw 16D2h ; chksum ROM, check EEPROM
# _7 N7 _' h6 F, aE000:61C8 ; on error generate spkr tone
( g1 f3 G. ^' XE000:61CA dw 1745h ; Check CMOS circuitry
- s" f% r# h( s* l8 PE000:61CC dw 178Ah ; "chipset defaults" initialization
& b+ i$ g* c; V9 K, a. z: OE000:61CE dw 1798h ; init CPU cache (both Cyrix and Intel)
! C n3 c1 w# d+ A! ]; h( M! aE000:61D0 dw 17B8h ; init interrupt vector, also initialize
3 K+ l$ B% q, h$ V2 U) u% }, ]; g( z" _E000:61D0 ; "signatures" used for Ext_BIOS components
' p* Z9 e3 Z& e% \, }/ wE000:61D0 ; decompression1 V( V3 b, T* w& V/ D
E000:61D2 dw 194Bh ; Init_mainboard_equipment & CPU microcode
7 F- B1 c1 R3 mE000:61D2 ; chk ISA CMOS chksum ?
7 v+ k8 X6 E7 o3 pE000:61D4 dw 1ABCh ; Check checksum. Initialize keyboard controller
1 K% I4 I" r; t4 V6 ZE000:61D4 ; and set up all of the 40: area data.$ i% ^! U3 ~+ V6 H& C2 X ]3 U
E000:61D6 dw 1B08h ; Relocate extended BIOS code
{% |6 `6 ]: o4 Y/ RE000:61D6 ; init CPU MTRR, PCI REGs(Video BIOS ?)
8 \* A% w) | J9 I, R ?E000:61D8 dw 1DC8h ; Video_Init (including EPA proc)
! _& _" D2 l% @5 ^: G) B) F# j$ N; SE000:61DA dw 2342h# ]0 S; \ T, e0 l
E000:61DC dw 234Eh& O3 h5 \' a3 Z4 L* W
E000:61DE dw 2353h ; dummy0 P% m4 A+ @/ h0 e5 [+ t/ n& E
E000:61E0 dw 2355h ; dummy
1 y" o/ L/ ~0 s" p6 {# @E000:61E2 dw 2357h ; dummy
+ w# h3 n" K! k+ B$ sE000:61E4 dw 2359h ; init Programmable Timer (PIT)
0 O: O2 i" ~5 r9 }1 CE000:61E6 dw 23A5h ; init PIC_1 (programmable Interrupt Ctlr)
1 r# U6 q1 t' \E000:61E8 dw 23B6h ; same as above ?
1 M8 L) j& J4 c4 Z d' [E000:61EA dw 23F9h ; dummy2 R; H2 ?& N: v- R* ^6 |
E000:61EC dw 23FBh ; init PIC_2$ C# m; M- s3 [* Z2 N. E
E000:61EE dw 2478h ; dummy+ `* I9 z1 g, U
E000:61F0 dw 247Ah ; dummy O8 |2 f, [; k6 Z7 q! @; S* o8 B
E000:61F2 dw 247Ah
% t/ C# h, q/ ~. g3 ?7 p- ?5 i" AE000:61F4 dw 247Ah* e; e" A% F& i8 s Q+ j
E000:61F6 dw 247Ah; [+ Y0 Y. }8 }
E000:61F8 dw 247Ch ; this will call RAM_POST_tests again ! U/ H- S; j# s2 P8 H/ o9 ]
E000:61F8 ; for values below(a.k.a ISA POST)4 W7 j, a7 c& K6 ?& V4 X0 _7 E) p* w
E000:61FA dw 06 w$ i6 V: g3 g; p0 @
E000:61FA END_E0_POST_TESTS_TABLE
W3 y6 g8 C8 D1 N________________________________________9 j. g9 b# a2 {
" K) U* ~$ Q5 p, ?: @( BE000:247C last_E000_POST proc near9 u" W/ F/ N2 D- _# ~
E000:247C cli ; Clear Interrupt Flag
0 R, \9 ~& i6 j9 Y C+ V8 L. ]E000:247D mov word ptr [bp+156h], 0
+ [' J: V! T$ t- W: P, [E000:2483 mov cx, 30h ; '0'
9 ?( {5 s1 U. ~# {E000:2486 mov di, 61FCh ; this addr contains 0000h& k t1 x1 J- l/ U5 A0 l8 {
E000:2489
% K8 j1 ]# j: d# ?9 C, k& M QE000:2489 repeat_RAM_POST_tests: ; CODE XREF: last_E000_POST+10/ V: `1 q3 {! q6 `& p
E000:2489 call RAM_POST_tests ; this call immediately return
( ], G, Y- F0 a) bE000:2489 ; since cs:[di]=0000h
, R) a% H9 R' F# _; h; XE000:248C jb repeat_RAM_POST_tests ; jmp if CF=1; not taken) e" K @/ w; d1 M0 A/ E) l
E000:248E mov cx, 30h ; '0'* M! v" @7 y9 C
E000:2491 mov di, 61FEh ; cs:[di] contains 249Ch: y. c/ e% E/ g" \, \& q' U
E000:2494 & m* R/ Q, Q, ^$ w- Y- }
E000:2494 repeat_RAM_POST_tests_2: ; CODE XREF: last_E000_POST+1B. w5 C) X* B* j0 k7 a2 F
E000:2494 call RAM_POST_tests ; this call should nvr return if4 f: ]# K: e9 O' n7 E5 u
E000:2494 ; everything is ok: V: v- n- A* q/ m: ?) x U: _. K
E000:2497 jb repeat_RAM_POST_tests_2 ; Jump if Below (CF=1)
2 z' y1 t& v4 X' [E000:2499 jmp Halt_System ;
( ?3 V% R" Z7 DE000:2499 last_E000_POST endp
- k8 |: p2 p6 i" e* ]9 I3 a1 ?________________________________________
4 @* w7 Y* F* n
" y0 d8 C+ Y( a& mE000:61FC ISA_POST_TESTS
" I& f* Y+ L+ j0 x- Q& P9 T0 U6 CE000:61FC dw 0& @( i0 r5 p5 w8 {$ t' v$ E" L$ W
E000:61FE dw 249Ch+ l1 e# b* m$ h( C# o9 Z/ P
E000:6200 dw 26AFh: Q% J0 ^9 u+ E7 Z! `% _; L0 f
E000:6202 dw 29DAh
" j: J! }$ j2 M. K" O, aE000:6204 dw 2A54h ; dummy
/ _( [. M! ~7 V ^, n" DE000:6206 dw 2A54h( G5 M1 R$ B+ b0 {8 }
E000:6208 dw 2A54h" Y) D8 c5 |9 r( C3 J! B" {
E000:620A dw 2A54h+ Q# [ G1 f# D$ X! U3 [3 z* E' l# r
E000:620C dw 2A54h
) H/ k' x- `+ o( Z6 y# |E000:620E dw 2A54h2 \ Z- }3 U5 z4 y/ y5 {$ B. ]' M
E000:6210 dw 2A56h ; dummy
$ M4 B) q8 d2 FE000:6212 dw 2A56h
1 v+ l' q5 y' w& C5 j: J0 LE000:6214 dw 2A56h1 D, D! e5 A: i! @& |
E000:6216 dw 2A58h
/ z, o1 }' O; v1 d0 E; X( ?1 T( L9 wE000:6218 dw 2A64h
* i W8 z) B4 \' c& _+ K+ ?* a. AE000:621A dw 2B38h
# d# S i* |4 y) ^% L1 n3 aE000:621C dw 2B5Eh ; dummy
. a9 r& n7 w F% KE000:621E dw 2B60h ; dummy
- [# L' i* a4 ^ b+ gE000:6220 dw 2B62h& c8 x- r0 ^$ N+ T2 e0 o
E000:6222 dw 2BC8h ; HD init ?
0 z( y/ _; @+ H, wE000:6224 dw 2BF0h ; game io port init ?
3 o" \% H0 c5 c T7 x, z( aE000:6226 dw 2BF5h ; dummy8 x. a; R4 H/ V5 q" ?
E000:6228 dw 2BF7h ; FPU error interrupt related
4 B% U1 n: I5 V; YE000:622A dw 2C53h ; dummy
3 K5 k: i! m% p& |; m2 ]1 uE000:622C dw 2C55h! T: M/ C% _* S9 `
E000:622E dw 2C61h ; dummy
" U- Z! g/ ^- [. h$ j5 e9 }E000:6230 dw 2C61h
7 B) [$ u& f* `E000:6232 dw 2C61h6 k/ ^+ i; \) F ^! X
E000:6234 dw 2C61h" s! f9 J- L, x2 S" W5 p
E000:6236 dw 2C61h" }. O' k! x3 D, ]! _( |- U
E000:6238 dw 2C61h7 D9 v: A8 j0 l H
E000:623A dw 2CA6h& Y j! m% r2 \% x/ P
E000:623C dw 6294h ; set cursor charcteristic
7 U+ g% `- x( [# l' ME000:623E dw 62EAh
6 b h; N- Q: U: D& |/ c3 D+ dE000:6240 dw 6329h* |# L- @$ y2 ]: |* o5 E
E000:6242 dw 6384h0 D4 W" O5 U$ z9 q/ S5 Z
E000:6244 dw 64D6h ; dummy- i% y3 K8 s$ b9 R) ~
E000:6246 dw 64D6h
: R9 ]" f5 S6 n4 g) P. |# vE000:6248 dw 64D6h
3 O. e; @8 P" H, `# x: \E000:624A dw 64D6h& c6 i" x. A9 u: U) o
E000:624C dw 64D6h2 z# t$ X' ] F I" W
E000:624E dw 64D6h0 ~- I' l6 H( d! m" v5 j: W, o
E000:6250 dw 64D6h0 H& q* n" F* C5 N. n, Z; K2 B
E000:6252 dw 64D6h6 }( [- T5 `2 P. }7 p% D1 M
E000:6254 dw 64D6h
4 i" [: m9 ?( _0 |4 _' gE000:6256 dw 64D6h& W3 q, H l) P- _9 k
E000:6258 dw 64D6h
5 C/ ~( O5 `& a. U$ @3 n* JE000:625A dw 64D6h
: u3 N; O' q5 U! z9 ZE000:625C dw 64D6h- l) r1 a# y4 v/ {
E000:625E dw 64D8h ; bootstrap
_! I) l `* d3 i& S" ^" q+ XE000:6260 dw 66A1h7 ~. v4 {( R; J7 R/ L/ {
E000:6262 dw 673Ch
) i J9 M- | T) nE000:6264 dw 6841h ; issues int 19h (bootstrap)
+ V2 e) ^, w4 u' g7 u: O+ v+ n; _E000:6266 dw 0& x1 R( f7 t9 Z( p
E000:6266 END_ISA_POST_TESTS+ R3 ], {" f0 A: e1 o3 D& H" j
" D) C: x5 U! k1 t* I& h( V# n注意:# a; `, v% E* O6 V/ O
这个“POST jump table”例程在他们遇到一些执行错误的时候会设置Carry Flay(CF=1)。在POST例程返回,这个Carry Flag就要被测试,如果它被设置,然后这个“RAM_POST_TESTS”就会立刻返回,这样就会使系统崩溃,系统扬声器就会发出声音。:) |
|