|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 6 a" K# X3 d5 `
- ;
$ z( p6 X( o4 |9 i* w - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-016 z( g5 V' ?6 ^
- ; ml A20ON.asm 7 w8 e" f. J9 ~# @2 W1 D
- ;
8 b6 o7 k6 w6 }% v - .model tiny6 X6 ~ i* L/ r0 x3 ^$ |/ K
- .code
/ F1 w: O9 e# C6 w( Y - .4864 M: X3 k2 s1 i7 b$ Z7 \
- .startup' P7 f) F. X3 r
- & P8 v; u7 B' p. \: [, \
- mov dx, offset msg_author
: C' X* {( o3 E0 K* E% n% f - mov ah, 09h
' w0 y0 Z [1 w( e& l - int 21h1 |( y9 ]$ _* \$ |8 l
" ]) k8 b1 U! j p( X7 \# }- mov dx, offset msg_fail
8 z( G+ j/ u/ ^/ |; @+ h - call A20_ENABLE
3 E+ |+ s2 c% }, P9 w, U3 g - jz exit10 t; v b% D) ?* Y4 K& a
- mov dx, offset msg_ok
" @# ^2 Q) q2 k; \! I
- t1 b8 L$ p) ^& l. ]- exit1: mov ah, 09h
2 A4 P4 r: k2 l2 l& m4 j - int 21h 8 z# N0 C+ H& W4 w. ?
- mov ax, 4C00h
+ ]0 w, U! F' S% k9 Q { - int 21h % @5 b8 B/ b! i9 t
-
! ]* d$ P3 O" N, V5 z- w - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
! K% X4 R, J6 n, o y5 J" [1 J - "2008-07-01",13, 10, "$" 6 S+ s9 j: Z* w* ~5 H6 r
- msg_ok db "A20 Enable OK", 13, 10, "$"
) H& P" ]2 T) v: e2 `! D- E - msg_fail db "A20 Enable FAIL", 13, 10, "$"
) ~" _, _) J- g5 D) u+ k! m
; b$ j! _' t, f- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
3 k/ Y2 q# u0 K+ o- }, Q) M! u - A20_ENABLE: x) T# X7 U1 n3 z8 u! |' D
- call A20Write
, [2 {! ^; R( H, l( `, r - jz exit_enable
& ~4 R0 Y4 D" l1 Q( ?) m' x$ N% o - 2 a2 j' Z8 M, l) k6 l T4 j
- cli ; Only need for reading value from KBC
4 l* h7 t7 B/ t - mov al, 0D0h ; J" u0 |+ L! I' e3 p% ] X* Z$ g) m1 K+ Q
- out 64h, al
6 P2 W( M- G6 n. q# j) r4 P7 i - call A20Read
) ^! j0 \9 ^( J: G - jz enable_int
$ |( Q8 M ~. I - 6 N- i" T7 x @0 g" v, C
- in al, 60h ; Get current status ' ~1 V% j2 W4 L& |8 w1 q
- mov ah, al 7 N: J' [$ z! {) ^; t! b# ^
- call A20Write ) C/ l" {5 y, e2 A! b! s" B; \
- enable_int: sti
5 Q: b; Z5 H$ k1 J; i4 u# i3 H - jz exit_enable2 z L9 P2 T7 N3 a$ R1 l8 D( b
0 K4 D* L7 q h/ Q- W. V- mov al, 0D1h ; Tell the KBC , want to write to the
* p6 _) `, z6 X& l% |7 L. s$ x - out 64h, al ; Out Put Port next % I- \+ }8 n4 `' y" Y, ?
- call A20Write 9 w3 ~ h. Z7 U1 s" W/ \& X) E
- jz exit_enable F/ k3 S2 x4 R7 r; z: G& a
# q5 r' @) ^1 A+ R6 E5 t F8 S- mov al, ah
- i. E/ ^0 _* q# ?- u - or al, 2 ; Enable line A20
# \8 S6 p2 c4 C - out 60h, al
" {$ @) ^! ^$ T8 y- c - call A20Write
! a. I- ^" g9 u0 ` - jz exit_enable
l( v8 z# I% _7 e F
, O: a2 m. D" H, L- mov al, 0FFh ; NOP $ c: J8 p9 A3 o/ c
- out 64h, al
' I5 T. m5 g& C& t - call A20Write & T1 b( V9 N4 r; h' G
- 7 Y) Q8 @! W$ T* a9 C! t9 j# Q o
- exit_enable: ret 0 F, ~3 Y' l' U1 w2 U1 X4 i9 D
$ H L) @' T4 e" {% `/ z5 s! c- A20Write: xor cx, cx ; Reasonable wait
9 n. {* o7 o* [ - get_wirte: in al, 64h ; Get KBC read status & m( r7 z2 K3 {6 t1 w5 A7 a; D7 F
- test al, 02 ; See if buffer empty, bit 1 clear
* n3 q/ S) ~& ? - jz clear 2 i4 W; n1 t$ i1 Q% B+ c$ X
- dec cx 4 L. {+ c; h+ i# q) o
- jz exit_write
. D" J8 d, X) y! R, @ - jmp short get_wirte
0 p8 i" ]- \! ]- U1 h6 H - clear: inc al ; Clear ZR
5 l0 n4 `2 s; _( F - exit_write: ret 0 e" g% l/ M% N- o7 [3 C! v+ b
- * l& i- l+ j" A7 M) a
- 2 c. P/ d, ]/ S9 V) x0 M
- A20Read: xor cx, cx ' ]: |9 T$ C4 e* ^, P
- get_read: in al, 64h ' W# a1 A7 r3 p _3 A# E/ \" d7 z
- test al, 01 ; If the 'output buffer' is full, has
) g' @4 [0 ]( v) j - jnz exit4 ; ...
7 h" `0 @! e+ z4 T* N1 ~ g. y* { - dec cx
& z( T I5 `8 f5 q" y - jnz get_read8 a# Q) w+ W# }1 c/ G
- exit4: ret
0 u% c( o2 Q/ y. s2 y4 K6 h3 K - $ e8 U& X( S: `/ {4 @
- end
复制代码- ;A200FF.ASM . {1 t7 D4 O" {$ t @" @! X
- ; 0 v7 a. z) R* Q" A
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
# h2 d) ^& F$ G& z# I" e7 j - ; ml A20ON.asm
: ?6 l2 H! }3 `, q$ Q, B, G5 K7 {2 i - ;
/ j- t6 `5 O' f% i - .model tiny
5 f+ {# l1 m, U; Q' \ C" k" E( z - .code
/ R& l* n6 j; v0 h1 S - .486& |0 c3 s0 K( x
- .startup6 ], C$ L. v0 O! ?9 O( s. w
- + c* H2 H% n5 ~6 M# y9 T6 [
- mov dx, offset msg_author" j7 e1 O& A p" ^( ?
- mov ah, 09h
" o6 e: q+ w5 p - int 21h
$ E5 X3 V( n% _ - & p( I4 @- a. x" q4 y# X
- mov dx, offset msg_fail 0 h$ `, \: [6 b8 u; @6 _
- call A20_DISABLE& m% _4 g( s/ q& R7 h: x
- jz exit1, i1 Y; H$ M; Y8 K- e$ F2 e
- mov dx, offset msg_ok 1 n, f6 ?& m. m8 p2 K. ~' Y( c4 ?
- ! q2 v% {8 ?9 R5 e9 P$ p& u# \& ?+ r" Z" P
- exit1: mov ah, 09h & I9 f1 G# A P9 Y
- int 21h " H6 q# N0 Z' R4 e1 D$ a
- mov ax, 4C00h
6 }. R+ N. j b" b - int 21h * N" ^' p8 k, z$ V. Q
-
* u7 [$ T/ j9 z' [: y - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
6 s: d/ K- H# J- E, e - "2008-07-01",13, 10, "$"
7 `; k( d/ p' A5 \ S - msg_ok db "A20 Disable OK", 13, 10, "$"
: _4 S. v' O& Y+ v6 T - msg_fail db "A20 Disable FAIL", 13, 10, "$" ( ]& {) ^+ R6 y5 D
- ! i h# T1 D3 |6 d+ [" A$ P
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------5 ~! C1 @ Z8 ]" f3 s6 M" q5 s$ j. y
- A20_DISABLE: 1 I+ i0 E9 z4 v& l; e8 [
- call A20Write
: C: g: C9 F- [" t! ~! @) l - jz exit_disable
2 w& N: R [9 X3 S9 g4 K0 t - 5 I" h. Y1 Y% V/ j
- cli ; Only need for reading value from KBC
- O/ Z/ ~5 z" a' C N* i - mov al, 0D0h
$ t& I, A- ^0 P) N2 K - out 64h, al
0 x5 ]4 r1 n; R) D( t9 q0 Z - call A20Read . O; \" X2 F, y& ^* W0 x
- jz Disable_int
& V. F3 I; B1 `% t; Z
( Y6 G) `( E2 h# H; E- in al, 60h ; Get current status + o8 r) [7 E& I( ^4 P/ u. `" `
- mov ah, al - b! l+ D2 x/ v+ {' P
- call A20Write
% {& g3 u& ?; s8 ] - Disable_int: sti : j3 x9 @. }" g9 F. C# |+ ?- ]+ C
- jz exit_disable% o0 d" q5 D# F; x7 t: ]
# V2 I( H* b1 m% |6 k: M% @- mov al, 0D1h ; Tell the KBC , want to write to the
+ y3 }1 c/ \: T8 |9 x9 k: z% ]4 T - out 64h, al ; Out Put Port next ; p. } X. k1 V3 e+ m) N6 W
- call A20Write
, h" X* ^1 a* f3 j* a - jz exit_disable2 T, ^/ u/ I& |% G5 v
7 p" r) `. ^5 ^/ Y1 b' D- mov al, ah
$ ?: L! B$ j& i2 r, E* w3 h - and al, not 2 ; Disable line A20 ' A, u# P- W- a2 S1 G& V1 p
- out 60h, al
7 `$ g- J: @; g0 w# F - call A20Write : z) @( N6 Q' b" J
- jz exit_disable
4 F+ U% l1 \. q. s2 e2 | - + X, n; S" M' l8 D
- mov al, 0FFh ; NOP 7 h2 \: g# a; i
- out 64h, al ' c/ W# A2 c. v# x
- call A20Write
1 @5 p/ n6 p. { - 8 e# k2 Y8 Z3 t: K4 h) w* o9 W
- exit_disable: ret
3 k( _( H- w. _9 C( p' K; k - 9 Q2 N g @) Z* V
- A20Write: xor cx, cx ; Reasonable wait % ?( X0 r' U6 _. q v6 x5 G, K. j
- get_wirte: in al, 64h ; Get KBC read status
; L: T; ]* Z3 f0 ~* A( s) t - test al, 02 ; See if buffer empty, bit 1 clear
0 X+ B5 w1 @8 q4 A; j4 T - jz clear
+ H* z6 w# Y% V' b" d, u - dec cx ( L5 I5 B/ A, Z+ S" i" _
- jz exit_write
+ u# ]0 B6 |5 w+ i - jmp short get_wirte , K( F! {7 j8 r4 b% t
- clear: inc al ; Clear ZR
1 ~% A/ Z, C( V - exit_write: ret
) @; t( M, U6 @4 y& S
/ i; H# ]& `$ v' q& Y7 F- 9 ?* ]+ s, E9 W8 Z& y z
- A20Read: xor cx, cx
; k. m N+ }# _3 N - get_read: in al, 64h 7 f% z$ F& u; Q" E9 {6 m
- test al, 01 ; If the 'output buffer' is full, has 7 Z2 p, e0 [- |
- jnz exit4 ; ... " c D, C8 |6 o
- dec cx
, ?, D- ]& y7 i& P+ O( g5 o# V - jnz get_read
! p( o6 l7 k+ ^2 z& W( U$ C - exit4: ret 0 c" M3 S! P6 N! F
- ! k- ]) ]6 b1 _9 y g* Z
- end
复制代码- ;A20STATE.ASM
6 V" {- w+ B" O$ s# K - ; 3 ~6 R! c/ U' s* P* b: E" o R% F) Y. j
- ; Returns the status of the line A20 through the KBC
' `) e* u) A# t5 e8 i - ; programming by bini for debug. 2008-07-01
4 N2 k7 A) z. m6 N - ; " R1 ^ H) U, R; o |
- .model tiny
8 P" O! c1 M1 k" e - .code
6 ?' {! H, s& _) K1 [. W; @7 P - .486" E, P8 i- ~4 ^- j! D
- .startup7 T0 a% f; @9 u. j
- mov dx, offset msg_fail 6 r8 v, Q% I4 x
- call _GET_A20_STATE_ b1 V$ N( o0 U ^7 M2 C
- jz exit1 ; was a problem
k: q% M( a n$ D; G9 J* F$ w& A! g - push ax ; Save state, AH 2 C" x* w ^$ _3 G$ c7 F' v
- mov dx, offset msg_ok ; There wasn't a problem # d, z6 a% u, j7 k
- mov ah, 09h % I( ~- }* b8 ~7 s) d m
- int 21h ; Print message
4 E! z+ k( _8 L( l - pop ax ; retreve state
' q9 [; w( G/ H" c; A
2 }7 W% V- H D4 a- mov dx, offset msg_dis 7 b* j) s! m6 f- j' q
- and ah, 00000010b ; bit 1, 2h, indicates state
, ]: j, T2 }% _/ j! b( b - jz exit1
1 b& s6 k( v* O2 U$ N. z+ N. M - mov dx, offset msg_en
! z- g1 h% ^+ C - 1 l. L) F# n' U% ]
- exit1: mov ah, 09h 7 \& R5 w" B; I* l2 Q7 p
- ; DX already contains address of string
. f. E, O. J) [: j9 ~3 T: S+ c - int 21h / X1 D7 V/ a0 X j" c' [+ f8 U
- & U* V+ V6 y2 ]7 \
- mov ax, 4C00h ' I- `4 {) g) \ z
- int 21h ( l. y% A' W' g* I L/ h5 B0 B4 ?
$ |+ C, ^% z' [- b. Y1 ]; z" P. M6 J- msg_ok db "OK", 13, 10, "A20 $"
5 a2 E) T' F5 a( @ - msg_fail db "FAIL", 13, 10, "$"
) s+ N5 n$ N; T/ d - msg_en db "ENABLED", 13, 10, "$" , E |: A+ o# g9 ]3 z9 y
- msg_dis db "DISABLED", 13, 10, "$"! `. W6 \6 X" z: u9 d: L* x; c
- % m' e# `& Y' p8 H: _7 ?# Q, U
-
2 y* A8 x# Y5 @% n - _GET_A20_STATE_: # s( v6 P* t. ?* C6 d) w" @# Z
- call A20Write ; Wait till the input register is empty
- c7 V( f q" V, Y - jz exit2+1 ; Bypas the reset int's
2 W& C! W# N- j1 \ - cli ; Disable ints so we'll get our value
! p0 t; y) _: r) ] U - . v# }- W' x6 P. n) Y
- mov al, 0D0h ; Send command to the 8042 command register
" X$ m. B( f2 k- c1 a0 o - out 64h, al ; to tell it we want to Read the Output Port 7 ~; Z1 G6 ]3 z* X
- call A20Read ; Wait till the 8042 output register
3 o2 `0 K3 p& X, W" E) m4 V) ^ - jz exit2 ; has something in it's buffer 7 A/ \4 Y4 R. E& a, U, h) I
9 F1 w$ G# }2 i- l) D, H1 D5 O- in al, 60h ; Get it
" U& V: \, T1 s) u7 k0 Q( \! F, y - mov ah, al
3 t! `( t6 m5 V! ]$ z - call A20Write ; Make sure the input register is empty 0 ^, s& [7 T+ A' |
- jz exit2 7 |* [( C. y$ w
6 V- s6 w6 h3 w E- a) L- mov al, 0FFh ; KBC NOP command, does nothing 2 B! @, H7 g/ v1 c+ p
- out 64h, al
; e% G$ W4 a' { - call A20Write ! G, m$ k% k6 o, q9 M$ y: ?: ]
- - [+ o* S: [& o7 M
- exit2: sti , i% V/ c& R3 j1 B
- ret
3 P( _# v9 O$ m* S - * U9 C8 S" t. o+ q" Q/ m- `0 h
- " w! J9 y3 }; ~0 M7 N' F# z! N) _/ k% ~
- A20Write: xor cx, cx ; Reasonable wait - K( w$ M* o8 @ F, e0 _0 D
- get1: in al, 64h ; Get KBC read status
# z* d% Z$ `& {8 l - test al, 02 ; See if buffer empty, bit 1 clear ! I- x4 u, t. P
- jz clear + c7 q$ w4 ~( L3 j5 T
- dec cx 2 ? m$ Y" @- w# X' q" {
- jz exit3 + @: i" B0 L3 x a$ u% v8 u& }
- jmp SHORT get1
" F% |7 h8 W8 Z: _" l/ B - clear: inc al ; Clear ZR ( j/ n+ A5 u8 y5 M2 K& m% ~
- exit3: ret 5 a* d5 O1 m) @
- . a7 t& H2 }' S# H
5 b( G, S9 S) i% h) B- A20Read: xor cx, cx / ?( @& A7 P/ `0 P
- get2: in al, 64h
3 j: K) x1 S/ |$ R! Q; x9 F' ] - test al, 01 ; If the 'output buffer' is full, has
# S9 ?& `$ C. u- z& a# g" V& i - jnz exit4 ; something for me
7 Q& a6 C& V: N0 r3 N - dec cx
" f7 H0 z) ?- Z$ V- m6 H% L - jnz get2# { f- N# `" f. R
- exit4: ret
* a- _/ a+ { f* [& P, a7 @: Z; R3 } - ( o% I+ V1 x( B( C
- end
复制代码 |
|