|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
5 b5 a7 x0 z9 l) [1 F& H - ;
- C5 e* r) n9 q; X3 B; s% E - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01" H) u' z- `9 _( M. H/ k# K
- ; ml A20ON.asm
1 P/ S# M' {) l0 _+ F5 f: L7 j - ; S9 @ z1 B. H" P9 N* k! Y* N0 W% q
- .model tiny! b, ]) q- f! B& K/ \! M0 L
- .code8 r# ~! d4 y; _ N# ~" v0 z
- .486
+ n O; l- K- f, s0 T - .startup
* o7 K0 I c! D9 F D8 N. ]& V9 y - 7 m S# y0 | L- m5 a
- mov dx, offset msg_author
. i: n7 C- ^' F - mov ah, 09h
: P6 O- P7 @0 J. K - int 21h1 s' @, s5 H- X/ S3 `' Y9 S: ]
. j, S6 |& `8 Y0 @. X& N; f r: v9 i- mov dx, offset msg_fail 9 w$ v: N3 u9 O2 T! o8 G6 S
- call A20_ENABLE
6 O% V4 H- p: ?- D - jz exit14 N; c* k( D( ?& @8 j3 c- s
- mov dx, offset msg_ok
' D2 I8 N, ?( M& _
& s6 ~6 r& \: x" I- exit1: mov ah, 09h
5 U9 X2 F: W& o B - int 21h + w0 j$ J% Y; Y
- mov ax, 4C00h 7 F* F6 l/ ]8 t9 Z3 y
- int 21h 5 g1 P, U, l& W, x; f; {. T
- - Y& ]( I5 L# f
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
# ]' X/ {+ ]% E" W. s - "2008-07-01",13, 10, "$" & i$ \& c, K& r" G- M
- msg_ok db "A20 Enable OK", 13, 10, "$"
7 f9 o7 I) x5 ?! r" A% F: v8 s2 o - msg_fail db "A20 Enable FAIL", 13, 10, "$" . O- L2 ~( L2 C: b2 S0 O8 l& ^: l3 s
- : i& J4 b1 W7 J
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------+ @. \/ o+ u3 I
- A20_ENABLE: # Q+ {6 M N+ f3 ?# O9 X; r2 u! ?4 X: f
- call A20Write
" Z5 Q6 v+ p [1 T0 G. \ - jz exit_enable- o+ {* d1 g7 m
' @/ z0 A, B0 Y' b7 y# t- cli ; Only need for reading value from KBC ) A! b3 Q: q1 a; `+ X v/ j
- mov al, 0D0h ! ^2 B4 s# v9 k- }( J$ U( L
- out 64h, al
- {; K, L; d$ ~+ Z M% t; B - call A20Read
, e. K! V6 C( k( N1 y - jz enable_int
* m: v- }9 t4 `3 H* H6 ]
# M$ A) B4 r. X( H; o3 [) ?7 f- in al, 60h ; Get current status
7 u' O7 D$ |8 q2 V2 F! c# W - mov ah, al
6 y+ J8 t! R+ R& Q) Y. V# r6 d% O) \ - call A20Write
5 j+ ~ B$ c( ?8 u2 ^4 S8 H - enable_int: sti
& K( W2 s7 k$ U; b& _! e - jz exit_enable Y8 r6 x2 V' B8 Z5 p' V
- ( h; ^, p% A! l$ {* A
- mov al, 0D1h ; Tell the KBC , want to write to the
* o/ E, _6 o8 r L: q7 X' d7 k" c - out 64h, al ; Out Put Port next ; q4 u) V- E+ A1 I8 G- P' S
- call A20Write ; \; {) m$ Q! s: r# ]" r; e9 ?
- jz exit_enable
) L+ m( \, J m; \3 Z: i0 ^# R/ O9 J: @
5 O0 H0 Y' S* e- mov al, ah
/ Y( ]5 t% j C4 o3 C1 ?% \ - or al, 2 ; Enable line A20
( t; s1 Q6 P4 q. ?/ G - out 60h, al
# W) Q& o* Y7 j/ J6 n7 q8 p4 { - call A20Write 1 ]8 C+ s" T5 R$ x8 r) F* @. [
- jz exit_enable
$ W g( l) i% ~2 @3 }3 X6 y - * q5 C) Y r) B8 ?5 U; ?4 _! \
- mov al, 0FFh ; NOP
- [+ b% T: \5 O8 d - out 64h, al 7 n# L! O: \, N
- call A20Write % F$ ?2 h T7 w+ b, h, c$ v% |
- : h. Y1 D, h1 L: j1 Y1 f( ^
- exit_enable: ret 7 x0 i% S: P. g" s6 w( N- @' B2 ?7 i
0 I6 w0 |/ z9 y' K" }. E: H- A20Write: xor cx, cx ; Reasonable wait
* ^* R+ `. h% A3 e! I8 L - get_wirte: in al, 64h ; Get KBC read status
) Z/ x$ U/ f+ `5 C( ? - test al, 02 ; See if buffer empty, bit 1 clear
4 Q/ S# K, A7 h, b - jz clear
4 l* R |& H3 w - dec cx
9 W& f2 t" Q% f - jz exit_write
. u. S% ~4 I+ ?3 r! x* t5 ~ - jmp short get_wirte
+ t( P1 @7 ?9 A% e* X2 f5 i: t - clear: inc al ; Clear ZR 5 o* I, f+ m: J" u) b5 Z3 P4 g4 G
- exit_write: ret & C- ~1 n: a4 W$ Z5 Y) j _
7 b1 s ? V' Q. I1 n- . U; h% [- D& Q8 q5 C
- A20Read: xor cx, cx
+ N1 b4 U( }) A9 Z" A) T% G - get_read: in al, 64h
1 C; F, z t( j: k) F S8 P' S - test al, 01 ; If the 'output buffer' is full, has 3 Q2 @. z* M/ m, N0 i- Z2 ~" l; z; t
- jnz exit4 ; ...
' [3 i5 I1 E$ U2 j5 _0 l: j' P - dec cx " \$ E) B- D; {5 \/ K& x0 H) Z
- jnz get_read. E3 l: T% N8 ?/ g
- exit4: ret
7 j5 j4 Q0 d/ R - ; u+ i; U1 V# ^( K' l& A0 \
- end
复制代码- ;A200FF.ASM
" s$ {+ d* {$ s8 j# K7 E4 @ - ;
$ C q5 B- b' j5 d7 W, ]# H - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
6 I1 z L7 x& G/ y' e - ; ml A20ON.asm
) ?) M1 y z' e, V - ; - E+ K* U n7 g; p e y0 O' v8 N
- .model tiny+ z4 x& V0 J% v6 d# l& ^9 z
- .code
/ R; G" r7 F: k* |" O" o( x* m( } - .486
2 ?9 S+ @" T3 A8 _0 r' i# l - .startup
3 ^# X, r2 Q. n1 w6 \+ [9 X- _ - ! Z. g0 s% I8 r6 @0 _9 h
- mov dx, offset msg_author
# w' w2 p, X4 p7 t/ E - mov ah, 09h) N* S% N/ `- S, `) E0 o K
- int 21h& i; ~/ y; g$ W P
. ^, k9 S* a6 W+ J2 p- mov dx, offset msg_fail 1 e: g- r) h" s& D2 {
- call A20_DISABLE Z8 ~- O- u# b% R+ H* `
- jz exit1! o' Y3 @$ e! f: j5 M4 I% c
- mov dx, offset msg_ok
* Y, e4 r& s6 T6 t - , U- P, g5 Q1 a; T( I5 {
- exit1: mov ah, 09h : {) [. I. e* M2 |/ z
- int 21h : p2 B M- E; n
- mov ax, 4C00h
5 D4 K7 n9 N; B- h& h4 l& ] - int 21h 0 s$ N7 f. e6 f& U' Z' l8 i
-
8 E/ A* ~6 c* A1 i& |' Z( ?' |: } - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10," c, t2 I2 h( l
- "2008-07-01",13, 10, "$"
6 ?, S: |" \5 f' A - msg_ok db "A20 Disable OK", 13, 10, "$"
; a E: w& S3 N8 W: } - msg_fail db "A20 Disable FAIL", 13, 10, "$" + u# I5 d m5 j9 g2 ?! z( Z
. @. X1 W3 d' ` b5 C* M. D- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
$ ]. {7 k( a7 I+ I' o& F - A20_DISABLE: & H. Y) c: ]. [% |& @/ g1 I/ k
- call A20Write 3 P$ k% z. i( [- j/ z Z9 ]' {- D
- jz exit_disable
6 _' U& d( l% v4 ~6 } - : A- f J' H: b: k9 r' H# ]7 ?
- cli ; Only need for reading value from KBC
* B) n0 G* j9 |2 J7 i' B6 e - mov al, 0D0h
8 d y7 A2 e: `' R6 L1 q. p& o - out 64h, al / t: x% a& p% I7 z
- call A20Read
% i/ `) A- J5 p4 A - jz Disable_int E: K% y8 P% @ L
$ ~- g |, v7 [9 w8 d6 r- in al, 60h ; Get current status
" [# G" V9 a9 ]( l8 d0 r9 M - mov ah, al
4 f5 p; G1 p; }/ C& g" v - call A20Write
, q( L) D, \5 f# h% D9 u7 E - Disable_int: sti
3 O- F, }/ Y. n3 @ - jz exit_disable% [7 U" S/ _, o" k H
- - a* q1 }+ l: Z' S1 M2 _+ e( O, z
- mov al, 0D1h ; Tell the KBC , want to write to the 5 v5 E9 ^4 d8 n! z$ R+ X( Q
- out 64h, al ; Out Put Port next 6 g! ~* ^' \0 _ q+ I! J
- call A20Write # V* }$ G' t- F& q! F+ E, h
- jz exit_disable: A. y2 g8 m/ u" w) I* T" e" B2 Z
- Q3 h+ y# h5 H" L# ^
- mov al, ah - [% I( D$ m/ T
- and al, not 2 ; Disable line A20
; D3 U- r5 ]2 l# Z9 u - out 60h, al
. A$ x& b; q+ G. [: y( I - call A20Write 6 f' l$ F- ]2 x. E* p
- jz exit_disable
s6 i4 y7 ` l7 B7 V# a5 f! V
% p9 T1 n& t: l, E" M- mov al, 0FFh ; NOP
4 |( P( M) O" `7 q3 n0 q - out 64h, al # z' A* L% ^8 t' Q' a8 C. @
- call A20Write
6 R2 ^9 S- h/ h - 2 a) l9 u3 N. f% x
- exit_disable: ret
* i7 U& ]5 j( D: c - ' Q& N- [4 \( @4 S. ^- ~+ ]
- A20Write: xor cx, cx ; Reasonable wait
- B S( l( Q& e) Q7 E - get_wirte: in al, 64h ; Get KBC read status
/ f0 B% j1 g- H7 c' s) P - test al, 02 ; See if buffer empty, bit 1 clear g! }' z8 `) J5 q9 O
- jz clear
; U4 {$ v1 t2 j$ Q- P* ^( U' ? - dec cx
# t7 h6 L1 n7 q& y* e- l% S" u% E3 w - jz exit_write ) d9 {7 L. ?2 v% C% |% m4 i6 N
- jmp short get_wirte 9 @7 d7 J' `6 i- T9 Q
- clear: inc al ; Clear ZR
+ |+ ` z' u5 @$ W0 r - exit_write: ret 4 e; _9 P2 U% `8 ~9 P9 O3 f/ M
6 N: N6 i" y6 O+ N: A4 g- 8 k8 a$ y$ X, V0 G* a
- A20Read: xor cx, cx % r2 o7 R8 N3 g: u2 ^8 F4 F- H+ `
- get_read: in al, 64h 6 y4 G% B" r6 E) e- ?
- test al, 01 ; If the 'output buffer' is full, has 1 f, H$ T7 I; ?: t4 |; [8 x
- jnz exit4 ; ...
, K1 o5 [- }% i. j) b - dec cx
2 X7 k7 |7 a, n5 i9 K - jnz get_read
8 M! E G! d& V0 l& L - exit4: ret
* W) B8 p, W! M- e# a& X% u -
9 [' n2 |" n, b# G8 o) o. | - end
复制代码- ;A20STATE.ASM
# X8 g7 _9 C& h7 t( n - ; 3 `3 {$ }/ o7 h; U
- ; Returns the status of the line A20 through the KBC
& R j0 M# R! Q- y6 o( B - ; programming by bini for debug. 2008-07-01; r4 H3 B7 d: y2 L" F/ z
- ;
* `9 _* {0 l5 k, u: x+ g | - .model tiny) T( |' @; `* W# |: B+ e
- .code
2 q: R9 x+ v; M0 j& n - .486
/ d2 N( c# X. @) L' I - .startup( E; n" A- a/ ^ B
- mov dx, offset msg_fail " t; W1 w, z2 y) C. P0 Q# W, e5 `
- call _GET_A20_STATE_% c. P1 \. X7 t5 d4 u+ j
- jz exit1 ; was a problem% ^% r! l7 a7 H1 E0 z7 c
- push ax ; Save state, AH ]% u2 k. r0 `' C
- mov dx, offset msg_ok ; There wasn't a problem
0 j& k' ^% J! |/ v& N5 s - mov ah, 09h
w; h) \( K P( T- l2 t8 Q" o - int 21h ; Print message
0 \+ R' T6 w1 \4 _. ^1 l - pop ax ; retreve state " h+ u- `0 m9 N# \
- & C& u$ x' l9 g% d" D
- mov dx, offset msg_dis
$ Z+ ~- B4 |0 n: l3 F: [3 B0 i - and ah, 00000010b ; bit 1, 2h, indicates state 0 P1 d0 y! Z3 w5 K% U9 Q
- jz exit1
: a* ^3 ~' Q+ l+ s - mov dx, offset msg_en ! p8 }6 L; g9 F k2 y) i
; f# l$ [* E" {- exit1: mov ah, 09h 2 X+ H: r: U9 u
- ; DX already contains address of string
' P' N& R& f3 X# f - int 21h
; B6 G T: K4 }( m4 P' D; Z" b - $ S8 \% W6 S k/ a" H, I, a
- mov ax, 4C00h
9 A9 _; n+ n- Y! l+ e - int 21h
$ B9 A- u4 s. a. b- v; c - $ B# [: |% C* \1 _
- msg_ok db "OK", 13, 10, "A20 $" + b& q) J0 f) r6 q! @% n0 f1 x
- msg_fail db "FAIL", 13, 10, "$"
! N, d+ S! L9 z4 e8 G$ I6 m - msg_en db "ENABLED", 13, 10, "$"
) n+ r, u; _$ N - msg_dis db "DISABLED", 13, 10, "$"3 ]7 M0 n+ H/ M
- - L9 M4 h# x4 a. n
-
7 j5 P( Y# U, s, Y7 J- d - _GET_A20_STATE_:
3 g( ^4 H. @. x/ L/ i8 ^& y( ?5 S6 J- Z - call A20Write ; Wait till the input register is empty 3 {% I- X3 K. l/ M1 ~/ L5 H. p! p
- jz exit2+1 ; Bypas the reset int's
: e2 ]# t$ N5 j4 O& e4 } - cli ; Disable ints so we'll get our value
) W# o' |# L' f
9 l3 I/ R+ r1 r r- mov al, 0D0h ; Send command to the 8042 command register - H `! t, ]7 M+ X; T
- out 64h, al ; to tell it we want to Read the Output Port
% I, o9 _6 ~# x {+ w# G- C2 A1 x - call A20Read ; Wait till the 8042 output register 8 M$ b, g( m' w" l$ c, T' S' T: c
- jz exit2 ; has something in it's buffer F; s3 k" l: h/ E% t
' W7 g! p, a9 L3 t7 O0 T# w! y3 s- in al, 60h ; Get it 7 i# I2 o+ T( ~ q
- mov ah, al
" }+ T: l+ {/ S; R - call A20Write ; Make sure the input register is empty
: t# r/ w2 g# n0 c. Z - jz exit2 ! \2 ^& } {7 Q/ B- h* ^+ f, ~
' h% n4 H- N. F* r! v8 u. U7 p- mov al, 0FFh ; KBC NOP command, does nothing
3 \5 I( T H4 T4 S; z, d - out 64h, al
/ I6 Q U/ L! o3 Q - call A20Write
/ s5 D$ z; {8 f8 y- w
$ X) H6 E4 g2 G2 B- exit2: sti 5 s3 @7 m5 D5 y9 F- E
- ret
; b8 h' e0 S! g6 W1 h$ S5 B - 1 ?! y3 p n8 u# U3 N# b, Z
- 5 D& m* R0 K# v1 A; ]8 P( y
- A20Write: xor cx, cx ; Reasonable wait 7 _# |# f) ]( b, B) i: m1 q2 v
- get1: in al, 64h ; Get KBC read status ) k6 Z# E& R) @) B
- test al, 02 ; See if buffer empty, bit 1 clear ( K9 J, G( d+ E2 G9 L
- jz clear " |4 z2 E z1 r* N
- dec cx
! s i, o% a$ J& H/ @" x/ G$ x - jz exit3 9 L+ ^& V, |) L1 W& {/ I0 d
- jmp SHORT get1
! w! |$ c9 m( E - clear: inc al ; Clear ZR , D9 T+ F, F8 u1 G( W! u
- exit3: ret
+ B& H! K6 k( g! F2 k
) _: R2 l$ N5 a& _! ~! ]: A- 9 e. ^. g0 \! K& G) N
- A20Read: xor cx, cx % r) W2 F5 @; N6 f( n" z
- get2: in al, 64h
7 Z( k* f' t0 o+ b- Y2 N3 { - test al, 01 ; If the 'output buffer' is full, has 5 l. ^- l! ~; w" P/ q
- jnz exit4 ; something for me . ]( i1 [7 Z4 p2 ]0 {% u$ t$ ~
- dec cx
9 h2 {" @# Z# ^+ F4 O - jnz get2
3 m$ y% `+ e) r5 c - exit4: ret : ~, C' |& ?1 ?
-
- O4 J/ r+ D- L+ N - end
复制代码 |
|