|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
) V$ K4 X! I: p3 }' d0 t P( X - ; / l2 T( ?) t( G# t2 u9 e
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-019 R2 z6 r" j1 J( @
- ; ml A20ON.asm 5 M- _6 y% Y; t7 d* a
- ;
6 U; w& q' i' F q* K% s5 @, K" H( N - .model tiny, ?7 k- L. E8 {: E+ Y7 G
- .code
7 t; G$ q) E" w! Y. J - .486; [" i% f z' Y+ i. Y
- .startup
" x1 U) m# L; y% O* z
; e1 T0 u) z$ H- U Z+ y. Y- mov dx, offset msg_author" ~6 l4 B/ P; s+ A ]
- mov ah, 09h
- ] Q* ?% P" X& W/ I$ I5 q - int 21h: u6 }0 n) o1 N! {& A6 [
- % X5 z* d4 _) q" ^/ ]% P0 f3 Z
- mov dx, offset msg_fail # z4 t& d ]0 K9 S" J
- call A20_ENABLE U; \- V2 h8 Z' E$ X6 ?
- jz exit1# f2 T5 X4 w! ]: h
- mov dx, offset msg_ok 4 F( _- |3 B3 h; z- K& m) P- H
1 E: Y( }, d: y3 o# W- exit1: mov ah, 09h
4 A6 _- H1 [# _3 L* p% y2 l - int 21h 5 B8 A m4 y! G6 j6 s% U7 a5 f
- mov ax, 4C00h
2 q2 B0 l1 @3 g$ D - int 21h
9 h8 ` M# L8 z" N- L- v9 i - ( W: T; R: Y6 M
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
% T# w0 J+ J, L- m ] h - "2008-07-01",13, 10, "$"
, n2 W; v* V7 ?: Y# Z; V& @$ V) z - msg_ok db "A20 Enable OK", 13, 10, "$" . N' E! g- [0 H3 U
- msg_fail db "A20 Enable FAIL", 13, 10, "$" ' x7 j6 g8 }6 q! _9 Y
6 ~& Z1 p: v% k3 g; o, n% N1 X- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
5 H; j+ b% F% `7 j - A20_ENABLE: ; E8 m. M q: b- k0 Q; s
- call A20Write
2 e$ I7 N$ |9 F! z- R' Y/ L1 F - jz exit_enable
' R" h z! Z" H9 ^8 p
. L+ g; M& s! Y" m! J4 a4 e& `- \' Z- cli ; Only need for reading value from KBC
( \2 ^0 _8 v$ W$ t! }+ I9 C - mov al, 0D0h % b& n/ D" K. z8 c- _- ?
- out 64h, al 6 C, p. b. f; ~* [9 e
- call A20Read
4 b+ i, H0 F0 e& T2 \1 D - jz enable_int
0 O( Q$ x1 H5 c* k6 g
7 K! a# o, M' O* i8 |- in al, 60h ; Get current status
5 S7 P0 H9 s( {* S* d - mov ah, al " z* H: P) [5 m5 q1 w* a
- call A20Write
5 S/ E, {/ {5 @ - enable_int: sti ' C; u C! h2 g, m0 S: j2 s
- jz exit_enable
5 j. H& T* s$ m
, i3 {0 B, D/ C- mov al, 0D1h ; Tell the KBC , want to write to the : [3 i* M4 w- z) [
- out 64h, al ; Out Put Port next , g; e9 X2 k( B9 v8 D0 N% g5 b& k
- call A20Write
' u/ x4 j7 x& ~" r$ d0 k+ C. G - jz exit_enable
! w k6 u) `& t+ j7 q: C: `
" v/ I- b d' q5 J9 ~$ k4 C4 l2 {- mov al, ah
2 \0 V( \1 K+ Y' u - or al, 2 ; Enable line A20
. G6 x& U0 s" V s" K- Y - out 60h, al " l. i5 s8 ~" n& z4 d7 s# X
- call A20Write : Z" f4 t3 D9 b f7 Q3 w( S& M; M8 l
- jz exit_enable0 D7 p0 y6 }$ \% i# E9 U; X
- ! w; [& d1 J+ r c& ]
- mov al, 0FFh ; NOP 9 q, p: P6 v, @" T3 k2 i$ b+ V- t2 G
- out 64h, al 6 ^- a( k' B" q a
- call A20Write $ q9 O+ T) |# V; f- y) L
: Z, g% J, i! w: \- exit_enable: ret ) [5 z* C5 G8 T0 Q3 x$ r) |% E
# }! Z- ^1 f; _4 P' c* z- A20Write: xor cx, cx ; Reasonable wait 8 h3 A3 s9 R0 ]: F3 l7 H
- get_wirte: in al, 64h ; Get KBC read status
8 N2 O& C- d4 c0 R2 l ] - test al, 02 ; See if buffer empty, bit 1 clear
- c) E) a2 E% E, E: T, c# w - jz clear
. p/ F2 t7 d* A4 }) m - dec cx % Y* z: ?* e6 Y2 d. \
- jz exit_write
9 Y0 ~( ~& q# d* O# V - jmp short get_wirte
7 o7 C& H9 G# _+ e: I: x* ?/ Q - clear: inc al ; Clear ZR - ~ A: E: G, t& f
- exit_write: ret
2 `8 _) c) t3 U" m) j/ J# N, q
7 _! ^, q- \/ Q$ G7 ^4 b1 L
9 R+ k& J d# R; x8 J6 W7 @$ ~- A20Read: xor cx, cx 3 E. p) x$ Y- v7 i" I# m- S
- get_read: in al, 64h # T2 r4 E6 Z; W6 z2 g
- test al, 01 ; If the 'output buffer' is full, has
5 _) v2 K& t9 B - jnz exit4 ; ... 4 Y; X% h2 }) A# f
- dec cx
7 `' i1 O% k/ a, R% J" q - jnz get_read
7 T" a! {8 y& k: c5 V9 l! B - exit4: ret
; P7 [% D! x" d' D+ G: _ -
$ [* j3 Q9 w2 z* [5 n, j' @ - end
复制代码- ;A200FF.ASM - A! f7 X0 v2 \$ m: B# g$ R2 T H0 e t
- ; ! B v, C8 ?8 D( R& c
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
; y" [" X( v. z4 p, d( s - ; ml A20ON.asm 6 U2 E* \9 A2 T; L# C" t/ k$ a# J
- ; % s2 u/ t0 `6 I% y `. K
- .model tiny0 I) c% h: B( h& `3 e. b# x4 R2 a# L
- .code
' j8 K+ g3 D5 C - .486
9 J7 T9 ]2 [3 _0 x$ @7 g7 T+ ?( s - .startup
) A1 {! d' V [ z! _ - $ C/ Z7 Y, J, M4 s, e# _2 h
- mov dx, offset msg_author
3 C9 E) j8 _7 U/ W2 B3 \ - mov ah, 09h$ n" a* H e- E: |+ O/ T' {# O/ a3 b+ X
- int 21h
. l$ n1 B! Q7 ?+ o- e: L
% {$ J0 i3 o2 F: G2 u$ N) O- mov dx, offset msg_fail
" K" [. m7 f$ m - call A20_DISABLE3 A0 q. B: }9 c" |1 R- M
- jz exit1
6 P% u+ @- |, x7 z5 _ - mov dx, offset msg_ok 4 b2 q9 \1 Z+ c) G: s' n7 Q2 k
9 n% T" o, f: _! U- j3 v- exit1: mov ah, 09h 1 ^" p7 c! L2 n3 V3 O3 j9 E3 K
- int 21h . U; V6 [/ l( s; m, [
- mov ax, 4C00h
! M" u) n, S Q3 r" T/ ^/ g8 u! Q - int 21h + D" v- g7 `8 W s! A4 V
-
$ h' i! p8 Z7 i/ ~( K - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,) w+ X% [& ]! @- W6 u
- "2008-07-01",13, 10, "$"
$ v# J( L; Z: f# s3 b/ U5 ?* | - msg_ok db "A20 Disable OK", 13, 10, "$"
& j! H0 x' Q2 C9 `9 ^' |/ a - msg_fail db "A20 Disable FAIL", 13, 10, "$"
3 M O! [3 ?- g5 s" d. J- ]
0 u; q' }0 O7 _' w; g6 L# [" k- ;------------------------ follow code maybe make to lib, if you want...-------------------------------6 d$ s3 ]: Q6 ]# a" H
- A20_DISABLE: 6 C! P& T. i. v( n5 R/ i
- call A20Write ( x) A7 n! S" l9 { @
- jz exit_disable
/ {1 x1 z. ~% U$ j
7 q a9 Y5 q+ S# O) F! Z; y5 y- cli ; Only need for reading value from KBC
J' G3 ]& S4 S& D - mov al, 0D0h
/ X$ v( ^$ I8 `7 P& \ - out 64h, al + ]. \1 }0 R0 R2 g9 ^3 O
- call A20Read
' H, B1 a) c% A( d - jz Disable_int
3 a) l3 d5 ~1 c& {4 j! b3 \& m - 5 w" l' I Y+ t( p* P. j) [9 t, B( ]1 O
- in al, 60h ; Get current status
# c: y. y) L8 l' x - mov ah, al 8 o. @4 Y/ J c% [
- call A20Write
) k6 A+ N, R6 J$ f- |. { - Disable_int: sti
" E/ E7 o6 @0 ], P5 @" f: }' H7 p - jz exit_disable
. z( M6 _; C. @0 T" z; Q - 5 Q' b# Y: s9 v3 p, j
- mov al, 0D1h ; Tell the KBC , want to write to the ! _6 v" n1 g$ R' s, M- [* \& I
- out 64h, al ; Out Put Port next , G$ r" t, b2 J9 b& h: u
- call A20Write - T# G" @6 d% ?' V l9 g' I- ?
- jz exit_disable* A' Z6 J% P; Z" H( S
$ z( h0 [' I5 l1 F( L- mov al, ah
" t" c% O- Q- j/ ?% T" q/ x - and al, not 2 ; Disable line A20
+ D; a P/ @' }% b - out 60h, al
2 S, Q/ B4 h) G* b - call A20Write
* U6 h" }, K& Q1 J5 L3 i - jz exit_disable
4 q7 d4 p4 \/ B; ^ - $ Y) F- g: r' R5 \# y+ q( V4 {3 j
- mov al, 0FFh ; NOP \6 V1 `( f& \, G
- out 64h, al
- u/ m* y$ A6 j! u - call A20Write
8 J/ ^' J T/ v2 |
8 Z5 `4 y8 _: M% |2 j0 d# a' @" g; x- exit_disable: ret
3 v& [7 e; j2 w6 `- d. Y* } - 8 {# u& j: g: v7 d, N8 T
- A20Write: xor cx, cx ; Reasonable wait
_; }0 K! d6 _; ^' _, R - get_wirte: in al, 64h ; Get KBC read status 8 x! t, X7 @, ?& q" o+ ^
- test al, 02 ; See if buffer empty, bit 1 clear ! Z7 Z$ l) p5 N# g
- jz clear
# P# F& R' |3 x7 D! j: x - dec cx & n$ V9 G) B& N3 J7 H
- jz exit_write
( \4 b) _. ?' k$ w) v& }" t - jmp short get_wirte # i' a% j2 D' p2 f: y, g0 i
- clear: inc al ; Clear ZR : z/ c9 [3 c" j. U: k) I5 z0 M
- exit_write: ret
* _( Q7 G# |/ L9 r$ u* K - ! h1 X4 C- D7 P% |3 P/ L* Y
- c. X6 G; z# Z9 }* P" }+ i+ K# R- A20Read: xor cx, cx 1 u0 B& {3 v" k9 f$ |8 k; t6 g8 i
- get_read: in al, 64h 9 I) }1 n( S6 d- ^" u- D
- test al, 01 ; If the 'output buffer' is full, has
6 U2 k2 Y! y6 d6 W, J2 n6 p - jnz exit4 ; ...
& b: g- Y" t5 L6 x `0 U - dec cx " U* X- `- D/ f1 b) s
- jnz get_read
2 \ C6 X( x: q& A0 k - exit4: ret
. g: Y$ V% J& P' s" ] -
& D" z V% `" o8 y, R7 r2 J+ z - end
复制代码- ;A20STATE.ASM
5 S3 \. `6 b. y% j - ; , l% h9 d& a$ L% }% U1 r5 b$ I- m
- ; Returns the status of the line A20 through the KBC
& u s# H, |9 ~8 t0 ? - ; programming by bini for debug. 2008-07-01' J1 r" b' L4 z
- ; & m2 W9 I B/ B/ h
- .model tiny
5 i% \# |/ w* x8 T4 z - .code5 ~# \& L; y6 T {1 }
- .486& @7 I# m: T3 n I2 g2 p; ~
- .startup
& Y9 b8 p. j3 u0 k. s& H - mov dx, offset msg_fail y: }2 E9 u" d b& J4 h
- call _GET_A20_STATE_' m! d) y" L$ c" B6 K0 I. b
- jz exit1 ; was a problem/ n& E. T% _) I9 @
- push ax ; Save state, AH ) ^7 e! N0 L$ [3 \ c+ \* }9 v" \5 N
- mov dx, offset msg_ok ; There wasn't a problem - m$ F/ r: U* B9 u
- mov ah, 09h 6 I5 @& j2 V4 q4 B$ T' j) Y
- int 21h ; Print message 9 x0 m y# j# R7 Z) t; g. A
- pop ax ; retreve state
1 D; S2 X( d9 Z. c, t# Q
6 ^. C1 x$ w5 `4 d6 A- mov dx, offset msg_dis
. u3 r( }" n( J$ o" Y$ @ - and ah, 00000010b ; bit 1, 2h, indicates state * z! u9 H ~, L2 R1 G9 s9 X! V
- jz exit1 " ^6 s- o Z+ e, T0 G
- mov dx, offset msg_en
1 B# k2 {& f, _2 j3 I% \( \ - ! x; s2 N4 b1 V$ i2 H: m. x
- exit1: mov ah, 09h
& M; p! K8 e- t5 h - ; DX already contains address of string
6 n$ e, ?7 w! X1 f$ `) T - int 21h . }0 ]7 G4 K6 X, l9 \
, g7 O& S; }7 u. w- mov ax, 4C00h
$ r7 N) R8 h2 f+ l - int 21h + y1 n+ C. O2 x7 p
! ]: L( ~8 i1 `% I$ Y- msg_ok db "OK", 13, 10, "A20 $"
& N5 }4 V3 y4 b( w - msg_fail db "FAIL", 13, 10, "$" r1 K9 r. v1 I _
- msg_en db "ENABLED", 13, 10, "$" " h0 l8 P8 v8 p2 y: Z9 c G) [
- msg_dis db "DISABLED", 13, 10, "$"
! [# B9 W7 f3 f3 T& K2 C - " t0 Q0 A( {5 | B' S6 U% V
-
6 k* G9 e- [! d" R2 _ - _GET_A20_STATE_: 0 [/ w1 o+ w" A O8 l
- call A20Write ; Wait till the input register is empty 1 A9 W1 v9 s: i# e' X
- jz exit2+1 ; Bypas the reset int's 5 F; H+ z8 r. ?- k
- cli ; Disable ints so we'll get our value
5 J4 d% f: p; k
- C0 |6 ~4 Z$ z- ~& x' H- mov al, 0D0h ; Send command to the 8042 command register . J8 F# | W: ~, a# v
- out 64h, al ; to tell it we want to Read the Output Port
; n& w4 @2 b% a5 V$ r: }+ q - call A20Read ; Wait till the 8042 output register & M0 d7 i! S+ ?0 G" H& g
- jz exit2 ; has something in it's buffer
# h6 E/ Y- ~; L, B/ i( J: _ - 1 R/ ^; ]- z0 a" X
- in al, 60h ; Get it 7 z% a# y$ o. U; [$ A3 r
- mov ah, al + g% a: M" m7 u- i$ _
- call A20Write ; Make sure the input register is empty / l( K- b' m' t; z
- jz exit2
^. j. X! e! e3 n4 | - # U/ A) S* Y* L, l
- mov al, 0FFh ; KBC NOP command, does nothing
* f/ m* c3 x: X7 i - out 64h, al
. R" [; Y% q c& J* F7 r - call A20Write 6 Z3 f( w: m$ V9 d- [4 M
- % k( a& G0 g3 r6 T# P1 \
- exit2: sti 3 h7 M8 L7 D5 ? H% w L' k
- ret Q+ k- [ O* X$ t* `
+ U7 d- ^. ^, C7 H5 w( p' A- 7 v: X4 J" g7 \( d' h. A, I. @
- A20Write: xor cx, cx ; Reasonable wait
h4 T( X7 f6 u2 k( Z - get1: in al, 64h ; Get KBC read status
" V: f) m7 C- ^& |: ?/ E# @8 V - test al, 02 ; See if buffer empty, bit 1 clear , {* C4 e, a; F& O# }
- jz clear 7 C! x8 m- Y- q7 n
- dec cx
3 w) I4 U1 J1 l5 V: @9 y, r - jz exit3 + V) P7 k- K: Q, n) \; o( L: [) y
- jmp SHORT get1
5 f6 v0 \6 W' r1 n% N" q& d - clear: inc al ; Clear ZR
! F- o, c6 _" d' E - exit3: ret
: y. T% F; x" ` c, V. t/ C - 6 t$ K$ z# }# T: E& T7 c" f
% i; A1 e' \5 h- A20Read: xor cx, cx 3 E' ~9 {7 f* c- {
- get2: in al, 64h 1 I' v9 D' Y, C* C, I. ?% s
- test al, 01 ; If the 'output buffer' is full, has
S" g- c+ Q7 V: r, G/ q - jnz exit4 ; something for me 2 y l; ~$ z3 s- H& o1 c. r+ X
- dec cx
" {( ]3 r; t& ]( l: W4 `$ t+ G' P- v - jnz get28 S! Z1 X4 n2 P; k9 L; E
- exit4: ret
! I- C) d3 |$ d6 n% p' d4 B - 1 a) A i7 L' w* `, n' I8 X, o
- end
复制代码 |
|