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