|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM # Y' ~; I! a j9 n
- ; 8 @6 `( a2 `6 a* c6 Y, `$ A
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01& x; h( n! B r2 R3 V+ \" h
- ; ml A20ON.asm % n5 ] N! ~+ F$ c, C
- ;
1 p- p. @6 Y* W - .model tiny
) c4 ]% O; G, X7 M7 k% D7 v+ u - .code9 v7 j' Q5 W7 Q1 u
- .486/ r6 V9 ^& v# Y# K' i! @
- .startup
1 B8 B! q0 f7 h i& N Y0 K - / e. `% N; Z7 `: Q
- mov dx, offset msg_author
5 P4 V, `. c1 |; D. M9 X% h - mov ah, 09h7 L+ T; y/ h4 N, A' K4 w, ]
- int 21h
+ ^# ] V, Y6 r- a: A - 9 @0 }7 q# f0 N# a& u6 Q5 Y0 }
- mov dx, offset msg_fail ( B( J# ]6 J1 W1 i2 u5 g- }+ K
- call A20_ENABLE" D4 l6 U. Y, b) t e$ s& P
- jz exit17 c: R# I j) k3 j/ A9 J4 A: {
- mov dx, offset msg_ok
3 w; {7 \, G6 b; k- U. Q
: U' W9 Z, k' M6 [3 O2 ~- exit1: mov ah, 09h ! b0 p$ J1 y3 e* M
- int 21h
6 V; I4 R' G* a/ P5 n/ C$ i5 e# G - mov ax, 4C00h
2 w" B6 B8 `) ?$ O - int 21h 7 z8 A+ C, F6 F. t. B5 c9 r
- . O* R5 s- b* |% _ ]* h3 N
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,( {3 I. H4 o1 Y: j$ U+ ]
- "2008-07-01",13, 10, "$"
6 M1 Q3 Y; R, S( H( R- O& C m$ N8 ^+ R! I - msg_ok db "A20 Enable OK", 13, 10, "$"
1 b {" {' |6 a: `7 k - msg_fail db "A20 Enable FAIL", 13, 10, "$" 6 R: Y! Z+ \8 }+ x
- + p Z5 w5 x( I* }2 G
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------4 E+ O J. j6 J9 g: O8 {% g5 F
- A20_ENABLE:
6 I- t8 @+ R7 \, t _) j7 I - call A20Write
+ G% i6 z1 J( Q5 o - jz exit_enable6 @2 @8 i( [+ }% D6 H6 t9 E
7 |" ^& k/ m, @. H, g+ |1 y. m& n5 d- cli ; Only need for reading value from KBC
1 G! n$ U" ], i Y$ s- s - mov al, 0D0h
( L8 D6 p# M6 q" }3 a3 X - out 64h, al , ]" Z4 A2 a% A8 a s
- call A20Read
9 ?8 p Q# \+ c - jz enable_int
9 Z3 U9 k- l: }# x7 W - : X* E6 g; t5 {
- in al, 60h ; Get current status
& R( y s, V8 D - mov ah, al
* Z# X* @: V) U) l' p7 } - call A20Write
. ~4 Q" X( D1 d# Z7 R, E3 | - enable_int: sti
( J6 l$ v5 I7 I+ [4 i - jz exit_enable
: a6 N2 X; O% W: O7 G2 T - 0 L0 d% M/ I0 G2 A3 ~4 f% k
- mov al, 0D1h ; Tell the KBC , want to write to the
$ R3 c B' V7 |2 [ - out 64h, al ; Out Put Port next
# v1 {: @/ R4 T% _* v k9 n - call A20Write
1 E4 X5 f" Y( w7 T( ]# e6 g6 a8 a - jz exit_enable
& ?4 k3 {* N" S - ! [1 z) e* l9 B; H( [+ f
- mov al, ah & X: M) @6 n' L
- or al, 2 ; Enable line A20
! k1 [8 t/ d/ @; d/ j4 y9 E) F6 @ - out 60h, al 3 B' C1 X) l% Y( W
- call A20Write * c8 ]3 s4 F* ]% q; E6 A
- jz exit_enable- j+ ]" r! J6 v# p' q
- 4 x' w$ _; R* V
- mov al, 0FFh ; NOP 5 u( T, p, C% t9 E, T1 ^3 E
- out 64h, al
3 N2 L( f- S$ z! i5 d2 G9 X3 I7 a - call A20Write 2 `# I* ]- M$ x/ V/ C
# l B- Z5 }* e3 S2 L9 j! i, h8 v- exit_enable: ret 2 O' j0 M9 \9 Y* E
- ! x' m0 w1 |5 `8 E" w+ m. i
- A20Write: xor cx, cx ; Reasonable wait ' Y/ `: m1 m8 S1 ]3 S$ @& F' Y
- get_wirte: in al, 64h ; Get KBC read status
% D0 t) H+ ?' i - test al, 02 ; See if buffer empty, bit 1 clear
" b& P6 a$ r6 x - jz clear
2 `" B3 ]8 g3 u% K% l. R' | - dec cx
' s6 O& f- ]: E# M* }1 Q6 m - jz exit_write ( I$ V: N. @. J1 [: i
- jmp short get_wirte
7 j( u$ m) k3 ], I) {7 I - clear: inc al ; Clear ZR $ d7 o3 X' v" N% j9 {, z& z
- exit_write: ret
; q+ J% B7 I' s6 _
1 M7 U3 U& B: R4 p& V- ) a5 N) T$ x; b0 K# G
- A20Read: xor cx, cx
1 d M; H# z0 S$ x3 J5 g - get_read: in al, 64h
8 `( _2 o4 X M$ D/ z - test al, 01 ; If the 'output buffer' is full, has : w4 w, l6 W% x# e8 g6 d* l
- jnz exit4 ; ... 9 b+ |3 L$ M7 j5 o' [: @! {1 a# d
- dec cx
* w5 ^4 I; a4 a y4 I# Y% x" }( G9 J - jnz get_read
, Z% b* p& |- U$ Q. O - exit4: ret
c. e& C, ?) r2 q5 x1 t. T1 N0 { - ; B: `* b) _6 x9 c
- end
复制代码- ;A200FF.ASM
) i9 \8 }+ r& a. L+ q - ; # X5 u# L) x3 [( f I, G2 s
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
" k2 Y& ?+ g! i2 `, }3 z - ; ml A20ON.asm
* B, z$ S/ L2 |& M8 m/ c+ W - ; 4 e3 a3 j+ J/ T' `& q
- .model tiny& J5 q9 v2 B+ ^5 O
- .code+ c) ]. G/ D* U5 b/ ~0 ^
- .486
2 W. O; V; _/ F" Z - .startup7 |6 z) \5 }# ?0 _! x* F. W
/ n9 z/ a) s& a- mov dx, offset msg_author: _8 j: g+ u$ Y( i& S- U+ v" c
- mov ah, 09h
0 {' e4 C; u% n% z. _3 }5 C4 S0 b* Y - int 21h' n( D% J* Y4 d' ]
- * n9 |1 }+ @- R( O
- mov dx, offset msg_fail
* u9 X& e3 c; h2 V6 r# P8 ?6 I& V* z$ i - call A20_DISABLE
6 c1 @2 B" L; ?: a- y - jz exit10 l+ g. { ~# w) ^) L" [! ]
- mov dx, offset msg_ok $ L+ V$ [, t9 r; R: R* H
( l, L8 l6 V! p2 z5 V' |- exit1: mov ah, 09h
9 D/ M9 Z9 ], Q. G' Y* z5 f1 Z2 j3 N - int 21h
* g# h ]- d7 V1 m- j - mov ax, 4C00h 5 E! W/ [! E. t9 H' d3 L
- int 21h
5 F$ a2 l, V5 l5 W( L- I- ? - l8 Q4 n+ J+ c: ^& u: Y
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,4 Z' t+ Y8 ?( g) e
- "2008-07-01",13, 10, "$"
; A- E! u) @7 |; C. S- H - msg_ok db "A20 Disable OK", 13, 10, "$" + ? d4 C, u, F/ f
- msg_fail db "A20 Disable FAIL", 13, 10, "$"
S- ~4 h, |0 C9 ~ - 2 b3 n q+ \; X
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------* h" a" Q- \, h9 R
- A20_DISABLE:
. A7 ?0 E/ a/ k+ F - call A20Write 1 L$ W3 w* ~1 ?1 ]- w6 `
- jz exit_disable4 q# s. }, o4 F( j I; O
- 1 h1 Z# `3 K& v* n
- cli ; Only need for reading value from KBC
) ~ O; ?2 E' M( b0 I - mov al, 0D0h # R- D3 p; p; L. Y' t# Q1 K
- out 64h, al
9 S2 d0 n. F* `* l - call A20Read ! a" L) e y0 M9 i# k* `
- jz Disable_int 2 j& k& | p1 G6 Z; n
( u9 R+ U' s9 ?: G/ p- in al, 60h ; Get current status
+ c- ~5 o4 t3 @ - mov ah, al
7 ?9 B7 w, r% [+ ~2 j* Z. C - call A20Write : c( C$ |3 E; B& ~- g
- Disable_int: sti + l/ `& E* O9 [/ a2 o7 f( P0 f
- jz exit_disable" _* o6 w+ B5 H
- 7 X( S1 r1 b+ [* U& ]
- mov al, 0D1h ; Tell the KBC , want to write to the @. L( L# T% o! b# B" [5 p
- out 64h, al ; Out Put Port next - |- H. [3 |/ c- H$ L
- call A20Write
4 `1 }9 I- j5 n9 E - jz exit_disable8 F1 A+ C8 ~; o" c8 o1 Z' \
- 3 Z% |) d9 `8 H
- mov al, ah ' P# H% Z5 W2 S
- and al, not 2 ; Disable line A20
7 e I* ?8 s; ^0 i2 n8 w4 C4 ` - out 60h, al
! x7 z! `, K- x/ w9 y8 r. A6 N9 o - call A20Write
# f7 [! ^2 f% \ - jz exit_disable
+ `/ _4 F5 d( q - ' w. m4 q! c' L0 K, n
- mov al, 0FFh ; NOP $ j. z# c6 v- i) ` l* z
- out 64h, al 7 I/ `+ {- ]) {
- call A20Write
: i- E9 w8 O0 b: }$ O# u3 ^; U - 9 {( g6 A0 G$ ?! x* H
- exit_disable: ret
6 h) E) I+ N5 R& n - 0 Q! L# L1 I# M# H4 x$ M% u
- A20Write: xor cx, cx ; Reasonable wait * c& c3 R# ^( c' Y$ F3 ~' f
- get_wirte: in al, 64h ; Get KBC read status
7 u' N# W1 e" S& v0 e - test al, 02 ; See if buffer empty, bit 1 clear
/ g% i% n* s7 O3 \- ]) D ` x - jz clear
( l. @; U! f! M) j - dec cx
, H3 z& w8 i# P) d" V - jz exit_write
& r+ O( B) q+ f( D! J - jmp short get_wirte
# }" J% D: i+ H - clear: inc al ; Clear ZR 7 Q5 \( l8 o! }, f: s5 |# J* a' d- e
- exit_write: ret
& }3 H4 {! ^ d Z4 z
" q3 |2 ?( J$ ~" i% i- * m" `+ u- I4 m$ h0 K" I% r5 Z+ B5 t% N7 X
- A20Read: xor cx, cx
- Z9 [9 `) L- w" Z g - get_read: in al, 64h ( c9 y) |1 k2 l( Y
- test al, 01 ; If the 'output buffer' is full, has t3 j0 q/ f! H8 e/ l- M
- jnz exit4 ; ...
: ?0 [9 {! |! O. h$ x4 l - dec cx
: g, ]! {& c7 Q) s9 Y" E9 N - jnz get_read
7 m" c' T' U5 N4 Y - exit4: ret & H3 J" |2 K1 [
-
& \: b4 C# V) [& m, f, A2 p# u - end
复制代码- ;A20STATE.ASM
8 v' p" B/ x& V9 W: M9 j2 g. K - ;
% N1 I2 v' y( O - ; Returns the status of the line A20 through the KBC
% H }% V6 x" f4 L* p# a( p; W - ; programming by bini for debug. 2008-07-010 ?. W- {6 ~8 H- A- T$ u
- ; " s/ h) F& z/ u. c. b2 ]
- .model tiny8 E6 T8 f2 c/ t5 M/ j& @, [, I
- .code9 H2 `) r6 [" A7 H# U4 ?9 o
- .486
2 \% x8 A, p: |6 W2 b - .startup
" c1 V& L7 _: Q - mov dx, offset msg_fail ! o: Y% I1 D' M- Q
- call _GET_A20_STATE_$ v( a4 N4 q: D, z, l( T
- jz exit1 ; was a problem/ c: ?$ Y! j; Y0 V# Q# a
- push ax ; Save state, AH
1 e; k v1 g9 Q( S - mov dx, offset msg_ok ; There wasn't a problem
2 A) P- j0 ~! I( ~& M- d7 D - mov ah, 09h
l% N$ R: V3 O( v1 p - int 21h ; Print message $ _. Q% S: ]3 R
- pop ax ; retreve state # p* f7 a! r3 f" A2 K, `" E) b
- & q2 W: l7 d$ `& ` V
- mov dx, offset msg_dis
$ ^7 K; F1 u9 q v& F3 i - and ah, 00000010b ; bit 1, 2h, indicates state
' f7 D( Y" E% V% n! y S$ ? - jz exit1 / D& l! R# z9 [& }2 Y
- mov dx, offset msg_en - c& t0 V O s0 W1 F
- ( m d# |7 V* h9 e& r3 d& w& h+ {
- exit1: mov ah, 09h
1 `1 G" V G- ^/ {8 _6 o - ; DX already contains address of string
8 c( {/ B4 ~# e. n - int 21h
# u# i" [# \) _
/ f3 _: z1 K5 W1 k+ j- mov ax, 4C00h " } X% B- K4 ]7 b
- int 21h
* f9 Q* F0 M' e3 o - Q5 k" v4 i6 S: Q
- msg_ok db "OK", 13, 10, "A20 $" - {$ W% {) ^" G" a
- msg_fail db "FAIL", 13, 10, "$"
$ s" d* [% Y; v2 f `. C4 P+ h - msg_en db "ENABLED", 13, 10, "$"
( D' H7 B/ ^: F - msg_dis db "DISABLED", 13, 10, "$"% M' t* C, S7 g# G/ E8 N+ g1 D2 w, W
% Q/ i9 U) T0 E) E9 W7 h3 y3 v" G( Y- # d# D' t8 T0 f! ~
- _GET_A20_STATE_:
% w& `1 O# m" y/ G, w5 m5 E - call A20Write ; Wait till the input register is empty . F8 J7 I. Z& P
- jz exit2+1 ; Bypas the reset int's ( l; T6 f' H- u) K9 f* v6 L
- cli ; Disable ints so we'll get our value
6 N& m& e% b! q1 E% O
+ Q$ O! e6 J, C6 ]6 C6 b- mov al, 0D0h ; Send command to the 8042 command register , e) P$ K! O) T. a* k4 n3 g
- out 64h, al ; to tell it we want to Read the Output Port 7 `6 N! `' C* E- n2 R
- call A20Read ; Wait till the 8042 output register
0 b% i* j' t& n5 r - jz exit2 ; has something in it's buffer
Y6 d# x [" F2 B0 r - + z7 z. Y! q; L( ^$ D( U
- in al, 60h ; Get it 6 [0 ^1 E+ B6 K! o8 H
- mov ah, al
+ r. J6 U* j6 ^+ t; e5 S - call A20Write ; Make sure the input register is empty
: s' K6 R/ j; O- F2 x4 A; a+ V - jz exit2
4 Q. @! e. j/ Z0 n. a
( g+ m( }; {( D6 A- mov al, 0FFh ; KBC NOP command, does nothing
/ r# D- S" Y' s0 V% U - out 64h, al 4 K- d: A# m# z9 x1 D# g
- call A20Write
@- Z; ]7 D2 M) X4 d% o7 H - : X. M- a! r) |
- exit2: sti ) N6 ?! n" q6 [$ F5 y/ X: p. p8 R+ }
- ret
, c& \: r7 L0 X( M0 l5 Y - ( M4 j$ V3 [; A; Z5 x$ t
- 0 N I% |5 @: f+ o' A
- A20Write: xor cx, cx ; Reasonable wait
# O S8 ]: r" M - get1: in al, 64h ; Get KBC read status
. J/ B k! g& w# ^ - test al, 02 ; See if buffer empty, bit 1 clear
, Q4 h7 W5 ~5 O( ]4 A d7 S8 o - jz clear
; b$ C+ m: E; G/ `( {/ l" e* U - dec cx
* q6 T+ O' i2 Q9 I - jz exit3 . F) Y( [/ W/ z6 Q' \+ A7 i2 `- y
- jmp SHORT get1
' n; o) _1 M, S+ Z: | - clear: inc al ; Clear ZR 1 E8 X8 M6 Z) m N ]; u, U* {' e9 c
- exit3: ret
7 S- Y' Z. }+ d) |* Y7 s: N
, u3 V5 C4 x9 \4 s" Q, {4 X& R8 A; u
/ S m" Z0 D2 k* @/ W- A20Read: xor cx, cx
4 F7 t! a0 _4 i n - get2: in al, 64h 8 p. t. Q; Q" X0 l9 |' o U9 ?
- test al, 01 ; If the 'output buffer' is full, has 6 F- c5 y& ] p5 E$ q8 N1 e
- jnz exit4 ; something for me
# J' z8 b2 x$ T' [ - dec cx
/ X" k" X; z% I: z0 M+ A. q - jnz get2
) o' I5 {; y& N# \- ? - exit4: ret # g0 }. _0 N2 r6 T5 u2 J) T5 X
-
" _% L- k- g- F. L - end
复制代码 |
|