|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
" N6 ^/ w0 K, t6 u: t3 e7 i - ; J) S7 l" E6 f% \ u' }
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
4 ]4 x2 U3 X# `' k8 n - ; ml A20ON.asm
: l9 b1 g0 k8 w$ o/ ~1 ~/ A7 b1 B8 M - ; * N8 I0 D' U! W4 f2 A; }
- .model tiny* l0 c" _) O: r. _% V6 L
- .code$ r0 a! F1 h# ~( n% V+ b' a& b& H4 C! e
- .486
/ i) l% m# [9 b - .startup1 D0 ?2 k9 q0 Z
# s) \4 M& _. z. E- mov dx, offset msg_author
- k; P2 D" t( x2 Z - mov ah, 09h
9 u6 T' T3 r4 C5 \8 O: } - int 21h! L4 y. t9 T% t2 v
- 2 S) f Q" ^* S$ m) _+ p& V" @) m0 P
- mov dx, offset msg_fail
. T$ L V& }3 z0 d' ~$ `; D7 h - call A20_ENABLE8 T* S6 q4 |$ e0 n" H
- jz exit10 ]8 H0 D' w: X$ W
- mov dx, offset msg_ok
/ K2 @) Q% L4 o* `: X* k7 l4 w - ( _( F; k0 ~9 m' ~
- exit1: mov ah, 09h
9 u; t) X) ^3 m: n: { - int 21h 6 G$ z1 E s7 m' y5 @7 D
- mov ax, 4C00h
$ j) l9 ^! `9 D4 Z) H7 C' C: x5 y, e - int 21h 6 c% @5 G6 j& a! F- S7 ~
- & @6 ?3 N- n! T0 y: b$ Z
- msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,
# n6 e9 o1 z7 C) }8 @) p4 T - "2008-07-01",13, 10, "$" # r& P: e1 a4 [3 F7 a u5 V, ]+ l
- msg_ok db "A20 Enable OK", 13, 10, "$" & Y; z# z$ u/ c
- msg_fail db "A20 Enable FAIL", 13, 10, "$" 6 o& m/ M, `; _ }
8 m& J0 c. M, Y4 m5 }( l- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
3 K* V4 k F, Z' Y2 U - A20_ENABLE: & Y) w4 K7 G& t6 o. A( G+ b& Y
- call A20Write
- [! T1 n* C1 S - jz exit_enable. i9 c9 R4 z( \- d- S! z6 p- E
- : i# x- ~3 y: u
- cli ; Only need for reading value from KBC
0 N( G1 B7 |2 O( g4 m: W# a6 ~ - mov al, 0D0h , f" \; A k/ H6 E) j) e% z$ y
- out 64h, al
3 y0 p6 Q2 x6 _) K5 S - call A20Read * K! E: Y* j! j) [' ` ?0 @; a
- jz enable_int
* a S" Z/ C# K8 x6 N# |
$ X, w/ b8 N$ ^! _0 y3 n* n& B' ^1 p- in al, 60h ; Get current status 8 r: z. N2 D2 Y2 _2 T' C r
- mov ah, al ! A( T: d7 l& s; g9 v
- call A20Write
1 Q! @" w+ k, O& ~7 s& B+ b4 ]$ X - enable_int: sti
' A2 ]' B% o* M ?# r- i, U0 o" \. q - jz exit_enable* V- @8 u" E! J: f" l( S& F
* Z' q$ S! E' ?# H5 T* ~ X- mov al, 0D1h ; Tell the KBC , want to write to the # y1 d$ d9 l& ?' B0 K( O
- out 64h, al ; Out Put Port next 2 {0 l' q: k0 U" c
- call A20Write
4 Y }% H* N3 h/ H* z, q3 p+ O - jz exit_enable
/ {+ L9 f3 Q& O% F - , q7 {: U/ ~$ d8 T1 o5 W) E
- mov al, ah : }4 _5 O" q# J( ?/ Y
- or al, 2 ; Enable line A20 ) r0 k7 z0 [% M. i
- out 60h, al r- }! ? S; {4 p% v& X
- call A20Write 9 _3 _% S6 e% O4 A! z0 q8 O% {
- jz exit_enable3 |: n& W" ~4 n0 i$ J) |
! i) {7 m1 g6 m2 ~8 o2 e- mov al, 0FFh ; NOP : A1 ?: I; p3 s) T6 H
- out 64h, al 6 P) a* j* s5 x; v7 F3 F" L
- call A20Write
5 d& P' w3 t0 l/ v$ B - 4 V2 A( H3 \( j& N& {
- exit_enable: ret
, T3 }+ z. V) q: Q0 G( N* f
* D9 Y+ P2 A% g- A20Write: xor cx, cx ; Reasonable wait
6 E8 h2 I7 S$ b7 k% _6 G - get_wirte: in al, 64h ; Get KBC read status
( [ v' S7 r) ?5 J - test al, 02 ; See if buffer empty, bit 1 clear , [) b( s7 w5 Z. B9 Z% Q# u+ i
- jz clear
7 ]+ Z/ d4 R" [+ ? - dec cx + h+ B6 Q" Q/ z( G
- jz exit_write
" S- y. @3 Y" @/ S4 l8 P5 m - jmp short get_wirte
, ~5 Y* U! z* H6 A4 T# e - clear: inc al ; Clear ZR
% n6 `0 i! o' c; s S/ k+ T - exit_write: ret
( J* ^" l U- O/ H- _8 b4 Q3 }( K - 2 E4 g. m5 i! @, q& M2 N4 o
1 U. l/ t$ Q! v5 x- A20Read: xor cx, cx
$ ?. p: X) t. |* e - get_read: in al, 64h * X8 p4 ?& c' K. ]; u8 W
- test al, 01 ; If the 'output buffer' is full, has ) O% X& ?& \* F
- jnz exit4 ; ... 9 F# r+ T# p" w8 d q# c5 J
- dec cx " b+ g: G% A( _ g% }8 V
- jnz get_read1 s' B; u* o$ t9 B+ V+ Z
- exit4: ret * P* o4 A9 @7 w+ m, ^; t' s( {. O
- ! E+ [& ~( K" n& p" ]( V- W
- end
复制代码- ;A200FF.ASM ! }9 @' `2 t6 B7 q X# D
- ; : u' \, ?# s3 w8 ~8 ^
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-010 N0 A X% f8 ~& `: A, }
- ; ml A20ON.asm
) H" j- @( j& C3 h* Q U- s - ; : a& W( y0 ?. H* c- g2 A" V1 M5 \
- .model tiny
* }" ]: I% V# L2 w; `4 D - .code& c, V3 u2 \. h$ Y
- .486$ [& g7 i3 N4 ~
- .startup
) O, v1 \# Y' e: t
% o% U" g# r5 X8 W* C; R7 e- `8 P- mov dx, offset msg_author) y2 E: s! x4 J" ~1 B3 G5 I
- mov ah, 09h$ n2 N, W. ^" }: U) p7 L
- int 21h
8 J( Q) l$ L; [; K i
4 b; L, X8 J) z, x- mov dx, offset msg_fail
+ d. b2 n( ~# h9 ] - call A20_DISABLE
4 I! h4 G' T* Z! e9 ~5 X( B0 j7 c - jz exit1/ {6 @0 H3 d/ B8 J7 O
- mov dx, offset msg_ok ! q Q* t/ i6 G+ ^
- 6 c/ L% }( {, n8 R' h9 I4 s& V' l+ D- B
- exit1: mov ah, 09h
$ a$ e' f/ J, S6 e0 r, |3 I - int 21h
) C" v5 B( f h+ I - mov ax, 4C00h D+ v- G% ~# ^
- int 21h
1 A# m! t9 Y: W7 \ - 3 {2 {8 X# G- \0 J
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
& J- o, I0 T' W8 K4 M - "2008-07-01",13, 10, "$"
- r6 [; y4 \0 g( x - msg_ok db "A20 Disable OK", 13, 10, "$"
. V6 \% f/ v: ]9 { - msg_fail db "A20 Disable FAIL", 13, 10, "$" S h' {9 w' p# X3 R
. J' W0 @ E' G/ z C, P6 {: |% F- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
' Z- t- r& j2 Y# Y' q& P& l1 K - A20_DISABLE:
0 U# k/ L7 B- F2 ` - call A20Write
( ~% x+ Y: s, g! a" D$ h/ X1 i4 L/ P - jz exit_disable/ P0 S, w4 L: Y8 b
- ( P* B0 \2 o8 K, I x$ I
- cli ; Only need for reading value from KBC ' j$ K* x. ]$ k
- mov al, 0D0h
- x/ m0 P) v' Y! f" z - out 64h, al . Z7 g9 V5 s8 g* L |2 q
- call A20Read
4 M* u% ?% h, T$ H: E8 r - jz Disable_int 1 l m- R, I" T' A" b# Z1 Y0 n
- 7 {/ H) n; I% h# X5 A8 u
- in al, 60h ; Get current status
( d2 V; J0 |' q; U9 m3 c- ` - mov ah, al
( l) c0 u1 K4 Z- ? - call A20Write
6 O' j( ]* A5 j+ y/ ~" r - Disable_int: sti 3 S& I: ^$ [1 K' \' I- n0 @8 m9 J9 _' g
- jz exit_disable3 R8 l$ N% m& {! _- z& M. i* E6 d
- - U x- z7 c7 ^3 L
- mov al, 0D1h ; Tell the KBC , want to write to the
. S) I( p1 [" H8 }, I! C/ b7 T - out 64h, al ; Out Put Port next " P! P; P% T" Q' ?* m
- call A20Write
6 J) Z4 O) }0 j! c - jz exit_disable
2 E( Z; y: q' o/ {. P - ( \7 ^) P2 G1 O6 I7 L
- mov al, ah : b1 g9 l* l( d5 K( ~* F
- and al, not 2 ; Disable line A20 . A! }" S7 }! P# t
- out 60h, al
9 D( P% f$ n9 A r, z - call A20Write 6 f8 s# h4 e2 `) [, z% d1 l
- jz exit_disable
( c# e( Z6 L5 ]# H* q& G - # V7 K$ t' R: p6 i5 n4 s' f% _
- mov al, 0FFh ; NOP : S' v$ h0 l/ f* k$ s- m$ M- G# a
- out 64h, al
. d- S/ M; T* j: Z/ Z - call A20Write 9 n0 v* f6 c+ p9 W0 K( C
! P+ h( \5 T! n' |- exit_disable: ret , q4 p6 R( p; j* \ U- N% {! W
5 n5 E8 ` M. ?& n- A20Write: xor cx, cx ; Reasonable wait % }9 d* U% J% u) f* b# d: K1 ?% u/ D
- get_wirte: in al, 64h ; Get KBC read status 2 Q; Z0 o! C4 E* z1 w5 L: T
- test al, 02 ; See if buffer empty, bit 1 clear
1 A0 G8 L B; e, D - jz clear ( ]( T; S J* K8 }5 n0 b4 p
- dec cx , ~/ Z, S# g4 q8 y$ I# M7 Q
- jz exit_write & o( ]2 f4 s7 s: g+ n
- jmp short get_wirte 0 M0 v/ R2 H" J! O
- clear: inc al ; Clear ZR
9 @3 B* X" O: Y$ d1 | - exit_write: ret * c9 ^8 v2 o" o# w# f# [
) J2 t! R, e) H8 Y3 v( J- 2 f5 S$ \. u% i# e% p7 h, q
- A20Read: xor cx, cx 7 a4 c$ D3 a9 N9 w& |
- get_read: in al, 64h 3 J; p5 [6 z- f" m$ F5 ~: ~
- test al, 01 ; If the 'output buffer' is full, has
8 r1 y9 b* C6 `% V5 @: o - jnz exit4 ; ... & r# h9 z' b. y: I# O; [7 Z6 W
- dec cx 8 C* G+ _% `5 `: e- U
- jnz get_read: ?; r# n6 x" d- }7 O. f# Z4 h9 G+ [
- exit4: ret # v+ {9 ?* l W2 Y& Z( C
-
8 T7 Z, {4 S/ U! ~ - end
复制代码- ;A20STATE.ASM 7 ` k' o; }( ^2 h; l+ d
- ;
# y0 D3 n, K8 C8 I( \. @3 ^ - ; Returns the status of the line A20 through the KBC 1 N/ z6 |; }, A9 Y- ]- f
- ; programming by bini for debug. 2008-07-01
# y1 a* h. d" [/ b; s - ;
) y$ S- N8 q6 k0 x s - .model tiny4 {) F( C0 j2 |8 r* y
- .code1 ~) @) A& e6 J
- .486
' g# W" g+ L) x - .startup
& Y8 a0 [/ u S4 F2 W& c' d9 D: K - mov dx, offset msg_fail ) O$ Y0 R, g9 t4 E
- call _GET_A20_STATE_& H; E( r0 Z: m/ S8 N7 z7 ?
- jz exit1 ; was a problem" b7 W+ x0 N# s& ^% V
- push ax ; Save state, AH # i( o* f% k: t
- mov dx, offset msg_ok ; There wasn't a problem
- ?2 i2 Z! n- s! J6 @5 e2 c - mov ah, 09h ) d4 W5 ?! O/ B( g9 C
- int 21h ; Print message " |! E r5 Q( M% c8 t1 z: q
- pop ax ; retreve state % X0 y$ m7 \6 T7 S: w4 |: v
' j, o& A) E! V( {/ e- mov dx, offset msg_dis
9 B9 D8 H, e. o5 U3 c G" \" q% ^- V - and ah, 00000010b ; bit 1, 2h, indicates state
; g: k/ U' m" n S" C3 I9 { - jz exit1 ) U3 t. H1 G$ r! ^
- mov dx, offset msg_en ' [! Q. L" I' p; t" O0 J- s
$ F+ |' W: h. H" C$ f- exit1: mov ah, 09h
% r2 ]+ X; |6 G9 d8 ], O - ; DX already contains address of string
: {# t7 n$ o5 H) o; @% [- ?2 w - int 21h
8 {' L, Z2 Y0 P* Y& S
. j8 j, r8 N" k& c/ V- mov ax, 4C00h 4 g% a0 _* p( ]& D. D& ^% u
- int 21h
& X+ \1 b- k6 s$ S6 q( r
" v4 C. m5 f* ?0 ?1 x a- msg_ok db "OK", 13, 10, "A20 $" ) b8 ?0 q1 E# p8 N% Z
- msg_fail db "FAIL", 13, 10, "$" 4 E7 ]. M/ o9 T3 ?4 l. r! _( X- Y
- msg_en db "ENABLED", 13, 10, "$" ' y9 B( B- I- w, X5 M, b h
- msg_dis db "DISABLED", 13, 10, "$"" E0 n6 u0 I0 b. v
- : D; U5 ?. U4 w' Z2 K
-
% h" S. c% E0 a! d - _GET_A20_STATE_: $ p$ k! I, l. D; W4 S) z
- call A20Write ; Wait till the input register is empty 3 M! y, k/ q+ T) }2 N) ^/ Y% } x
- jz exit2+1 ; Bypas the reset int's 5 y8 X$ V. d; c4 y
- cli ; Disable ints so we'll get our value ) [& y9 Z2 F+ K3 D
- & j5 q- Y! z$ A# W/ D" n5 D8 a5 a$ B
- mov al, 0D0h ; Send command to the 8042 command register
, |0 l6 D' l% F* ^ - out 64h, al ; to tell it we want to Read the Output Port
' V1 L6 a' J1 o - call A20Read ; Wait till the 8042 output register , Y$ U+ Y: l8 q, M1 X& N& ^
- jz exit2 ; has something in it's buffer ]8 i( h: u2 b0 u
- 1 l2 i; z' \3 [* ?* y( \( f$ R) x
- in al, 60h ; Get it
2 H1 t0 {8 V' X5 D# | p/ E& T' `4 l" ~# @ - mov ah, al
6 Y! @1 X( Z8 ]: @ - call A20Write ; Make sure the input register is empty 2 g% M( z0 f5 [6 i( w6 e2 S
- jz exit2
# l/ I/ i- a/ i! b; Y - ; b% U. x1 Z N% O/ ~+ J
- mov al, 0FFh ; KBC NOP command, does nothing . C' F' u) E, E% g! Y8 w
- out 64h, al
$ F* y) Z$ T9 ~0 U: [! C# l - call A20Write
4 Y5 I' m1 d8 d2 U' R' L4 [
5 b) e5 [$ ^1 a" q+ l0 b- exit2: sti + }7 ~* N4 p4 Q$ b& p
- ret9 I) y% w9 s0 ^, Q8 \# K; N; ~
" W) ^% G' D0 s5 b- - v/ P( q3 M6 t) O
- A20Write: xor cx, cx ; Reasonable wait
- G, [3 ^7 u. {* v! s, p - get1: in al, 64h ; Get KBC read status b; D4 ?* {7 G; ^
- test al, 02 ; See if buffer empty, bit 1 clear * ~% Q: R* o" R! E, J
- jz clear % Y3 D3 k2 z5 u2 d
- dec cx
% A) C4 s) h: b% l# M - jz exit3
7 y# n: M) ]. p$ Z! ^ - jmp SHORT get1
; U$ X1 y) g2 j - clear: inc al ; Clear ZR
8 L$ S9 w4 h. d. z' K. _! N7 ` - exit3: ret
. M3 F8 J$ Y5 t# \/ ]
! Y$ f. E- D' Q: v: a* r
; A; B: k3 Y4 J7 @) G- z) @2 T* v- A20Read: xor cx, cx ; o) }# L! i0 F6 {) d' H
- get2: in al, 64h
9 R* ^( [- V4 `. v' c - test al, 01 ; If the 'output buffer' is full, has % Y2 f$ f) r8 a: Y' w N/ P3 b0 c
- jnz exit4 ; something for me * ]4 \! R2 u" e9 l. }. q' w+ b- o0 l
- dec cx
: f( D3 b1 X1 d7 c3 Z; ~ - jnz get2
3 y: r3 y+ y7 ?3 N4 ]! R. X+ G* B - exit4: ret + W/ W, D( r* R* N9 h& Y, ?
- $ i5 ]9 b" H, s- d
- end
复制代码 |
|