|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
6 T7 i/ d: k' {4 K# x - ;
; Z% G" A* c& @: i( ` x - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01 C1 m" l j: M/ e# x7 j8 Y
- ; ml A20ON.asm : x* A1 `" r3 J5 m; m. y& T
- ; ; F; q/ R0 S- _2 o
- .model tiny
) @) M, Z8 [0 f9 [. E! Y - .code
9 ^' Q, R) t2 W3 `* M- }$ E/ @ - .486
5 j! M1 D% Z9 z* z2 a/ g0 p - .startup
$ Z7 T% w- E# F5 L4 V1 }0 K. o$ X
6 H' }, c) e# H- mov dx, offset msg_author
$ i" H/ z! R" S) }4 D& j" W- g, x - mov ah, 09h+ ~! J0 O$ D a# E4 B5 L
- int 21h
/ D0 P$ o- C- W( d- i+ p0 `
9 I. M+ t/ g3 Z- mov dx, offset msg_fail
2 i x6 J! G& E) _' J - call A20_ENABLE; X: M4 V9 w9 e- Z: |- O
- jz exit1
) @) E% u# O" r0 v5 n - mov dx, offset msg_ok 9 X* X# A/ C# g& `
- 9 i( k! {, a8 s4 Y4 b3 R
- exit1: mov ah, 09h
$ Q- j8 ?/ q: [( p6 Q - int 21h
4 u% C6 j: `1 L - mov ax, 4C00h
: Z9 p: C3 O1 g. M - int 21h
+ F' ?: \& ]- [% L4 A - 7 r$ l! P4 x3 X+ h
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
/ B8 {; o2 f4 X. s: p: B - "2008-07-01",13, 10, "$"
l: s6 Y8 ~6 S2 h - msg_ok db "A20 Enable OK", 13, 10, "$" 8 e T7 F% u7 |
- msg_fail db "A20 Enable FAIL", 13, 10, "$" " z' H6 J/ K* e
- 5 K. a1 x" g$ \7 k+ s$ p4 @) ?$ e; }/ k
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------+ D4 m8 ~* _( H; }( y
- A20_ENABLE: " c. ]" c+ `0 |; f5 X& Z
- call A20Write : `. l) S- v0 [
- jz exit_enable) w# {4 j" w1 P8 t& N7 Y. \
% c1 K4 O: U" e [1 ]- cli ; Only need for reading value from KBC
7 L" C8 w- y+ B5 ^- t) h+ u - mov al, 0D0h
( B5 j) V% z O2 t7 S. h, ~# s - out 64h, al
; h' g6 Q! A/ n3 V, b3 r - call A20Read 6 X1 d7 ~( h4 ~! A% ~1 j" G. v& Q9 N
- jz enable_int 9 e1 ~0 _ x- w
# e* f- u! m) Y, H: `- in al, 60h ; Get current status % P6 M2 ^1 g1 U& h0 x1 t
- mov ah, al
6 o0 M. t4 L1 m# ` - call A20Write ) x3 U& ^( {" ^9 v
- enable_int: sti ; ?: a0 Z$ f; }0 Y4 y
- jz exit_enable4 J' c, l, \# d6 x& o: [
) x! _, u8 D- ^+ w2 Q' D- mov al, 0D1h ; Tell the KBC , want to write to the ; }+ S0 T4 S% j: j9 w$ Q! X5 \
- out 64h, al ; Out Put Port next ' g5 c) h" [, s, Q3 X, S
- call A20Write
" s$ f7 u8 I% L6 U - jz exit_enable+ H/ d8 ]# P: d' b+ D
' r$ Y5 Z d q! N% ]- mov al, ah
# } Z. b" A" q' J8 i- z% e7 | - or al, 2 ; Enable line A20
2 [3 z; U% M" u# C K& ] - out 60h, al 9 l( V* [9 k8 f8 l: d
- call A20Write
* T$ c6 H! b- P" k* V0 y - jz exit_enable
* k2 a: X. [/ t0 ?6 T3 r" K+ ~- u& _ - : o+ x+ b. a: s
- mov al, 0FFh ; NOP
& t5 U/ A# a' f# K; J - out 64h, al
4 ^5 D& k7 i$ U" t - call A20Write ' z/ x. d( L; e9 d
- 6 W& {0 Z* \2 O0 \. a
- exit_enable: ret
$ N2 K7 p, M) F - . O& R8 Q" O: e" e
- A20Write: xor cx, cx ; Reasonable wait
- R" ~: C" S( k9 U1 q- V- H - get_wirte: in al, 64h ; Get KBC read status ( o: J3 {! M; J$ u& a5 U
- test al, 02 ; See if buffer empty, bit 1 clear
" Z" y* P6 x8 e3 W - jz clear
$ x Y; h) j. ~" \* l3 e - dec cx 0 ]) T! f2 m9 N( F4 b, X c+ u
- jz exit_write
+ G M% m4 |+ }$ _ - jmp short get_wirte
4 h- t$ s4 [& s/ D( c4 J2 A - clear: inc al ; Clear ZR ' }" p, c7 P8 O( h- ?. Q3 e
- exit_write: ret
- ]; _& q3 ?3 i6 s; \! k - ' q0 y) I" V8 l1 w0 \# r5 |
4 d) h, j X ?% y( D# w- A20Read: xor cx, cx
# H' m v8 D! }# ~4 q- j" o, Q - get_read: in al, 64h
3 b6 k1 F0 P9 G6 S" c$ a - test al, 01 ; If the 'output buffer' is full, has ( s$ y( l! W( H2 r
- jnz exit4 ; ...
- l1 h, B* A7 {- {, K' e - dec cx
. D. A9 W5 q. H L v - jnz get_read
$ d O2 V! E) A! T- j - exit4: ret & ^7 C7 s! V6 }, `- K5 ~
-
9 t a+ ^, x$ T$ R - end
复制代码- ;A200FF.ASM
6 E! p9 v/ H* I# p( q1 ?: M) ^$ d2 B - ; ; ~1 u A7 [& }7 `
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01% A% N' R1 x1 C* \/ P
- ; ml A20ON.asm
s6 ]* G6 s( n- k8 ~0 Y - ;
4 ~9 h/ e# a6 _% J4 b% A" t - .model tiny9 y$ d A2 v- R; [' |$ q" A" _
- .code6 l6 {9 J& W3 H3 u7 j7 i. {
- .486
# v/ l! S' [3 H; |# M2 }4 C% r; l) y - .startup0 A* S, y0 S( M) ?1 w
' {& r7 e4 z+ p( o- mov dx, offset msg_author
( z+ _3 j" |3 G; @$ z6 C - mov ah, 09h) ?0 l, I2 q& V, G( s3 }
- int 21h
* J* c4 ~* Y) x8 G. R
6 _$ g Z7 P# @/ B! u- mov dx, offset msg_fail ; g4 X5 P; F" X5 L3 @
- call A20_DISABLE2 P' N ?1 V1 {, l4 a3 p3 ^' F
- jz exit1; M3 q( m4 B2 m0 o6 `
- mov dx, offset msg_ok
# w) ]8 o, f" c: b - 5 M I# d' w1 @+ L, n. R
- exit1: mov ah, 09h 2 w, y8 c' ^4 n0 Y4 y; L4 x$ ]# m* \
- int 21h
+ O- I% A& V" b- P7 k - mov ax, 4C00h # n" {- k% a1 _. M" p: F9 L
- int 21h
; l0 P2 M/ ^0 Y" t U -
4 D0 N) x9 V1 L/ ^# i - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
6 l7 d, H& y3 N; T6 U, ]3 w - "2008-07-01",13, 10, "$"
3 S( N& M2 {% f - msg_ok db "A20 Disable OK", 13, 10, "$"
# N" J2 N6 M" k+ V - msg_fail db "A20 Disable FAIL", 13, 10, "$"
$ M5 ^- f- h8 X, S4 G/ j - - H3 l' @7 R0 M
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
7 F- |* N; o& l P6 `( x - A20_DISABLE: 0 X4 G5 \* {+ U$ Y6 w$ K
- call A20Write
4 v* X% E3 R. Z' V - jz exit_disable- ~: S6 [7 B* ]2 f( l. N
. K C8 S& c/ W% b0 ^! P7 f& w- cli ; Only need for reading value from KBC ' ^, E9 f" b G) b* G7 L [
- mov al, 0D0h % o" V9 y6 Q/ r: Z) h
- out 64h, al
; O. f* R$ U% T* w - call A20Read
* h0 t6 L) ?' }6 s7 @- f" g; A6 E - jz Disable_int ( y; ^( T/ y" C+ p, x) [
; Q4 {1 S2 n& v, {- in al, 60h ; Get current status
" G6 W4 `5 \7 ~ I( y( W - mov ah, al 6 M* g% v1 c D5 p0 N L% Q
- call A20Write
4 W: u2 n' |, n# |( h4 R! d2 b8 g - Disable_int: sti
5 J) j! ~) z* x" t/ P1 ^; w - jz exit_disable
$ W8 L- @7 n& A; M5 @& R5 {1 e - 5 ~ u8 e, W& S6 ^; Z) `
- mov al, 0D1h ; Tell the KBC , want to write to the ; r8 V5 ~) u: i
- out 64h, al ; Out Put Port next ' t" I( X* e& J4 ~5 \ \$ i
- call A20Write
* O7 k9 O% K+ u' ]8 B - jz exit_disable
; {5 ~5 e8 @- j* g# K- S/ y8 i - ; ?! Q. r% o" D
- mov al, ah + P! }; \. p; v; j0 N
- and al, not 2 ; Disable line A20
* n% ]* w/ `2 ` - out 60h, al 3 }5 A! |+ V0 E' V, ]2 C" d
- call A20Write * R# m1 v9 N2 Z [2 P- F3 B
- jz exit_disable
0 I8 x5 }6 P; c3 n4 y( A0 h
% `1 W0 V4 `: s8 z- mov al, 0FFh ; NOP ; Q% N! F$ F" g8 B
- out 64h, al
0 j' F$ O/ K+ b6 u* ^ - call A20Write 1 v( P$ E5 W: d, a. g8 H
- & E8 C, Z& p# M# ?8 }$ R4 {! r
- exit_disable: ret
+ q8 N$ q/ @$ ^( {; z$ ]7 }
7 t. n, U2 n0 S A3 s6 O- A20Write: xor cx, cx ; Reasonable wait 1 m( e( N+ h( E8 U
- get_wirte: in al, 64h ; Get KBC read status : X- C# k2 E$ q2 A
- test al, 02 ; See if buffer empty, bit 1 clear + t" z0 W' S/ E2 L! u/ `
- jz clear , _4 P8 v5 ]8 L) t( Y
- dec cx 7 D; \. `" H. S( x9 G! C
- jz exit_write
8 o3 M& ?: ]* J- r [4 ?2 ~- ] - jmp short get_wirte
+ \5 d' A6 d5 q# \/ u - clear: inc al ; Clear ZR
. e$ j: P3 r( { E - exit_write: ret
n- |6 v$ `( S: y. I6 F5 m# i" U
+ l9 W! `2 T% S/ a: E) o- 0 k3 T4 \6 N. T) A3 k% ^8 `
- A20Read: xor cx, cx
( o3 x- ]! P: }9 b* X - get_read: in al, 64h - F( N5 P% S$ d A: b
- test al, 01 ; If the 'output buffer' is full, has , s @/ C$ s; o9 J( C
- jnz exit4 ; ... ( ^# V0 K" I2 x0 j* c8 N1 R" G5 v* s
- dec cx 3 P$ u9 H! P, V2 Y
- jnz get_read
5 ~2 Z6 a" u5 B0 y* y+ U5 h8 v% W- n/ C - exit4: ret
8 `0 D2 D0 } k' x ` -
1 V+ v0 _* i; i I$ N - end
复制代码- ;A20STATE.ASM : `- R+ ]5 ^3 t$ ]
- ;
/ X' W y5 r/ f! ?( e: }2 C3 V - ; Returns the status of the line A20 through the KBC # g9 Z) O M+ y+ n1 U+ C
- ; programming by bini for debug. 2008-07-015 l/ O1 ?, \0 d) F ?4 D
- ; " x# A% b3 b8 `& |1 c ^( U
- .model tiny6 w0 V! w6 d! X
- .code3 ]/ m; s6 ]* D( [+ T! d
- .486
6 D2 n$ E# {( Y - .startup
% H, T# U" }/ v - mov dx, offset msg_fail 7 n& C, c$ u. u
- call _GET_A20_STATE_
9 S d9 D+ y v( I- M% o# i( o& D - jz exit1 ; was a problem/ S7 ?4 r9 w' X6 r5 h
- push ax ; Save state, AH , ^1 B) {! I, H6 R
- mov dx, offset msg_ok ; There wasn't a problem + _4 b5 [1 P& s X+ O
- mov ah, 09h - q/ d M8 c" I1 G' X
- int 21h ; Print message 6 N# `) z) }6 W. ]
- pop ax ; retreve state : H! V) {* ?# E
- 9 a6 K* ~. X+ m0 {$ x
- mov dx, offset msg_dis
; W* P. y, u5 S* [: K' Q - and ah, 00000010b ; bit 1, 2h, indicates state
" [" k% u# N/ L4 d - jz exit1 4 s. g8 w& f; Y" b7 V/ O& U8 j- D
- mov dx, offset msg_en
4 N# O0 A$ Z: Y: d5 X% ] Y
0 z! n$ }# W4 U8 U+ f- exit1: mov ah, 09h ! F$ y% i, Z8 W; F0 B
- ; DX already contains address of string
3 T! g9 l9 D% h' T' I' l7 o# J - int 21h
+ M& Y3 J4 \ }- Z' [ i" m
5 ]7 J* A7 [ O6 k- mov ax, 4C00h ~2 I' c3 ~7 o9 C6 h
- int 21h + P) P1 v: H2 k( |# s( ^* D
- 9 Y0 `/ |5 h$ d6 e
- msg_ok db "OK", 13, 10, "A20 $"
* i# R7 ]$ j! s! @4 H - msg_fail db "FAIL", 13, 10, "$" 0 I" _5 H: h0 g& Q& ~ B( P
- msg_en db "ENABLED", 13, 10, "$" / n4 U8 `( V: Z/ p
- msg_dis db "DISABLED", 13, 10, "$"$ ^) [5 D3 y2 x3 \$ a* k( r
: z0 z1 }8 f5 O7 B( ]-
' S# P& {' O; P$ v0 s& o. P - _GET_A20_STATE_: $ J' N7 y% l1 B$ B' O! R! s
- call A20Write ; Wait till the input register is empty ) \ ?) \2 j6 V4 ^
- jz exit2+1 ; Bypas the reset int's 3 l* N0 W& C5 \' p/ Z# n: ~5 j, c
- cli ; Disable ints so we'll get our value
9 y0 I: Q; P( n- j* Q* K
1 Z# _7 l, R' L0 C, \; k w; C0 R- mov al, 0D0h ; Send command to the 8042 command register , n0 o6 f0 T" k/ y' V' {9 |
- out 64h, al ; to tell it we want to Read the Output Port # L5 T8 v: {' X0 H, l# c9 C4 F
- call A20Read ; Wait till the 8042 output register 9 d6 B; ?8 s. [* T- u% ~
- jz exit2 ; has something in it's buffer 0 N; G2 G) l2 `3 s0 X% T2 @, Y
: D2 u3 I& r' e" n' @5 s: E; c- in al, 60h ; Get it 0 N4 N* f! z; j7 j
- mov ah, al
7 J6 K4 J/ V2 @4 V, ]2 ^! A - call A20Write ; Make sure the input register is empty
3 w7 v$ O0 T( _4 H3 F - jz exit2 8 a, c4 h2 ~% u
2 |' ?7 u+ P0 h1 `1 N0 `- _) A- mov al, 0FFh ; KBC NOP command, does nothing 3 n* O$ Z* y$ S) o
- out 64h, al
4 z5 n& R/ J- G5 {& m: I - call A20Write
1 x4 w, L) w t2 ~9 p4 R - * z2 v- k! U8 p
- exit2: sti
* B, c) \3 D3 ]) r3 K' D - ret
" J9 Q1 F/ a F) P! ~
7 D0 ~# c7 I$ X; B+ g+ N- % s! e; `' ?, t5 |: V
- A20Write: xor cx, cx ; Reasonable wait
1 t! s( o9 c! {- V/ g - get1: in al, 64h ; Get KBC read status
* c* j" s$ e! I. W - test al, 02 ; See if buffer empty, bit 1 clear 3 o; P9 a! T/ Z+ m9 J
- jz clear 8 S4 x& k7 c6 [1 p7 @ B/ T
- dec cx
; |; [& P+ J" N' @1 A, W - jz exit3
% x6 `: S1 w7 c c) Y- _+ ?+ B- J - jmp SHORT get1
( V a& n: t; Y' P' Y - clear: inc al ; Clear ZR
* C. T) W% o. Z2 M& K - exit3: ret + t8 ]# ~' t" l! L% ~ E8 \- u) i
A3 P5 S4 l7 Z6 y
) Q$ A) @% n: `8 C! j- A20Read: xor cx, cx
- G' T4 X ?# u6 y" D - get2: in al, 64h ; |% H3 _9 o6 l
- test al, 01 ; If the 'output buffer' is full, has : i9 ~- D) M3 z' L0 u
- jnz exit4 ; something for me
, ]8 X& k5 f( [/ h - dec cx
: [( H: {" }; X. u/ W8 [& _ - jnz get2
1 U1 a; |9 t) t$ u- |" [7 [6 F& |* k - exit4: ret 6 E0 ]1 b$ F4 f0 S6 p/ T. }
- ' u" d' w8 i0 e) t( I3 M5 w+ j
- end
复制代码 |
|