|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
: W$ \7 y9 @( Z) y' p) y) |% A - ; 5 e" Q" x4 j+ D8 M4 |! g2 P/ N
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01% J/ l9 e' h7 i5 F
- ; ml A20ON.asm
& C; E8 o' F o+ w. s4 I3 O - ; ; ?: j/ |; Q! y0 E* [& L. D4 p* S+ b
- .model tiny
/ a& z v8 O8 ~* z/ E - .code
) H1 q3 [% K; H) y6 r/ _2 F - .486 v D% s" u5 V8 Z5 D
- .startup
! L/ @ h' }2 Y6 T# R! X
) f8 P& ]% y2 l1 ] _2 R/ U0 h. R h- mov dx, offset msg_author! v# {) ^. C& \1 I3 q$ R
- mov ah, 09h! o' X- V3 A( P W2 n4 t% s
- int 21h8 r9 U/ Y3 d0 P( w j# n4 R3 A
- 5 g" h% G: P8 ~3 G8 G8 X
- mov dx, offset msg_fail : _$ T# ^5 q0 ^
- call A20_ENABLE" v8 k. [: Y' E& B# @
- jz exit12 R$ m; _# p6 Q" z; H2 g8 s: z2 }
- mov dx, offset msg_ok 1 _0 k- F2 d% y, B+ n4 Z. Y; R9 p
; F4 V3 f" T. R- exit1: mov ah, 09h
' u9 _/ U, w! |9 G8 z* c/ d( a - int 21h
9 }5 z( S& J6 ?5 ?& U - mov ax, 4C00h 8 ]4 i6 b4 j& t7 ?
- int 21h 3 R% k V4 u% g0 r( S' d
- 0 ` U9 U* ~9 g0 h# {5 L& |' `
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,. X& I3 H! o8 @$ p0 d
- "2008-07-01",13, 10, "$" ! l4 W2 v" e3 \0 m* l
- msg_ok db "A20 Enable OK", 13, 10, "$"
) v/ g: S0 y P9 P+ G& ^ - msg_fail db "A20 Enable FAIL", 13, 10, "$"
: l( a: U2 `- i
3 f' q0 y1 T0 x2 ~5 X- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
$ k0 L3 ]4 f" Y! v- o - A20_ENABLE: , a* ^% M% b7 ]
- call A20Write
; X8 j! U% q0 |2 s! t; H - jz exit_enable( p: d* }5 f$ n! p- B' j
- 3 u2 I. N4 {8 h* j6 M4 G
- cli ; Only need for reading value from KBC 8 _9 g. j4 a# y' j3 a
- mov al, 0D0h
$ N0 j; F7 Q! s3 H' x - out 64h, al
, ^% v4 h" r5 s$ s$ Y - call A20Read & b2 }4 l" w3 h& _* x4 B/ Z
- jz enable_int 1 Z& }! d6 o! ^
- * Z3 U8 z* y# r" l8 u7 C5 O4 x
- in al, 60h ; Get current status
0 K1 b( H$ x; G2 y$ c - mov ah, al
" H8 I- i- c, S+ F - call A20Write ) D% {% L" s9 j9 t: ]: P+ g
- enable_int: sti
$ r# F6 g* _7 W' ^" z - jz exit_enable2 P' M4 H) X( X; E K9 m
5 R& z& `% K: Z7 N# m7 z, y- mov al, 0D1h ; Tell the KBC , want to write to the
/ X4 K8 i( l4 E; L& d; N) M/ u - out 64h, al ; Out Put Port next % z1 f+ A+ R2 G* D# G3 [, @* _
- call A20Write ( N0 {- u4 o5 s" [
- jz exit_enable9 M) C0 J7 R0 T: C
$ v) [! W M" A' @- mov al, ah / r) L1 ]2 A* P8 l1 f
- or al, 2 ; Enable line A20
, v# H# K/ @. e9 ? - out 60h, al
2 }+ G" I8 A& F, W: P; Y - call A20Write 1 F" |, m( M! m1 x; Y
- jz exit_enable
* r8 {6 e( i! Q0 C1 T
: ~$ R+ `4 Y ^% M$ m! H6 W( w- mov al, 0FFh ; NOP # G o2 {* V" U" f- M' e9 n3 Q: E
- out 64h, al
% r2 b+ x3 P8 Z1 ] }' o- H - call A20Write
$ |! w g+ l/ D - + ~9 }/ b6 }) X8 k6 d; A
- exit_enable: ret
; H& W. g4 Y& D - 8 R# Q# C5 G+ B* V6 z Y) X
- A20Write: xor cx, cx ; Reasonable wait . }6 r J W2 o$ M5 s% ]9 u( {" j+ W
- get_wirte: in al, 64h ; Get KBC read status
2 u! Q, a: [- U - test al, 02 ; See if buffer empty, bit 1 clear 1 Z: x/ `3 e' R5 L7 C z3 s& @( M- t# ~
- jz clear
0 Q! V; ?4 k- n1 C" z - dec cx
# `* y' B* t- K0 b9 }$ c$ L - jz exit_write
- _9 z$ P! |1 R' K0 B8 ~ - jmp short get_wirte
% _9 y; y( b) n9 g3 O - clear: inc al ; Clear ZR
: `+ l# R. }% h* s3 ] - exit_write: ret
}# @& m: j& `+ {0 P9 w4 n- H
5 s7 O4 G( F" f$ c
( \/ o' Z3 J0 G& T: T. ]) K$ {- A20Read: xor cx, cx
; Y0 V) j5 A9 L7 f# B2 i* H% w - get_read: in al, 64h
7 @; J2 A+ Q2 A - test al, 01 ; If the 'output buffer' is full, has 7 P% K# y/ M' p) l/ u, n. [
- jnz exit4 ; ...
2 _! @/ l+ m. e/ N5 h1 v - dec cx
2 r0 ~6 H: U- [ - jnz get_read
e6 O$ c0 i+ T/ \/ \) B - exit4: ret
( z. d3 `- G c6 A! Q& q - 5 Z4 i. z$ y' j4 p3 t
- end
复制代码- ;A200FF.ASM 7 H* _* g' ~ O& ^$ e* ~# p- T9 X
- ; u" ^ x, c# k5 a' e& Z0 o* w) Z
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-014 e! h6 o5 c* u# M2 o: q% P# w+ ?
- ; ml A20ON.asm : b( g! F& |% [! g; V
- ; ( C0 @5 b4 N7 J' K) l: Q
- .model tiny
' X6 l, A- X8 Q* R - .code# {* [2 a$ a5 Y/ h$ K. c# e
- .4861 X$ |, x2 L- B& {0 `5 Q5 n9 ?
- .startup. P' r' G$ W# j: @% n& i; m
- : i* _4 v5 ?, s ^5 V* Q; f. {9 r
- mov dx, offset msg_author
2 U* S! f1 y2 P) b: F+ q8 A, Y - mov ah, 09h
% n6 |' U2 e8 I& @& S0 M+ o, C - int 21h0 M" _, T2 i7 F7 R4 C9 `+ @
- | O2 `1 O# I1 ~+ x- mov dx, offset msg_fail
* r2 G) ^7 i3 K7 z J - call A20_DISABLE
2 }+ W" m/ ~ Q$ m. X5 i/ E; N, B5 e - jz exit1: Y- t) A: s0 @
- mov dx, offset msg_ok
- q) d# i7 V0 ^8 R- M
# h* `/ f8 f: l5 T5 c6 N- exit1: mov ah, 09h
" b( _0 t% c5 J7 s5 D - int 21h - u9 [4 W8 }! V( A7 m' V
- mov ax, 4C00h
3 q4 ]2 y. J% Q+ x. L; _ - int 21h ) k1 ^/ {7 F) O- D
- + j! m6 g: D% |( R' i2 s( q5 ^3 D) Q! W
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
$ j! S" l) W! ?; w! g - "2008-07-01",13, 10, "$"
. A" g; x9 o o+ n" ~ - msg_ok db "A20 Disable OK", 13, 10, "$"
( } ?( A4 T8 V, P5 X% U* E0 W - msg_fail db "A20 Disable FAIL", 13, 10, "$"
2 d2 R, t! D1 L' A) S$ D$ b - , a0 H# @& K" { N
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
- p% R- l! v) B- B, N) v - A20_DISABLE:
7 V# {1 H9 S8 b4 t4 e/ F - call A20Write 1 j- }* p6 ^3 ]0 z
- jz exit_disable
+ q8 X! W. ?0 s9 l1 T
! A, k' {, v, l) D- cli ; Only need for reading value from KBC 4 u: q, n) X( F6 K- t2 n# x6 R4 x- l
- mov al, 0D0h 9 M, q3 Z3 f2 F, ~
- out 64h, al
1 ?2 _ X9 z. v9 P" v - call A20Read 6 M- E# r4 n6 Q# r/ F
- jz Disable_int
; J1 e9 c" u: d* p2 j) e - 8 n% d* T+ S, E& P( ]/ b
- in al, 60h ; Get current status
" j0 m# C# q0 j* w9 { - mov ah, al
( ~4 U) h S% n( C3 l, L* Y0 X - call A20Write 9 J1 i6 B+ l$ ~1 ]7 `& @
- Disable_int: sti
) @& s( e, _' p. F7 q - jz exit_disable E2 q) Y. ^# b# D* g
3 f$ c' }# v0 ?& q9 a- D, W2 | T Q- mov al, 0D1h ; Tell the KBC , want to write to the
! A1 b/ h$ U' E2 E3 ]' p6 _5 y& c - out 64h, al ; Out Put Port next
' d, [8 p4 f7 H5 F5 s - call A20Write
3 G8 f$ D7 R: c9 w2 z - jz exit_disable& m* p1 z6 P& ^* ^, c7 \- \' n, P( }# W
- * i: D1 F5 d& K, ~2 [
- mov al, ah
$ W3 K j' Y4 w/ @: \6 j' ` - and al, not 2 ; Disable line A20
% j# d. r1 g' p" l - out 60h, al
) s9 m8 }& K. ]* u4 X; L - call A20Write 3 Z: S2 Y# M7 ~' T# `
- jz exit_disable* I* n5 Z$ x) b3 P: g2 p: s
/ C8 _- [% P: {/ h: ]- mov al, 0FFh ; NOP
- o. _. Q* [3 ^, z1 N& \2 I) ?! b - out 64h, al
6 A+ b% ]& q/ X, ^1 r* n - call A20Write
. d& l7 d3 s ~0 N! c- B/ O - 1 u. G' Y& u0 }. k
- exit_disable: ret
( i, e' g* W ?1 n/ u. C
! G) G6 f* y d- o$ u- A20Write: xor cx, cx ; Reasonable wait
9 |3 Z& f1 Y+ ]$ J% Y: Q - get_wirte: in al, 64h ; Get KBC read status
( L& {* Y2 J6 U! G - test al, 02 ; See if buffer empty, bit 1 clear
: d' q6 ~( ^9 v- {6 t - jz clear ( \" y( o# y- X$ N: I
- dec cx
: |: Z' } b8 L" u! A! g: j* F0 x - jz exit_write
4 ]8 P0 b# |- i4 k2 U6 ?2 N* ^ - jmp short get_wirte 8 s6 j6 D. L8 @( X* D) i/ c9 e& J; U
- clear: inc al ; Clear ZR
- u/ F& e8 l- |) Y0 ^ y" T - exit_write: ret - t# \1 c3 C$ T) T/ O
4 D/ H" k7 A& U# s) z' ?) [5 ?/ C- ! g: g( N! C: `) {
- A20Read: xor cx, cx
8 i; X$ x& i9 c: _ - get_read: in al, 64h ' X& s) T2 a- @( B C
- test al, 01 ; If the 'output buffer' is full, has
4 a; T: t' P7 M' i) d' L - jnz exit4 ; ...
' k" `% p/ L7 d5 [- c! S - dec cx 9 n0 W+ f% N3 t4 J; m7 n+ [
- jnz get_read
t2 g' d# W' c9 W+ T1 G - exit4: ret ' k0 @1 q+ K9 v, Q3 G. [
-
* J8 r7 U: `/ `5 d# _! R5 e+ X2 Q" t - end
复制代码- ;A20STATE.ASM 1 n/ ^! Z) Z" Z, G( k @! T. N% `0 v
- ;
3 y- e; Z! B) b - ; Returns the status of the line A20 through the KBC
( ~ m1 _% e4 Q% \ - ; programming by bini for debug. 2008-07-012 f3 D2 h1 T; p' V7 C& b5 m
- ; 7 S6 l9 a' D! c) P& N& g; h
- .model tiny
3 A4 _4 F. B+ l0 H9 W - .code
, d" z9 q6 @9 U* s% X - .486
& S4 H! W. P6 e4 d4 n& {" q8 a( A! X" r - .startup. \, p9 a5 G$ p7 V9 ?' x; d) @7 L
- mov dx, offset msg_fail
! H& O2 d- L5 D1 a% h+ K% X - call _GET_A20_STATE_
, B: J/ L* f/ V! R$ {8 O - jz exit1 ; was a problem$ g }0 l2 R/ E! d7 b
- push ax ; Save state, AH
1 F( a& D* K: M! ]; e) F/ D - mov dx, offset msg_ok ; There wasn't a problem % N0 p% E: z" m: E9 P( x) H; [, C
- mov ah, 09h 8 \+ K$ R, c) a/ F" S3 _- M
- int 21h ; Print message
; |: {: j, k' r1 T/ @. x2 g9 J( g - pop ax ; retreve state 6 [8 b6 Y& i* F' E" l( d. D! X
0 |0 U" `6 R& ]8 r- mov dx, offset msg_dis
+ \) e- h& z1 Q. v* i" C# W - and ah, 00000010b ; bit 1, 2h, indicates state
' |0 G% f3 a3 J" m; V - jz exit1 : d7 _4 G6 ?# ]$ x
- mov dx, offset msg_en
2 o; C& K" b% C+ O h$ V! E - ; r) A' ~8 s2 R U( k& W% p
- exit1: mov ah, 09h 6 g0 V& w9 ?6 b
- ; DX already contains address of string % G6 K0 a' b2 w k
- int 21h , l7 _; @3 s* M
]& l7 v; P, k) W/ Z- mov ax, 4C00h 3 h8 ~0 ]9 T/ g# Y
- int 21h & ?2 e/ x# c9 \; w) }: @
- ' h6 |' a7 B/ s O0 C
- msg_ok db "OK", 13, 10, "A20 $"
9 v# N1 F* O5 Y - msg_fail db "FAIL", 13, 10, "$" # v- V7 [; K6 k( R0 U; W. e/ |: |1 V8 P
- msg_en db "ENABLED", 13, 10, "$"
- ?! U( g4 f/ j& o' H" L - msg_dis db "DISABLED", 13, 10, "$"
8 Z' w3 R. O5 g. K
0 T, Y3 _, D: E q- 0 \7 T& N0 u6 R
- _GET_A20_STATE_: - T; j- M+ u/ t& x' ^. m. ?
- call A20Write ; Wait till the input register is empty ) L8 N: @: S2 c9 E; @- }( I
- jz exit2+1 ; Bypas the reset int's
8 a& S# R/ C3 b [' [* m8 _6 ~7 O2 [ - cli ; Disable ints so we'll get our value 4 [0 a* i$ T" I. ?* |9 [
4 {* z1 Y( o2 O, h- a4 z9 e1 C- mov al, 0D0h ; Send command to the 8042 command register
) t2 O; o0 c% C9 Q* ^, N- a) h - out 64h, al ; to tell it we want to Read the Output Port " I3 B! m/ n& d8 Z6 P; G
- call A20Read ; Wait till the 8042 output register
$ [* Z2 y- x+ C4 S$ \" L0 f - jz exit2 ; has something in it's buffer 4 S: f: T6 o% N9 I) I* F& a* ~
4 g( w( R8 H5 [6 }0 R5 }- in al, 60h ; Get it + @9 X7 n5 E- }0 s, ~4 z3 D' t
- mov ah, al
/ L# D4 {8 Y& j - call A20Write ; Make sure the input register is empty
: L- d9 t j4 x' z: J' j- X - jz exit2 % t! l7 D0 L! D
1 i8 N' [3 m9 j8 i7 r5 q3 P- mov al, 0FFh ; KBC NOP command, does nothing ( q" j: _6 v7 }& w
- out 64h, al
0 e, e5 A: q$ Z6 G - call A20Write
1 R% m, c0 S# L* d8 V
. d) y6 K$ T1 b/ c! t* T8 ?- exit2: sti
, J6 I) \6 I1 m% I5 W& | - ret3 {$ g% |; v' u, E
- * P& o2 B( i& t, `; Y% q$ D" c
8 w3 d: b' t; X+ |- A20Write: xor cx, cx ; Reasonable wait : }/ ~- M" m! h: {9 L0 D
- get1: in al, 64h ; Get KBC read status
% }- r) M8 U) b% L0 G( U - test al, 02 ; See if buffer empty, bit 1 clear
: Y2 Q- x+ k' h4 B! I1 C$ W. V5 @% E - jz clear ; S" _4 f; N$ ^1 R, w
- dec cx & X( S# T( z6 ]5 w- h
- jz exit3 ; B A4 J, \; s. _* S* e6 u
- jmp SHORT get1 4 ` |9 d. U- ~/ c
- clear: inc al ; Clear ZR ( o. `$ F0 H2 i( C8 A) C
- exit3: ret
4 ~7 C2 X3 G7 [2 w- n1 ?) X - - \, A: G& A$ u
/ T, T/ ]3 ]0 `' Z- A20Read: xor cx, cx 9 f( h: b" c! J0 B# W
- get2: in al, 64h
; Z/ N1 O8 G4 m* r" r( g$ T - test al, 01 ; If the 'output buffer' is full, has
* }7 P5 M/ i' m2 c% U) }5 B - jnz exit4 ; something for me ! m/ E% a+ F$ z* ~6 p
- dec cx . |( t4 k, q# P" l" z8 A1 q
- jnz get2
- d, [! L* \5 @, ~" \ - exit4: ret * g2 u6 \6 z4 N
- / ~, z7 m9 A' a$ H( u V5 x8 y
- end
复制代码 |
|