|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 4 n6 p! S* S" y: J; t
- ;
0 d, f3 `8 J+ Y3 V - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01 U( F" o( e9 C- S
- ; ml A20ON.asm
) r3 L& Z0 P" J9 ^7 O: S7 g - ;
, N) s1 e) \$ o( U1 j - .model tiny4 n8 X) L7 L' b1 X5 Q, R4 m* Z2 e
- .code
5 d8 M) l, u, q' t! s - .4869 D6 n3 P. q4 ^
- .startup
0 d+ T( g$ v$ W) t - 0 e: [; G$ b8 {& v
- mov dx, offset msg_author
4 M, \/ u9 y& t3 I) u& U5 N- K- o - mov ah, 09h* Y& G$ y" }! O# d) r& e f0 c1 N5 o
- int 21h
# C. O, D- F$ _* y0 ~) c - 2 `# J. z$ B7 h3 O3 X N" Q
- mov dx, offset msg_fail
5 Z' S. q8 t: w( S% H1 c - call A20_ENABLE$ Z: k/ y) ]* z& C7 g' d& X
- jz exit1
9 s' _0 t$ |& O+ Y+ K4 W - mov dx, offset msg_ok
' z2 L' ~' \! l3 y2 b% D& H4 b - 3 X( Z# ~8 P: Q0 j) j" N
- exit1: mov ah, 09h 8 r3 [: Y4 Z3 Q
- int 21h 1 E" f, q; M% t1 Z- g
- mov ax, 4C00h
3 x; r3 h/ m7 V2 e6 ]+ i - int 21h
' m8 ~+ X) c/ s2 I -
% J5 B5 O+ T2 C0 d; h2 j+ o - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,; X# b8 q5 A9 f" [1 ]1 T
- "2008-07-01",13, 10, "$" + S# J9 F- P" M9 ~% h. D
- msg_ok db "A20 Enable OK", 13, 10, "$"
0 J5 u4 L- V0 y7 x ]* t! U$ p5 Y, { - msg_fail db "A20 Enable FAIL", 13, 10, "$"
D; j7 Z- v' v( @6 Z3 p - 7 F! z6 y: v' L8 ^. r0 n |, z* r
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------- \" H$ | F; Y0 J+ B
- A20_ENABLE:
9 x# N0 Y& M+ z - call A20Write ) N( O& F- s( Y3 }) Z& y+ O
- jz exit_enable% K3 o) k" ^+ `! r5 n1 x% j$ L; g: z% ` K
# x; J( O- }7 `0 |* ]3 q5 I- cli ; Only need for reading value from KBC
- a% B& f& c; |' j8 u1 |$ I5 E/ M. X - mov al, 0D0h
* o+ g) S. h" T) b& N$ U - out 64h, al
. e1 G9 a! \) j; o. F: X" ? - call A20Read
% e0 B- R; [! ?! f# N - jz enable_int 5 O/ I D9 m3 _) V7 X' [" b
1 | t$ l. t/ S9 ~5 H# l9 L- in al, 60h ; Get current status 1 n, t" X8 h$ u d8 b( E
- mov ah, al
# T( s- T" _& g0 ^ ~ - call A20Write
0 N1 ?" o ?& x: J/ u - enable_int: sti s5 D0 Y# K( I: X0 n$ h
- jz exit_enable/ Y, g; s7 M. d+ L
- + j+ H' _3 c7 N: N ?1 A4 f0 j6 l
- mov al, 0D1h ; Tell the KBC , want to write to the " p- p* R" s" P. e) X0 n
- out 64h, al ; Out Put Port next c1 a9 Y1 `6 }; `% r
- call A20Write
O0 @" d: e. E3 p2 E; D3 V3 C1 n - jz exit_enable! u5 |2 ~, C m9 N2 Q) t( |8 h8 c
; o6 T- J; H/ v' |3 `" ~- mov al, ah # Y$ q2 ?6 u# I7 `
- or al, 2 ; Enable line A20
, o* m8 L0 j9 m* z7 i* m$ r - out 60h, al
* w; c! ~) _! X - call A20Write , x& B- X6 {$ u+ B
- jz exit_enable
) p) D, }, f: u3 h& y6 [
* F% g6 m! Z7 Z0 q- mov al, 0FFh ; NOP
4 h! q* P- ~* ]" W - out 64h, al
& M4 S! r ]/ g- m) y. ^4 `) h/ @8 e - call A20Write ! w, u p0 X# Q& x5 L9 o
- 3 I8 h% g: C" N. z5 j1 ^7 q7 |) S
- exit_enable: ret
4 r' L2 h' w+ G! J+ W
# m1 d$ b0 b1 e. s. m- A20Write: xor cx, cx ; Reasonable wait
" B8 t! i6 b! Y0 u - get_wirte: in al, 64h ; Get KBC read status , }7 [ l" y S7 v3 Y0 _* ]; p
- test al, 02 ; See if buffer empty, bit 1 clear
/ K) I; q4 N' @9 H( u6 g* z - jz clear
+ ?" R: D9 \6 J5 y; P3 O8 _9 t8 p - dec cx 8 J6 l( j; x6 P8 o* \, O
- jz exit_write
; P. N8 `) K, B' i- M: B1 G- f3 f - jmp short get_wirte
" N% v/ X* v2 F. V% m1 Z - clear: inc al ; Clear ZR 8 O* W0 ]+ K9 n4 N9 ?, n
- exit_write: ret 0 B% H/ @0 f# R% `
' G1 _# s, g0 O! v D3 g- . L! S$ @; y! u7 p& `' k) t
- A20Read: xor cx, cx
' A8 C: M6 N2 k( s" ^& S" | - get_read: in al, 64h
, {' N' r0 J8 o6 ?9 y+ A; u# A) B - test al, 01 ; If the 'output buffer' is full, has
; }9 k h' o2 R - jnz exit4 ; ... , y* K# E& u9 I. g
- dec cx
3 [8 ^! Z( x3 m2 m/ U* z H4 u - jnz get_read/ P3 x- @& Q. c* Q, ?. A6 V1 e
- exit4: ret
) g4 M4 m6 P2 O" C+ c -
, d9 E# p. |7 n! t - end
复制代码- ;A200FF.ASM ( B b1 K1 ~' u" R( K, E H1 q1 D% k
- ; ( v Z* I+ Y! g8 j% S" H& Z
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
- w( x0 ~4 b/ u8 A2 L- t - ; ml A20ON.asm
! z7 n+ _" ^8 W% z S - ;
3 K% A( x) Y, W; n' E - .model tiny
: K- e9 P( P) k( Z4 u" { - .code: X0 t! n8 d; ~4 n2 y
- .486* Q1 g m0 s9 R+ N4 o, f) a
- .startup* }) y. r, O' E/ \; N
b+ b$ ^/ U x2 M' _( v3 L- mov dx, offset msg_author
1 _7 l3 z) ?: D0 s/ ]9 o - mov ah, 09h
, g# q: t, N4 [: \; z. s( Y - int 21h
2 I8 H9 ~6 B3 }! ~' i8 B* i- k6 M
& q, y( B% O$ c! Q) Q6 o! y- mov dx, offset msg_fail ) Y+ b, {: E" X% S3 M
- call A20_DISABLE
1 X2 N9 w8 D2 [ - jz exit1, E z0 \2 J7 I3 E H; Y8 A
- mov dx, offset msg_ok
( ?! c5 T6 g( ^- G8 D* d; W f" ^ - 9 Q4 E3 N: _& l/ U% p5 u; H
- exit1: mov ah, 09h ' _# s: }5 c/ L0 _. V$ w
- int 21h
/ m" V2 h0 s4 G - mov ax, 4C00h ) j* C$ w, ^5 l" P7 U
- int 21h 6 O+ o5 O% v) B4 s8 B
-
) }- ]6 a& e5 }4 ^9 Z - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
# R0 n& W" V7 |9 L. o/ @8 F - "2008-07-01",13, 10, "$" + f% p8 v( Q6 n: g
- msg_ok db "A20 Disable OK", 13, 10, "$"
t* |( z% q, y - msg_fail db "A20 Disable FAIL", 13, 10, "$"
9 T8 s. G7 J; r5 O - . y/ a( D! [# _1 c
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
- L7 {7 y& A- S( \8 J$ r - A20_DISABLE:
8 y# f6 h9 t6 ^5 S& I4 s& Y. q7 W1 _ - call A20Write
# d& K0 k3 R" Y7 W0 R2 n - jz exit_disable5 r% N& O' x1 G/ N' V) `" m" z. q
4 p6 O' x1 g: }- O- cli ; Only need for reading value from KBC , e% T, }6 b% f8 u& U) J$ w% N) _
- mov al, 0D0h
8 ~- A, G+ P0 \$ P* R5 b) E - out 64h, al
$ H3 Z4 \- D& e; L9 V - call A20Read
6 d: T& R+ u0 R; {$ i5 S. F - jz Disable_int 2 p4 P1 F1 x8 {4 U& ]" v& \; Q
! W F- @7 j' b) a0 y0 z* Z- in al, 60h ; Get current status ( g4 p+ K. P& U5 n
- mov ah, al
* K4 E, T. H1 | - call A20Write
- X+ A. t' n( ?# M* {" h - Disable_int: sti
+ K9 x4 \4 z, X: b0 E/ w0 {9 E1 p3 e - jz exit_disable/ F' D! V% x x4 t: L& G* E
- , ?" {& C8 a- m" X! ~" x
- mov al, 0D1h ; Tell the KBC , want to write to the
$ p$ \% h2 U: G; H4 v - out 64h, al ; Out Put Port next
9 {2 g2 T. U1 u0 o8 Z - call A20Write * d3 S3 Z. H" ?) I2 X2 `4 F
- jz exit_disable5 p/ T' \/ g1 A {( f7 [ L0 y- e
- ' G4 o3 O' ?# h; i
- mov al, ah 3 Q$ G7 ~9 K& n: R$ ~6 ^+ h) C6 q
- and al, not 2 ; Disable line A20 , d) p0 K" j/ U( U) M
- out 60h, al
$ F2 n: D* C" l6 u' X% \* D6 n - call A20Write 7 a7 O( d$ t. H Q: s6 g
- jz exit_disable
# G! a- M* Z" ]% g6 W6 E - " P; U- _6 J7 g6 ]5 U
- mov al, 0FFh ; NOP 5 Z @$ s1 v% c* u% S' f
- out 64h, al 3 E, Z- U w& H+ F
- call A20Write
3 o& L R, r5 Y1 }7 c* _ - - N' o* I e! u1 i1 R
- exit_disable: ret , F' \: N% a9 T) Q
- 5 \) E& l) F9 L; _5 [4 _* v, I
- A20Write: xor cx, cx ; Reasonable wait ; w- o' t( h) T/ z& m$ d# k
- get_wirte: in al, 64h ; Get KBC read status
) t5 i7 }) e! n: ^ Q - test al, 02 ; See if buffer empty, bit 1 clear
7 \* k9 ~+ O- C - jz clear ( P0 @9 n9 b+ m( ~% z
- dec cx ; Y( ~* K& k' ~ I7 n; |
- jz exit_write
: q& ^% W, D6 u& L - jmp short get_wirte
) z3 J7 R1 e `' E# E0 ? - clear: inc al ; Clear ZR
- t6 m. o( A0 T) C# \; t - exit_write: ret ' O8 }6 W$ i1 `/ V `
- 0 f! K3 I. Y- t/ v& s
- 0 L6 W: p) V* g7 @! q
- A20Read: xor cx, cx
0 w9 q. [3 P6 I! r- W* d% V. e - get_read: in al, 64h H$ y& r- I0 g+ ?6 f
- test al, 01 ; If the 'output buffer' is full, has 1 n, l5 c+ n% `2 l7 x
- jnz exit4 ; ... / r% B$ V8 f" ]7 D
- dec cx
" ?( B, k9 F$ ?; C - jnz get_read
6 z5 y0 X7 e9 Y" L - exit4: ret
8 h2 ^0 h7 T0 n; `0 k -
6 p$ n( q7 ^ k1 ~8 w c - end
复制代码- ;A20STATE.ASM
% T( g6 l) c% W- e - ;
! V: b( {4 K/ ^$ [: T V9 r - ; Returns the status of the line A20 through the KBC 9 [# l- L& h: F+ P- K' L; Z% g
- ; programming by bini for debug. 2008-07-01
' n$ s) J+ g o/ D, M1 e3 ~, h - ;
+ `7 b! Q5 E* E, _ - .model tiny
; A9 j$ H: A5 o: R5 L - .code
: {1 Y0 e% F' H4 a - .486' ^4 N/ i( w+ m; q2 R( I% V0 E8 }
- .startup
0 z% P2 f1 W' ~( a8 r - mov dx, offset msg_fail % q, K/ Q9 Y5 \2 B! o
- call _GET_A20_STATE_
! \0 o6 L& a5 Y5 X0 L - jz exit1 ; was a problem
/ m, m, j1 y* X7 ~% r: D3 x - push ax ; Save state, AH
+ }! s* `. R) u+ E - mov dx, offset msg_ok ; There wasn't a problem
X3 }6 C1 q( M# r c - mov ah, 09h 5 v% S/ G) m' F3 U/ @
- int 21h ; Print message 6 ~% ^- i, J4 J" V
- pop ax ; retreve state
2 Y; L2 r" X$ D- \8 s* o - / r& O( [8 J5 S3 U/ n: Y
- mov dx, offset msg_dis
: G2 P6 N) G7 ?) O5 f - and ah, 00000010b ; bit 1, 2h, indicates state , e& h5 ]& j/ }4 u
- jz exit1 . w1 e2 a b8 _6 Z6 k7 z
- mov dx, offset msg_en $ M" m+ A% `1 F+ d0 ~
* A1 s5 f1 T- a9 d# k- exit1: mov ah, 09h ; ], c% O4 z8 ` ^, r, F/ I3 m: p
- ; DX already contains address of string " h$ D2 f" w' [
- int 21h 0 y3 F O M1 I5 E* y
6 R1 H0 L. ~9 i! |( q5 R- A$ j- mov ax, 4C00h . r, U. r* d( R) f0 t9 E% `8 o; O
- int 21h $ i- ^$ [: d/ d1 \. E3 z
' z% ^3 K; `. q) d- msg_ok db "OK", 13, 10, "A20 $" 1 o( |9 {0 a4 [5 W- @
- msg_fail db "FAIL", 13, 10, "$"
% D# x& [& @+ O2 C - msg_en db "ENABLED", 13, 10, "$" 5 r+ v& M$ j8 F; S4 t. D
- msg_dis db "DISABLED", 13, 10, "$"& G `3 |6 h, h
- / L1 W2 p. x7 F$ h( Q; o" W" F
- 1 ?0 C# W: Q/ \
- _GET_A20_STATE_:
1 e' G7 @) L* s% C. u V - call A20Write ; Wait till the input register is empty
( \4 \) s3 k1 i" H" g - jz exit2+1 ; Bypas the reset int's
5 N7 i1 V/ u! }- _/ M3 G - cli ; Disable ints so we'll get our value ' r0 h+ b& j) ]# S0 j
- : d; w3 b* Q( W
- mov al, 0D0h ; Send command to the 8042 command register . U9 k: T4 e9 n' @' [2 }& T& R8 T
- out 64h, al ; to tell it we want to Read the Output Port
) \( C5 R* |/ Y% ]. p* I - call A20Read ; Wait till the 8042 output register
. ?& ~: P2 r* K1 T% F6 y - jz exit2 ; has something in it's buffer * Y3 o$ l! @% M O8 F9 w- H
- ' ~4 A- e/ E: F3 N% m" y
- in al, 60h ; Get it
k9 ^$ C( o5 t# ?2 V. f0 k - mov ah, al
+ `. ~) O) b& [+ z - call A20Write ; Make sure the input register is empty F, n Z( P: l6 H' t+ r
- jz exit2 * j$ d7 M( \. u6 |
- 6 X5 V$ F0 J" x# ?2 w' T
- mov al, 0FFh ; KBC NOP command, does nothing
: i% w: K0 O/ Z8 J# K! }$ J - out 64h, al
' ?/ O* a+ r9 O8 N. P - call A20Write
; m3 S$ k5 q! t1 k7 m
3 x/ ]/ O0 ~! B& T8 m4 F- exit2: sti " P! z' i" P2 l j5 o. P- x+ e* @- f
- ret
( i# d# @+ d5 t% n
* G" i- u" ^. H C% K2 |
& {1 D3 S2 ?1 [6 U$ z6 a+ b- A20Write: xor cx, cx ; Reasonable wait + i9 D$ w( f( D q* b" C
- get1: in al, 64h ; Get KBC read status
& Y$ h0 f0 | ]0 e# E/ { - test al, 02 ; See if buffer empty, bit 1 clear
! h# e s. a# x, d7 P( a - jz clear
; N: _$ @0 o' Y. T* s% d - dec cx " |# n" U6 {9 R# S0 F1 K
- jz exit3
, E6 y, X+ y* E# r1 i - jmp SHORT get1 ) p$ J+ R& J6 ]% C' V
- clear: inc al ; Clear ZR
9 K7 u' W' K; h9 Z, I - exit3: ret
9 l8 `5 h0 j0 c7 C2 B; h
( v; I2 h3 K/ P- b
. d" z; L$ j0 Z- g' C- z% R9 L d! w- A20Read: xor cx, cx
5 I5 ]+ T! Y$ ~/ e% z - get2: in al, 64h q$ F8 |8 x* d3 V) o/ A/ g
- test al, 01 ; If the 'output buffer' is full, has " H9 r' h4 D4 t) j( w$ v6 F0 I
- jnz exit4 ; something for me
. e# p) }" p9 P" l" ~4 ? w) N - dec cx , n/ I% \. s5 S1 C8 f/ i
- jnz get2
; E4 b! I' {; [" n7 E0 }$ o - exit4: ret
3 f4 F, t2 F( Z( P) w - ; T' `4 \+ |# d2 [. Y, G1 R
- end
复制代码 |
|