|
|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM
9 E1 V! S# d3 p( V0 D - ; 0 }! V$ ?- E/ j$ {9 _2 k
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
4 ~* q0 M ]7 J- ^) o - ; ml A20ON.asm
0 v+ @ i' R/ ^' I! g5 B* L0 X - ;
+ k: |" q5 ?7 L; w& c - .model tiny+ m" ~# J) ^. A4 i
- .code6 n# {7 U; D% ^
- .486% G P: ^! E' l! Y8 Z1 w7 `* @6 y5 d' u
- .startup
9 l; O& @/ _% \; Q3 |, {. P6 w) x - - r# ?! T: @2 r! v4 @
- mov dx, offset msg_author
/ Y% G1 e1 G3 {2 ?/ s8 K - mov ah, 09h
0 T" G, k: W, ?$ [ - int 21h
% m R# a$ x3 @. F3 Y0 z
M1 n# D) i% y" {% S5 D. ]- mov dx, offset msg_fail
/ H" s6 C* v3 F0 u5 A# n* F: e5 \) O - call A20_ENABLE
. A3 ^- q; c; L/ u( T0 N3 I - jz exit11 h1 G. S( O& w+ e1 _
- mov dx, offset msg_ok
$ ?. [% q2 @( {# D - / t" o" T6 ?# ~8 N8 Q1 g0 ^# @
- exit1: mov ah, 09h # ^9 f q: i# s8 X! F
- int 21h 4 `1 f7 M2 h' [0 p: w$ P
- mov ax, 4C00h
4 T6 i3 Y! H/ F% {$ ]( z) m" c - int 21h # C; D6 g- D) b; t
-
- L$ ?! [+ T+ z: Z4 _ - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,% ]$ E+ T- }$ n. o# v6 E2 J* d) B# r
- "2008-07-01",13, 10, "$"
' G$ w8 f3 V; W; N7 [% L - msg_ok db "A20 Enable OK", 13, 10, "$"
W: Z, D/ u% o8 n9 K; }: ]6 T0 r - msg_fail db "A20 Enable FAIL", 13, 10, "$"
4 W% _ _0 ~0 ?! s
9 R' r9 A/ [! ?& S( m* O( [, ?: h- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
) d, o1 q5 A" y4 ]: u$ V - A20_ENABLE:
" p8 s, o+ z% D( V4 F/ w - call A20Write % E9 |! I3 Y5 T* O
- jz exit_enable
& y9 s! s1 Y9 Y# o/ m2 ^ - 0 M8 Q5 K0 j4 F$ {% G3 |: M$ _# B
- cli ; Only need for reading value from KBC c# ^7 Y% {+ Q. S7 K0 G
- mov al, 0D0h
6 _: w( `7 [/ P1 C4 l - out 64h, al
- o3 |. j& ^. t8 N2 j - call A20Read
: X) g3 m$ |: N+ c, e) G/ } - jz enable_int , ?& @% c* _; q+ R4 Q
5 o/ s- w6 V1 Y5 K- in al, 60h ; Get current status ]/ U( X6 F1 D
- mov ah, al
( v, ~2 i! Y$ F7 Y+ L, w - call A20Write ' F3 z: W8 F) K2 j/ D1 m5 L
- enable_int: sti
, \9 [& S$ f4 M2 I3 A7 c0 t. V - jz exit_enable7 x1 E$ o8 p7 n; \( d2 i
8 j+ _- t1 d1 [- mov al, 0D1h ; Tell the KBC , want to write to the " e) {, ]2 X. ?5 q5 c
- out 64h, al ; Out Put Port next
& e# v9 ~+ j* O" u. F - call A20Write
' h" e' c$ T8 z( M1 {) ~& B8 ` - jz exit_enable
; Z( u* T. i$ p( s6 E' l& \$ v - . T! _4 v" Q( J; q8 n/ M
- mov al, ah 3 [8 e @& E: x$ D j
- or al, 2 ; Enable line A20
6 T: P5 c6 M! c0 @6 |* E& L# \ - out 60h, al
, b9 w& {6 N9 t, J! [1 Q - call A20Write : A* {/ N0 s# o" h- c
- jz exit_enable
* A4 h4 X; x7 j% c6 u j" ^: ?
+ L4 b: R" t0 a+ [$ }7 Y W3 n- mov al, 0FFh ; NOP - |# H1 Z+ |% D' K c/ p
- out 64h, al
+ V8 L+ ?* U9 q% O' q& F - call A20Write % \$ ?( J* G F: l, w
- 7 v( f7 m5 J5 P4 \+ I
- exit_enable: ret
5 d6 d& J. f" `$ g2 }$ W - 9 R H3 C1 i/ h2 [+ Y
- A20Write: xor cx, cx ; Reasonable wait
) M k: y& v! e- w0 K/ } - get_wirte: in al, 64h ; Get KBC read status 6 ?$ z; ?$ |7 [1 D0 X
- test al, 02 ; See if buffer empty, bit 1 clear
. [2 B) C m; J* D - jz clear
/ l; K0 v7 L }4 f1 Q8 p, z2 K% K - dec cx - H1 Z2 w. S4 J
- jz exit_write
4 U& P; x- E: y2 Z4 g: A0 t1 \. m - jmp short get_wirte 7 V. A: i3 m2 f0 h" z+ p
- clear: inc al ; Clear ZR
: C) O* L* K5 t - exit_write: ret
! T' |/ f. m; g' F f' o
* c6 ^* w. N9 Y/ U0 g- ]
g8 O" A; `& }- A20Read: xor cx, cx
# U7 U6 L# I/ s ?3 U - get_read: in al, 64h " v1 O6 r! c7 v6 T0 _) D# D, }
- test al, 01 ; If the 'output buffer' is full, has
' O: i& Z# F: E$ o - jnz exit4 ; ... ! h7 x- Z0 _9 i0 q# {# ?
- dec cx & I2 N$ G+ ?3 D: O# n7 n! Q
- jnz get_read5 o7 ?$ J7 h4 h7 m" ?5 w3 T$ A; ]
- exit4: ret ! X; [$ @, o: q5 Q$ X6 P; ?8 `5 u
- " t8 o. _' u$ K3 R* n
- end
复制代码- ;A200FF.ASM
s) D5 a5 f5 q - ; ; E9 O2 q1 J% [: [3 B8 P0 J& s
- ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-018 w- T2 Q+ M( X
- ; ml A20ON.asm , Q7 X, a1 A! D) s- f9 d$ u( T
- ;
9 \5 P/ B8 @4 s- ^! u: _# | - .model tiny! Y' \# L. r, G% J) |7 `
- .code
D @1 y) ^4 v - .4865 P, z6 k/ W7 T7 e
- .startup0 ^; a2 k) z x* ?
- ! ?) a F8 X9 F8 R1 n `6 v, D2 ^% y
- mov dx, offset msg_author
2 x4 h0 j4 ]# v \; ]1 L7 @4 I - mov ah, 09h' }- x3 t7 e9 M$ y
- int 21h- h3 Z8 ^* ~- S* d. M
- % |6 {) Z/ L, g2 X
- mov dx, offset msg_fail
; f# F0 h: }! a1 k( g y& S - call A20_DISABLE
/ G3 ?5 C2 ~3 f5 }2 e6 J - jz exit1& Y9 H0 e3 M! A: @
- mov dx, offset msg_ok
6 E( a5 D( P- P+ L3 y/ R! k - $ Z4 H' Y5 |. I, N6 n
- exit1: mov ah, 09h
) b/ R8 m& f' G0 M$ w. X7 ^# o - int 21h
4 c1 H9 c- x) @- b* e5 h1 V - mov ax, 4C00h
# {+ E) g4 F7 p" I - int 21h
6 C" Z$ h) ^( V, s - * Q4 r2 A P8 [0 U# N
- msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10, m2 S. Y4 @( ^' G
- "2008-07-01",13, 10, "$" , g5 `& E3 u+ j- K
- msg_ok db "A20 Disable OK", 13, 10, "$"
$ R! f d# ~9 k! T - msg_fail db "A20 Disable FAIL", 13, 10, "$"
4 ^: w5 ?% |5 ]* k; {/ R- d - 1 z' P2 n; s9 F7 R
- ;------------------------ follow code maybe make to lib, if you want...------------------------------- }$ @' ~/ w" S! E7 C; z \1 ^
- A20_DISABLE:
# B6 l7 {4 H$ Q& Z9 M - call A20Write
0 }9 |$ o( q3 _- \0 h- q" r - jz exit_disable
4 p# q' F6 \9 W+ T" d2 E. L - - X% g$ k n: @! o
- cli ; Only need for reading value from KBC 4 I% V9 u/ I; k J
- mov al, 0D0h
2 ?5 ?3 W5 I0 Z! i) W* M5 z4 z - out 64h, al 5 b# l$ a4 G0 o) h% _0 y0 w' |
- call A20Read " o0 D- h, p7 g+ p e
- jz Disable_int
4 z" P" `3 U% \8 x; u! G - ; N5 s! i6 O* W4 |! V' {& y
- in al, 60h ; Get current status
& X6 s; f9 U- {+ O8 ]8 T% R - mov ah, al
5 h5 S8 |) L' F z - call A20Write
2 D6 C9 F$ z* g2 H9 Q8 `; v - Disable_int: sti
$ f3 K9 d2 w5 g - jz exit_disable
; E" G& D8 I5 O8 W K$ j
5 O# e' f8 H+ K% w+ {- mov al, 0D1h ; Tell the KBC , want to write to the
% K! d" U6 i; S" {0 @ - out 64h, al ; Out Put Port next
4 N F. Z- F0 R6 K- O - call A20Write / j9 r; |/ \, ~' K
- jz exit_disable2 v6 N. K1 B/ R* \7 U' o
- / H$ ?2 t; N0 e( c1 `; o% \3 e
- mov al, ah 1 J6 e) v( p0 }; i. D6 `5 f
- and al, not 2 ; Disable line A20 3 k+ Y6 y( z$ z8 d
- out 60h, al
, h9 S8 f/ x! S. ?# z6 R# d0 x - call A20Write
Y) g) r' S% e8 }! g. K - jz exit_disable
+ G1 E+ g3 x9 G; e - # Z9 C0 [1 G0 K" N8 M
- mov al, 0FFh ; NOP x* v1 t; F9 A
- out 64h, al / V4 n$ ]' _0 j/ E& H$ g% {
- call A20Write 8 [) q/ Z' n- {# M$ F9 h! ]/ v
- - g. I8 j1 K7 |% \
- exit_disable: ret " R. j* w, ^; E) U. S" E1 E
- ; I' R* c' e1 d6 S. Q
- A20Write: xor cx, cx ; Reasonable wait & t" n) k/ ?3 x5 e) s
- get_wirte: in al, 64h ; Get KBC read status
! @6 J2 `" S+ {4 F5 I- W* u - test al, 02 ; See if buffer empty, bit 1 clear + M! [( l4 A1 S* Q
- jz clear
3 c9 U# Z" t' x; X$ h+ } - dec cx 9 Y: A8 W. I! i$ l
- jz exit_write ( |0 X- Y* ~9 J) }4 b4 p4 Y% _
- jmp short get_wirte
( I0 c- @4 G6 J Z! m: B* J1 F - clear: inc al ; Clear ZR & C: U2 f( N3 m' x: @1 S
- exit_write: ret
3 d" u, J# c# p8 } - ' x9 W, l# T' z* t& o* c K% t
- ( a3 X8 f3 U) a8 i1 h4 |' T
- A20Read: xor cx, cx ( O9 H$ [6 P9 V1 o6 I4 g
- get_read: in al, 64h ' [- w; b5 Q2 s' k z2 m) @! P
- test al, 01 ; If the 'output buffer' is full, has 1 l; X1 [9 Z8 l/ Y+ y6 c4 G
- jnz exit4 ; ...
, J! o0 d' Q$ V/ ~( \2 S3 u - dec cx " _# Y# Y7 Y' K/ D+ P
- jnz get_read+ B% p( Z4 I: T9 z* O
- exit4: ret * T ^" C* ]/ O% x: l" {$ y
-
* H3 a+ F( K$ V% O% a( V - end
复制代码- ;A20STATE.ASM 0 |% [5 M* Y6 r& ^" `* { ^- {" @
- ; ( @) u+ l: | I
- ; Returns the status of the line A20 through the KBC
( D' O' S) J5 l6 M0 r7 D - ; programming by bini for debug. 2008-07-01
9 O# u f9 G6 P- @+ P B9 F - ;
5 S% ]$ U; S% b4 w4 { - .model tiny! ~! N5 t9 B C3 F5 P/ L
- .code
+ |, Y8 ~( m, z0 h: V - .486
( g6 o! v3 X$ @ - .startup: m/ ~6 J6 T( X
- mov dx, offset msg_fail
! [* R' K( Y: N3 Y" S" n: p2 z - call _GET_A20_STATE_
! a( T/ l& O. c/ \3 i9 Y - jz exit1 ; was a problem# [# t! i8 @" j$ U @" d
- push ax ; Save state, AH
( P7 P0 W* E! b- A - mov dx, offset msg_ok ; There wasn't a problem 4 S4 Z' @ Q X k% _. e1 `
- mov ah, 09h
0 @6 a4 o' O- Z; h! W( o9 _ - int 21h ; Print message
2 f- T* s' w: Q$ {- q" a+ ?/ v2 Z1 g - pop ax ; retreve state ' |1 `" q$ w+ q F: S2 l( o
- 2 _0 O3 P8 b6 U2 B8 {# O
- mov dx, offset msg_dis
: l8 G4 ?) @5 I - and ah, 00000010b ; bit 1, 2h, indicates state $ W* m- ?5 d3 }( c/ Q3 q& I
- jz exit1
9 O2 n" g1 c% F) F - mov dx, offset msg_en 4 p. p" Z0 e; h
f3 V0 D3 R5 ]' x% I- exit1: mov ah, 09h
. Q, A$ g+ c( s+ l - ; DX already contains address of string
$ ~% F5 T/ F' M4 x% T+ z - int 21h
! [, Y- R1 D) [ - 3 |5 g( K) u- {& b2 `$ c
- mov ax, 4C00h 0 [. E2 r: i8 b& C5 t
- int 21h ! h+ K) Y8 X! v. ~6 Y
- % S1 m$ T; @3 D, g
- msg_ok db "OK", 13, 10, "A20 $"
; Z# c$ J' w( N: a0 l - msg_fail db "FAIL", 13, 10, "$"
/ X, D' N$ g( U, ?- _9 _4 e - msg_en db "ENABLED", 13, 10, "$"
( _- l* a+ I, A, B, e& U5 r# Q - msg_dis db "DISABLED", 13, 10, "$"
0 |8 C& ^ _2 i1 T5 W0 O0 _& d - * o0 i) [; |4 | a. T O
-
$ u4 V: d+ s" D2 F Y8 N. J - _GET_A20_STATE_: , C( f% l0 `. d B3 ~
- call A20Write ; Wait till the input register is empty 1 H8 L; \9 c" n. p) W, a
- jz exit2+1 ; Bypas the reset int's
+ D1 n" l9 {+ {1 [/ I% e - cli ; Disable ints so we'll get our value
) S. ~% r* ?- x ?
5 y; D1 F2 K. d0 E% d& m: O- mov al, 0D0h ; Send command to the 8042 command register . D) t" K! X( |* ?8 I9 v9 ~2 F
- out 64h, al ; to tell it we want to Read the Output Port
, P3 {6 |" U4 w7 w5 |6 c9 Z. h - call A20Read ; Wait till the 8042 output register K" d% K& | i. j
- jz exit2 ; has something in it's buffer
$ i1 z% J- B7 ~7 ~5 I, _7 ~! t, k - ) Z4 K, S( G! x4 N8 _( V4 e, _5 v( R
- in al, 60h ; Get it
! h N! l: g1 z. i - mov ah, al
# ]* Z7 P2 a. q$ } - call A20Write ; Make sure the input register is empty 3 Q, g% k0 W+ L7 h# Q! c6 P
- jz exit2 $ a, _' i' V$ ~' Z2 S$ B& k
) _, [, S: t$ P) f% Y7 H$ u8 m- mov al, 0FFh ; KBC NOP command, does nothing
: P5 j9 `* b, F/ K2 u - out 64h, al
3 f' y/ @* t, u# H* Y; z1 s4 Y) ~ - call A20Write 0 O" e# s9 _7 l1 g* ?( \
& y! Z9 f+ ?7 _+ l, j- exit2: sti
' a6 W* h( f8 V) @ o A+ R - ret
2 {: E$ g& t" n - 3 _; A7 G {: E) k
- & h) O) v) x( V: K. Y$ t; k0 \
- A20Write: xor cx, cx ; Reasonable wait ; R* Q7 r7 y( P1 S9 k o
- get1: in al, 64h ; Get KBC read status
3 y5 }; X7 W- k" | - test al, 02 ; See if buffer empty, bit 1 clear . @4 K5 {6 @: }2 g% H
- jz clear
% ~, l% r+ C _ O4 F4 ?6 M2 N- c+ J - dec cx , g3 @* L9 Y+ u7 k, T
- jz exit3 / T7 r' N; _# o6 |/ x7 X
- jmp SHORT get1
' B6 W: }0 \( Q8 M9 y: a - clear: inc al ; Clear ZR
1 A( H1 @& f% g* [7 d - exit3: ret " @1 X5 i' y! n1 u8 V
+ P/ h5 F; [5 L# K7 M- 3 t7 q* x0 J- u5 \2 R) [3 `
- A20Read: xor cx, cx ; Q1 K+ r5 g3 V1 j
- get2: in al, 64h
- K/ h/ u4 s7 y4 O" o$ w6 y - test al, 01 ; If the 'output buffer' is full, has
* B" O( n2 g! v - jnz exit4 ; something for me 3 g# _/ k0 N* B- d
- dec cx
0 i2 J( u' h3 x/ _3 f& u9 ^4 ^$ a p - jnz get2
! p4 C8 ~. m: X% \1 G3 ?/ P | - exit4: ret ( T5 Q* J& b, d+ Z U
- & o, W" o$ _% o4 ]1 k# [
- end
复制代码 |
|