1. paee aapo.
Kaapa coep eec popoeccop, oop ocpae
aoe aae a a ae ca-o op A pocxe
epeca c epepe, pacooeo a cceo ae. Ca-o o
ooaoe co, ae 7 o oopoo peca e-
ao oep, pcoe ao ae. Ha cex aax, poe
AT, cap oa oop o o, a aa aaa ( = 1,
o aa) ocooea ( = 0, o ocooe- ). Hapep,
7- ca-o a B - 48, 110000 oo ccee. Koa
a aa aaec, o op A ocaec o 10110000, a oa ee
oc - o 00110000. Ta opao, aoe aae a a
a pecppec pocxee 8255. a pa pocxea 8255
ae oepee popoeccop aap. AT paoae eoo
o-po, oca oox cax o o e ca-o, o
peap eo oo F0H, oa aa ocaec.
Koa ca-o aec op A, o aec pepae
aap (INT 9). poeccop oeao pepaae co pao
oe poep, aap ca-o. Koa ocae o o
a ca epeae, o eee caca acaec
a. Bo cex ocax cax ca-o pac- oppec o
coa, p co, o o oaec p aa- a (
poo cae, ca-o opacaec). Koeo, poepa caaa
opeee cao a ca epeaee, o pao
o o o (o "a" "A"?). oce oo ee o
oeaec ep aap, oop ec oac a,
cocoo ao o 15 o- x coo, oa popaa co
aa, o opaoa x. Ha pc. 3-1 oaa , oop poxo
aae a a epe e, a oac Ba popa.
eec a a oo coo, o ASCII pacpee o. Ko
ASCII - o ae ca, oope cooec pac- peo aop
oo ASCII IBM PC. IBM PC o aop ae oe co
e a, a ae p ceax coo ceopa.
ASCII o a ae 32 pax oa, oope oo co-
c epea oa epep cpoca, a e oc a
co a pae; oao a x ee cooec co,
oop oe ee a ce, c cooae po
apeca ceo a. (Cpo- o oop, oo epe 128
coo c aco co- a ASCII, a a ASCII - o
apeapa o Aepac caap o oea opae. Ho
popac oo oop o oax ASCII, o o x o px
ce. Hapep, "ASCII 8" oocc ae "Backspace", o pe
a "8" - o pa, oopo cooece ASCII 56).
Bopo aop oo, pacpee o, pcoe aa
oa a, oope e e pecaeo x coa ASCII,
a a oae a oa c ae Alt.
Pacpee o e 2 aa, pe ep a cea ASCII
0. Bopo a - oep pacpeoo oa, cco oopx pee
[3.3.5]. Hapep, o 0:30 pecae Alt-A. Haa o
ooe popae pae a o aop ASCII
pacpeo aop.
eec ecoo oa a, oope o ce-
ae e eepp ca-o. oa -
a , , c AT
PCjr. ce po apaee peopeee pe-
- 2 -
aa [3.3.2]. Bce ocae aa a o eppepo-
ac Bae popao ec o e ceaoe aaee,
cae c pcop eo, o Baa popaa oa coepa
o, oecea ocee oo ea.
K cac oepaoa ccea peocae pae poe-
p e oo epa aap, a cpeca
oe cpa eo cpo. oco poep oo
ea paec ce, o B oee oea, o paec
eccceo ca co poep opao oa c aap
oo ao ae eec oe ao pepo popapoa-
a o poe. Oao coepc ocee opoca o o,
a epepopapoa pepae aap.
2. Oca epa aap.
popaa oa oc ep aap, epe e, a a
apoc a o, ca e ca ocopoe aa a, oope
o o pee aoc epe. ep oe aaa o 15
aa a a, eaco o oo, c o ooa
oa ASCII xa pacpe oa. Ta opao, ep
oe oec a aa a aoo aa a a.
ooax oo ep a coep o ASCII, a opo - ca-o
a. pacpex oo ep a coep ASCII 0, a opo
oep pacpeoo oa. o o oo coaae co ca-oo a-
, o e cea, oco eoope a o opo- ac c
aa ca eepa pax oo.
ep cpoe a eca oepe, oop aa ae
epo FIFO (ep oe - ep e). Ka o ep o
aae epep oac apeco a. Oao e eec
opeeeo e a, oopa xpa "aao cpo" epe.
Beco oo a aae xpa o oo xoca cpo
coo, axoec epe e oe. Hoe aa a
aacac ox, cex a xoco ( oee capx apecax
a) cooeceo ooec aa- e xoca epa. oce
oo, a pacxooao ce epoe pocpaco, oe co
pooa cac, aa c caoo aaa epo oac;
oo oo ca, oa ooa cpo epe ee o
apec, e xoc. oce oo a ep aoe, oe oe co
oppc, p o pepae aap ae o epe
a.
B o pe a aae a oo caoe a ep e- e
co, aae a xoc caoe a o a oc- e
ee coo. Koa oa aae pa, o ep c. o
pape o 15 coo peec 16- ca o, 2 aa
oopo cea coepa o opaa ape (ASCII 13) ca-o
a , pa 28. a ca o eocpeceo
peece ooe cpo coo. 32 aa epa aac c
apeca 0040:001E. aae a oo xoc pacooe o apeca
0040:001A 0040:001C, cooeceo. Xo o aae oeeo 2
aa, coec oo a a. ae aaee ec
o 30 o 60, o cooece o oac ax BIOS.
oc epa ao poco cao aee e 0040:001A pa
ae e 0040:001C.
Oe, o popaa ee oooc ca co ep,
aepa cpo coo opaa ape cooeceo e
ae aaee. Ec o poea pa opao epe
aepee popa, o p opae pae MS DOS co
ca oe aoaec apea pa popaa.
- 3 -
Cpe poe.
0C pepa 21H oe oa c
aap 1, 6, 7, 8 A (ocax o ae), o epe
c ep aap. Hao poco oec oep oa AL
( o pepe - 1):
;---oca epa epe oae aa a
MOV AH,0CH ;pae DOS 0CH
MOV AL,1 ;pae oa coa
INT 21H ;c ep, e oa
H poe.
Ka pepe cooo po eae aee aae a xoc
pa ae aae a oo. ea pepa
aap apeae pepa a pe oa aae:
;---paae ae aaee a oo xoc
CLI ;apeae pepa
SUB AX,AX ;oe pecp
MOV ES,AX ;oao cee - c aaa a
MOV AL,ES:[41AH] ;epe aae a oo epa
MOV ES:[41CH],AL ;ocae eo aae xoca
STI ;papeae pepa
3. poepa coo epe.
B oee poep o c aap, e a co
epa aap. ep coe a aae, oope
oea oo xoc oepe coo, axoxc epe
e oe. Koa ae x aaee pa, o ep
c. Hao poco cpa coepoe ee a 0040:001A
0040:001C. (He poco poep co, axoc ooe
oepe, oco ep opaoa e eco oepe
o ee oo ocoo eec [3.1.1].)
Cpe poe.
0BH pepa 21H opaae aee 0FFH pecpe AL,
oa ep aap coep o oee coo aee 0,
oa ep c:
;---poepa a coa epe
MOV AH,0BH ;oep
INT 21H ;ae pepae 21H
CMP AL,0FFH ;cpaae c 0FFH
JE GET_KEYSTROKE ;epexo ec ep e c
1 pepa BIOS 16H peocae e oooc, o,
poe oo, oaae ao co epe. a (ZF)
cpacaec, ec ep c, caaaec, ec epe eec
co. B ocee cae o coa, axoeoc ooe epa,
oeaec AX, o co epa e aec. B AL opaaec
o coa ooax coo ASCII, ae ASCII 0
pacpex oo, oa oep oa - AH.
;---poepe ae coa epe
- 4 -
MOV AH,1 ;oep
INT 16H ;poepa a coa
JZ NO_CHARACTER ;epexo ec ZF = 1
;---eec co - cop ao
CMP AL,0 ;o pacpe o?
JE EXTENDED_CODE ;ec a, o a p e
H poe.
Ka pepe cooo po poco cpaae aae:
;---cpaae aae a oo xoc
MOV AX,0 ;caaae oao cee
MOV ES,AX ;a aao a
MOV AL,ES:[41AH] ;epe o aae
MOV AH,ES:[41CH] ;epe po aae
CMP AH,AL ;cpaae x
JNE GET_KEYSTROKE ;ec epa, o poepe oa
4. Oa o coa e o eo a pa.
Oo oe co oc a pa, o o o, o
aeaao. Ho oa aoaecoe xo a pae eea- eo.
Hapep, op a e o aa a. oa ao caaa
poep oe co a o epe oo a pa. B
acoc, a popaa, opaaaa pacpee o, oa
ea aoaecoo xa, a a p o ep a x oo
(ASCII 0) e oc a pa, ca poe e coa.
Cpe poe.
7 8 pepa 21H oa oa coa, ec ep
aap c, a oa o oec, o e oc a pa. p
o 8 opeee Ctrl-Break ( pe poep opao
Ctrl-Break[3.2.8]), a 7 e peape a eo. B oox cax
co opaaec AL. Koa AL coep ASCII 0, o oe
pacpe o. oope pepae AL oc opo a
pacpeoo oa.
;---oae ee co
MOV AH,7 ;oep
INT 21H ;oae o coa
CMP AL,0 ;poepa a pacpe o
JE EXTENDED_CODE ;ec a, o a oco poep
. ;ae, o coa AL
;---poepa opao pacpex oo
EXTENDED_CODE: INT 21H ;epe opo a oa
CMP AL,75 ;poepe a "cpe-eo"
JNE C_R ;ec e, o ce. poepa
JMP CURSOR_LEFT;ec a, o a poep
C_R: CMP AL,77 ;cpaae ae ..
BIOS oeceae poep, oopa peocae e e
oooc, o MS DOS. oece 0 AH oe pe-
pae 16H. oae oa coa opaae eo AL. B
o cae pacpee o opaaac a oo pepa- e.
Ec AL coepc 0, o AH e coepac oep pacpeoo
oa. p o e opaaaec Ctrl-Break. ;---e aa a
- 5 -
MOV AH,0 ;oep oa oa
INT 16H ;oae ee o
CMP AL,0 ;poepa a pacpe o
JE EXTENDED_CODE ;ec a, o a ce. poep
. ;ae co AL
;---poepa opao pacpeoo oa
EXTENDED_CODE: CMP AH,75 ;epe pacpe o AH
; ..
5. Oae aa a xo a pa.
p oe ax eca, xo ox coo oo aec a
pa. p o ae co a opa ape ao epeoc
cooece epeee pcopa, a e opaac a ASCII
co x oo. Baa xa poc- xo o o, e
peapeo caoe pcop ec aoaec epeocc
a ce cpo p oce- oa ee. epeoc a ce-
cpo e pee ce- aoo oa, oco co oeac
ce o epo a ce, oopa pecae
ce o cpo, a ce 25 cpo ce.
Cpe poe.
1 pepa 21H oae oa coa, ec ep
aap c, a ae o eo a pa e o
pcopa. Opaaaec Ctrl-Break, oo oe oc poepa
opao Ctrl-Break. Bee co opa- aec AL. p oe
pacpeoo oa AL coep ASCII 0. oe AL opoo aa
pacpeoo oa ao oop pepae. ;---oee eeoo
coa
MOV AH,1 ;oep
INT 21H ;oae aa a
CMP AL,0 ;pacpe o?
JE EXTENDED_CODE ;ec a, o a ce. poep
. ;ae co axoc AL
;---poepa opao pacpex oo
INT 21H ;oae AL oep oa
CMP AL,77 ;poepa a "pcop-pao"
JNE C_R ;ec e, poepa ceeo
JMP CURSOR_RIGHT ;ec a, o a poep
C_R: CMP AL,75 ;... ..
a ooc oppe a . Kaa a
eppepec opao. Kaa ao cae pcop a o o-
eo, o co, axoc o o e cpaec. Kaa
ae epeeee pcopa ep o ee cpo
(e aoaecoo epeoa cpo).
6. pe coa e oa.
Heoope popa, paoae peao pee e o
ocaaac a aa a; o pa co epa
aap oo e oe, oa o oo popa.
Hapep, eece poeccopa o pe oa oa c aap
ocaoo ce ec a pae poo popae.
Cpe poe.
- 6 -
6 pepa 21H - o ece coco o
ee co e oa. a e ae xa a pa e
pacoae Ctrl-Break. epe oo pepa DL oo
oeeo 0FFH. B poo cae 6 c coepeo
pooooo e - eaae ee o pcopa co,
axoc DL. a caaaec 1, ec ep aap
c. Ec co p, o o oeaec AL. Ko ASCII 0 pe
pacpe o oe oepa oa pepae oo
oopeo.
MOV AH,6 ;oep DOS
MOV DL,0FFH ;apoc oa c aap
INT 21H ;oee coa
JZ NO_CHAR ;epexo ec e coa
CMP AL,0 ;poepa a pacpe o
JE EXTENDED_CODE ;ec a, o a ce. poep
... ;ae AL o ASCII
EXTENDED_CODE: INT 21H ;oae oep pacpeoo oa
... ;oep oa AL
7. oee cpo coo.
Cpe poe.
0AH pepa 21H ooe o cpo o o 254
coo, aa xo a epa. a poepa pooae o
ocax coo o ex op, oa e aaa aa opa
ape. DS:DX aae a apec a, a oa oeea
cpoa. p xoe ep a o o oe coepa co
ao, oox o cpo. oce oo a cpoa eea,
opo a ac co peao eex co- o. Caa cpoa
aaec c peeo aa.
Hao oec ocaoo a cpo o c a
aa ecpopa cpo o oao a opaa
ape. Koa B caaaee aca cpo epo
ae, o e ae oa 1 opaa ape. Ko opaa
ape - ASCII 13 - oc a oce co cpo- , o o e
aec peae, oop oeae o opo a
ecpopa cpo. Ta opao, oe 50-coo cpo
ao oec 53 aa a oec ep a ASCII 51. oce
oa 50 coo opo a e coepa ASCII 50, a 53- a
oeeo a - ASCII 13.
;--- ceee ax
STRING DB 53 DUP(?) ;oac cpo 50 coo
;---oee cpo c aap
LEA DX,STRING ;DS:DX aa a apec cpo
MOV BX,DX ;c BX oe aae a cpo
MOV AL,51 ;caoa cpo (+1 CR)
MOV [BX],AL ;ocae 1- a ecpopa
MOV AH,0AH ;oep
INT 21H ;oae cpo
;---poepa cpo
MOV AH,[BX]+1 ;eep a AH
B o poepe oo cooa oooc peapoa
cpo MS DOS. Haae a ao "cpea-eo" ae co
- 7 -
c paa, a ae e oeae eo a. Paoae a- a a-
, pacpee o oppc, ce cpo ocac (eec
opa ape, oopo e peece poo coa). Ha
epae p oce paoo pa cpoa epeocc a ce
cpo, a p oce paoo eo a pa caec a
cpo epx. Koa oc oe coo, e oeeo eca
cpo, o e co oppc aec o aa.
MS DOS oeceae po coco oe cpo, p oopo e
oc xo a epa. 3FH pepa 21H - o
oa oeo aae, oopa ae ceo coec p cox
oepax. Oa pee peopeeeoo ecpopa aa (file
handle), oop ec oo co, coe oepaoo
cceo ooae cpoca oa/oa. ap co-
ec ecpop 0 o oe oee BX. oece DS:DX
apec, o oopo oa axoc cpoa, a CX - aca -
cpo oe : ;---ee cpo e xa
MOV AH,3FH ;oep
MOV BX,0 ;oep ecpopa aa
LEA DX,STRING_BUFFER ;aae a ep oa cpo
MOV CX,100 ;acaa a cpo
INT 21H ;e oa
Bo cpo aepaec aae a opa ape DOS
oae oe cpo a coa: opa ape epeo cpo
(ASCII 13 ASCII 10). -a x oaox coo, p aa
cpo 100 coo oa oe aa o 102 a a. a
eeo cpo opaaec AX o aee ae a
coa-opae.
8. poepa/caoa caca a-epeaee.
a aa, pacooee eax a 0040:0017 0040:0018
coepa , opaae cac a ca px
a-epeaee ce opao:
Kaa aee, oa = 1
0040:0017 7 Insert pe ca e
6 CapsLock pe CapsLock e
5 NumLock pe NumLock e
4 ScrollLock pe ScrollLock e
3 Alt aa aaa
2 Ctrl aa aaa
1 e Shift aa aaa
0 pa Shift aa aaa
0040:0018 7 Insert aa aaa
6 CapsLock aa aaa
5 NumLock aa aaa
4 ScrollLock aa aaa
3 Ctrl-NumLock pe Ctrl-NumLock e
ocae e coc
pepae aap eeeo ooe caca, a
oo e aaa oa a-epeaee, ae ec e o
cao ooo coa epa aap. o epo a
Ins, oopa ecea x 8 a oeae o ep
(caoa caca Ins eec ae ec epe e eca
coa). Oe, o 3 o apec 0040:0018 caaaec 1,
oa ece pe aep Ctrl-NumLock; oco o coco
- 8 -
popaa pocaoea, o o ececee.
pepae aap poepe cocoe cacx o epe e,
a eppepoa aae a, oo oa popaa ee
o x o, o e ao e, a p eco aa
cooece a. B oee axoe cao cocoe a
NumLock CapsLock, o e- pe, o o e peeoo
a. Haoopo, Baa popaa oe ac e caca x
a, apep oo, o ec e cac a pa.
Oe, o aapa AT pao caaae ceoe aop
coco a, ae ec epee popao.
Cpe poe.
2 pepa 16H peocae oc oo - o oo
oo - ao caca. o a o apec 0040:0017, oop
coep oe oeo opa. a opaaec AL.
;---poepa caca a ca
MOV AH,2 ;oep
INT 16H ;oae a caca
TEST AL,10000000B ;poepe 7
JZ INSERT_OFF ;ec 0, o INSERT e
H poe.
B ao pepe caaaec pe ca, a ce ca- o
a 7 aa caca o apec 0040:0017 (oop apecec a
0000:0417).
SUB AX,AX ;caaae oao cee a
MOV ES,AX ;aao a
MOV AL,10000000B ;oo 7 caoe
OR ES:[417H],AL ;ee a caca
9. Hacae poep oa c aap oeo aae.
Ccea oo, coex aapo, e oaec poco
pepea. Ko o e 1 2 aa e poco- o
cooec e o oa e, c o ooa- e
coa pae oopoae. He ce oa a ae
a a o, oo eoxo oaoe c, o
pa x. H o ASCII, pacpee o e opoe a
opao, oop oo x poc ppo poep oo.
p coa, poepa oa c a- ap oeo aae
pee xoooo popapoa.
Cpe poe.
o pep oaec o peeo eoo pacoaa epex
acx cae Ctrl-H, -I, -M -[. ec, oa cae opoc o o,
o aa o p aa oo a, oa c
ae Ctrl, poepec ca-o. o eo oee pae, e
poepa a caca, a a ca-o aoaec epe
aap, a caoa a caca oe eea.
;---oee oa aao a opeeee eo a
NEXT: MOV AH,0 ; oa c aap BIOS
INT 16H ;oae ee o
CMP AL,0 ;poepa a pacpe o
- 9 -
JE EXTENDED_CODE ;ec a, o a ce. poep
CMP AL,32 ;poepa a pa co
JL CONTROL_CODE ;ec a, o a ce. poep
CMP AL,65 ;ec co e xo aop -
JL NEXT ;e a, o epe ce
CMP AL,123 ;
JL NEXT ;
;---eep opaaae co AL
STOSB ;aoae co o apec ES:DI
MOV AH,2 ; oa coa a pa
MOV DL,AL ;oeae co DL epe oo
INT 21H ;o eo a pa
.
.
JMP NEXT ;epexo cee co
;---aape pae o
CONTROL_CODE: CMP AL,13 ;o ASCII 13?
JNE TAB ;ec e, o ce. poepa
CMP AH,28 ;ae poepe ca-o
JNE C_M ;ec e, o o Ctrl-M
CALL CARRIAGE_RET;opaoa opaa ape
JMP NEXT ;epexo cee co
C_M: CALL CTRL_M ;opaoa Ctrl-M
JMP NEXT ;epexo cee co
TAB: CMP AL,9 ;poepa a a...
.
.
CMP AL,10 ;ae poepa px
.
.
REJECT: JMP NEXT ;epexo cee co
;---aa pacpex oo (2- a oa AH):
EXTENDED_CODE: CMP AH,71 ;poepa e pa
JL REJECT ;ec ee, o ce. co
CMP AH,81 ;poepa epxe pa
JL REJECT ;ec oe, o ce. co
;---AH coep co pae pcopo, aape eo:
CMP AH,72 ;"pcop-epx"?
JE C_U ;ec a, o a poep
CMP AH,80 ;"pcop-"?
JE C_D ;ec a, o a poep
.
.
C_U: CALL CURSOR_UP ;o cooece poep
JMP NEXT ;epexo cee co
C_D: CALL CURSOR_DOWN ;o cooece poep
JMP NEXT ;epexo cee co
10. epepopapoae pepa aap.
Koa popoeccop aap oeae ca-o op A
pocxe 8255 (apec opa 60H - c. [1.1.1]), o p o aec
pepae 9. aaa oo pepa - peopaoa ca-o coa,
ocoac a coco a-epeaee, oec eo ep
aap. (Ec ca-o cooece ae-epeae, o
ep aap e ec eo, a cee ca a
<Ins>, a eco oo pepae ee a caca, pacooee
oac ax BIOS. pepa "oa c aap" DOS BIOS a
cao ee ceo pepa "oa epa aap". Ha cao
- 10 -
ee o e pacoa aa a. Toee, o a eppea
eex a, oop oeceo pepae 9. ae- , o PCjr
coe cea poep (INT 48H) peopaoa oa o
eo 62 a 83-ao pooo, coeo p IBM PC.
Pea o poep epeaec pepa 9, oopoe oe
co pao a oo. B pepa aap oo e p
ocox aa:
1. poa ca-o oca aape oepa ca.
2. peopaoa ca-o oep oa cao oecpa
caca a-epeaee.
3. oec o a ep aap.
B oe oa pepa ca-o e axoc ope A.
oo caaa ao o o poa coxpa a cee. ae
coec op B (apec 61H), o cpo oca ca
oepe popoeccop aap. Hao poco cao-
7 1, a ae cpa e eo aa 0. ae, o 6 opa B
pae cao aco aap. O cea oe caoe
1, ae aapa e ea. apeca opo pe
AT, xo o e ee pocxe epeca c epepe 8255.
Caaa ca-o aapec a pee oo, a aa
aaa (o aa) oea (o ocooe). Ha cex aax,
poe AT, o ocooe pec caoo a 7 ca-oa
1. AT, oopoo 7 cea pae 0, o ocooe coco
x ao: caaa 0F0H, a ae ca-o. Bce o ocooe
opacac, poe ca a- -epeaee, oopx
eac cooece ee- aax x caca. C po
copo, ce o aa opa- aac. p o o o
ec a caca a- -epeaee. B cae e co-
x oo, ao poep a caca, o opee, apep,
o ca-o 30 cooece e epxe pecp A.
oce oo a ee co epoa, poepa oa c
aap oa a cooec e o ASCII pacpe
o. pee pep co opoo, o pac- cope ce
ca. B oe cae ca-o coocac eea a
ax, oopa aapec cpe XLAT. XLAT pae AL
co o 0 o 255, a opaae AL 1-aoe aee 256-ao
a, a oop aae DS:BX. Taa oe axoc
ceee ax. Ec AL axoc ca-o 30, o a e oee
a a oep 30 (31- a, a a oce aaec c ).
o a ae oe caoe pa 97, aa o ASCII
"a". Koeo oe aao A a pa aa,
oopo opaee e pocxo, ec cac ca caoe.
aae o xpac po ac o e a, o
o cae ca-o ao e oa ceee, opee- eoe
caco a-epeaee.
Haoe, oepa oo o oee ep aap.
poepa oa caaa poep, eec epe eco
ceeo coa. B [3.1.1] oaao, o o ep cpoe a -
eca oepe. ea a 0040:001A coep aa- e a
oo epa, a 0040:001C - aae a xoc. coe aae
a ceee oac ax BIOS (oopa aaec ceee 40H)
axoc aaoe o 30 o 60. Hoe co cac e
epa c oee cap ape- ca, a oa oca epx paa,
o ce co epeocc oe epa. Koa ep
oo, o aa- e xoca a 2 ee aae a oo - poe
ca, oa aae a oo pae 30 (aao oac epa), a
o cae ep oo, oa aae xoca pae 60.
ca coa ep, ao oec eo o, a
oop aae xoc epa ae e aae xoca a 2;
- 11 -
ec aae xoca pae 60, o ao e eo aee a
30. Bo ce. Cxea pepa aap oaaa a pc. 3-4.
H poe.
ea poepa pee ooo poa. B o pepe
a oo cae aa. O pae oo a e
epxe pecpax, pe ce o ape o a, oopo
epxeo pecpa axoc a 100 a e, e x ae
pa. Aapec oo ea aa ca eee cocoe
a CapsLock oppec.
;--- ceee ax
TABLE DB 16 DUP(0) ;pocae 1-e 16 a
DB 'qwertyuiop',0,0,0,0 ;epx p aap
DB 'asdfghjkl',0,0,0,0,0 ;cpe p aap
DB 'zxcvbnm' ; p aap
DB 16 DUP(0) ;poc o epxeo pecpa
DB 'QWERTYUIOP',0,0,0,0 ;e e co a epxe
DB 'ASDFGHJKL',0,0,0,0,0 ;pecpe
DB 'ZXCVBNM' ;
;--- aae popa caaae pepae
CLI ;ape pepa
PUSH DS ;coxpae pecp
MOV AX,SEG NEW_KEYBOARD ;DS:DX o aa a
MOV DS,AX ;poep opao
MOV DX,OFFSET NEW_KEYBOARD ;pepa
MOV AL,9 ;oep eopa pepa
MOV AH,25H ;oep DOS
INT 21H ;ee eop pepa
POP DS ;occaaae pecp
STI ;papeae pepa
popaa pooaec, ae ocaac peeo [1.3.4].
;---o cao pepae aap
NEW_KEYBOARD PROC FAR ;coxpae ce eee
PUSH AX ;pecp
PUSH BX ;
PUSH CX ;
PUSH DI ;
PUSH ES ;
;---oae ca-o ocae ca oepe
IN AL,60H ;oae ca-o opa A
MOV AH,AL ;oeae o AH
PUSH AX ;coxpae ca-o
IN AL,61H ;ae cocoe opa B
OR AL,10000000B ;caaae 7
OUT 61H,AL ;ocae ee a op
AND AL,01111111B ;cpacae 7
OUT 61H,AL ;opaae cocoe opa B
;---ES oe aa a oac ax BIOS
MOV AX,40H ;caaae cee
MOV ES,AX ;
POP AX ;opaae ca-o cea
;---poepa a ca
CMP AL,42 ;aa e c?
JNE KEY_UP ;e - cop ceee
MOV BL,1 ;a - ee caca
- 12 -
OR ES:[17H],BL ;ee po pecp caca
JMP QUIT ;xo poep
KEY_UP: CMP AL,170 ;e c oe?
JNE NEXTKEY ;e - cop ceee
MOV BL,11111110B ;a - ee caca
AND ES:[17H],BL ;ee po pecp caca
JMP QUIT ;xo poep
NEXTKEY: ;pocop px epeaee
;---o coa aa - eppepe ca-o
TEST AL,10000000B ;o ocooe a?
JNZ QUIT ;a - xo poep
MOV BL,ES:[17H] ;ae epe a caca
TEST BL,00000011B ;aa ca aaa?
JZ CONVERT_CODE ;e - xo ae
ADD AL,100 ;a - a aaa a
CONVERT_CODE: MOV BX,OFFSET TABLE ;oo a
XLAT TABLE ;peopae ca-o ASCII
CMP AL,0 ;opae 0?
JE QUIT ;ec a, o a xo
;---o a oo, poepe e oo ep aap
MOV BX,1AH ;ceee aae a oo
MOV CX,ES:[BX] ;oae eo aee
MOV DI,ES:[BX]+2 ;oae aae xoca
CMP CX,60 ;ooa a epe epa?
JE HIGH_END ;a - epexo ce. ca
INC CX ;eae aae oo
INC CX ;a 2
CMP CX,DI ;cpaae c aaee xoca
JE QUIT ;ec pa, o ep oo
JMP GO_AHEAD ;ae cae co
HIGH_END: CMP DI,30 ;poepa ce. ca
JE QUIT ;ec ep oo, o xo
;---ep e oo - cae eo co
GO_AHEAD: MOV ES:[DI],AL ;oeae co o xoca
CMP DI,60 ;xoc oe epa?
JNE NO_WRAP ;ec e, o oae 2
MOV DI,28 ;ae aae xoca = 28+2
NO_WRAP: ADD DI,2 ;oae ooe aee xoca
MOV ES:[BX]+2,DI ;ocae eo oac ax
;---aepee pepa
QUIT: POP ES ;occaaae eee
POP DI ;pecp
POP CX ;
POP BX ;
POP AX ;
MOV AL,20H ;ae ca o ooa
OUT 20H,AL ;aapaoo pepa
IRET ;opa pepa
NEW_KEYBOARD ENDP
11. epepopapoae oex a.
o epepopapoae a oaec coco aca ee
aa po o. Ho o pee, oa popaa oae o
aao a, pepae aap e poeppe- poao xo-
ca-o peopaoao eo eoop apa- ee peopeee
o ASCII pacpe o. K cac, aa c MS DOS epc 2.0,
ccea coep cpeca epepopapoa a. o cpeco
- 13 -
ece oo ec o ocpaec epe DOS oa c
aap - pepa BIOS 16H pooa eppepoa
aa a opa opao.
epepopapoae oco a ce Esc-oceoaeoce.
Kopoa cpoa, oopa aaec c coa Esc (ASCII 27),
peaaaec oa a "caapoe cpoco oa", .e. a
epa. Ho aoap a oa Esc co ae e oca
oopa. Beco oo aa cpoa acae MS DOS o po
eppepoa a, aa o cpoe. Kaoe eee
a pee coceo cpo, p o o o e o oe
pcaac ao oo oec a.
O ao cpo ao: oa aaec c oa Esc (ASCII 27),
a oop e [, ae oep oa epeopeeeo a, ae
oa c ao (;), ae o oep oa, pcaa- e ae ,
aoe, co p. Ta opao, cpoa 27,'[65;97p' ee A (ASCII
65) a a (ASCII 97). Pacpee o acac c aae oox
ao, pe a ep e ao o co oa c ao.
Cpoa 27,'[0;68;0;83p' pcaae ae F10 (0;68) o e o, o
ae Delete (0;83). B oee pcaa oo pacpee o,
peee ae pacpex oo [3.3.5].
eec ecoo apao ocoo a cpo. Bo-ep- x,
coe a o ooaac ca coo, ae
a. Ta opao, cpoa 27,'["A";"a"p' ae ee A a a.
Bo-opx ae oe pcoea ea cpo- a coo, e
aa coo x oox oepo pae. Cpoa
27,'["A";"A is for Apple"p' pee o, o p aa a a
A epxe pecpe, e eaac c cpoa A is for Apple. Ha
cao ee Esc-oceoaeoc - eo oee, e cpo,
oopx ep o co aae a a o
epeopee, a ocaac ac cpo aae aoe aee B
xoe e pa. oe, o oepa oo o cea
paee oo c ao, a co ae a. Ko
co o epeea x coeax. oo o ae
epeopeee a oo, eoxoo o paep ANSI.SYS
ape p ape oepaoo cce. B poo cae
Esc-oceoa- eoc oppoac.
Cpe poe.
coe 9 pepa 21H oc cpo a
caapoe cpoco oa. DS:DX o aa a ep co
cpo a cpoa oa aepac coo $ (24H). ec F2
(0;60) epeopeeec a opao, o oa ecoaa a Del
(0;83).
;--- ceee ax
CHANGE_KEY DB 27,'[0;60;0;83p$'
;--- ee opeee a
LEA DX,CHANGE_KEY ;DS:DX o aa a cpo
MOV AH,9 ;oep
INT 21H ;epeopeeee a
12. Coa aa ca-oo.
Kaa aa eeppe a a ca-oo, "o aa" - oa
aa aaec, "o ocooe" - oa aa ocaec.
cex a, poe AT, o ocooe a 128 oe oa aa
( 7 = 1). Ta opao aa T coae o 20 p aa o
- 14 -
148 p oca. AT coe o e eo o oo
aa ocooe, o o ocooe coco x ao,
ep oopx cea pae 0F0H. PCjr ee cea ca-o
o a, oep 55. o o opoaec, oa oopeeo
aa p oee a, o ooae ea oo p oe.
pepae aap opacae o o o e caec c
a oo ASCII pacpe oo.
Ka e a
Kaa Ko aa Kaa Ko aa Kaa Ko aa
"1" 2 "T" 20 "L" 38
"2" 3 "Y" 21 ";" 39
"3" 4 "U" 22 "'" 40
"4" 5 "I" 23 "`" 41
"5" 6 "O" 24 "\" 43
"6" 7 "P" 25 "Z" 44
"7" 8 "[" 26 "X" 45
"8" 9 "]" 27 "C" 46
"9" 10 "A" 30 "V" 47
"0" 11 "S" 31 "B" 48
"-" 12 "D" 32 "N" 49
"=" 13 "F" 33 "M" 50
"Q" 16 "G" 34 "," 51
"W" 17 "H" 35 "." 52
"E" 18 "J" 36 "/" 53
"R" 19 "K" 37 poe 57
pae a
Esc - 1 Ctrl - 29 Alt - 56
BackSpace - 14 left shift - 42 CapsLock - 58
Tab - 15 right shift - 42 NumLock - 58
Enter - 28 PrtSc - 55 ScrollLock - 70
oae a
F1 - 59 F5 - 63 F9 - 67
F2 - 60 F6 - 64 F10 - 68
F3 - 61 F7 - 65
F4 - 62 F8 - 66
Ka ooeo aap
"7" - 71 "5" - 76 "3" - 81
"8" - 72 "6" - 77 "0" - 82
"9" - 73 "+" - 78 "." - 83
"-" - 74 "1" - 79 Sys Req - 132 (oo AT)
"4" - 75 "2" - 80 a - 55 (oo PCjr)
13. Coa aa oo ASCII
o o ASCII o 1 o 255 oe ee c aap, ec
epa aao a Alt p aope oepa oa a ooeo
aape (c cooeceo caoe peo NumLock). Koa
aa Alt ae ocooaec, o o oc.
Co 10- 16-p o Co 10- 16-p o
(null) 0 00 00000000 0 48 30 00110000
- 15 -
1 01 00000001 1 49 31 00110001
2 02 00000010 2 50 32 00110010
3 03 00000011 3 51 33 00110011
4 04 00000100 4 52 34 00110100
5 05 00000101 5 53 35 00110101
6 06 00000110 6 54 36 00110110
7 07 00000111 7 55 37 00110111
8 08 00001000 8 56 38 00111000
9 09 00001001 9 57 39 00111001
10 0A 00001010 : 58 3A 00111010
11 0B 00001011 ; 59 3B 00111011
12 0C 00001100 < 60 3C 00111100
13 0D 00001101 = 61 3D 00111101
14 0E 00001110 > 62 3E 00111110
15 0F 00001111 ? 63 3F 00111111
16 10 00010000 @ 64 40 01000000
17 11 00010001 A 65 41 01000001
18 12 00010010 B 66 42 01000010
19 13 00010011 C 67 43 01000011
20 14 00010100 D 68 44 01000100
21 15 00010101 E 69 45 01000101
22 16 00010110 F 70 46 01000110
23 17 00010111 G 71 47 01000111
24 18 00011000 H 72 48 01001000
25 19 00011001 I 73 49 01001001
26 1A 00011010 J 74 4A 01001010
27 1B 00011011 K 75 4B 01001011
28 1C 00011100 L 76 4C 01001100
29 1D 00011101 M 77 4D 01001101
30 1E 00011110 N 78 4E 01001110
31 1F 00011111 O 79 4F 01001111
poe 32 20 00100000 P 80 50 01010000
! 33 21 00100001 Q 81 51 01010001
" 34 22 00100010 R 82 52 01010010
# 35 23 00100011 S 83 53 01010011
$ 36 24 00100100 T 84 54 01010100
% 37 25 00100101 U 85 55 01010101
& 38 26 00100110 V 86 56 01010110
' 39 27 00100111 W 87 57 01010111
( 40 28 00101000 X 88 58 01011000
) 41 29 00101001 Y 89 59 01011001
* 42 2A 00101010 Z 90 5A 01011010
+ 43 2B 00101011 [ 91 5B 01011011
, 44 2C 00101100 \ 92 5C 01011100
- 45 2D 00101101 ] 93 5D 01011101
. 46 2E 00101110 ^ 94 5E 01011110
/ 47 2F 00101111 _ 95 5F 01011111
Co 10- 16-p o Co 10- 16-p o
` 96 60 01100000 153 99 10011001
a 97 61 01100001 154 9A 10011010
b 98 62 01100010 155 9B 10011011
c 99 63 01100011 156 9C 10011100
d 100 64 01100100 157 9D 10011101
e 101 65 01100101 158 9E 10011110
f 102 66 01100110 159 9F 10011111
g 103 67 01100111 a 160 A0 10100000
h 104 68 01101000 161 A1 10100001
i 105 69 01101001 162 A2 10100010
- 16 -
j 106 6A 01101010 163 A3 10100011
k 107 6B 01101011 164 A4 10100100
l 108 6C 01101100 e 165 A5 10100101
m 109 6D 01101101 166 A6 10100110
n 110 6E 01101110 167 A7 10100111
o 111 6F 01101111 168 A8 10101000
p 112 70 01110000 169 A9 10101001
q 113 71 01110001 170 AA 10101010
r 114 72 01110010 171 AB 10101011
s 115 73 01110011 172 AC 10101100
t 116 74 01110100 173 AD 10101101
u 117 75 01110101 o 174 AE 10101110
v 118 76 01110110 175 AF 10101111
w 119 77 01110111 176 B0 10110000
x 120 78 01111000 177 B1 10110001
y 121 79 01111001 178 B2 10110010
z 122 7A 01111010 179 B3 10110011
{ 123 7B 01111011 180 B4 10110100
| 124 7C 01111100 181 B5 10110101
} 125 7D 01111101 182 B6 10110110
~ 126 7E 01111110 183 B7 10110111
127 7F 01111111 184 B8 10111000
A 128 80 10000000 185 B9 10111001
129 81 10000001 186 BA 10111010
B 130 82 10000010 187 BB 10111011
131 83 10000011 188 BC 10111100
132 84 10000100 189 BD 10111101
E 133 85 10000101 190 BE 10111110
134 86 10000110 191 BF 10111111
135 87 10000111 192 C0 11000000
136 88 10001000 193 C1 11000001
137 89 10001001 194 C2 11000010
K 138 8A 10001010 195 C3 11000011
139 8B 10001011 196 C4 11000100
M 140 8C 10001100 197 C5 11000101
H 141 8D 10001101 198 C6 11000110
O 142 8E 10001110 199 C7 11000111
143 8F 10001111 200 C8 11001000
P 144 90 10010000 201 C9 11001001
C 145 91 10010001 202 CA 11001010
T 146 92 10010010 203 CB 11001011
147 93 10010011 204 CC 11001100
148 94 10010100 205 CD 11001101
X 149 95 10010101 206 CE 11001110
150 96 10010110 207 CF 11001111
151 97 10010111 208 D0 11010000
152 98 10011000 209 D1 11010001
Co 10- 16-p o Co 10- 16-p o
210 D2 11010010 233 E9 11101001
211 D3 11010011 234 EA 11101010
212 D4 11010100 235 EB 11101011
213 D5 11010101 236 EC 11101100
214 D6 11010110 237 ED 11101101
215 D7 11010111 238 EE 11101110
216 D8 11011000 239 EF 11101111
217 D9 11011001 E 240 F0 11110000
218 DA 11011010 e 241 F1 11110001
219 DB 11011011 242 F2 11110010
- 17 -
220 DC 11011100 243 F3 11110011
221 DD 11011101 244 F4 11110100
222 DE 11011110 245 F5 11110101
223 DF 11011111 246 F6 11110110
p 224 E0 11100000 247 F7 11110111
c 225 E1 11100001 248 F8 11111000
226 E2 11100010 249 F9 11111001
227 E3 11100011 250 FA 11111010
228 E4 11100100 251 FB 11111011
x 229 E5 11100101 252 FC 11111100
230 E6 11100110 253 FD 11111101
231 E7 11100111 254 FE 11111110
232 E8 11101000 255 FF 11111111
14. Coa oo ceopa ocpoe pao.
He pee oca oepo oo ASCII, coo
ceopa, coex p ocpoe pao.
218 194 191 213 209 184
195 197 180 198 216 181
179
192 193 217 212 207 190
196 205
214 210 183 201 203 187
199 215 182 204 206 185
186
211 208 189 200 202 188
15. Coa aa pacpex oo.
aee 2-o aa Cooece a
15 Shift + Tab ("back-tab")
16-25 Alt-Q - Alt-P (epx p )
30-38 Alt-A - Alt-L (cpe p )
44-50 Alt-Z - Alt-M ( p )
59-68 oae a F1 - F10
71 Home
72 Cursor-up (cpea epx)
73 PgUp
75 Cursor-left (cpea eo)
77 Cursor-right (cpea pao)
79 End
80 Cursor-down (cpea )
81 PgDn
82 Ins
83 Del
84-93 F1-F10 + Shift
- 18 -
94-103 F1-F10 + Ctrl
104-113 F1-F10 + Alt
114 Ctrl + PrtSc
115 Ctrl + Cursor-left
116 Ctrl + Cursor-right
117 Ctrl + End
118 Ctrl + PgDn
119 Ctrl + Home
120-131 Alt + 1 - Alt + = (epx p)
132 Ctrl + PgUp
|