|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
5 l1 d6 u- P) r - ;
( F; |$ C9 r& ]3 p9 F# ` - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
4 ?" v; r# N1 D! O1 ]! Q# l7 [+ F3 T - ; ml A20ON.asm
8 z. o N7 i X+ A; T" F - ;
) Z4 n; v" |2 i! q - .model tiny
" A) Y l& p9 }6 x! N4 R* W+ d - .code8 ~: B& g( P' X O0 p' s
- .486
' Z- a6 y* d4 V, m7 O* g' W - .startup
3 {+ U) q9 e2 q - : V& I" G2 k- f6 p4 j/ S
- mov dx, offset msg_author
8 h2 j7 V' z4 ~ - mov ah, 09h
! h# i% N7 O4 s# `7 [: M! Y! V - int 21h/ K( i- ?5 f4 f- q4 u. X, z
4 ?: ?' V5 }& a4 `- S- mov dx, offset msg_fail 5 m9 I" n4 k3 v8 {; o k9 a- _
- call A20_ENABLE
8 O2 b8 Z* W! V; W9 P - jz exit1
4 d* }2 k; u9 W$ A - mov dx, offset msg_ok
! L1 n! }% f3 v V - $ |5 g9 v1 e3 G9 S: `
- exit1: mov ah, 09h
4 T5 _) q3 ]; \ - int 21h ' ^# W. r: ]* D; q
- mov ax, 4C00h & o: P0 {. P% w
- int 21h / l9 _0 f# p9 w. q
- % @0 c" I& C) [5 I
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
* b* B/ t+ q9 C% b' O2 K$ E - "2008-07-01",13, 10, "$"
" n" ^5 f+ x3 i! ?9 T9 R) n% N - msg_ok db "A20 Enable OK", 13, 10, "$"
8 }' q; M% i* P, X) ]2 L- Y - msg_fail db "A20 Enable FAIL", 13, 10, "$" 1 B% I# t/ o+ \2 z: K
* f1 ?9 B, z; t6 S) U N0 p- ;------------------------ follow code maybe make to lib, if you want...-------------------------------* c3 q" Q; j2 K0 R. ^1 O1 P
- A20_ENABLE: & k- U: }7 E# X3 e
- call A20Write
, `8 l- P! d, z; G, E5 A# Q) c - jz exit_enable
* b) `" }# \- P
; d/ X% v- w y8 L D* z- cli ; Only need for reading value from KBC 2 e0 d" Q" d2 V) ^8 Y/ Q$ ` r. w
- mov al, 0D0h
$ X) O! H. j1 s6 k( W0 i D3 @( v2 E - out 64h, al
& o# r+ a* o3 D+ o! C - call A20Read f! W( d/ j3 K
- jz enable_int
& |8 q. b+ q* G$ U/ u6 A9 V1 u J/ {' ` - 1 w6 D3 `. N+ J, ]9 g9 H( s5 k4 q
- in al, 60h ; Get current status - K& E- j6 I9 ?9 y: M
- mov ah, al
2 k! z ]$ }/ ~( w - call A20Write
7 A) i t, w* v/ M - enable_int: sti 5 X- w) m5 }* }/ S
- jz exit_enable
( A5 Y4 ]+ V. L2 q$ p - * v' p$ p; x9 A3 y
- mov al, 0D1h ; Tell the KBC , want to write to the
0 h n# D5 O- j6 L - out 64h, al ; Out Put Port next % n9 E0 k; I2 \' N. ~
- call A20Write 0 ^! b4 a# P7 W
- jz exit_enable, D; k. y7 D0 k3 ]# r/ g
- 0 @1 R _. p$ m3 B, j
- mov al, ah
. m5 Q& A! ]$ h - or al, 2 ; Enable line A20
+ ?5 x8 y2 v& B9 N' \8 M: f+ N. Y - out 60h, al : D: n& G5 m, q c- [5 W5 j
- call A20Write
( v$ i* G* L9 z3 k' h% i4 l - jz exit_enable
" f% l, s5 \9 s% R* H1 T8 T! I - 5 k A! X' Z% t2 r( k2 {5 D
- mov al, 0FFh ; NOP ( `3 M, u/ o2 f I3 C$ h. W- J5 j
- out 64h, al
& N T3 v. r, c. t( L \ - call A20Write 2 S9 r5 f8 a( \8 k6 g1 D
- 5 j- [0 S2 d; A5 z
- exit_enable: ret 3 D; S8 c# T- O3 q7 s1 x/ x
; l+ X3 {: ?: u' z6 [- A20Write: xor cx, cx ; Reasonable wait
3 x: k, t; _: ]# t$ O - get_wirte: in al, 64h ; Get KBC read status
. c) Y, c: u$ u. x - test al, 02 ; See if buffer empty, bit 1 clear . j( H: q; Z9 I" z
- jz clear 0 G5 C1 A7 ~6 ?' g5 Q( [
- dec cx . @2 A( Y' e" d+ y8 ~, v; Y
- jz exit_write 9 }1 l# c& l' }
- jmp short get_wirte / H5 O7 r* B E. \0 M
- clear: inc al ; Clear ZR & H! r# v( c% |1 i' h! V+ ?9 \
- exit_write: ret ( | R) V. c# z: I" Q
- ; G" [ L! x O
& L/ c3 Z7 k% C5 d( E7 t- A20Read: xor cx, cx
+ ?8 t* N; `0 l - get_read: in al, 64h ; Z) |2 m w! y2 f3 F% U
- test al, 01 ; If the 'output buffer' is full, has
8 W: ?" i& K% @* m# z - jnz exit4 ; ...
+ _2 s: n8 K( n& F E. S - dec cx
9 P# S5 a% |; H7 |, N - jnz get_read
" {, X) v" k% ?* P4 h - exit4: ret
& g5 j) M* W6 ~ - # a! r. `% K% Y2 d% B
- end
复制代码- ;A200FF.ASM g6 q2 k8 {2 V4 U! `) I5 k
- ;
( D. [) g2 n, u5 F - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01+ \( t8 F0 I2 {- [# [7 b* f: Y
- ; ml A20ON.asm
8 y1 U$ b; Y6 B* |" x3 z2 R; J1 { - ; 8 X9 o3 [: `8 P& ?5 \$ L2 V/ v/ h; d
- .model tiny. V. H) b2 n4 Q7 P
- .code+ |! Y" a% i5 l$ e+ l2 H3 U# x0 H
- .486
8 p5 c0 D: p" g. J" \ - .startup4 o8 G v: V. l9 _9 E3 N2 t2 l0 j
- r- b- d8 K/ \- mov dx, offset msg_author6 J* D4 d6 g! J2 r3 w' o# C7 x! S
- mov ah, 09h o ~/ O) U: o- a# X/ ?) F( E
- int 21h
; A5 i+ J& m+ \7 t - $ v: P/ C! N) X! k& c
- mov dx, offset msg_fail
$ R7 G1 ?0 R& Z5 U" z8 s2 T" R6 D - call A20_DISABLE
, d) I f, Y; n+ S- S! T) U* s - jz exit1$ g ~. V; [% j. I! _& u
- mov dx, offset msg_ok
! m1 j. H$ c6 J
5 }5 l( k" E0 ]8 C% T2 m X- exit1: mov ah, 09h
. T6 \" j# ]/ Y G' r - int 21h
1 z% \; s1 k, d) _+ M! y. y( Y8 R' { - mov ax, 4C00h
% W; }7 C9 s* F% _5 f8 @5 k( A! a - int 21h 8 y" |6 j2 {. h3 p) ?3 \
- $ }3 R* L' `0 ^4 j3 X/ _
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
, |2 C3 _) o* A% T V3 U! f% B - "2008-07-01",13, 10, "$" / ` N% |7 v6 y9 H0 n
- msg_ok db "A20 Disable OK", 13, 10, "$"
0 J: T- g9 e: V' m6 k& J, D7 I - msg_fail db "A20 Disable FAIL", 13, 10, "$" 5 [1 ^5 f* l: u8 k3 t# a( ?& A
, H8 j _! Y8 y% n2 _- ;------------------------ follow code maybe make to lib, if you want...-------------------------------, f# A# Y% N+ t6 J- C, r
- A20_DISABLE:
K5 ` Y! T9 Z, V3 ? - call A20Write
9 ~5 H" w$ M* Z% A9 H9 o - jz exit_disable
( Z9 z$ V; O- Q& [ - * F- F1 b# e6 p! `; G, x
- cli ; Only need for reading value from KBC
~. p; ?2 C2 O, V' u L+ ^5 Y - mov al, 0D0h
9 T) `$ Z- L, C7 \; }4 c4 x* S6 ` - out 64h, al
8 e' }8 Y& j# g9 W: a. ` l- @ - call A20Read
: V- z% H9 N+ l% u - jz Disable_int
7 O# A1 z, o- d( e7 R
) R+ D6 S' D' E! l/ n# L- H1 i- in al, 60h ; Get current status
1 @9 t- O5 e" B8 [$ z: y8 B( f: A1 A - mov ah, al 8 r0 } Y( w, [7 \
- call A20Write
+ o7 ^; t8 n* a' x# W* {# h - Disable_int: sti
) T& s" p( e( u9 x - jz exit_disable' H4 F+ {; k0 B5 w( q
- 6 K5 E; V" ?& k# }" ?8 O6 Z
- mov al, 0D1h ; Tell the KBC , want to write to the 6 N/ o; N) a& e7 B+ K. b0 G, ^# m
- out 64h, al ; Out Put Port next
: C1 `/ G, t, u! ?' ^0 x - call A20Write
7 Z6 i P+ x; D$ Z F7 c - jz exit_disable
" I e, r- H0 L, R
- c0 a9 N' m" y, |5 U$ ?6 D. B- mov al, ah
5 V: y0 h$ U! D( S9 J - and al, not 2 ; Disable line A20 6 e7 Q- s7 z' D! \6 s
- out 60h, al
T8 a2 k7 F3 F# n$ B4 V9 A - call A20Write , X. E5 D8 w0 E. M' t! T7 z
- jz exit_disable
" t# `: a. ?5 W0 V+ s - # V* d; ~6 V! ~+ m Z, w! `- O
- mov al, 0FFh ; NOP
/ @$ b& w/ u3 F1 V3 Y, y - out 64h, al
- h# [- I4 D9 o* ]2 e - call A20Write
4 V" G/ i5 k: L, @+ l. f/ V5 T6 v* ?! J
+ F6 ?8 c0 g& n* w- exit_disable: ret / S3 ~1 D, t9 P
- 3 Z1 d5 s4 `! L' G+ d1 r9 V! _1 D# o
- A20Write: xor cx, cx ; Reasonable wait
- \9 w" h; G6 O9 y6 ^ - get_wirte: in al, 64h ; Get KBC read status
. t( h1 m& m2 X s# ] - test al, 02 ; See if buffer empty, bit 1 clear
5 g8 [ f8 T( ] \8 n- g/ h - jz clear ( h+ k6 O. J( s' S
- dec cx # J/ X, c/ X8 T. G5 @8 j9 {
- jz exit_write
, I' B, e$ b- Z7 [+ K3 [% k - jmp short get_wirte / v9 J0 {8 o, c2 N" C4 L
- clear: inc al ; Clear ZR
9 K4 k+ v- {7 C8 B8 H - exit_write: ret
- h) A8 `) d2 ^* K. J. K
* ?9 D; j. D- R. u- ( t6 T' I- y0 d: h1 l
- A20Read: xor cx, cx
7 R1 D& v: c/ Q7 B3 X" o; S - get_read: in al, 64h : C9 ~, B; U% t+ B
- test al, 01 ; If the 'output buffer' is full, has 3 U. G, h& m+ B0 Q! F
- jnz exit4 ; ...
2 ~. S+ ]& N9 l' R/ ]" ~' R - dec cx
0 Y% ]4 G2 u* `. Q9 u1 e, w n - jnz get_read! R+ s8 I! E0 |) R# _) U
- exit4: ret % o7 p5 Z V* c2 K" P! n x5 f
-
3 E5 Q4 ~' o5 }/ n ~' u3 _ - end
复制代码- ;A20STATE.ASM ! D# A l5 w: U
- ; . M& C0 e" H/ @2 \+ b# k
- ; Returns the status of the line A20 through the KBC
- e/ D# K& a, B' b. G - ; programming by bini for debug. 2008-07-01 P1 J' T& c: M
- ;
/ ^& }/ h5 P! U% h5 R - .model tiny
" R- K! a E5 x0 T9 |6 E' a, p - .code) k+ P' Y3 y4 k7 R8 V6 z" q
- .486* y$ s9 D% [6 P" C4 ?5 j; C
- .startup9 u- l, R' a7 F% p* l. Q( l2 `
- mov dx, offset msg_fail
' N! f5 h! S: }1 Z7 l/ m6 p - call _GET_A20_STATE_! l$ z$ C8 R$ b! ^6 D
- jz exit1 ; was a problem) \* L5 ~( c* ^* a
- push ax ; Save state, AH
2 Y M: f) I3 N! F1 U0 K - mov dx, offset msg_ok ; There wasn't a problem 8 |, Z0 [% J4 B+ H0 A% N' H$ {
- mov ah, 09h
: D0 j4 @+ y5 n9 k0 Z. e4 A, @ - int 21h ; Print message
3 M1 d, R. X: l& T - pop ax ; retreve state - z: A! e% O6 S6 ?2 C' ]+ P3 i
7 b% ]) C1 L4 T" C+ R- mov dx, offset msg_dis % h8 ?8 B& Q: Z) U f
- and ah, 00000010b ; bit 1, 2h, indicates state . _( p. ?0 p, y! M0 W
- jz exit1
# c5 Q6 [! R, ] - mov dx, offset msg_en
6 [# Y. A+ @$ T8 f/ Q
; ]. |* ^. p- a+ }( f3 y- exit1: mov ah, 09h
* M1 P/ k. A5 Z5 s. \( w - ; DX already contains address of string # ~: E. |, b" ?% B4 P( i$ u
- int 21h
: \5 k; V, @3 s, W5 V: I$ W* k4 w* x - 8 J" i3 c4 |$ |# ]
- mov ax, 4C00h
0 V. a, z! n3 t( H - int 21h
, n: `8 V* F7 y7 V& g - Y* C$ Q* n* ]# f, I5 s. D+ p
- msg_ok db "OK", 13, 10, "A20 $" ! E( v; C/ g9 r# h/ X
- msg_fail db "FAIL", 13, 10, "$"
4 \5 B" V; I( u, H - msg_en db "ENABLED", 13, 10, "$" # q$ {) t. g8 H. @ V, f: [+ \
- msg_dis db "DISABLED", 13, 10, "$"9 d3 ^) f7 u7 M& X; k# y( k
: U9 [9 X9 g4 b% A) c# n0 c; C% X-
% k+ y8 r% U5 {* u D4 w) B - _GET_A20_STATE_:
0 O$ P2 j5 J- ?% n - call A20Write ; Wait till the input register is empty 7 n0 l" y/ C5 }6 q7 B
- jz exit2+1 ; Bypas the reset int's 1 O, R0 `8 a2 s+ `
- cli ; Disable ints so we'll get our value ) `" P# }) S" b0 f& Q! q2 v& r
- " D$ P0 I* Z9 y2 `* h
- mov al, 0D0h ; Send command to the 8042 command register
/ t( V% J& Q. v8 \4 B - out 64h, al ; to tell it we want to Read the Output Port
5 m. T- w8 k1 u9 W, g+ f) ] - call A20Read ; Wait till the 8042 output register $ h1 h: B$ U, ?8 S- H! G* J
- jz exit2 ; has something in it's buffer ) M& ?! c+ x s, S: D
5 o# }9 J+ u: p- in al, 60h ; Get it
5 N e: r0 R W* L - mov ah, al
/ A' ]# i/ s4 y! x - call A20Write ; Make sure the input register is empty
* J* H3 M+ J$ `) P6 k4 h - jz exit2
6 a2 @, ?* S+ ^8 c7 y: G# d f
6 a2 i. R1 u- H/ H! ]- a- mov al, 0FFh ; KBC NOP command, does nothing - |. p- c8 e- \' F
- out 64h, al `2 X3 K( B# ~
- call A20Write
9 E! C# l# f& R" z
$ y, Q3 i% F. d1 M+ ^, o& d8 y- exit2: sti
% H; @/ W" |# C- b( W - ret0 n, k6 t, z% E$ X, ^
- 4 x7 q& Q) _" b
- ) M Y" e/ m3 h/ k
- A20Write: xor cx, cx ; Reasonable wait 2 K3 Z5 A/ j2 D. h, f [. M" j
- get1: in al, 64h ; Get KBC read status . H. P! N: X9 l* I7 J
- test al, 02 ; See if buffer empty, bit 1 clear
4 q" {1 O& @. k+ V9 G - jz clear
1 T: b( B/ R- G! T( l9 Q5 q - dec cx ; N; a1 J' T9 k; I4 u ^( ]
- jz exit3
$ W2 P; [$ u) R9 A' M. p0 o% R6 a - jmp SHORT get1 1 g6 _: b1 q0 {5 c8 d2 w) v% \, e
- clear: inc al ; Clear ZR
+ B# f6 s* X$ ?! O$ a# E - exit3: ret
2 v4 Q" k7 T8 N. X& K/ u. _
( @% G$ Q) G. {# g
# G/ b" ~$ l% T. ]' h6 p- A20Read: xor cx, cx
7 O& ~4 D' T7 H* d& A - get2: in al, 64h ( }0 |' S7 E. V, }+ s3 P* ~
- test al, 01 ; If the 'output buffer' is full, has & c9 m, T4 a: k+ D& ?# m
- jnz exit4 ; something for me
4 u; z6 M2 V4 X - dec cx 8 y7 x' w* }4 B/ X/ @5 _2 c# Z1 L( ~
- jnz get29 `3 `1 w% Y. @ R9 a2 M
- exit4: ret
+ q6 c O' `0 a6 \: n8 O - ~9 w+ T2 R% G9 e
- end
复制代码 |
|