|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 7 O1 ^! G# |% t7 N: ^! I2 O
- ;
; N: n8 B1 _. _ - ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
" I6 K( ~4 K% A6 @( p! c+ o) e - ; ml A20ON.asm
) e1 V' c0 N- I9 P. i8 m5 s% R! | - ; # ~* y% m2 Q$ M5 F6 Z) r
- .model tiny
, U" y' s% ^3 |: ~+ g* V - .code
' h5 O$ J/ t% u9 E5 e: @7 s: Z - .486+ D% I. s w7 u1 G
- .startup
, z9 S9 k1 w% U6 t# E - 6 b3 I: ~" N+ ]; g& o7 F% C8 H
- mov dx, offset msg_author0 B5 K" |* {8 S* N5 O$ _
- mov ah, 09h. D. e+ a$ |1 X% E/ N' m9 P
- int 21h
/ X2 G6 E- k( K8 ? - $ m7 { F/ z% p
- mov dx, offset msg_fail
' V* R2 f5 ^& ^ - call A20_ENABLE
9 h& M' o& T1 W2 P - jz exit1
; g2 }2 {( O1 s( _4 b1 s - mov dx, offset msg_ok
/ y" [* F& b/ T# M) }7 s - - \/ F' x2 m |. c2 P5 Z: n
- exit1: mov ah, 09h * _; u9 N9 y* `0 K7 e
- int 21h 9 o* w: o) `7 C$ K: L6 `
- mov ax, 4C00h ) l1 s: o3 \, g4 @2 _, }) W9 T7 s! s
- int 21h # \9 W w: K! k j
-
3 @6 r2 c, @9 @ w9 n - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,1 ^- J+ X: S9 }# ^1 E% @. `
- "2008-07-01",13, 10, "$" * C% Z% A/ M7 K
- msg_ok db "A20 Enable OK", 13, 10, "$" 6 i; s9 c+ ~1 a: d5 M& s- j
- msg_fail db "A20 Enable FAIL", 13, 10, "$" ; f7 [( q7 X; t- G) X
- P; @5 f, b, \4 P6 [* i
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
6 u" B- s& H# Z - A20_ENABLE: z. y# `3 O! n+ R+ d7 @
- call A20Write
, I- s; L8 Y, R0 H! V2 Z - jz exit_enable: z' F! l: ?0 b) a& B+ Q7 U
( i B. t s/ a3 N0 r; V- cli ; Only need for reading value from KBC + S0 f8 m# X! e. p- D6 f6 }+ J
- mov al, 0D0h
$ j3 A; a( D! G! \0 m& t - out 64h, al ) v# h; g0 H1 {( e. v
- call A20Read
1 }0 E s0 {0 y- b; }7 y- D$ k - jz enable_int ! j" A& e b- X# _2 ~1 M/ Q
- 1 r% [) ^: m: V; `% g! A" l
- in al, 60h ; Get current status , A9 C( C# Z0 J7 E+ |2 v- r- T
- mov ah, al " R4 L2 Q8 t' q9 f. b6 Q+ |+ c
- call A20Write : ]0 L% d1 X( p) T! y2 S+ V& G
- enable_int: sti
4 h1 Z7 N: |9 |2 M. l. A - jz exit_enable. J t# p* C0 l0 R! }" K* C' D* p
- $ c% d- \) P6 [1 Q1 @( T, ^
- mov al, 0D1h ; Tell the KBC , want to write to the
2 [1 C, s+ G) @; M3 o - out 64h, al ; Out Put Port next - q0 Q0 a, k B. o* Z
- call A20Write $ ] Z$ K( A7 Z, y9 S; I
- jz exit_enable
1 [! V6 s9 F5 R& ^
; @6 U& O/ m @% r% L& X0 q- mov al, ah ! \7 [- E* p& a+ U
- or al, 2 ; Enable line A20 7 `3 E1 ^, V6 F+ ?' @
- out 60h, al , Z- t1 W1 b1 `* [! R) t
- call A20Write + Q; A, _; N( R. P0 X0 i
- jz exit_enable
0 i+ L$ f2 J. M* g0 G! \
. K: C" X- ^, }% m |5 ~2 r- mov al, 0FFh ; NOP
# ^' d! Y8 n# w0 s- C1 E) Y6 ~: g - out 64h, al : c' Z' v2 \7 [- z! Y+ A4 S, m/ |
- call A20Write
7 o R3 p |- ]% X0 B - . `) H; w: K& p3 S. _
- exit_enable: ret $ t+ d9 p& I. B! e
- 7 t0 Z, D5 S* `3 f) {
- A20Write: xor cx, cx ; Reasonable wait : b3 A1 k1 b4 k+ h* E9 z* _" K! W
- get_wirte: in al, 64h ; Get KBC read status
* {2 w/ F: x5 d' k6 c9 R: n+ g - test al, 02 ; See if buffer empty, bit 1 clear 8 X' ?6 H/ |0 Y5 p- G: Z
- jz clear
: O8 _: @* j+ u8 z( ` - dec cx
0 |: I2 v8 f6 \5 z* h - jz exit_write
! `7 K* D1 f) O6 K - jmp short get_wirte
: P5 k# e$ ?# \3 k0 C - clear: inc al ; Clear ZR
) d& D0 {! k) l2 J4 S - exit_write: ret 9 M& \8 Q8 E1 f6 y5 p
- / X& @- F3 s9 `; a' p8 U
- 2 h! j: U; U# r. O, J# [
- A20Read: xor cx, cx
' }+ m/ k8 m" k) N1 P. B - get_read: in al, 64h 4 L# A1 i2 y% i4 c
- test al, 01 ; If the 'output buffer' is full, has
! G% C& _: w' j7 l" K4 V - jnz exit4 ; ...
- D g# F& B! }- T, D4 }8 S5 S - dec cx
& g; u2 r- U. C+ m3 z, w4 b - jnz get_read4 H$ I. a$ }: x. c# c" c1 u. {
- exit4: ret ! L* m0 y8 l1 R$ [. v* }6 @
-
8 j$ \: y! ?% s8 l* Z - end
复制代码- ;A200FF.ASM 8 @" |, c$ M% c8 V8 J) X' _( i
- ; ( x. m& I9 }6 I$ H8 D# S
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
5 V0 I4 R+ g! g3 q( o - ; ml A20ON.asm
; U; t% o$ E8 z5 S: p8 x9 y8 s - ; * d U) O* O _
- .model tiny
8 Z3 {4 {0 G( ?* O" H+ V8 n - .code) E2 c; m* ]* k# I! K
- .4861 o0 K M% o& F6 `2 Q$ D ^
- .startup8 A4 K0 R; g" T; C( N; `5 e h
- O6 {$ c7 l' e
- mov dx, offset msg_author
* D. X$ M* A3 Z C - mov ah, 09h* K" B* A6 G9 r2 z
- int 21h3 g/ X* \' x# n, r" N# }8 L3 A. C
- & u3 k$ u# F* P) p( ^6 R
- mov dx, offset msg_fail 0 Z4 |; x3 p$ ]1 ^: e1 {) i- N2 `
- call A20_DISABLE
+ E4 u6 i, u$ b - jz exit1- `+ ^6 ?, `, W2 T: v6 x
- mov dx, offset msg_ok 2 j s( \7 T& @, E K8 V# o% H: o
7 N+ r6 P/ w1 f G# H4 {. Y- exit1: mov ah, 09h 1 W) w+ l- Q4 f7 i {2 j0 l
- int 21h y$ v, `# G p2 m7 e" C- t# d
- mov ax, 4C00h 6 {* x z3 [1 @$ e0 }& o/ w: P. c
- int 21h
, e0 a% Q: x+ s. f d/ u' S% I7 N j - & h- r' U2 m# Q: f) a
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
( j, g$ }- @* }$ n, \0 q& R - "2008-07-01",13, 10, "$" , C+ R5 k4 V: x# l: D4 d. h
- msg_ok db "A20 Disable OK", 13, 10, "$"
3 Q) C: E$ G k2 i) {& n - msg_fail db "A20 Disable FAIL", 13, 10, "$"
' f2 l1 F: c6 k
" l* |7 q1 L, S9 V) z) m- ;------------------------ follow code maybe make to lib, if you want...-------------------------------5 p" J4 ]8 _! A( y0 o% }$ ?/ }
- A20_DISABLE: ; ~. j l- u! R9 v$ x, ]
- call A20Write ( f0 |! n( X. M. {" k3 J
- jz exit_disable
& |" s# v) Z5 A) H4 w - 7 M2 O3 k* g; {, i
- cli ; Only need for reading value from KBC 6 Z* m1 C$ a) m8 v l
- mov al, 0D0h 3 d! c8 G- z9 b$ y
- out 64h, al
0 S5 a* _7 |! I4 h - call A20Read
+ s3 a; x' o7 W) H - jz Disable_int / V; D5 b3 x, i* [
+ R3 a8 y+ ]; N7 e& j, t% }- in al, 60h ; Get current status 8 R! u, x4 f( t. k9 y
- mov ah, al
( g& K! y B, N" t4 F9 V2 i. s/ I5 | - call A20Write $ b1 z& K% M" X. I
- Disable_int: sti 6 t% P# w4 W1 T: r m( l( [! {
- jz exit_disable
! w: i* r k6 |3 B( { - & F8 D6 y7 `4 P3 p" @9 u
- mov al, 0D1h ; Tell the KBC , want to write to the
# @$ b7 ~0 U' t# A/ v& y* F - out 64h, al ; Out Put Port next 1 i9 r! I }+ g* W
- call A20Write ; G. ?! K7 P. k X7 x
- jz exit_disable* j0 S/ S) a6 H: H! k
0 f' h. `$ |) I% `$ j4 D- mov al, ah
4 |9 \5 s9 y4 R& f; N) `! N4 x. J - and al, not 2 ; Disable line A20 ) k5 H" |( C" P4 h* o" X
- out 60h, al * h- E. L3 W- V& j, `
- call A20Write 8 q0 ~/ ]# @- z1 |8 q4 h
- jz exit_disable
8 ?- ~) Z/ h: o3 e9 ]: s
7 C. t, F+ ^1 a- mov al, 0FFh ; NOP
p1 V0 F P- ?! G1 {. n" h+ g( X - out 64h, al : _: L8 l/ {9 b$ U+ g) c1 h8 o
- call A20Write
% X2 l) q4 L, W0 T u Z
# r8 C" S, L2 ?+ f* D- exit_disable: ret
: c3 b7 B! G: i; k0 S - * z+ R( w, ~8 |
- A20Write: xor cx, cx ; Reasonable wait
8 g! T' ?1 u u( z5 a. s - get_wirte: in al, 64h ; Get KBC read status $ U M: m* k3 _; I; }! t
- test al, 02 ; See if buffer empty, bit 1 clear
# a: B$ |( R. [, i - jz clear
$ M6 Q- k. `" n# Z5 O5 H: f+ S - dec cx
, v3 I6 h; s7 l+ ~$ L$ ] - jz exit_write
! A9 ?0 V3 F) D! z7 y - jmp short get_wirte
7 T8 S5 z: i8 x0 A - clear: inc al ; Clear ZR
3 l# @) R% a: l$ H7 }5 ^6 | - exit_write: ret
; e1 ~* ]) k( y1 M, d, j - ' i% x( N4 ]* U# O
- 0 m, s1 S' m' k: Y
- A20Read: xor cx, cx & s7 m0 B# e( d3 ]/ ~& J
- get_read: in al, 64h
5 i# ~7 P4 T: }; ]" T1 f# X - test al, 01 ; If the 'output buffer' is full, has & K1 q- D* n$ }; w. O+ {
- jnz exit4 ; ... 8 Q4 @# Q( g, W. c; ]! C
- dec cx 3 g% Z, M! n) P) a- l
- jnz get_read" U$ K7 I5 F# I3 p& u
- exit4: ret
5 J; v7 R5 A, K3 S. t/ ?3 | - 2 W% l4 M7 S0 q* ~! n
- end
复制代码- ;A20STATE.ASM * K7 h4 B8 F1 Y$ b7 ^/ a
- ; 4 L8 [, r$ M8 P, x$ l
- ; Returns the status of the line A20 through the KBC 1 }( x% z8 N8 K/ b, U% T2 M* [1 C! N
- ; programming by bini for debug. 2008-07-01
- h. ]" }' M) M( T) }! z - ;
' D+ ?1 s7 N2 x% Z - .model tiny) I! [6 C2 f+ c# v+ e+ J3 v4 `
- .code
8 [1 h+ l1 p( a" q1 c+ } - .486
9 Q ?' F b/ [5 N' i9 C - .startup+ r" w7 `7 f# K+ `4 x
- mov dx, offset msg_fail ' `( V# o8 ?6 \$ ?6 a* h3 T* @
- call _GET_A20_STATE_
7 c: \" J( h) x0 s. Q; |$ F - jz exit1 ; was a problem* o2 Z* S+ g9 P; ^/ u- ?8 G9 O
- push ax ; Save state, AH , a* D3 B3 d- l! \% p; n$ p* H# w x
- mov dx, offset msg_ok ; There wasn't a problem / d, H, k* Z! b& U" c3 _" W5 y
- mov ah, 09h
: t+ i! v1 J; X [+ X - int 21h ; Print message $ j W/ D' l {0 o8 n
- pop ax ; retreve state
6 g: ]$ c7 ]3 M7 V% d/ I) b - 8 j5 ?9 s) D1 d9 m/ h" P7 e
- mov dx, offset msg_dis
& F1 j& _( O; M- y# K& F/ m - and ah, 00000010b ; bit 1, 2h, indicates state
+ w h1 j: E9 v8 Q7 A - jz exit1
# t4 C6 }$ e5 j) t7 h5 } - mov dx, offset msg_en 1 m2 y1 ` S4 @" L6 j" L4 g+ u
- 4 h( }5 v+ _8 b! t/ o& t
- exit1: mov ah, 09h 3 N7 @& b3 I% U% [
- ; DX already contains address of string
* z2 p: b: ]" R3 Y! x y - int 21h 4 C: M! |$ W8 c0 [- U! p
- 8 w& I; I( l! r4 ~. h7 g5 l1 @
- mov ax, 4C00h
$ e* x+ v6 ~" Y( P' T - int 21h : f0 h8 O# g( Z" E Y- z
- 5 r) ^: S! q5 ]) p7 ^$ E0 I4 j
- msg_ok db "OK", 13, 10, "A20 $" 8 `; Q$ V; y/ J7 j7 Z
- msg_fail db "FAIL", 13, 10, "$"
1 ]) A! H# E7 {" l" F6 G, \ - msg_en db "ENABLED", 13, 10, "$"
9 m9 }) H& `& n$ x- L8 \. Z; z0 l - msg_dis db "DISABLED", 13, 10, "$"
+ H2 F! d8 V+ e8 \ - # A$ g3 ^- A0 a0 }( Z f; w4 J
-
% o& r' h$ L; T; [$ y7 b - _GET_A20_STATE_:
5 n, D' |& j+ t& Y+ T. n - call A20Write ; Wait till the input register is empty
, ~( \3 Z/ ?3 y+ l( x4 \5 k8 I% q - jz exit2+1 ; Bypas the reset int's
+ Z p- u& k1 N8 _& | - cli ; Disable ints so we'll get our value
w0 U8 o7 p: k, ?
s5 o! s r( K: U e0 ~& D, c- mov al, 0D0h ; Send command to the 8042 command register . T# m/ }; U& }* f# b. W, d
- out 64h, al ; to tell it we want to Read the Output Port ) W8 j+ }0 ]) \3 |4 K& `: t/ o- t
- call A20Read ; Wait till the 8042 output register 5 H* |/ [6 A/ @% H4 }
- jz exit2 ; has something in it's buffer ! d' Q, C& h+ u$ X: d) W+ U
3 J, `" q( _0 G- in al, 60h ; Get it
$ A# b3 `3 {9 Y+ D4 J- J. x - mov ah, al
5 u) ] S {8 t% m+ l; z1 L - call A20Write ; Make sure the input register is empty ! E) d& }, u ]4 F
- jz exit2 % A; F9 n& `2 X' A7 `' y7 X9 S
: V8 b7 H& d! U1 ]* y1 s- mov al, 0FFh ; KBC NOP command, does nothing $ _3 g1 z9 Q' X" p' H8 Z9 U+ d% T& e
- out 64h, al
4 x+ v! m; |7 W - call A20Write
$ k0 j3 `8 s; s0 J* v" S& j- r5 ~ - 2 X4 N" o9 Q( }6 v, M8 j
- exit2: sti , s2 A0 Z# W+ I! ] q
- ret5 T) Z9 q7 y5 \( k6 s( p* ]
- 3 v7 l4 U, U. J; C/ D
- $ y4 r& i. c: }2 i/ U* c
- A20Write: xor cx, cx ; Reasonable wait
& @8 q. n' W- k; {. ^ |: K - get1: in al, 64h ; Get KBC read status
z8 p+ I* h& C+ d# o - test al, 02 ; See if buffer empty, bit 1 clear
: x% ?' b; q2 `3 _ - jz clear & K% \, I5 T4 R
- dec cx
1 l8 _. J- c; m - jz exit3
/ I$ l' W" Y: q; B% ~ - jmp SHORT get1 & I2 }; m% G4 J7 O; j
- clear: inc al ; Clear ZR ( V7 G6 j' R# W4 v7 c6 m
- exit3: ret
4 t/ k8 l( G5 o5 n5 v; J
0 J* R0 _1 x2 ~, S5 ], T% a9 [- x9 ]
& o- ^( x9 t3 o! u* n) v5 A6 U, D- A20Read: xor cx, cx
9 J: @! {" }7 y; A9 ^$ V" F% R C - get2: in al, 64h * Q" O2 c9 [, r1 ~2 ^ v6 `
- test al, 01 ; If the 'output buffer' is full, has * _9 G% L7 y" }0 G! k, O- S; J* }
- jnz exit4 ; something for me $ W9 c3 }' `+ J J2 e
- dec cx
/ f, F- Y; z, c) g. D - jnz get2
$ `+ i9 m5 C& D( o - exit4: ret 3 [, m4 J$ w! _& O* h
-
9 v3 ~7 B9 g/ w1 z1 u( Z9 r } - end
复制代码 |
|