|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
6 h% ?3 F1 J# e a7 y$ z+ B - ; 6 @; Z9 ?1 ?* W4 w# a% V
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
! W! _/ r! A6 ^: a - ; ml A20ON.asm
! i) f$ b, u. b* F2 s+ e - ; $ q3 h3 M$ N$ C- _4 Y* [- r
- .model tiny+ K N3 e$ p k8 P8 H
- .code3 B* ^2 ?6 c" `4 f/ M1 A
- .486
: y/ x& S' d/ K; E - .startup* L: z7 l$ r- b0 n: Z* Y9 N
- 9 Z3 ~- \" Y2 f9 H: c7 Z' y
- mov dx, offset msg_author
; {( ?$ K+ @. v+ e' A+ \ - mov ah, 09h. A2 v' _" z$ l& @9 ~
- int 21h0 |: K$ N# k1 x! A
5 @1 ?5 h, N/ c. W" d& f0 Q- mov dx, offset msg_fail
/ a( x* T' V* v/ y* M! u - call A20_ENABLE8 j& Z2 l' G0 H1 D f. z
- jz exit1
1 X9 P- |! D7 I y9 ^: y& L4 v5 Y" c - mov dx, offset msg_ok 9 S+ V2 n1 y6 H+ M7 L/ G) m* F
9 d5 y4 Z' X2 c6 U1 u" \9 O L/ h- exit1: mov ah, 09h # e6 d Z5 E9 \/ c( P- w
- int 21h 5 q! v& J' H$ Z5 w
- mov ax, 4C00h - L8 j# \' Z1 k& ?- s
- int 21h ! N. e! g3 V8 n
-
: m: s7 D6 G( ^, L' ]9 e7 Q - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
+ ~2 P/ N' M8 d. X9 z- E& M - "2008-07-01",13, 10, "$"
: J8 T( @4 F r9 S( g - msg_ok db "A20 Enable OK", 13, 10, "$"
/ a6 X* ^. y6 s- V& e - msg_fail db "A20 Enable FAIL", 13, 10, "$"
* b3 @1 j) y: h8 Q+ K$ M$ k5 k - 1 _8 @4 q8 |2 X0 o3 x& V
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------# D& r. |" j. m% k6 Q! l& F& e' h
- A20_ENABLE: ! I i6 X4 ~: z8 X0 y6 ~
- call A20Write
* E9 v: U6 Y, v1 a - jz exit_enable4 u& z6 i0 j/ O- S- t& @
' E. x, [2 i% S/ N! B; x- cli ; Only need for reading value from KBC , q+ @# g4 P; L* Y7 o" i. X5 i
- mov al, 0D0h % K/ T" ~2 {* m2 d' O2 c
- out 64h, al 6 I+ V% f9 A! u' N" N* I
- call A20Read
% W& O% z/ h! E; u" N- | - jz enable_int ' T) o+ y q) J' k" E. A
; I1 U% G' G. z7 |- W/ v {7 t- in al, 60h ; Get current status
6 G# d0 m& ?+ i: Y) @- ~ - mov ah, al ! t4 N0 g& C9 C- @! d; c& T
- call A20Write ' I! Z0 S' u) u+ A
- enable_int: sti / R& X+ V% c) X% U2 t0 ]6 g: B0 x6 I( C
- jz exit_enable' h( g5 M" s% s ^1 l
- . |5 Q5 Q6 m* p0 k9 I7 ^& g" y
- mov al, 0D1h ; Tell the KBC , want to write to the * U V" |/ K) L5 N, P
- out 64h, al ; Out Put Port next
: ^ o" l' ~6 s2 ^( L1 M2 G! s - call A20Write * d, ?: j4 ~! d+ f0 `0 c
- jz exit_enable
- o# e2 p, M9 b& Q
' u2 v& _) @0 ~5 t I+ z1 M- mov al, ah , F- o5 T$ q m! K) q
- or al, 2 ; Enable line A20 - t" a; O. i/ H% v( e1 [
- out 60h, al $ a$ q8 T+ }; J u; ]
- call A20Write
0 T3 t0 U. K$ V7 | q$ l - jz exit_enable
6 h3 F0 j2 D! P# ~, o+ {
, ]& }/ s% U, C& \& ^5 m+ _. U8 x- mov al, 0FFh ; NOP , F( C9 \; F0 B" Z; K# Q
- out 64h, al , k8 s. B# z. v' {
- call A20Write , s$ {8 k- D6 r" h
- / A1 k$ ?. Q7 E
- exit_enable: ret
* e& h: v, |' d1 p2 f2 x3 u
$ S- Z! i( s+ [& m- A20Write: xor cx, cx ; Reasonable wait
- Y' q5 E# D% S: u - get_wirte: in al, 64h ; Get KBC read status ; o/ T% }9 l `: A) r/ }% v; K
- test al, 02 ; See if buffer empty, bit 1 clear ; ^+ M# l- L: ~4 T s
- jz clear ) A- M! q* y) K$ m
- dec cx 7 l" R% ]8 ]" N( Z4 B- a
- jz exit_write
H$ m3 G) \; R4 A6 c; i$ a - jmp short get_wirte
- C4 J9 j. M$ D( w- X9 Y& F+ Q9 G - clear: inc al ; Clear ZR / d9 q" x% E* j. h" Q
- exit_write: ret # J8 l/ W+ U# p4 }4 o
- ( v0 B9 N* X- ~: ?6 f& y
. e* n1 L( ~' q( {& i- B) s. _3 P- A20Read: xor cx, cx
- A% f+ l4 o0 _9 D X0 z( t1 X - get_read: in al, 64h 8 r8 o3 y$ l1 H, A# n& o+ y
- test al, 01 ; If the 'output buffer' is full, has " S P0 E0 c) h4 R o A+ l
- jnz exit4 ; ...
0 Y; L- r! H* s* y7 O - dec cx
' b1 ~3 I* I; p' c. j5 U! j7 K - jnz get_read/ [ Y9 c, l4 j- d3 x% M3 q
- exit4: ret 7 v) G0 Y6 K2 _
- E/ _( g' g& W% \7 Z# ~
- end
复制代码- ;A200FF.ASM " `8 j5 g* V3 p& Y
- ;
" u; X0 X U V4 Q. D3 n1 E - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
$ v- }$ f- q# X- q/ c) u# D - ; ml A20ON.asm
: U8 C! D5 |; W2 z& V - ; ' A2 l- g' x5 T, j, `3 e( Y
- .model tiny: B0 y3 }: f7 D& X6 j
- .code: @' @+ n$ I0 B" ], M& t9 ^6 }8 L
- .486- h4 f7 V/ l. ]& g) Z
- .startup
9 m4 [+ W( T- Z! j: H - $ D8 F! T: G7 D3 q
- mov dx, offset msg_author
! g8 ?/ I6 v- ?5 Y7 \ - mov ah, 09h
4 v) H0 L) F7 a9 D- } - int 21h) {/ N3 m+ V) Y j+ ^- r5 q
- z# y$ _' ]! a. Y. ] S- mov dx, offset msg_fail
4 `. w# |/ C1 {( A0 G - call A20_DISABLE3 V5 ~. J8 d( G ]
- jz exit1
, _ M, V9 ^5 ?- y0 g - mov dx, offset msg_ok
& i* e5 ]5 d4 G1 q - 9 S% f) }2 c) t1 r# ?
- exit1: mov ah, 09h # J% z& T! o g5 i- p y
- int 21h 9 \: e, x( q& y: j( j, ` A
- mov ax, 4C00h
* j0 X: I% r. z - int 21h
) b k/ d* n, l -
3 A4 W! o; x( ^8 p- y8 Z! i - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,4 ^3 G: |; k; r/ ^2 v
- "2008-07-01",13, 10, "$"
' q( b: X0 z/ Z' H H - msg_ok db "A20 Disable OK", 13, 10, "$" 1 e4 Q3 T) L* D! B
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
# _' z" j8 I9 h, Q" M t
0 v L! d ?* ]' {* C1 B' R- ;------------------------ follow code maybe make to lib, if you want...-------------------------------. V' i. I! [& X1 m
- A20_DISABLE: % ], V. n0 Z3 f0 _$ I: i( r: q# u
- call A20Write
# g- f% @) N0 \& m5 b - jz exit_disable0 l1 {5 M! B; D2 I9 S
- - i$ {/ _5 d6 ], \- L4 t
- cli ; Only need for reading value from KBC
/ h9 D. {& `% B |" V0 x" { - mov al, 0D0h
4 `" `. G) s2 E8 K: D: T - out 64h, al
2 r) L; n) A5 z- n6 D/ D - call A20Read & Q; D$ z2 [7 t, n
- jz Disable_int 6 ~+ E" W) d$ |( ~' U p, ]
$ \2 P! L* M0 r* {- in al, 60h ; Get current status . I0 Y1 Q, e: a2 ~$ F) i0 Y* M6 f4 a) L
- mov ah, al
# d8 _9 [3 w' q, U - call A20Write 7 v n3 D4 A S. `7 @ }7 E
- Disable_int: sti * M! T& \+ u; b9 {: @8 x4 V
- jz exit_disable
) [; h9 R* x1 T( H9 e - H" l; n8 D8 e2 ~
- mov al, 0D1h ; Tell the KBC , want to write to the ' r5 t& [4 P' n8 [- ?
- out 64h, al ; Out Put Port next B4 l4 \( g) N) L( I% b
- call A20Write 0 r. I3 M: l5 P% p9 C" ^0 }
- jz exit_disable6 |, {6 Z7 |5 u0 `6 B- _
" a H; Q( I. P4 B' h) M' u9 x- mov al, ah
' U8 M6 K1 j" p8 ~ ? - and al, not 2 ; Disable line A20 & k. z4 @$ U& _
- out 60h, al ! V" y* n [) S. t* y* ^3 Z
- call A20Write 6 }0 `7 d1 n) S0 M+ r" }0 P
- jz exit_disable I6 W& @7 e" W6 u
- $ j- j% m3 ^: _% K1 j0 l
- mov al, 0FFh ; NOP
% R% o' W# v# ?( G; b5 y - out 64h, al
# X. Y$ H5 g; [/ ^ g$ B - call A20Write
; l0 P3 S9 B4 W, A! r: ^ \+ S3 k - % l4 f2 r" g& D! S0 w+ n$ z `4 s
- exit_disable: ret
0 p& }' K' x4 q6 h$ y W$ j2 ]& U0 | - 6 Z2 A0 e1 C9 ~
- A20Write: xor cx, cx ; Reasonable wait - E5 x( b0 h. Y3 \& q: H
- get_wirte: in al, 64h ; Get KBC read status
8 ^- w7 L# ^3 W7 i - test al, 02 ; See if buffer empty, bit 1 clear 4 J+ t ], N) G- Y5 C, f+ q$ ]- S
- jz clear
9 U3 g$ M- o5 k# g) { - dec cx . D$ b3 Q/ C1 f
- jz exit_write
1 m# p; n% T/ H* `6 T - jmp short get_wirte 9 |% _+ e* e9 H1 Q5 q/ q
- clear: inc al ; Clear ZR 3 t. ?: e& o* T4 t0 [, n
- exit_write: ret - w* G# @3 P) q! d* v2 y" X) K
& m* H. P+ U" }4 b" B, y
' s! f0 j8 \. V& }9 [- A20Read: xor cx, cx / M# C( G5 D9 h2 ^
- get_read: in al, 64h
/ S- g: { K a! V1 { - test al, 01 ; If the 'output buffer' is full, has
( Q; M9 L7 v2 @" ]0 K+ L( b - jnz exit4 ; ...
Z% {8 w& I6 ~2 i* L - dec cx # R3 m T+ l; A: \4 r+ t$ p
- jnz get_read
1 U) A6 D; M2 c! z* l* k) \ - exit4: ret 4 u( X6 l$ a% @3 t( K
-
- D" a X0 V* i" c, \ - end
复制代码- ;A20STATE.ASM " @9 u# N$ b6 L
- ; 9 ^3 m0 O* z4 d" |2 q
- ; Returns the status of the line A20 through the KBC % c1 C1 q) v5 O6 O& O
- ; programming by bini for debug. 2008-07-01
3 x- t* C( _2 L' g) Y7 U Y - ;
& S: d' y, f8 q3 N3 m - .model tiny
" y7 M' Z; B% U& ~8 R - .code* B! J. a Q/ W
- .486. u0 ]* U) [. ^$ B% Q, d( j: }
- .startup
f0 [6 f; _$ R! K' h) {4 _ - mov dx, offset msg_fail
, l6 k7 I2 I" R6 }# n7 r! G2 w - call _GET_A20_STATE_5 d7 H4 D2 t7 r& G# l2 o! @
- jz exit1 ; was a problem. d2 d" Y1 }: u" r
- push ax ; Save state, AH
6 N) n) ~. S* ~9 ^3 r1 Y - mov dx, offset msg_ok ; There wasn't a problem
0 L& H' \8 N$ i( p3 T - mov ah, 09h
% r' `5 I8 w# m* Q) O5 G8 k# F- B - int 21h ; Print message
0 i: [4 D( M5 ], ]7 R4 v% B3 a - pop ax ; retreve state
% Z. J+ u# }) x0 a3 X2 T
" A q, k; ~4 F) ]8 n3 y0 j5 D- mov dx, offset msg_dis
) [. C$ ~, a/ Q1 Z0 N) s - and ah, 00000010b ; bit 1, 2h, indicates state 5 j- K# ?2 m* b7 p6 y# ]* S, ?
- jz exit1
& H7 Y$ V. t6 T - mov dx, offset msg_en 6 k1 S( t* D- @# F
- M4 S2 J+ v2 d' J! o- g. K- exit1: mov ah, 09h
, c$ f& S) o% u M; {0 ^* m/ i8 a - ; DX already contains address of string
3 U& g/ I: p- q$ ] - int 21h
" C0 [! \6 b9 }" k$ h8 C& V$ r - - N7 V4 \+ L3 D( t( x
- mov ax, 4C00h 2 p4 K3 R5 a+ w# D% O+ _; o
- int 21h
; h6 \0 }' K) l! i* A/ C- D - $ `$ u1 V5 d- a% U b9 H2 O
- msg_ok db "OK", 13, 10, "A20 $"
% d8 N+ v1 U8 u+ E' V - msg_fail db "FAIL", 13, 10, "$"
( x7 H! a8 u4 q& q, N7 q - msg_en db "ENABLED", 13, 10, "$" * Z& T4 u/ B% B% w% M4 x$ U
- msg_dis db "DISABLED", 13, 10, "$"- ]7 K. [1 ?! j5 E& m
- 1 t& m8 w& ~$ K, f
-
" Q2 B) l, j- R3 g: |9 M: F0 X - _GET_A20_STATE_: k& L$ B" |" x
- call A20Write ; Wait till the input register is empty % Q: ^: _5 B2 [4 ], z
- jz exit2+1 ; Bypas the reset int's
: y4 n) o% C; b, ~ - cli ; Disable ints so we'll get our value : r5 r2 j, d1 S
9 {" d/ d; n5 A4 o+ b- mov al, 0D0h ; Send command to the 8042 command register
9 D. C; A v8 |% J! | - out 64h, al ; to tell it we want to Read the Output Port
2 W7 v! b6 b3 s+ x( Z" v3 `, L - call A20Read ; Wait till the 8042 output register ' k1 ]+ E+ ^6 k6 N- f
- jz exit2 ; has something in it's buffer
! [% ` \# ~" O8 P& @& _7 U - ' x4 j+ H+ Q$ W' j$ Z& e a! t. n
- in al, 60h ; Get it 1 t( v7 D* k4 X+ R) ?
- mov ah, al
; e t M$ p4 T6 ?1 x - call A20Write ; Make sure the input register is empty }0 ?0 @! t* |. c4 y0 C
- jz exit2 - V, n% w. b1 h3 T, G) x1 y/ {7 X
% P* U# y. ~; P! S) T" u( U- c- mov al, 0FFh ; KBC NOP command, does nothing
; u! z4 G l: Z0 E - out 64h, al . u5 t3 g; c+ J
- call A20Write 9 f& @4 |. [0 G
8 _, H4 T7 Y0 W1 L/ M3 [# r- exit2: sti
# s' ] I* N+ `9 E - ret
7 F0 b$ N: h o+ G z
5 Y' m% k$ x7 Y. D1 P3 q8 J
( V- C) {. L0 b" |9 G- A20Write: xor cx, cx ; Reasonable wait
2 l! N! y; t7 d, m, N1 F& o9 _ - get1: in al, 64h ; Get KBC read status 8 G; R# y* C* t# \# [
- test al, 02 ; See if buffer empty, bit 1 clear
$ k- ^+ Q% v, {3 C& R - jz clear
4 ?. N/ f& J- x- e5 s - dec cx 9 w1 c% Q) M) v U0 z5 U
- jz exit3
3 ]7 b0 V, ^8 I/ ?6 {- j - jmp SHORT get1
5 \8 j. ]* {; g& p9 P1 a( A% X - clear: inc al ; Clear ZR " s; j+ y, H( }- d6 D7 J( ^
- exit3: ret ' F- d8 w; ~# [/ \
- $ B. ]) X* X0 g9 O; `
- , q2 n2 z/ `8 j. ]: N5 ]" p% B
- A20Read: xor cx, cx $ m3 C. ^4 w" S" }
- get2: in al, 64h & V) ^# E4 u! |$ S9 z6 E, R' {
- test al, 01 ; If the 'output buffer' is full, has
/ G! W' ~% H8 U {: } - jnz exit4 ; something for me 6 R& h1 N7 y/ z" X
- dec cx : Y+ ?2 \% i2 W. A7 h+ b
- jnz get2- ?0 m2 f) E5 J
- exit4: ret
! a0 y' o/ ^& ?& j- ?+ J -
0 ?1 g: a& L# ? - end
复制代码 |
|