|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
+ Q+ H$ J7 Q5 ]" Q! X - ;
( G+ c7 {' M& Z9 x8 P7 |- @ - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-014 R5 u& y3 h5 b6 {" i/ o
- ; ml A20ON.asm
* I, c% e/ @! }* l- M$ s+ y' o- C - ; % L! |, @9 {6 R
- .model tiny$ P, W/ L, i" U% ]! O
- .code
/ C1 ]0 C& Z$ w4 | - .486
( H) d( z2 t+ _" S. N - .startup2 y% m0 }! E2 u6 ~
- $ @4 ~8 i5 h1 x" a
- mov dx, offset msg_author; G- B# _8 c" B n; c
- mov ah, 09h9 N0 j; `( T; Y9 C" x
- int 21h' _& ^2 p1 O9 J% }& ~1 A4 ]* F
. s, J: t4 v6 d0 I. ~) i- l/ |- mov dx, offset msg_fail
, d X* ]+ W! G- u- z) w - call A20_ENABLE
, I& ]8 G# z! ~4 l5 e) `6 d# P! U: ]1 E - jz exit1
$ o3 I/ q& l: S L - mov dx, offset msg_ok
) r6 T- V1 [9 n/ Y
* O+ }( ?4 A1 F9 p9 E0 Q5 w- exit1: mov ah, 09h 0 v* x5 U/ d7 h n! a& E
- int 21h
1 w5 y( V# h' q - mov ax, 4C00h % M' V4 n B6 I" c7 Z8 ~5 V
- int 21h / d6 {7 f; }9 S8 a; b% C
-
4 d" B$ b# {4 o2 ] - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10," g, B* a9 f/ t/ |" l9 _
- "2008-07-01",13, 10, "$" 5 r a: O' w3 f9 v+ A
- msg_ok db "A20 Enable OK", 13, 10, "$"
: H5 _9 I: e+ ]- w/ u - msg_fail db "A20 Enable FAIL", 13, 10, "$" ( R) U1 a* ~, K* W4 w( o/ }! Z
|" m0 x0 d& }: \4 P) Z' P- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
& w/ F% s( F9 {# ?& T# z' D5 w - A20_ENABLE: P, o: x' O# i0 e' M8 A% P2 Q* q
- call A20Write . r: {! r5 J7 l* t1 {
- jz exit_enable0 E. v% M' T0 h* w% P! X
& ^0 h8 ~) S5 ~! u- h- cli ; Only need for reading value from KBC
- J# s$ i; e5 o/ N" p+ B - mov al, 0D0h
5 B' f8 ?5 c) q1 F - out 64h, al + x6 Z1 v/ l5 ?; ?" E
- call A20Read
3 L7 \- H. ^/ k8 F - jz enable_int ( N6 l; P$ H1 i6 \1 ^% N
# _( p- C1 y( p- in al, 60h ; Get current status - W4 q$ a+ a- L& G& h+ u$ R$ K' @. i! {
- mov ah, al
+ s% Z$ |) H$ p! {) g+ S3 s. q - call A20Write 0 B( T/ m+ T- F+ N
- enable_int: sti 8 H# r7 C% i# g3 k
- jz exit_enable
' W8 T' ?( L, B7 T - 3 K$ [ \' q( I* e5 N
- mov al, 0D1h ; Tell the KBC , want to write to the
4 U9 q3 h1 V0 i6 p# d - out 64h, al ; Out Put Port next
4 T3 y1 r6 y" n8 z: p1 L& W% Y% h - call A20Write
; i9 [0 V& |" \ - jz exit_enable
; u: j) _8 J# {/ s. l( G
* m; Q; L0 C. e( M* X0 c- mov al, ah
$ Q( ^) f$ X$ k0 E - or al, 2 ; Enable line A20
9 n, O L$ C" I4 N0 N$ w; _5 _1 z - out 60h, al
6 R5 a4 o7 \' g% P2 d( O - call A20Write
+ m2 i4 ?( l! D( p$ ] - jz exit_enable e! J Q/ P7 _3 f; L8 m& w2 M
1 z# l8 Z5 ]9 I- j- mov al, 0FFh ; NOP
4 |1 i; i4 c) C$ f+ T2 Y4 G# ^, y - out 64h, al
# ^7 R& Z! G( p/ m - call A20Write
& g1 `; X: c; a) W6 X0 Q
6 j1 ^4 Y6 z$ I8 x0 Z3 E- exit_enable: ret ; i) Q% n5 v e! r- ]6 B! `( A
- 2 c% S* ^% ?+ A* ~, \$ t! m0 p
- A20Write: xor cx, cx ; Reasonable wait
" X0 ?! u3 M7 G - get_wirte: in al, 64h ; Get KBC read status
6 k2 l$ J5 W$ i0 ]' w9 K- C; n - test al, 02 ; See if buffer empty, bit 1 clear % m. t0 w) {0 T% g; E
- jz clear
4 i/ `$ ]7 W$ X% |6 U; @& \% Q - dec cx * y) a6 N2 Z. @/ h$ R
- jz exit_write - c% [& T& H, ?6 F/ ~
- jmp short get_wirte 8 |+ K! n+ A! V: E K
- clear: inc al ; Clear ZR
7 k& u# I2 C: ]7 \3 e& s - exit_write: ret
3 R% h2 _# E/ o% \, J8 [+ o3 z
3 F2 `% {* ?0 [4 |0 X9 L* \3 t! ]( ~ X- & M' s0 e1 t) l0 t' B5 O
- A20Read: xor cx, cx
- K# J R, g' ^2 d# Z$ z* _! H+ g - get_read: in al, 64h " ~& n. ?9 n' q
- test al, 01 ; If the 'output buffer' is full, has
( Z/ b/ E/ U+ F+ O9 l" D) U - jnz exit4 ; ... 9 B7 O8 P* ^0 v/ q- N) T
- dec cx
/ l% l2 p! ~5 L' G7 X - jnz get_read( V6 g+ l: F, c- b: m4 @% K
- exit4: ret
' z& d" s' S6 Y+ E -
: u/ v; g' D, p) F2 b - end
复制代码- ;A200FF.ASM
- S _" E2 x8 E: X4 `8 ?' @ - ; 1 D% Y9 S4 i, V4 M! ]& f; T0 l
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
7 y, E* E# Y! \ - ; ml A20ON.asm
: H7 k% f: ?" n5 c; z - ;
- r7 t. o: f0 u; c6 ]4 z# h0 a - .model tiny: k( |# `" \3 F" T
- .code: i$ u& k* o3 e* |( F V# @
- .486- M$ E1 t0 j& }' {- \4 H6 H) R
- .startup
3 s8 R4 g/ z3 @5 _! H - 9 K. \3 ]# I% \; t. \; g
- mov dx, offset msg_author
* R1 ^& R ]2 y, M - mov ah, 09h2 O! o/ |5 D% f2 W$ S% C
- int 21h! B: f' E, N; Y7 d# R8 o8 H
, p8 i, U! f7 f% y4 `- D% r, |- mov dx, offset msg_fail
# @: R" x% d/ n4 Y! j: e! @ - call A20_DISABLE
* B! X0 i8 Z0 v2 `9 i" |% ~ - jz exit1
: E% Z) x w- b/ ]) ~ - mov dx, offset msg_ok
+ u) ?. P. A6 d# W
+ b s: y: Y+ V- exit1: mov ah, 09h
3 H5 n7 c" Z8 H& w4 y - int 21h
% f4 ]2 G c8 x+ [& P0 Z - mov ax, 4C00h ! e4 V" D4 V- O- H" i) o6 u
- int 21h
& \/ F1 ~% M' [ B3 G - / i0 h, h& A: A4 I. V+ N% e' [
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,, t5 m$ x5 i6 R+ J$ `
- "2008-07-01",13, 10, "$"
- }& ^# c2 L7 L8 ?/ [ - msg_ok db "A20 Disable OK", 13, 10, "$" 6 [8 l; [! G, g5 w* U( V
- msg_fail db "A20 Disable FAIL", 13, 10, "$" 5 o& J% K' b* d
- , K4 t3 K9 L( v3 ]8 J$ c
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------* j. }; b. S% L) n: o. G
- A20_DISABLE:
( r/ k8 h, G$ S o" R - call A20Write
7 _- H! f, J8 i3 v) t" z - jz exit_disable' Y' W: a- V' v8 X
- 5 P+ t; ?& {6 O
- cli ; Only need for reading value from KBC + ]8 u Q0 ^5 W9 n6 S% [ |
- mov al, 0D0h " q' y: E7 G0 j- F1 A! {
- out 64h, al
' D! B" @8 {; h! v9 U - call A20Read
* r9 q, ~" Z9 J$ l - jz Disable_int M4 P/ U: D4 { b$ Z$ J1 C' \( C) D
! Z7 T+ b# _+ n% D" Z- in al, 60h ; Get current status : s9 ?5 R, J' m6 Q, K. ]: Z" }, E
- mov ah, al
/ b9 [2 ]+ u) H% x3 Z - call A20Write
( p5 g9 ^; S3 Y6 u" a - Disable_int: sti 1 Z/ M8 U' W& y; W+ P) A3 N
- jz exit_disable
' w! c7 T( b: {4 Q
7 H) f- p# g5 y8 X$ B- mov al, 0D1h ; Tell the KBC , want to write to the ! `! }: x+ N0 w+ w6 e
- out 64h, al ; Out Put Port next
# N/ K- G3 Z& F' c8 u - call A20Write % @$ L. |9 P1 w% Y$ T" w
- jz exit_disable# s& a$ R1 A$ i" Q5 M+ h. n
- C* K2 L( W( C& [# u. H+ j) s! Q" R# r- mov al, ah 3 e4 B2 M6 K6 c! O0 |
- and al, not 2 ; Disable line A20 , s4 _4 b" Y6 Q: ^# d; u1 l6 v
- out 60h, al
* B% I# K. c) B' q - call A20Write ) p/ n2 Z' w' L7 O7 B0 q
- jz exit_disable' i' X% U0 f" `
- ) D q' N7 F( r" F
- mov al, 0FFh ; NOP * @: A. m9 w3 ~$ h, a' s
- out 64h, al
' }& G! c; k5 Y4 K - call A20Write
, u1 @" _- E( r. F! q, Q; V
# T9 E/ N0 f) F5 T! D/ g- exit_disable: ret # R& k9 b4 R7 a# U- K' I" I4 p
- 6 Y$ H* }$ B6 h: H k
- A20Write: xor cx, cx ; Reasonable wait ' Q3 y% p; w# x8 C0 ^' T1 @9 [
- get_wirte: in al, 64h ; Get KBC read status ) a( r8 X& H8 B4 | S
- test al, 02 ; See if buffer empty, bit 1 clear * s/ @; T0 e: n9 s6 I, y7 q6 r
- jz clear {) E/ Z8 R" A2 `' R$ \ J
- dec cx ) y9 M4 T# w) [: |" W' U
- jz exit_write
$ w0 `4 C1 n( c! | - jmp short get_wirte
6 m( r4 J- `+ K5 ?$ W7 X2 r - clear: inc al ; Clear ZR 3 E$ k, K1 }% ^5 U4 G, r4 w0 ?, k
- exit_write: ret : i; [2 F, {) v3 }9 H0 d4 Q* `
- # c7 s- l; e5 `5 [( f J7 J7 ^+ }
2 T3 q9 z: J9 i! N1 a! m0 M4 a' _- A20Read: xor cx, cx 7 Z! H3 ~. u8 m) I, O
- get_read: in al, 64h
5 a9 I( M$ h& ~6 n - test al, 01 ; If the 'output buffer' is full, has 1 u. `- Z1 b$ B5 |2 U2 Z* |
- jnz exit4 ; ...
5 S8 G9 B& s9 p- g, W - dec cx
3 W) D d$ g5 T, y) Y - jnz get_read
& t1 N1 {% ^$ }) P$ E4 e - exit4: ret
1 z) }) V5 k* t' B7 }7 h -
: Y. h4 o* w8 ~6 o - end
复制代码- ;A20STATE.ASM " h0 Y" X4 M- |* y9 Y# j# V! X
- ;
3 y. s7 z4 N. Z0 x2 E/ q2 I | - ; Returns the status of the line A20 through the KBC / U/ e. y6 C/ I4 ?( [# _
- ; programming by bini for debug. 2008-07-01
6 p/ y! E# D/ h$ U" I5 ~ - ; # k5 R; u: d- Y( W$ C- L
- .model tiny$ C" l5 N4 H- W+ p R0 l# U0 _9 j7 M
- .code1 R% u, \) X$ l+ L4 g. X
- .486
+ D& a# y- o" ^5 X! o+ } - .startup
9 Y; Y! H; b5 b2 O - mov dx, offset msg_fail
) a5 P4 J7 H5 F% K, e) n - call _GET_A20_STATE_7 J6 K' N1 p: x
- jz exit1 ; was a problem
' x# U J% U( M) O' G. G - push ax ; Save state, AH - @0 w0 b4 t6 Z, s+ T$ Z+ h% I; P# ?
- mov dx, offset msg_ok ; There wasn't a problem
9 k) Y. j2 W) a9 ~2 m1 z D- f# P7 E - mov ah, 09h u- K9 q% ?: }1 w \: [* B
- int 21h ; Print message / C F0 R: ~' g8 x
- pop ax ; retreve state
: h1 q; [" O9 W! @8 c/ Z - 8 C3 \# a9 I Z* Q) @/ o
- mov dx, offset msg_dis 1 w. d6 |% X1 [& ]- i
- and ah, 00000010b ; bit 1, 2h, indicates state , @! m* ^% e6 _" U4 j6 j8 U. t
- jz exit1 2 C7 l. M: z4 c/ L
- mov dx, offset msg_en & Z$ t/ P5 t* E' @1 ^+ U; U
- - w3 k' ^5 P' d4 T2 s4 R
- exit1: mov ah, 09h
6 f$ e! n0 [5 l5 a - ; DX already contains address of string ( d: n! C$ k2 d6 p' v8 ~, [
- int 21h " _$ ]: r+ j1 @: ?
- 0 H4 d! B1 |* ]5 j
- mov ax, 4C00h / M! M; R( ~6 ]2 |; G+ r% f
- int 21h 6 m8 K0 M$ T! \/ K* [2 u
J* L6 Z) c& q S! q4 p: R- msg_ok db "OK", 13, 10, "A20 $" 8 ]0 v/ z% b( A+ {5 }& [
- msg_fail db "FAIL", 13, 10, "$" * _' _( U3 \/ K0 D1 V
- msg_en db "ENABLED", 13, 10, "$"
7 o/ }8 x. j& U- d - msg_dis db "DISABLED", 13, 10, "$"$ v) j4 S; S; I) T. u3 S
: W3 V, c. G4 D* o: P( h- 0 z4 g- V2 r& H+ N- ~. S2 ~
- _GET_A20_STATE_:
7 f( q! v; a5 o- O; K - call A20Write ; Wait till the input register is empty - M# _' K/ s y3 z$ F1 ]& F& {
- jz exit2+1 ; Bypas the reset int's & A' n" d+ I8 t: L$ c5 @' ~: x1 I8 M
- cli ; Disable ints so we'll get our value " U3 H' @% l# }1 N" ~, m+ ?: j8 n
- - p4 R( b7 q0 D- ?! p* n
- mov al, 0D0h ; Send command to the 8042 command register
: r4 n( {8 U0 b' D - out 64h, al ; to tell it we want to Read the Output Port
) _. _& X& ~( ?; ^& y5 G - call A20Read ; Wait till the 8042 output register
. d* ?" P7 j0 J; d4 h4 _ - jz exit2 ; has something in it's buffer ) \% Z4 V, \1 N; C6 B! I( v
$ T' j( w+ C8 d. \/ }0 r- in al, 60h ; Get it 6 R8 |. b" a7 D8 z; J* w* z
- mov ah, al
9 }) U1 {/ o4 U- l - call A20Write ; Make sure the input register is empty
/ [% ]! o# t4 g - jz exit2
/ R c. U! r, _3 W, c- a - 7 m( ~$ F2 l( S6 Y7 U9 m' h, o
- mov al, 0FFh ; KBC NOP command, does nothing
6 H8 s% R! ~6 y - out 64h, al
- F$ n3 o' R6 x: F# w0 k7 c) x+ A - call A20Write
2 Q' c6 y4 |6 q4 E; z
$ t- _1 C2 F; Y- exit2: sti # f, P V( I" s, c$ C
- ret I) g2 ]9 }4 J( x. ]
/ Z. q' o y% Q
+ q: ~6 ?* _" m7 \2 u- A20Write: xor cx, cx ; Reasonable wait
7 m# D0 @3 H( Y - get1: in al, 64h ; Get KBC read status . S: t9 g. E- V/ @! h5 v2 E k
- test al, 02 ; See if buffer empty, bit 1 clear
5 l3 f* k! N+ P- U1 r8 P( t - jz clear 0 t7 V6 R; R- p7 ~8 s
- dec cx 1 ~1 b2 T) h; A- G* c' U* N( A
- jz exit3 $ {) y K4 H+ ?+ A
- jmp SHORT get1 4 F$ b( }- u: c
- clear: inc al ; Clear ZR * w# Y0 D7 R8 S* [9 I' ?' G
- exit3: ret 3 |2 z' P+ j! \6 J% P3 O
- % b" z$ B* L, i! Y6 Z
- 8 k# O) z9 }; m# F; T, S
- A20Read: xor cx, cx 6 G1 T# F# K C- Z* _, b; e
- get2: in al, 64h 0 e0 X4 D+ X: S. J) {" w- f8 q; B4 D
- test al, 01 ; If the 'output buffer' is full, has ; M+ y" _/ V9 ~* h
- jnz exit4 ; something for me
. W: v5 U5 |7 z" U! N$ E - dec cx 8 U h: `& g) c9 q7 Q W. c) f
- jnz get2
% U( A/ e& V; f8 B( H) f - exit4: ret
% L2 G' C; S$ Z -
3 A# L' ] f7 \! T; F% k" g - end
复制代码 |
|