|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
: N% Q# M0 ^' G3 w3 t - ; 9 s2 l) ]* T, H+ s- z+ Q
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01/ c3 ?9 @6 l5 I: k2 Y! F
- ; ml A20ON.asm 5 }6 U" `) ]) z5 q# C* [( b4 d/ _
- ;
! r) D% e" {9 G+ L+ I' p - .model tiny5 i% D' }& b" _% l! o1 m$ O
- .code# V* a/ \% `! [3 F2 b
- .486" _8 i; p/ `- q8 b! ?: G. O$ m {* O
- .startup( I, j9 f+ x6 O: V h
- ; {1 A9 @. E- D. [8 w
- mov dx, offset msg_author+ e) i$ w4 z, l, P4 h$ d2 P
- mov ah, 09h
; E, v- N. ^* C- e: N - int 21h
) y% d: T }+ \% e! g0 q
2 Q" [9 V v! Z6 e, g/ m- mov dx, offset msg_fail 8 r; ~! ]$ q/ s, u$ L" P
- call A20_ENABLE
% Z, {5 j: }6 ]. b; ~% l - jz exit1/ C! L. o- x6 Z( I* H4 U. z
- mov dx, offset msg_ok , K5 _& ^! a Z7 B s7 i# O: Y0 K
- - |) k5 `( R5 x# p& P; n
- exit1: mov ah, 09h $ I7 g/ l" H; p3 L' w. N
- int 21h
0 _& L' j: ^) K- M' \1 N - mov ax, 4C00h
, I8 p! I. Z% [* x - int 21h
% M' C, T5 C) F -
7 T: {2 I* d' ?8 { - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,# P. u2 s, T( U6 N o
- "2008-07-01",13, 10, "$" 1 g0 e& f0 b8 l9 }
- msg_ok db "A20 Enable OK", 13, 10, "$" + p2 ~( c3 G# J8 l! x- ~
- msg_fail db "A20 Enable FAIL", 13, 10, "$" ( z1 S$ r z; a4 B4 U
- * p) X* i9 v! Y. {1 j
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------' }1 c, @1 M$ ` y% `8 m
- A20_ENABLE:
+ T8 q. A+ ?2 G - call A20Write ( d {4 h E$ X7 p
- jz exit_enable# O O) [' Z# q. y6 ]+ A
- 1 d+ g* Z. s! ^* z9 P$ m& n
- cli ; Only need for reading value from KBC
: \0 Z# \' T7 } - mov al, 0D0h
% _( b( R+ ]: w. b9 I2 @# ?% h$ B4 P. t - out 64h, al
3 Q0 f" j: n! B4 t7 J% Z i6 M, v% j - call A20Read
/ }8 ~7 @4 V: P- ]6 e' G! Z - jz enable_int
" P" {" c" G# ?2 T
5 a0 a5 T0 N+ d' S; i- in al, 60h ; Get current status
% `5 W0 F* C# ^$ U* w9 l% Y- _8 s - mov ah, al
+ Y* P9 y& ]2 ?3 s& b0 E+ ? - call A20Write b: N4 ^- K9 I; N# _: X' N+ F
- enable_int: sti
y6 l4 Z0 Q) q0 A2 j1 {' T& F - jz exit_enable
6 o; ~5 L0 [0 t* ` \
$ [3 Z8 I( E+ Q9 H# y- mov al, 0D1h ; Tell the KBC , want to write to the / L( ^3 W% X9 q* Z% F G [- u4 E! k
- out 64h, al ; Out Put Port next ! r: [5 {( t6 m8 {6 K, z$ D" @: P
- call A20Write 5 c: k+ \2 U7 z/ c4 X4 Y
- jz exit_enable
+ j3 k5 T3 m! Z, n+ s4 |
" [3 M4 q7 C" N g k) Q$ w- mov al, ah
. w" U* j; x8 v; }3 I' o. ]+ m - or al, 2 ; Enable line A20
5 Q- p# ]; N2 \- J/ O1 s# E( m9 g) | - out 60h, al ?/ m& m. w/ G1 l; [, Q
- call A20Write
7 O& V0 N) L0 [$ s* r. F) ` - jz exit_enable# {( q3 I8 C9 w& Z# S' }) p8 C
- " r) D8 P1 l x2 m$ g( N
- mov al, 0FFh ; NOP
+ |$ X: o( o& q8 r) K' R - out 64h, al
) \3 b$ i' q8 k& k+ ~+ t6 ~ - call A20Write
2 B+ W4 o# {! |+ [( M - ) R" L, x: B/ U8 F6 D" r
- exit_enable: ret
( D" b" |* G e0 l. w
: R% C0 c( M9 l9 ^# c8 h% t9 ]- A20Write: xor cx, cx ; Reasonable wait * z; T+ I9 \4 A; G' }: Z
- get_wirte: in al, 64h ; Get KBC read status & e& Q2 t" S) N: k7 G; T
- test al, 02 ; See if buffer empty, bit 1 clear 8 P* e! z6 U' y8 R8 y' P# l
- jz clear + a5 V. r7 l$ y* ]) h( m( G9 b2 ]
- dec cx
. @: f- \# {9 V - jz exit_write
, `7 L& T. ~0 B# ?& } - jmp short get_wirte 0 P+ t4 B" p3 y. h4 N9 x
- clear: inc al ; Clear ZR / z9 a: X' ^' _4 o; K% w% q* u
- exit_write: ret 3 `5 } K; {% _: x' o! [ q" c8 X
- 3 H0 x/ m4 d8 L! l3 _
- p. T4 Z& x {2 Z8 c& g
- A20Read: xor cx, cx
4 {# a4 q% r( h5 b2 w' y& }3 o - get_read: in al, 64h
3 U5 Z1 }" m5 \, f8 C) j% E1 z - test al, 01 ; If the 'output buffer' is full, has
& o' ~! M) |! d8 F/ @, h" k6 k - jnz exit4 ; ... & f. _' l% x, X; ?6 Z9 F9 p
- dec cx
; K+ o" ]# F+ K( j) v6 v1 [7 H - jnz get_read
( N5 Z& K7 i/ e" ], n - exit4: ret 6 ~3 n6 h* @' O
- , ~9 @7 a0 q, a6 v
- end
复制代码- ;A200FF.ASM * z% M/ B2 [1 i4 A# v Y& S( O
- ; 3 m: Y1 G, C+ D- }9 l' C( G+ K1 q: z! W
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-01
7 `$ h% L( U% s" c$ `( `! f: l - ; ml A20ON.asm
7 Q1 i0 W- P9 U# s - ; 4 i8 y* K7 G. f* a5 A8 Q8 ]- j
- .model tiny! d# F7 C# Y; J) v L
- .code
' |; F5 W2 I- \/ O - .486 L% Z* e3 F) E8 I/ x" R7 @
- .startup: g$ ~+ h6 r- w3 Z. t) K. \
- * K8 l* U. ?: @& \5 N6 p2 L
- mov dx, offset msg_author
% ~/ F$ h# M1 s8 y2 J6 W0 Z - mov ah, 09h% y4 ^7 e& P1 {' J: c, s
- int 21h' ~5 _" m6 X( A2 }/ M8 T* {: i
/ H# z3 \* j0 x* j6 b5 D- mov dx, offset msg_fail * b9 X' W, P" L; r# s
- call A20_DISABLE
, s' s( G( r. N2 s2 c - jz exit1
6 w0 b& t7 X5 J8 L - mov dx, offset msg_ok / d& O+ l: o2 d2 C0 s* P
/ |! `# H, W8 z9 j7 e- exit1: mov ah, 09h : U& w* a. O; ~" k
- int 21h
2 s4 a( V/ M0 V' c8 J - mov ax, 4C00h
% `2 C7 Q1 z) Q* X3 m7 \ - int 21h
/ n( j& P( I a2 X$ p, d# c -
) ~# o3 `. L( u+ F - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
5 O- l7 X1 B5 v, F3 o# @1 B - "2008-07-01",13, 10, "$" 5 L/ M& k2 U# G$ x+ J
- msg_ok db "A20 Disable OK", 13, 10, "$"
$ u! d2 Z8 J2 _3 O M4 m+ T0 z1 q - msg_fail db "A20 Disable FAIL", 13, 10, "$" / n7 t, D2 c; v- D$ F; j
- 6 ^5 n9 V0 _2 x' O: W. y& g2 k* s) e
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
* T7 a' ^8 z. z% u% D4 [$ F0 K - A20_DISABLE:
% U* T6 g2 K: E! u3 A& o! e - call A20Write
% D5 x6 t. M3 i8 u3 Y0 D - jz exit_disable% p; M5 N, r+ q0 x9 y1 c5 L, w
- & h% v4 _0 t7 p4 i
- cli ; Only need for reading value from KBC
% K0 m* U2 [0 @+ P2 K - mov al, 0D0h
- @ p4 g' I) ] Q6 k' F2 ^7 A - out 64h, al $ u$ E* S1 m! V* x4 n: I6 c
- call A20Read
6 g$ B% m- r# z( Q; u! Q. S" T - jz Disable_int + z! g/ Q2 v, I2 q, m8 O
- : A' n, y) p! o5 D/ _
- in al, 60h ; Get current status
# M# S7 b$ @+ N% f* x$ o - mov ah, al
# w! {) s+ J3 e) @5 I1 _2 t9 |+ { - call A20Write
( A# R* {! l8 ~- a! M - Disable_int: sti : m- |" V" l( d3 _. |: z$ o. x0 A4 i
- jz exit_disable
) L3 f; q( }2 k1 Y6 p4 D: d
4 p2 |! I8 s( V$ E$ ~7 B- mov al, 0D1h ; Tell the KBC , want to write to the
/ n5 _2 x9 S8 a7 f- t1 \4 g - out 64h, al ; Out Put Port next
. {; p7 n9 Q8 T; n3 A4 g7 ~ - call A20Write
& O% A' e3 f: d/ D( ~( S& E - jz exit_disable: B, n) ^9 z, N' C
- & d: Z0 a! h$ b8 O& k
- mov al, ah % n% `; L- _1 k4 f8 G- `- {
- and al, not 2 ; Disable line A20 # k' h( f( p+ [5 }
- out 60h, al
, F3 W' k+ R- t - call A20Write & [8 {9 ]1 m3 R* P2 ^5 K& O8 k: g
- jz exit_disable" n5 u! U/ f# M O5 i2 n
- - x& [5 Z, i3 _/ H$ W
- mov al, 0FFh ; NOP ; N8 c9 R) d8 K$ q6 E: o
- out 64h, al 3 p0 t8 W4 A" S4 a# g( m0 M
- call A20Write
8 G Z3 }# L4 q% a* L9 i
& t2 ^1 k' T$ x9 i2 [- exit_disable: ret 4 |' F7 ^9 Y5 |
/ S" @$ `# ^# w& Y: X @2 M; f- A20Write: xor cx, cx ; Reasonable wait 0 ~* W. `7 X9 g% z4 b+ S, ^
- get_wirte: in al, 64h ; Get KBC read status 2 Y H. b1 k2 @9 B# J8 }$ o
- test al, 02 ; See if buffer empty, bit 1 clear
" }8 {9 G9 x4 G z F# b - jz clear # d* k3 z6 {" y/ M9 ?
- dec cx
: D; `1 g! j K+ Y/ X) j X8 c - jz exit_write ) w; ~7 d' c3 f; _& H8 N$ u
- jmp short get_wirte
5 r& C2 T5 U& y/ Z' z8 d/ k' i2 p4 T - clear: inc al ; Clear ZR + z7 W ?6 H; r: s
- exit_write: ret
6 B2 b: X/ N! n, D3 e) g - 1 f s. m& r& Z, [
- 3 R' V' _: G" r! M' [, U/ [
- A20Read: xor cx, cx
, U$ k4 Q: M! _ - get_read: in al, 64h 2 {/ ?$ l' R( b/ J+ o: S0 e( f
- test al, 01 ; If the 'output buffer' is full, has
3 T+ ~) A( K/ v$ w$ ^ - jnz exit4 ; ... ; T" N. C; \$ p# \8 e
- dec cx 7 K6 d) @- S; V
- jnz get_read
" A% A) @( q& W5 M% r - exit4: ret
4 r, l- |0 Y4 F7 {) V! O+ M -
7 @) G/ i- K) c+ o - end
复制代码- ;A20STATE.ASM 1 y6 I: E8 _) e. n A* O2 ~; o( z- F
- ; 1 k& `4 r# }, f7 y$ x' C! O) H+ J
- ; Returns the status of the line A20 through the KBC
y E" d+ `* b; j$ N/ o - ; programming by bini for debug. 2008-07-011 U& ^% V$ V* a" W
- ; ; a7 M5 B; g L' e5 a' C
- .model tiny3 l- N2 g7 L& ~/ W, B5 ^/ N! y) s
- .code
7 v* v( T7 b7 Q - .486
+ Q3 s0 I3 w Y n0 y' m - .startup
! { e4 V- A7 L( D$ X2 E$ [ - mov dx, offset msg_fail
5 D2 ?0 k2 I% {1 \7 } - call _GET_A20_STATE_
8 C* `, W2 u8 Y+ L, u5 }! G: V - jz exit1 ; was a problem& b3 T. s/ q" a# u" A4 @- p2 m
- push ax ; Save state, AH
: A8 J2 D( B) S9 N% M" }! D- W% c - mov dx, offset msg_ok ; There wasn't a problem
/ Y a( S a0 v. \2 o - mov ah, 09h
3 Q0 G9 n5 d- w& k - int 21h ; Print message p) z1 v8 `6 u! G/ z
- pop ax ; retreve state
" m9 Z6 H$ Y/ p, A- | - ) x' U/ ]5 X+ b
- mov dx, offset msg_dis & R; Y# X' r0 N2 j0 e% I
- and ah, 00000010b ; bit 1, 2h, indicates state
1 K! J& V1 W: H; _4 Y) n$ C - jz exit1
. K3 ?/ I8 A4 I6 b6 y - mov dx, offset msg_en c2 z U! j3 r8 o! a
# J' {8 q# Q* v T; `0 M- exit1: mov ah, 09h
8 A- n1 y& B: \7 A, E - ; DX already contains address of string
* H4 `0 l* b) `0 Y5 e - int 21h 2 e7 f: Y& k Z+ ~) z
) K' H5 Z6 E2 T- m# k- mov ax, 4C00h 0 A1 ^5 ]% I2 v; R, }6 M8 Q
- int 21h . K3 d4 ~7 B8 i# S6 D
' x6 _9 S, E4 N! |% `8 E# w7 G- msg_ok db "OK", 13, 10, "A20 $"
; r% i7 L/ o$ q" R( R1 Y( ^- ~: @ - msg_fail db "FAIL", 13, 10, "$" ; G, z( P& s, k' S) d
- msg_en db "ENABLED", 13, 10, "$" ; I" g! F/ `% m" b- O2 x
- msg_dis db "DISABLED", 13, 10, "$"- Z4 N" d5 V, T) b, X; z z
/ T% I; p. N' j4 L2 a" k) n9 p- / |% L) O, V8 w" k* I; v
- _GET_A20_STATE_:
3 P; {/ I" }& z. u; d - call A20Write ; Wait till the input register is empty
9 T7 u3 y% F) p - jz exit2+1 ; Bypas the reset int's
7 ?- A# x) Z4 a; z3 ^ - cli ; Disable ints so we'll get our value ]6 f/ F% i1 t/ S
- $ W' C5 F, c0 t7 C9 C$ {' W
- mov al, 0D0h ; Send command to the 8042 command register 6 f9 k% E$ _, Y
- out 64h, al ; to tell it we want to Read the Output Port 4 j! c- A4 x5 M$ h @
- call A20Read ; Wait till the 8042 output register 5 k- Q- a; b7 l! h2 u" K+ a
- jz exit2 ; has something in it's buffer 2 T; \3 P. ?, g6 H% h; A. @
6 |+ k% W4 Z- D6 Z- in al, 60h ; Get it 3 o7 r. H8 I5 A0 F& j. Z3 s
- mov ah, al " ?1 x9 ^; K6 F/ e
- call A20Write ; Make sure the input register is empty
' }' H+ m8 |! l, `+ L7 X - jz exit2 % O/ e V. o+ G( K! ^
- - r! o+ A% ]8 K F& Z
- mov al, 0FFh ; KBC NOP command, does nothing ! M/ \1 }" U4 t# \
- out 64h, al
* Z- l9 n8 M- U - call A20Write ) ]+ ^2 \7 m' d! G: r
- + W% M4 L, |1 y( u1 y
- exit2: sti 0 H8 r1 V6 e1 Z% x3 U Q, N
- ret
* f% {; U1 I: l# U - 5 U: e% c* V& j0 I# U `9 [; l: W
- 0 S% T" P" X& H# _0 r
- A20Write: xor cx, cx ; Reasonable wait ' {: b1 r& U3 e4 Y7 h
- get1: in al, 64h ; Get KBC read status & j6 P! C) ]0 K# N
- test al, 02 ; See if buffer empty, bit 1 clear t7 W$ S2 W# r- A( ?0 T
- jz clear
8 Q' q3 `" ]4 A; ~ - dec cx 2 F5 _/ C `9 I( @2 Z' O
- jz exit3
( ~, [/ S6 J9 P- p; x: c - jmp SHORT get1 0 ?- M5 b2 U: N6 H) [9 w
- clear: inc al ; Clear ZR
$ T1 q j% v8 L4 p: B - exit3: ret
! d: o5 e, Y9 \3 k" e, j1 I( K* A% o - # o( ]* ]/ B Q: t4 Q! M" K
- * _6 p/ g# g/ A, g- k8 F2 Q
- A20Read: xor cx, cx
3 @& @- P! Z1 o; ]3 u( y( l8 i - get2: in al, 64h
5 q* Y% v! |4 Z5 J) w3 P - test al, 01 ; If the 'output buffer' is full, has
* z1 g. m) u6 e# L - jnz exit4 ; something for me
8 U% M, h( i {/ u: F5 B" k- I: P - dec cx + R) r- J0 v( z' |4 ~# v; V
- jnz get2$ V6 D" m. W/ B0 v
- exit4: ret ! b$ e# e$ W5 m( R9 @
-
: B* x/ j% }8 I l, N3 h5 \ - end
复制代码 |
|