|
反正图方便的,就拿去参照,也是之前遗留的code,整理了一下,好象其中的代码,一位Korea的同学有留下来一段code。- ;A200N.ASM 2 @2 b8 X' I: w0 N* U" f- r+ }
- ; ( v) U( |; y$ z3 G# D- U
- ; Trun on the line A20 through the KBC, programming by bini for debug. 2008-07-01
4 R! ~; i6 ?, k- K# l* ~8 } - ; ml A20ON.asm 3 d8 d$ ]! {9 z& \9 |
- ;
5 _" V% Z: Y# ~! w: \5 C; [8 q5 t. k - .model tiny
* j& @' }: B1 |/ r \5 N5 a - .code, ?8 Q) N" }( _. ~
- .4861 {# n; U/ A9 x ^- e+ X$ S3 d
- .startup1 b3 O2 R: f' u
- g2 E, k" a+ }. N- I
- mov dx, offset msg_author3 `8 M7 k; R, d
- mov ah, 09h
; V" ^( U" f8 Q2 A+ D1 b - int 21h9 H4 }8 b4 Y6 V7 |$ r. v0 V' ^* P
; A% a- B1 [6 m. e: D {; h- mov dx, offset msg_fail
2 R' {+ R# l& G( y6 i - call A20_ENABLE
; S6 c- N& A6 d$ v; v - jz exit1; J' k f w7 V" k, ?' x
- mov dx, offset msg_ok ; B) p4 q2 i# M2 V
8 q! `' s) c, A- Y- exit1: mov ah, 09h a+ N) ^/ r+ s7 g0 ~
- int 21h / A% `3 W( f n# y A1 R$ E0 n
- mov ax, 4C00h
e; v* x$ Y% O" {- {" Y, F - int 21h
6 J4 r5 _% s* P* S: p% h -
; j8 i2 X3 t* Y/ ~6 T; b - msg_author db "Trun on the line A20 tools through the KBC, programmin by bini", 13, 10,5 v5 g) N ?" Z$ e" b$ _7 S* `6 v
- "2008-07-01",13, 10, "$" * S; Z, d9 k; w( V0 A" P* V
- msg_ok db "A20 Enable OK", 13, 10, "$"
6 g/ q7 k: _( c( S6 W$ p/ R - msg_fail db "A20 Enable FAIL", 13, 10, "$" 2 @$ }8 ^7 P2 w* E* D
- # E# z& `8 ]3 o; D6 N/ x
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
5 M4 W8 F2 o% [# V6 U3 h" n& S - A20_ENABLE:
$ h5 B( l, b, l1 ^, ~. q - call A20Write
! z5 V `& n( d) S, b7 O, a, p - jz exit_enable- }/ X" f$ C; Q0 v3 W( S
- ' t& k3 Q, B# p, Y
- cli ; Only need for reading value from KBC
( F) g# a- c. i1 T9 Z( K/ O0 G - mov al, 0D0h 1 d8 z: I2 h0 w0 T( V# v" |+ K
- out 64h, al
Z/ S- `# B+ A+ l" H - call A20Read
% |) o& }" ^; c1 @# @' l- _ - jz enable_int 6 R4 K- F3 C9 v
; L8 K7 j. m, f" g, |/ v; f5 Q- in al, 60h ; Get current status
) y+ M% E1 N* d8 y! y# b& ^6 M - mov ah, al 9 u- V4 t" E$ l
- call A20Write 8 P) X% S$ K# D% y4 M& ~, A: ^
- enable_int: sti 4 K9 o4 n! ]5 r0 t+ e
- jz exit_enable6 p! n4 k; w% q1 b& c4 r0 u
- # M5 K5 ]) d* g/ j' V4 e* T
- mov al, 0D1h ; Tell the KBC , want to write to the N9 p6 p- Q& s7 ` w! \
- out 64h, al ; Out Put Port next
2 h3 ]% b8 ~( M/ X% U; S+ u - call A20Write $ e' u6 k: _8 N: ]0 o: g
- jz exit_enable
$ Z: @/ n$ U5 f" b( m/ R a+ | - 2 y0 z k4 q0 ~# Z; G% K- W! F( h
- mov al, ah
6 ` k/ q* i) V$ ` - or al, 2 ; Enable line A20
- k8 a& [. ^. _5 z0 w: k; D9 h* p: F - out 60h, al
$ R: m% [ {. S+ U - call A20Write / M- n% j# Z/ C+ b
- jz exit_enable
8 W# W- G4 C8 J7 z% r
. |2 E) |) X* T) C- ^- mov al, 0FFh ; NOP
% G4 _5 @% C* P( E! q) C+ z* l - out 64h, al / a4 V p5 B z3 F& v0 o
- call A20Write ! G+ m( ~/ P; V. t% L2 I
- ! C: B$ s i; ]# ~
- exit_enable: ret
. U$ @/ t- j; H2 t0 S - . S% H6 x# M$ p& C
- A20Write: xor cx, cx ; Reasonable wait 3 t9 q1 ^% l, ~5 D0 X. o
- get_wirte: in al, 64h ; Get KBC read status
/ f5 L% g9 d9 F' [ - test al, 02 ; See if buffer empty, bit 1 clear 9 F: @% R/ {: _; K
- jz clear
, H5 z5 h4 a1 ^) @* r& ~ - dec cx
3 n1 \; B5 Z/ s' S: o3 I" q - jz exit_write
) \& S8 Z" f" e8 Z - jmp short get_wirte ) y. _, E- Y- m( h6 Y, ]. c+ b; n) }+ \
- clear: inc al ; Clear ZR
/ }2 S) j5 Y' a' o - exit_write: ret
5 j6 U Q& r( g) `$ A; {+ U4 y - 2 W3 ?! \" b% v' p" }; [
/ J6 N4 F" |9 A# V) `/ Y) ]+ M- A20Read: xor cx, cx
) N( f/ t; B9 m - get_read: in al, 64h
* E, P4 w" ?9 Q8 U1 ] - test al, 01 ; If the 'output buffer' is full, has 8 f1 u8 x. b2 s4 |
- jnz exit4 ; ... : ^; e8 w7 w7 n. }6 v/ Z9 e) O3 H
- dec cx
0 N4 |+ _5 H. Q, I7 h - jnz get_read- P% B" a9 O+ m, M5 I: |
- exit4: ret ' n$ w* z. j! Q, P& t
-
# ~2 B2 D9 j+ O. p7 Y - end
复制代码- ;A200FF.ASM & o, E* {' s" W3 s) L9 z
- ;
9 S& [$ X1 g1 G% D% m% c2 y. ~ - ; Trun off the line A20 through the KBC, programming by bini for debug. 2008-07-018 F2 s5 c7 T. x4 n: |6 T
- ; ml A20ON.asm
: ]. w* P. X: M7 S. v - ; 9 A! H! r( f* ^: N& U' b
- .model tiny8 }+ o# I+ f. Q$ h
- .code( Q1 G4 m5 O M+ }, D- m
- .486
8 ], R t/ ?! l& e. A, z - .startup
$ p2 I+ ~9 }" p - ; Q! C! \9 L2 W$ A& ~
- mov dx, offset msg_author
% z5 a/ P% ^7 j% h8 B$ S - mov ah, 09h
5 s$ H" Y! \2 k* F - int 21h3 `0 x; c3 r, M6 L9 e0 ^
- 0 l0 r, Y2 K( v
- mov dx, offset msg_fail ; l# f+ A, s# L0 i/ d( i2 }% g2 }! d0 p
- call A20_DISABLE
2 z2 N% [2 k8 I) g; Y" y8 b! ~ - jz exit1
* D) T% }) X4 q7 r, S: F3 Z - mov dx, offset msg_ok
1 W- E1 D5 w% G5 ^* J2 Z - # x8 F6 [$ V! Z/ W- j! J
- exit1: mov ah, 09h , n/ H5 P$ i) V: X
- int 21h
5 g! U+ x" N! T. _& m$ n. d9 b - mov ax, 4C00h
" Z v2 C) i6 K% ~" m. Q8 T- h - int 21h + E$ Q& M+ X6 R
-
; N: T+ F! N0 D - msg_author db "Trun off the line A20 tools through the KBC, programmin by bini", 13, 10,
& n- [- B0 L6 ~5 Z3 x) X1 J - "2008-07-01",13, 10, "$" 6 x7 v3 H* Z! _! e6 Y, a; c
- msg_ok db "A20 Disable OK", 13, 10, "$"
0 \. q8 ^- M9 U* x6 K. Y# ~) y' @) i - msg_fail db "A20 Disable FAIL", 13, 10, "$" + }* ^; o/ Q" Q& A' c
- : p4 R/ A' @5 S4 J
- ;------------------------ follow code maybe make to lib, if you want...-------------------------------
$ X9 ^% b1 R* y" o4 [9 P - A20_DISABLE:
1 k2 ^; y$ _) X - call A20Write
* J+ a4 F2 ~4 t% U - jz exit_disable
! e1 B1 X6 Y0 H q3 `7 A - 5 h8 F: Y8 V8 v; c6 ~$ m! d$ q) G
- cli ; Only need for reading value from KBC 8 n- F* s2 [4 {2 u% H9 P
- mov al, 0D0h
! G v+ t& r7 _* O8 B - out 64h, al O. G+ ~9 Y+ }4 y3 ~, ?
- call A20Read
. A& q, h: P" x4 E - jz Disable_int % m8 T) G" O6 E3 E
- p* a* `- }/ Z& ]& J* x- in al, 60h ; Get current status
9 E- f( Q3 ^. Y7 r1 ^8 J - mov ah, al
! \0 O/ v' B+ Q y' C7 B ^ - call A20Write ) L( r) Y. O; t/ O
- Disable_int: sti
4 z9 G* C8 X. c - jz exit_disable
* [* E; e0 J6 j% O6 A
0 o* ?8 Q! ~# r6 i- mov al, 0D1h ; Tell the KBC , want to write to the , C7 j/ u$ e6 W& X5 C8 Y, `( a) V
- out 64h, al ; Out Put Port next
$ b- [: m" k. {) l - call A20Write
( }& j) g. X1 B+ L - jz exit_disable
t3 s& q1 s. G' b
; K" d! W* B9 f* r8 j" E! u5 [- mov al, ah ! h6 N) C. J. X+ d0 u/ h
- and al, not 2 ; Disable line A20 & Q# j1 I5 S: J5 O8 C8 b
- out 60h, al " V ^$ m) P; A& Z% T
- call A20Write
# S2 U5 M4 t9 Y7 g) E2 Q - jz exit_disable
) C. b% r( t8 {4 q
% [; h- S/ n8 ^0 _) Y0 l- mov al, 0FFh ; NOP : g; Y0 g, h! p3 J3 A
- out 64h, al
$ B5 B! B3 K; z2 x$ [' q - call A20Write * A5 ~) n3 P# n# S: g7 Q
; u- p% e3 P% j6 p4 X' U- exit_disable: ret 3 o5 K- ^! O( {# z
) a- m( i" I( x# f$ K- A20Write: xor cx, cx ; Reasonable wait / z' d5 `$ g1 L( y9 t- q
- get_wirte: in al, 64h ; Get KBC read status
; k% a6 A: R+ }* C, O. h! A) U - test al, 02 ; See if buffer empty, bit 1 clear " O; r- E3 y2 ^# z n
- jz clear
& \+ R5 ~- s$ t% R4 ~ - dec cx : \% Y' d$ c2 I' Q- t; J9 r
- jz exit_write
! a& Q6 F# d- q" A" C* s - jmp short get_wirte
4 t' |0 Q _4 g - clear: inc al ; Clear ZR
1 b. Z9 T& w" @2 T& {, U; g5 U) w - exit_write: ret g1 t# D1 P- X3 ?( o- G$ C4 ^
- ! _; O. l8 N4 w8 y" ?! i: D
- 7 y! K/ E( [/ a
- A20Read: xor cx, cx
( j0 H5 q# @+ i" Q - get_read: in al, 64h
2 L$ H3 `0 r2 z - test al, 01 ; If the 'output buffer' is full, has
& n- \, ^5 s4 G# l. k' |) y& @ - jnz exit4 ; ... , ~, ` r1 r/ u
- dec cx
, X1 d; L4 v2 F, C, z* N5 D0 O6 j - jnz get_read: |' c$ s% i1 _2 \! J! O: M2 J; E, o. e
- exit4: ret
P. W$ Z: E$ ~% Y4 y* t -
& m' }( v8 E+ P* O: z6 t - end
复制代码- ;A20STATE.ASM
5 G/ O& r7 w# r$ I6 x6 H/ j7 Y: | - ;
( i1 A# d1 _* X: i - ; Returns the status of the line A20 through the KBC ) l5 E8 T( i; J5 x
- ; programming by bini for debug. 2008-07-012 j1 o3 q5 h9 c2 O& A3 y1 E9 n
- ; : [, n3 f7 n1 ~) u
- .model tiny
9 S8 ^0 z% ?+ @2 I3 M1 | i0 [! t - .code
3 ]* A+ \( S$ v) | - .486( b; v% f: ~* O0 l% [
- .startup2 I! E R5 S, Q: H
- mov dx, offset msg_fail
1 U; S2 z& X* f5 g. X( z - call _GET_A20_STATE_
( q- f% K4 l8 ~, @ s, z) M - jz exit1 ; was a problem
/ I, }4 x1 z0 M! M$ K0 ~. Z* e - push ax ; Save state, AH ' ?1 l g4 w5 N) n [! r
- mov dx, offset msg_ok ; There wasn't a problem ' ~8 [' k3 S' _' p
- mov ah, 09h
* Q- k% _/ V3 `1 B w - int 21h ; Print message . Q, `% N. Z+ Z: @! Y/ C+ w
- pop ax ; retreve state 6 G+ H7 x% W8 @1 t( J1 o
+ t+ C0 ^" G1 B2 e1 z- mov dx, offset msg_dis
$ o. B: w. U" c0 e - and ah, 00000010b ; bit 1, 2h, indicates state
2 S4 K* R' h+ ^- o; w - jz exit1
/ }4 S5 G* b1 O* H - mov dx, offset msg_en
+ v' h4 ]/ g9 m3 ?5 J* j - 3 V" b* Y" ~( j
- exit1: mov ah, 09h
g8 R* b/ L7 P; q9 P - ; DX already contains address of string
3 {9 R9 v2 R" e0 G# k& [- q$ f+ A# B - int 21h ' B, P1 ^$ m, r0 _9 D" j3 {" O
- 5 |' R3 j8 ^, b9 u3 Q' g5 z2 _) t. O
- mov ax, 4C00h " l! S5 Q7 ]5 L- K P5 P1 c. y; ]& X6 U
- int 21h : Q8 N! m9 u8 O( I
- % B7 u9 ^7 J! A
- msg_ok db "OK", 13, 10, "A20 $"
% n3 h8 q- U0 z p - msg_fail db "FAIL", 13, 10, "$"
% k! D C9 X3 p8 @ - msg_en db "ENABLED", 13, 10, "$" 7 d) H' {, k! v1 S- {
- msg_dis db "DISABLED", 13, 10, "$"$ _! G, K" T; H# I. t
1 |0 J/ `3 `% k/ J- |8 T- , |' T0 O- A+ I/ u' @. ?! B
- _GET_A20_STATE_: * P, h) d! u2 n/ x, ~) ~0 y' l% B8 V
- call A20Write ; Wait till the input register is empty ( Q; A5 X5 F9 e2 q4 W$ j0 w0 R
- jz exit2+1 ; Bypas the reset int's 0 i3 u0 `$ [- @* b
- cli ; Disable ints so we'll get our value
% p- l0 C" q: i) m
$ x# v1 [* I$ k$ E4 u8 W9 G, e- mov al, 0D0h ; Send command to the 8042 command register 5 |- D% ~8 v% w0 x$ V$ i$ F
- out 64h, al ; to tell it we want to Read the Output Port
' _1 n7 x" X; ?) h; U - call A20Read ; Wait till the 8042 output register 8 f. `1 h9 G2 j: Q
- jz exit2 ; has something in it's buffer ' Z- B f r& |- ~! Z
- 9 D+ n4 ^9 o) k& _2 f- @7 l
- in al, 60h ; Get it 0 V/ P3 }1 F1 ?1 u1 s/ ~
- mov ah, al ' ~. b& z) D$ q6 T
- call A20Write ; Make sure the input register is empty
( J+ h# Y: H5 e9 z: G0 r - jz exit2
' u5 C0 r/ e: t: w2 r- O1 x1 f9 J
3 n6 D1 E5 H9 }# \6 ^" X) w- mov al, 0FFh ; KBC NOP command, does nothing
1 N. V' h- d* `5 a - out 64h, al
1 \" o( d) i( G# U - call A20Write , F2 ]# ]7 `3 \
3 ^1 L6 [$ J- f" v- exit2: sti & V8 }# V& M% i7 v
- ret
( P9 d% N. C8 _% s5 U8 C5 V5 [
. k9 j' h: I0 D) f
7 h2 t$ h/ Z" L$ q) R* w8 S6 q. ~, a+ E- A20Write: xor cx, cx ; Reasonable wait
' C9 Z9 U# [5 O. a - get1: in al, 64h ; Get KBC read status 4 k8 D1 Y, l3 H- [
- test al, 02 ; See if buffer empty, bit 1 clear
G0 d7 {: i3 _, Y0 [& k. s4 B0 A9 w - jz clear & B: ~3 f2 h7 L* H) z5 K2 e
- dec cx
d2 J* G$ M0 Z" ^ - jz exit3
& P, j, r" M; Q - jmp SHORT get1
n8 |* v* w) `- ^ - clear: inc al ; Clear ZR
5 d) E# O' P! f4 h/ n9 m2 Q - exit3: ret ( S. C0 ?% O/ h" h& |6 y, [( F% ?
- 5 O/ _+ u" P# _* g
# S; H" j/ _/ l& x1 ^+ C0 b- A20Read: xor cx, cx
/ v9 h$ O( q+ L4 y$ q1 o! o/ ? - get2: in al, 64h 8 Z* I% E5 J5 h4 V$ d: U
- test al, 01 ; If the 'output buffer' is full, has
8 S' N5 H" ^$ d1 T' e - jnz exit4 ; something for me / v; v" m# y: z! _: y7 F: D& m
- dec cx
5 t) k, {; I& g1 D/ X! x& ? - jnz get2
& @- t5 } ?4 c4 }2 N6 E- B! `+ o" m - exit4: ret
1 Q6 }1 h) e% g3 |0 e- ]; O - n; [. S. |; J- C0 ~
- end
复制代码 |
|