. , , ,

,,,

,

1

:

1.

2. IBM

3. ꠠ

: - 34 ;

- 32 ;

;

.

: -

.   -

, . .

, , , ..

, -

. - ,

, . ,

, -

, -

. -

. .

:

1. ;

2. ;

3. ;

4. ;

5. ;

6. .

-

.

- . .

.

,

( ).

.

. -

.

1.

.

, . -

, IBM/PC, "".

IBM/PC 8088, 80286, 80386, 80486

"", IBM/PC -

, -

. "IBM"

.

IBM/PC

: , ,


- 2 -

.

.

IBM/PC -

. , -

IBM/PC, , -

.

, - -

. , 64 ""

, , -

.

IBM/PC -

. ,

, -

. ,

.

, - -

, IBM/PC.

:

.

"IBM",

, -

, , -

, .

IBM/PC

, 62 -

. 62 , -

, -

IBM/PC. ,

. ,

, ,

.

: 62--

. /.

. -,

.

,

/ . ,

.

. -

20 ,

1024 . /

, 512 .

-

. -

, / -

.

IBM/PC . -

(

, .. DIP).

IBM/PC,

, , ..

-

. IBM/PC -

-

. , -

- , ,

.

,


- 3 -

, . -

; -

, ,

.

.

,

. - , -

.

IBM/PC 8088

. 8088 20 , ,

1024 .

2.

. -

80287, -

, ,

( )

. -

, -

.

, -

. -

( ) , ,

,

88248. -

,

. -

-

. -

, -

, ,

.

-

, 8253. -

. -

, "".

-

.

8288, - 82288. ,

.

( , ) -

, -

.

. -

, , -

( - 8237).

(8259). -

8259

, - .

-

( - 8255).

, . -

,

.

. -

,


- 4 -

, PD765.

, -

- 6845.

3. 286

-

286 , 286,

,

. , -

, .

286 -

, , -

.

: ( -

), , -

.

-

.

286 -

- , -

, , -

. 286 -

-

.

,

. -

, -

,

. .

286

, . -, -

: 286

. -, -

: 286 ( )

, . -

-

( ) .

.

, -

, 286 -

, . -

,

(). , -

, -

- -

, -

. -

, -

, (-

, , ). 286

,

.

4. ,

-

,


- 5 -

.

________________________________________________________________

! 蠠 _____________________________________ !

! |____________________________________| !

! _____________________________________ !

! AX |_______AH_______|______AL___________| !

! BX |_______BH_______|______BL___________| !

! CX |_______CH_______|______CL___________| !

! DX |_______DH_______|______DL___________| !

! _____________________________________ !

! SP |____________________________________| !

! BP |____________________________________| !

! SI |____________________________________| !

! DI |____________________________________| !

! PC |____________________________________| !

! _____________________________________ !

! CS |____________________________________| !

! DS |____________________________________| !

! SS |____________________________________| !

! ES |____________________________________| !

!______________________________________________________________!

16- , -

. , -

.

, -

, AX, BX, CX DX.

-

,

AH AL, BH BL .. -

,

.

,

.

.

(

) 64 . ( CS) ,

. ( -

DS) , ,

( ES) . -

( SS) -

, . -

7,

.

-

( 64 ), -

.

. ,

. () IP, -

, , -

, . , S,

, BP, -

. , SI, (-

), DI, -

.

, , -

,

. ,

: , -


- 6 -

.

Ѡ -

1- , -

.

, , , .

-

, -

,

. .

: , ZF, (

), , SF, ,

, CF, , -

, AF,

( ), -

, OF, , ,

, PF, .

. -

, DF, (, -

): . -

, IF, : -

. , TF, -

"" .

.

, 286,

,

. , , NT, -

, , IOPL, -

/.

┌─────────┐

│ │

│ Ϡ │

│ │

└─────────┘

┌────────┐ ┌────────────┐ ┌──────┐ ┌──────┐

│ Ӡ │ │ Р │ │. │ │ │ ┌───────┐

│ │ │ │ │.│ │.│ │. │

│ │ │ │ │/  │ │ │ │. │

│ │ │ │ │ │ │ │ │ │

│ │ │ │ │ │ │ │ │ │

└────────┘ └────────────┘ └──────┘ └──────┘ └───────┘

┌─────────┐

│ │

│.│

│ │

└─────────┘


2

1.

16- ,

, 65536 64.

, , 64 .

, 64 -

; ,

- 640. : -

, 16-

?

, Intel -

8086 -

. 16-

, ,

1048576 ( ) . ,

, , : ,

-

, -

.

" ",

20- (

1048578) 16- . ,

16- ,

ABCD 1234. ,

, (ABCD 1234)

16 . , ABCD,

0 : ABCD0.

( ) -

.

( 20 ) -

. , ,

20- ,

0: , 0,

.. .

, -

, 16- (1234 ) -

:

ABCD0

+ 1234

-------

ACF04

16- , -

20- , 0

1048577. Ƞ , -

PC , 16- -

.

. ABCD , 1234 -

. , 16,

.. , 0.

, 16,

.

-

, -

. 16- 0


- 2 -

65535 ( 64),

64 , -

.

, -

,

PC. -

: ABCD:1234. ,

.

DEBUG,

. DEBUG,

" ",

.

,

, .

, -

; , -

,

. ABCD 1234

ACF04.

, -

. -

CS , .

DS .

ES DS ,

. , -

, SS -

.

. -

,

. -

( AX, BX .. -

SI DI). -

,

.

.

,

, -

. ,

CS -

DS .

-

. - (..

), (

) 64 ,

. , -

, -

.

, , -

64 64 ;

, , -

. : -

, .

( 64) ;

, , . -

,

( ) -


- 3 -

( ). -

, , , .

2.

-

,

. -

.

- , -

. 1024

,

256 - , -

.

0 400 (). (

" ".)

-

ROM-BIOS. ROM-BIOS

, -

. -

ROM-BIOS, -

. ,

ROM-BIOS, , , -

, ,

,

( ALL-CHAR ,

,

).

ROM-BIOS -

256 400 500.

-

,

500 600.

, ROM-BIOS,

.

, -

:

(0-9). -

, -

. PC ,

, -

.

16 ( 64) 640, -

.

, , 0 -

.

( -

) ,

, (

), , -

( -

). : -, ,

() (),

, -, , , , -

, .

, -

.

,


- 4 -

.

0 1-頠 64ʠ 64

1 2-頠 64ʠ 128

2 3-頠 64ʠ 192

3 4-頠 64ʠ 256

4 5-頠 64ʠ 320

5 6-頠 64ʠ 384

6 7-頠 64ʠ 448

7 8-頠 64ʠ 512

8 9-頠 64ʠ 576

9 10-頠 64ʠ 640

A 11-頠 64ʠ

B 12-頠 64ʠ

C 13-頠 64ʠ (XT,EGA,3270 PC)

F 16-頠 64ʠ ROM-BIOS ROM-BASIC

. PC

PC

. 60% . -

640 , -

PC, , ,

PC, . -

64 128 PC 640

. ( ,

: ).

640, ,

, ,

, (

).

-

. ,

0,

, .

" ", -

" -

". , ( ) ,

640ʠ

, . -

, ,

.

3.

PC, -

8088, ,

AT , 286, -

.

286 ( -

6), , 286,

16 . ,

-

IBM. ,

IBM , -

.

-


- 5 -

, 286 -

, ,

. (. " ").

AT

(1024 ) , -

.

, -

AT, -

( ), -

.

PC, ,

, -

,

,

AT.

, , , -

AT.

,

ROM-BIOS. -

( ) -

. -

286 ( -

8088) .

, ,

. , -

,

-

, BIOS, , -

.

________ ________ ________ ________

| | | | | ,

|________|________|________|________| -

| -

|

|

|

______ |

| | |

|______| |

| _|______ _____ _____

| ________| |__________| |______| |____

|-->| |________| |______| |______| |

|________| |__________| |______| |____|

| / /

| / /

| / /

| / /

| / /

| / /

| / /

| / /

| / /

____________________________

| |

| , |

| |

|____________________________|

.


- 6 -

1- ; 2- ;

3- ; 4- ;

5-; 6-

4.

,

, -

, -

. , .

, -

" ", -

,

. ""

, -

. , -

286,

286 ,

, , ,

. " "

286 ,

, , .

()

, ( -

) . -

.

, , ,

. , -

,

( , )?  

,

, ;

-

.

- (,

, -

), -

. -

, .

, -

, -

; . -

.

,

.

,

,

.

,

, -

,

.

, "": -


- 7 -

, -

.

,

. -

, ,

, ,

.

5.

----------------------------------------------

,

. , ,

-

. ,

, ,

.

, , -

. , "" -

, 64 ( 512).

64 (64) . -

, -

, .

,

, , -

. , ,

, -

. ,

- - -

.

, ,

. ,

, -

-

. -

- ,

, "-

"(Lotus), -

, "", -

.

" -

//", ,

, ""

: " " ("Above Board").

, .

: - (

) (

, , -

). (

" " "" ) -

- 64 8 ,

16, -

.

()


- 8 -

. , -

, PC, -

. -

64, ,

.

, D E -

, ,

C. ,

- . ,

. -

, C400

C 16 D.

, -

(64), 16.

, ,

,

16 ( ).

, -

,

. -

,

. -

( 16) ,

.

____________________________________________________________________

| |

| |

| _______________________________________ |

| | | |

| | ------- ------- | |

| | | | | | | ߠ |

| | | | | | | ܠ |

| | ------- ------- | |

| | | ------- | ------- | |

| | | | | | | | | |

| | | | | | | | | |

| | | ------- | ------- | |

| | | | | | | |

| |_______________________________________| |

| | | | | |

| | | | | |

| | | | | |

| |/ |/ |/ |/ |

| ------------------------------------------------------ |

| | | | | | | | |

| | | | | | | | ܠ |

| ------------------------------------------------------ |

| 0 640ʠ ___________ ____________/ |

| V |

| |

| |

|____________________________________________________________________|

.

,


- 9 -

. , -

, .

Ѡ -

, , -

, -

, ,

. , -

, , , -

,

16. , , -

-

.

PC, AT . ,

AT ,

PC,

⠠ 

.

DOS

0000:0000 .

0040:0000 BIOS.

0050:0000 DOS.

XXXX:0000 IBMBIO.COM - DOS,

BIOS.

XXXX:0000 IBMDOS.COM -

DOS ( INT 21).

DOS .

XXXX:0000 COMMAND.COM -

22 (), 23 (Ctrl-Break),

24 ( )

.

XXXX:0000 -

( .COM .EXE)

XXXX:0000 ( .COM)

XXXX:0000 COMMAND.COM -

,

DOS,

,

.


3

1.

, -

. -

BIOS . IBM/PC

. BIOS -

-

. BIOS IBM/PC ""

, ,

IBM/P.

- " " .

- ,

.

-

( CTRL-Alt-Del).

.

堠 蠠 Ѡ

IBMBIO.COM IBMDOS.COM.

,

. IBMBIO.COM -

BIOS . 2.00

IBMBIO.COM ,

, .

BIOS , IBMBIO.COM , -

"" .

IBMDOS.COM . ""

/ .

"" .

, DIR. -

IBMBIO.COM -

.

- COMMAND.COM.

COMMAND.COM , . -

, , TYPE, COPY DIR -

COMMAND.COM. COMMAND.COM -

: IBMDOS.COM, -

.

,

FORMAT DISKCOPY.

.

, -

,

. , , FORMAT, -

, .

,

. IBMBIO.COM, IBMDOS.COM -

. COMMAND.COM --

, .

.

.


- 2 -

2. BIOS

- BIOS /-

, . -

,

/.

BIOS FE00 FFFF,

.

BIOS IBM/PC,

, -

. IBM/PC, BIOS -

, -

IBM/PC.

BIOS ,

( -

, ).

BIOS, , -

.

,

IBM/PC, . -

, -

. -

, , -

.

BIOS, -

, - -

. ,

" ".

,

.

, BIOS -

. IBM/PC,

, , .

- -

, BIOS

- .

IBM/PC. -

, , , , -

. -

, IBM/PC.

3. -

. -

. -

.

IBM/PC ,

Ctrl-Alt-Del, BIOS -

,

, 31744 700 ().

BIOS , -

31744. -

.

IBMBIO.COM IBMDOS.COM. -

, 512 ,

. , ,


- 3 -

IBMBIO.COM IBMDOS.COM,

.

.

, , "" - ,

, IBMDOS.COM

IBMBIO.COM. -

- , , -

.

,

,

. -

, ,

.

( , ).

  ,

.

, ࠠ

,

1.10.

4. IBMBIO.COM

, IBMBIO.COM, -

BIOS . BIOS , IBMBIO.COM

/ -

, .

, /. -

,

.

IBMBIO.COM , ,

BIOS . IBMBIO.COM -

,

BIOS .

, .

IBMBIO.COM

BIOS , . ,

BIOS, ,

.

BIOS,

IBMBIO.COM.

, BIOS -

IBMBIO.COM, BIOS.

BIOS ,

. -

BIOS, , ,

.

, BIOS, ,

IBMBIO.COM, -

, ,

(203) , , ,

IBM/PC. /

IBM/PC,

IBMBIO.COM ,

, BIOS.

IBMBIO.COM , ,

.

"" "", -


- 4 -

, -

.

-

,

, 2.00.

IBMBIO.COM,

, .

, , -

.

-

, BIOS. -

IBMBIO.COM. -

, ,

.

, , IBM/PC, -

BIOS . , -

/. -

IBMBIO.COM , -

, IBMBIO.COM,

. -

.

5. IBMDOS.COM

, IBMBIO.COM

IBMDOS.COM , -

, ,

.

, , -

, ,

, ( 33,

21). ,

, - . -

, , -

BIOS: .

32 63 ( 20

3F) .

, -

.

, -

Ctrl-Break.

, ,

/.

, , / -

.

- ,

, , . -

,

,

,

, ..

. ,

DIR COPY. , -

.

4.9 .

6. COMMAND.COM


- 5 -

, COMMAND.COM,

, , -

, .

COMMAND.COM . , " -

", , -

, .

, DIR, COPY, TYPE, REM

PAUSE, , ""

COMMAND.COM, .

, COMMAND.COM -

. COMMAND.COM,

. COMMAND.COM

DEBUG DiskLook. ,

. -

DEBUG SecMod,

. -

, , -

.

, -

, COMMAND.COM .

  , COMMAND.COM

.

COMMAND.COM

,

.

蠠  ,

COMMAND.COM ,

.

".BAT", -

,

ASCII , -

, .

COMMAND.COM -

, -

. -

, , -

, .

, , -

, . . -

COMMAND.COM

.

, -

, .

.

, COMMAND.COM :

1. 頠 , Ӡ

IBMDOS.COM . -

22H ( ), 23H ( Ctrl-Break)

24H ( ), -

. (

, ,

. , ). -

,

COMMAND.COM. -

"Abort, Retry or Ignore".

-


- 6 -

.

AUTOEXEC.BAT. , -

. -

, COMMAND, -

.

- ( ) .

: ( 3),

jds[ , ( 4) , -

(..

.COM .EXE). s

(Exec).

3 COMMAND (. A>),

( ) . -

Exec .

7.

-

. , ,

IBM/PC. ,

.

,

".COM" ".EXE", ,

. , -

.

DISKCOPY, COMP, FORMAT,

EDLIN, BASIC BASICA

,

, .

, -

.

,

, ,

FORMAT. , , -

, , , -

. Ѡ

-

- .

8. DOS

( ),

A:), -

. -

, , ࠠ ࠠ

IBMBIO.COM IBMDOS.COM ( ). -

, , -

. (IBMBIO.COM -

).

IBMBIO.COM -

, ,

,

. IBMDOS.COM -

DOS.

IBMBIO.COM, DOS

, -

. DOS


- 7 -

, 20-27

(. . 6) COMMAND.COM -

; IBMBIO.COM.

IBMBIO.COM -

COMMAND.COM ,

DOS. IBMBIO.COM COMMAND.


4

1.

-

-

. -

, ""

0 0.

: -

4-.

"" ( -

), -

. 2--

, , -

.

, DEBUG. -

D : D 0:0. DEBUG

128 32 ,

:

0000:0000 E8 4E 9A 01 00 00 00 00-C3 E2 00 F0 00 00 00 00

0000:0010 F0 01 70 00 54 FF 00 F0-05 18 00 F0 05 18 00 F0

0000:0020 2C 08 51 17 D0 0A 51 17-AD 08 54 08 E8 05 01 2F

0000:0030 FA 05 01 2F 05 18 00 F0-57 EF 00 F0 F0 01 70 00

0000:0040 90 13 C7 13 4D F8 00 F0-41 F8 00 F0 3E 0A 51 17

0000:0050 5C 00 B7 25 59 F8 00 F0-E2 0A 51 17 9C 00 B7 25

0000:0060 00 00 00 F6 8E 00 DE 09-6E FE 00 F0 F2 00 7B 09

0000:0070 27 08 51 17 A4 F0 00 F0-22 05 00 00 00 00 00 F0

" ": ,

. , , DEBUG -

(E8 4E 9A 01)

019A:4EE8.

.

, ROM-BIOS,

F, .

, (

: 019A:4EE8).

(, SideKick Prokey), -

DEBUG ( DEBUG

). , ,

.

, (

1) .

pepa o ooe poep, oope oep ae

oe opeeeo aa. Cec aapae popae

pepa. Aapae pepa pc aapapo, o c

cceo a, o c ap pacpe. O o a

cao pocxe aepa, cao o pepa, aae a a

aape oeco px p. Aapae pepa e oop-

pc c paoo頠 popaoo oecee. Koa aec

pepae, o poeccop ocae co pao, oe pepae, a

ae opaaec a peee eco. oo o e oooc

epc oo oe eco popa, apec oo eca (CS:IP)

aoaec a cee, ece c pecpo ao. ae CS:IP

apaec apec popa opao pepa e epeaec


- 2 -

paee. popa opao pepa oa aa paepa

pepa. O cea aepac cpe IRET (opa

pepa), oopa aepae poecc, aa pepae, opaa

cape ae CS:IP pecpa ao, e ca aa popae

oooc poo oee oo e coco.

C po copo, popae pepa a cao ee eo e

pepa. Ha cao ee o oe poep, oope ac

Ba popaa oe po pao, ao a pe

aa a a aape o a pa. Oao

opopa coepac e p Bae popa, a oepaoo

ccee exa pepa ae Ba oooc opac .

popae pepa o ac p pa. Hapep, ce

pepa opao oa c aap DOS co pepa

opao oa c aap BIOS oe coa epa

aap. apaoe pepaee oe o paee p

oe popaoo pepa. p o e oae oo,

a a aa opopaa opao pepa coxpae ae

cex coex e pecpo ae occaaae x p xoe,

e ca e oca ceo oo, o oa aaa poeccop.

Apeca popa pepa aa eopa. Ka eop ee

epe aa. B epo coe xpac aee IP, a o opo -

CS. Mae 1024 a a coepa eopa pep a, a

opao eec eco 256 eopo. Bece e o aac

ae頠 eopo. Beop pepa 0 aaec c e

0000:0000, pepa 1 - c 0000:0004, 2 - c 0000:0008 .. Ec

ocope a epe aa, aa c ape ca 0000:0020, oopx

coepc eop pepa 8H (pepa e pee co), o B

oape a A5FE00F0. e , o a a coa pacooe

caaa o opo IP:CS, o 4-aoe aee epeoc

F000:FEA5. o capo apec popa , oe pepae

8H. Ha pc. 1-2 oa aa cxea oe popao pepa 21H.

2. popapoae opoepa pepa 8259.

pae aapa pepa o cex ax IBM PC co-

ec pocxea popapeoo opoepa pepa Intel 8259.

oco a oe pee oe oc e o apoc,

pocxea ee cxe popeo. eec 8 po e popeo,

poe AT, oopoo x 16, opae coo ec po

ooaac copae o IRQ0 o IRQ7 (o IRQ0 o IRQ15), o

oaae apoc a pepae. Maca pope cooece

po 0. oaoe 8 poe AT opaaac opo pocxeo

8259; o opo aop poe ee pope e IRQ2 IRQ3.

apoc a pepae 0-7 cooec eopa pepa o 8H o

0FH; AT apoc a pepa 8-15 ocac eopa o 70H

o 77H. He p ee aae x pepa:

Aapae pepa ope popea.

IRQ 0 aep

1 aapa

2 aa oa/oa

8 ac peaoo pee (oo AT)

9 popao epeoc IRQ2 (oo AT)

10 peep

11 peep

12 peep

13 a. copoeccop (oo AT)

14 opoep cpoaoo ca (oo AT)


- 3 -

15 peep

3 COM1 (COM2 AT)

4 COM2 (oe PCjr, COM1 AT)

5 cpoa c (LPT2 AT)

6 opoep ce

7 LPT1

pepa pee co a aca pope, oco ec

oo e ocoo epc, o eep oaa ccex

aco. pepae o aap aec p aa oca

a; oo ae e co, oopa oo aaaec e,

o o a oe- aec ep aap (oa o ae oe

oe popa pepa).

Mpocxea 8259 ee p ooax pecpa, oope pa

oce aapax pepa. Pecp apoca a pepae

(IRR) caaae cooec , oa pepa

cape o apoce. ae pocxea aoaec poepe e

opaaaec poe pepae. p o젠 oa apaae

opa pecpa oca (ISR). ooe a e oeae

a cxe popeo. Haoe, epe oo pepa, poepec

pecp ac pepa (IMR), o a papeeo a

oe pepae aoo po. Ka pao popac opaac

oo pecp ac pe pa epe op 21H oao

pecp pepa epe op 20H.

3. ape/papeee oex aapax pepa.

popa a aaceepe o ape aapae pepa,

epecee . o acpee pepa; pe aa- pae

pepa, oae p eoopx oax (ax a eee a

o) e o acpoa. ec e p apea

aapax pepa. B epo cae ce pepa opc c e

o peca ac oa a oea eo, pee e aa

poee aoe-o poe ece. Hapep, pepa apea

p蠠 ee eopa aapaoo pepa, ea oe

pepa oa eop ee oo aoo.

Bo opo젠 cae acpc oo opeeee aapae

pepa. o eaec oa eoope opeeee pepa o

aoecoa c oepa, p peea. Hapep, oo

paccaa o pee poepa oa/oa e oe cee oo

pepao e co pepa- e.

H poe.

Boee pepa ac o ae aa pepa ( 9)

pecpe ao. Koa o pae 0, o papee ce pepa,

oope papeae aca. Koa o pae 1, o ce aapae pepa

apee. o ape pepa, cao o a 1, co-

ec cp CLI. oc oo aa occaoe

pepa - cp STI. e- ae oe pepa a

e epo. pepae pee co pocxo 18.2 paa

ce ec o pe- pa oee e o apoc o

pe, oa aapae pepa apee, o e apoc

opoe cceoe pe e opeec epao.

aa aoaec apeae aapae pepa p oe

popax pepa aoaec papeae x p opae. Koa

B ee co popae pe- pa, o B oee aa popa

c cp STI, ec B oee oc aapae pepa.

Oe ae, o ec a cpe CLI e cee STI, o o


- 4 -

pee ocaoe a, a a o c aap e aopoe.

acpoa opeeex aapax pepa o poco

oca pee eo o op c apeco 21H, oop

cooece pecp ac pepa (IMR). Pecp ac a opo

pocxee 8259 AT (IRQ8-15) ee apec opa A1H. caoe e

pecpa, oope cooec oepa pepa, oope B

xoe acpoa. o pecp oo oo aca.

Hepee pep ope co- oe pepae. He ae

oc pecp oe popa, ae opaee ca e

apeeo oce aepe popa.

;---acpoae 6-o a pecpa ac pepa

MOV AL,01000000B ;acpe 6

OUT 21H,AL ;ocae pecp ac pepa

.

MOV AL,0 ;

OUT 21H,AL ;oae IMR oe popa

4. Hacae coceoo pepa.

eec ecoo p aca coceoo pepa.

Bo-epx, oco 砠 oox pepa, oeceaex

oepaoo cceo, o oe, a oe poep, oce

cex popa, B oee oea oa coe oe.

Hapep, oe Ba popa o cooa poep, o

cpo a pa epao. Beco oo, o a ee a

popa aece poep B oee cao ee a pepae,

aca⠠ popa, oopa ocaec peeo a oce

aepe. Toa B oee cooa INT 80H eco

WRITE_VERTICALLY (ee , o o pepa ecoo

eee, e o poep).

Bopo po頠 aca pepa oe cooae

aoo-o oeoo aapaoo pepa. o pepae

aoaec aec p ooe opeeex co. B

eoopx cax BIOS ape eop oo pepa a, o

o aae a poep, oopa ooe eo e eae (oa

coep o oepaop IRET). B oee aca co poep

e eop pepa, o o aa a ee. Toa p

ooe aapaoo pepa e oc Baa poepa.

Oa ax poep o pepae pee co [2.1.0], oopoe

aoaec aec 18.2 paa ce- . Oo o pepae

oo ooe oaae aco, o B oee oa e o

o, oop B oeaee. Ec Ba o poepe oaa aco

cae p opeeee oe pee, o oo oepa

peao pee.

Cpe poe.

25H pepa 21H caaae eop pepa a

aa apec. Apeca e paep a coa. Capee coo coep

aee ceea (CS), aee coep ceee (IP). o

cao eop, aa a o Bax poep, o

oec cee poep DS, a ceee DX (ce op

epeeoo pepa). ae oece oep pepa- AL

oe . a poepa pepa oa aepac e

oo cpe RET, a IRET. (IRET aae cea p coa,

a pecp ao, o pe a RET oeae a ce oo a.

Ec B oaeec ecpoa a poep a o poep,

o oac IRET, o B cepaee ce.) Oe, o 25H


- 5 -

aoaec ape- ae aapae pepa poecce ee

eopa, oo e cece oacoc, o ocpe opo pooe

aapaoe pepae, coee a eop.

;---caoa pepa

PUSH DS ;coxpae DS

MOV DX,OFFSET ROUT ;ceee poep DX

MOV AX,SEG ROUT ;cee poep

MOV DS,AX ;oeae DS

MOV AH,25H ; cao eopa

MOV AL,60H ;oep eopa

INT 21H ;ee pepae

POP DS ;occaaae DS

;---poepa pepa

ROUT PROC FAR

PUSH AX ;coxpae ce eee pecp

.

.

POP AX ;occaaae pecp

MOV AL,20H ; e cpo ao cooa

OUT 20H,AL ;oo aapax pepa

IRET

ROUT ENDP

B oe oa aoo Bax aapax pepa B o -

cee 2 cpo oa:

MOV AL,20H

OUT 20H,AL

o poco coaee, o ca (20H) o e e oex cpoax.

Ec aapaoe pepae e aaaec cpo- a, o

pocxea 8259 e oc opa pecpa oca, c e

o a papeea opaoa pepa c oee po, e

oo o opaoaoe. Occe x cpo eo oe pec

pax popa, a a pepa o aap copee ceo oac

aopoe ae Ctrl-Alt-Del oaec ecoe. Oe, o

a oaa e a ex eopo pepa, oope c

pacpe cecx pepa, a a pepae 1CH, oopoe

oae o pepa pee co.

Koa popaa aepaec, o occaoe opae

eopa pepa. B poo cae ocea popaa oe

a aoe pepae epea paee a o eco a,

oopo Bae poep e e. 35 pepa 21H opaae

eee aee eopa pepa, oea aee ceea ES, a

ceee BX. epe caoo coeo pepa oe eee

aee eopa, co , coxpae ae,

ae젠 occaoe x c oo 25H (a e) epe

aepee coe popa. Hapep:

;--- ceee ax:

KEEP_CS DW 0 ;xpa cee aeeoo pepa

KEEP_IP DW 0 ;xpa ceee pepa

;--- aae popa

MOV AH,25H ; oe eopa

MOV AL,1CH ;oep eopa

INT 21H ;eep cee ES, ceee BX

MOV KEEP_IP,BX ;aoae ceee


- 6 -

MOV KEEP_CS,ES ;aoae cee

; --- oe popa

CLI

PUSH DS ;DS e pape

MOV DX,KEEP_IP ;oooa occaoe

MOV AX,KEEP_CS ;

MOV DS,AX ;oooa occaoe

MOV AH,25H ; cao eopa

MOV AL,1CH ;oep eopa

INT 21H ;occaaae eop

POP DS ;occaaae DS

STI

H poe.

Ocae e MS DOS poco oa e ap co

ax eax a. Ceee eopa oe ceo poc

oee젠 oepa eopa a 4. Hapep, o o apec

pepa 16H ES:BX:

;---oee apeca pepa 16H

SUB AX,AX ;caaae ES a aao a

MOV ES,AX ;

MOV DI,16H ;oep pepa DI

SHL DI,1 ;oae a 2

SHL DI,1 ;oae a 2

MOV BX,ES:[DI] ;epe a a BX

MOV AX,ES:[DI]+2 ;epe cap a ES

MOV ES,AX ;

He peoeec po caaa eop pepa, oxo -

DOS. B acoc ooaao cpee oepaoa cc- ea oe

oepa ecoo a eopo pepa pea ec

apec a oe ece oo DOS.

5. ooee cece pepa.

Xo e aco, o oa ae oeo oa o cec-

e pepa. B aece pepa paccop popa, oope

peopa oo aae a e opeeee ooaee

coe cpo (apoopeee aap). popa co-

a, o ec o c aap ocae ocae epe

0 pepa 16H BIOS [3.1.3]. Bce pepa oa c aap DOS

a pepae BIOS oe coa epa aap.

oo eoxoo opoa pepae 16H, a opao,

o oo co aao apoopeee, oce eo a

popaa e oa apoopeee, eaco o oo, aoe

pepae oa c aap oa coe.

Koeo, opoa pepa BIOS DOS epoco, oc- o

BIOS pacooea , a DOS ocae e ca o opae

paepa oeeo x a. Ho B oee aca poep,

oopa peece / cee a cooec pepae,

a poepa oe ac p oe pepa DOS BIOS.

Hapep, cae pepa 16H, Ba o aca poep

aa a ee eopo pe- pa 16H. Opaoe aee

eopa 16H e peee epeocc ao-o ecoe

eop, cae, 60H. Hoa poepa poco ae pepae 60H,

o coo- a opaoe pepae 16H; oo oa


- 7 -

popaa ae pepae 16H, paee epeaec Bae

poepe, oo- pa ae ae opaoe pepae 16H,

oopa o aep- e o opaae paee Bae poepe, a

ee e B opaaeec o eco popa, oopoo o

pepa 16H. oce oo a o ceao, oo poepe oe

coepac o o, a o, a oce oa pepa- 60H. Bo

paa coa eoxox ec:

1. Coa o poep, a pepae 60H.

2. epeec eop pepa 16H 60H.

3. e eop 16H, o o aa a o poep.

4. aep popa, oca ee peeo [1.3.4].


5

1.

2.00, DOS

.

48 - , 49 - , 4A (Setblock) -

.

:

DOS .

"", DOS

, "" .

; (

, , -

). DOS

,

. , -

, , , -

.

- , -

, .

, DOS 48 (Exec) -

, .

: 0 ,

3 .

,

.

0, DOS

( -

).

Exec . , -

, , , -

COMMAND.COM, .

Exec ,

, . ,

, .

. .EXE -

MAX ALLOC

. ,

, MIN ALLOC -

. LINK. ,

, .

Setblock . ( .COM

, -

, , DOS

). -

. -

, .

,

DOS, .

, Exec 0, , -

. , -

, -

. ( :

DOS : -


- 2 -

).

3

;

-

. ,

- , ,

DOS.

, 3 -

.

DOS; -

- -

,

. ,

DOS , .

2. Ma c a.

Koa MS DOS apae popa, o oa oeaec a

oac a, cpa e a COMMAND.COM caoe pae- pa

cpoc p a, oope pee a. B o

oe pee c a a popao oeea o popae. Ec

popae a a coa oac ax, o oa oe p-

eo c e a oaec ee o ae oec

pee oac ax oe eco a oo oa. opeee

apeca oa popa oece oe popa ceocee a:

ZSEG SEGMENT

;

ZSEG ENDS

B acceepe IBM PC ZSEG e oce ceeo, a a cee

pacoaac aao ope. C p accee- pa o

eceo oec cpo oe popa. B cao popae

ocaoo oca oepaop MOV AX,ZSEG AX e aa a

ep coo cee a a popao.

Tao oxo e paoa o ex op, oa popaa e e

peoaa o a a, oopo a cao ee e. O e e

ae paoa ooooaeco cpee, oa ecoo popa

o e e coo o e oac apeco. pee o

poe MS DOS ee oooc oc- ea 640K cceo a

oo o peoa popa o a oo paepa. o

a - o poco epepa oac a, eo aca paep

opeeec paepo oco a, acoc, o oe

oe ooo ceea (64K). Ec apeoa co oo o, o

DOS ae cooee o oe. a oooc epep oo

ce- a. Kpoe oo MS DOS oe ocooa, pea pacp

cece o. Xo popaa e oaa cooa

cpeca, o oo pecopeo ea o. Heoope

DOS pe, o cooa cpeca pae a DOS,

apep, aepee peeo popa [1.3.4] o po

popa ao [1.3.2].

pee e oec a, cec o (c a o aaa

popa o oa) oe opea o paepa popa. ae,

p coa oa, DOS coae 16-a pa o a,

oop pacooe eocpeceo epe oo a. epe 5 ao

oo oa e ceee ae- e:

a 0 ASCII 90 - ec oce o eoe, ae

ASCII 77.


- 3 -

a 1-2 0 ec o ocooe

a 3-4 paep oa 16-ax apapaax

DOS opaaec oa o eoe. Apec epoo oa xpa- c

o pee epeeo. aee o epeeo oo- e DOS

opee ooee epoo oeeoo oa, a opa,

coepaec e, oe ae ce o .. Ka oo

B aa coo- a cce pacpeee a DOS, o B

oa pepac ee. Ec popaa e coepoe pa-

eo oa, o eoa e paopaa DOS ae aa cooe

o oe.

MS DOS oeceae p pacpeee a, oepa o 48H

o 4AH pepa 21H. 48H oo o a, a 49H -

ocooae o a. Tpe ("SETBLOCK") e- e paep

a, oeeo popa; a oa cooaa

epe oca. oce ee oe oo cooo oo

ocooa o a. popaa oa ocoo ce oeee e

o epe aepee. ae a a e eoco

oceeo cooa- .

Cpe poe.

Bce p pacpeee a pepa 21H co

16- apec aaa oa a, c oop o oepp. o

apec cooece cee, c oopoo aaec o (o cea

aaec co cee 0 aoo ceea). Ta opao pea

apec e aaa oa pae o apec, oeo a 16. Tae,

cex pex , BX coep co 16-ax paeo a

(apapao), oope ooc ocooac. Ec

e oe oe- a, o caaaec a epeoca, a AX

opaaec o o, oc p. Boo p oa o:

7 pape pa o a

8 eocaoo a oe

9 eep apec oa a

oee oa coe o 7 8, a ocooe - 7

9, o pe a ee oa coe ce p oa. B

cee pepe caaa ooc o, paepo 1024 aa. p o

BX coep peeoe co 16-ax apapa- o, a p aepe

capo apec oa pae AX:0 (.e. ceee 0 ceee co

aee, coepac AX). Bopa ac pepa ocooae o e

o, a peec p a- epe popa. B ao cae

aee oeoe AX oeaec ES. DOS ce a paepo oa

ae aoe oeco apapao ao ocoo.

;---oeee oa paepo 1024 aa

MOV AH,48H ;oep

MOV BX,64 ;pee 64 apapaa

INT 21H ;aec oec o

JC ERROR ;opaaae o cae ea

MOV BLOCK_SEG,AX;ae coxpae apec oa

.

;---ocooae o e o

MOV AX,BLOCK_SEG ;oae capo apec oa

MOV ES,AX ;oeae eo ES

MOV AH,49H ;oep peeo

INT 21H ;ocooae o a

Haoe, pee pep cooa 4AH. ES coep-


- 4 -

aee ceea PSP, .e. caoo epoo aa a, c oopoo

apea popaa. o aee pcaaec ES p cape aa.

cooa SETBLOCK ao o a cao

aae popa (pee e ES e ee), o coxpa eo

aaoe aee oceeo coo- a.

BX coep pee paep oa 16-ax apapaax.

opeee oo paepa oece oao "cce" cee

oe popa. B apoaccceepe IBM PC cee pacoaac

aao ope, oo B oee oec eo oe eco

popa, p co, o eo o o-o poe "ZSEG". B px

acceepax eceo oeae 頠 cee oe

popa. popaa oe poa o oo ceea ,

cpaa ee co capo ceeo, o oeco a,

peeoe cao popae. B oe ap popa ES DS

coepa oep apapaa caoo aaa popa pece

popaoo ceea; COM ao CS ae aae a o-

, o EXE ao o e a. ;---ocooee a (ES ee

aee p cape)

MOV BX,ZSEG ;oae # apapaa oa popa + 1

MOV AX,ES ;oae # apapaa aaa popa

SUB BX,AX ;ce paep popa apapaax

MOV AH,4AH ;oep

INT 21H ;ocooae a

JC MEMORY_ERROR ;poepe a o

;---

ZSEG SEGMENT

ZSEG ENDS


6

.EXE

EXE, :

- .

- .

, ,

.

.

, -

.

:

00-01 4D5A - "" , ,

EXE.

02-03 512 (..

).

( 1.10

04; ,

).

04-05 .

06-07 .

08-09 16- .

.

0A-0B ,

.

( 16- ).

0C-0D ,

.

( 16- ).

0E-0F

.

10-11 SP .

12-13 -

.

14-15 IP ( )

.

16-17

.

18-19

.

1A-1B .

(0 ).

. -

, 06-07. -

: 2- 2- -

, , ,

, .

:

1.  

.

2. .


- 2 -

3. ( -

04-07 08-09

02-03). , -

, .

.

4. .

5. .

6. -

. -

;

.

7. , SS SP

, , SS

. ES DS

. -

, ( 14-17).

2.

-

Exec, DOS ,

. -

.

0000 DOS

(PSP).

0100.

0000 -

, INT 20, INT 21 AH=0 AH=4C, -

0050 AH=0

AH=4C.

: , 4C,

CS

.

COMMAND.COM ( 4C ).

,

Exec (4B). 22, 23 24 (-

, Ctrl-Break, )

. -

. COMMAND.COM,

.

, , COMMAND -

.

,

:

:

- 2C

. ASCIIZ,

=

<= 32K ;

. . , -

COMMAND, , , COMSPEC=

( - ,

COMMAND.COM). ,

PATH, PROMPT SET (. 10).

. , -

PATH, PROMPT SET .


- 3 -

- 0050

DOS. , AH

, (LCALL) PSP + 50,

21.

- DTA PSP +80.

- , 5C 6C

.

, FCB ,

.

- , 81,

, -

. 80 .

( > <)

, .

- 6 -

.

- AX ,

:

AL = FF -

, AL = 00;

AH = FF -

, AH = 00.

.EXE:

- DS ES .

- CS, IP, SS SP , -

.

.COM:

-

.

- . -

Exec,

Setblock (4A)

- IP 0100H.

- SP . -

6 0100H, -

.

-

(

):


- 4 -

----------------------------------------------------------------

| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |

----------------------------------------------------------------

| INT | Top of | Re- | Long call to DOS |

| 20H | memory |served | OP # bytes |

| | | | CODE in segment |

----------------------------------------------------------------

| 8 | 9 | A | B | C | D | E | F |

----------------------------------------------------------------

| cont.segment | Terminate | Terminate |Ctrl-break exit|

| of long call | address IP | address CS |address IP |

----------------------------------------------------------------

| 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

----------------------------------------------------------------

|Ctrl-break exit Critical error exit address | Reserved |

|address CS | IP CS | |

----------------------------------------------------------------

| 18 | 19 | 2A | 2B | 2C | 2D | 2E .... 4F |

----------------------------------------------------------------

| R e s e r v e d |Segment address| Reserved |

| |of environment | |

----------------------------------------------------------------

| 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |

----------------------------------------------------------------

| DOS call | R e s e r v e d |

----------------------------------------------------------------

| 58 | 59 | 5A | 5B | 5C | 5D | 5E | 5F |

----------------------------------------------------------------

| R e s e r v e d | Unopened Standart FCB1 |

----------------------------------------------------------------

| 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 |

----------------------------------------------------------------

| Unopened Standart FCB1 (cont.) |

----------------------------------------------------------------

| 68 | 69 | 6A | 6B | 6C | 6D | 6E | 6F |

----------------------------------------------------------------

| F C B 1 (cont.) | Unopened Standart FCB2 |

----------------------------------------------------------------

| 70 to 7F |

----------------------------------------------------------------

| Unopened Standart FCB2 (cont.) |

----------------------------------------------------------------

| 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 |

----------------------------------------------------------------

| Parm | Command parameters starting with leading blanks |

| length| |

----------------------------------------------------------------

| F8 | F9 | FA | FB | FC | FD | FE | FF |

----------------------------------------------------------------

| C o m m a n d p a r a m e t e r s |

----------------------------------------------------------------

:

1. - ; . 1000

64K.

2. 6 .

3. 2C .

4. PSP 00 5C.


7

paee popaa.

oco popa apac a, acac, a ae

ac oepaoo cceo p aepe. co- oo po

oo e e aepa. Ho popaco a acceepe

eec pa oooc a pae eocppe ee. Heoope

popa ec a paep cpoc paep pepa

o o coxpae a ("pee") ae oce x

aepe (eopa pepa oecea exa, ocpeco

oopoo ocee popa o opaac ꠠ pee

poepa). oa popae eoxoo ac ce p

popa. Ha cao ee DOS ooe popae ap a

op o COMMAND.COM, oopa oe cooaa a cpeco

epeca c ooae- e oe oa a COPY DIR.

1. ac oo popa po.

MS DOS oeceae EXEC (oep 4BH pepa 21H), pea-

o oo popa po. epa popaa aaec

"poee", a apaea acaea - "ooo".

Cpe poe.

4BH oee coa, e ocae, pe epex oo-

oex ao:

1. ooo a eco, ocoe popae.

2. Coa o apaepo.

3. ocpo cpo, coepa aoe, po-

pa.

4. Coxpa ae pecpo SS SP epeex.

oco p ape popa MS DOS ee e c oc-

a, o eoxoo ocoo eco a. Ec e ocoo

ac a, o e e eca ap opo popa. oce

oo a a ocooea, B o poco oec BX peeoe

co 16-ax apapao, aca 4AH AH o pepae

21H, ea oc popae eo o co apapao, oopoe e

peec.

o apaepo, a oop o aa ES:BX o 14-a

o o a, oop B o oec ce- opa:

DW cee apec cpo cpe

DD cee ceee oao cpo

DD cee ceee epoo FCB

DD cee ceee opoo FCB

Cpoa cpe - o cpoa, cocoa oo oee ce-

a, oop cee MS DOS p oe popa. ee

cpo cpe ae e, a e o oo oap co- o ae

CONFIG.SYS. Hapep, cpo oe oeeo VERIFY = ON. poco

ae cpo c epoo eea, aep eo coo ASCII 0, oo

ae ce .. a oce eeo o ceoa a

coa ASCII 0. Cpoa oa aac a pae apapaa (.e. ee

apec o o 16 oe pae ). o ao e, o

cooec頠 xo oe apaepo, aa a cpo,

coep oo 2-aoe ceeoe aee. Bce o e o, ec

oa popaa oe paoa c o e cpoo cpe, o popaa

"poe". B o cae ao poco oec a coa ASCII 0

epe 2 aa oa apaepo.

Cee 4 aa oa apaepo aa a oa cpo


- 2 -

apaeo popa. "Koaa cpoa" - o coa cpoa,

opeea coco pao popa. p ape popa DOS oa

oe e poe EDITOR A:CHAPTER1 NOTES.MS. p o aec

peaop e epeaec aa oaaoe aoe A

eeeoo op. Koa B ooaaee oa cpo

EXEC, o ao a oo oce ac opa, o e

apaeo popa. epe oao cpoo oe co a,

coepa o cpo, oa oa aepac coo

(ASCII 13).

ocee 8 ao oa apaepo aa a pae o

ao (FCB). FCB coep opa o oo x aax,

aax oao cpoe. Ec opaex ao e, o ao

ao ce 8 a coo ASCII 0. B [5.3.5] oceo, a

paoae FCB. Haa c epc MS DOS 2.0, cooae FCB

eoaeo B oee e a opa FCB, eco oo

co o oe ecpopa ao (file handler), oopo

oc a peocaec o ooo oep, a e epe FCB

(ae ocaec [5.3.5]).

Haoe, B o ocpo cpo c aae aoe,

e aa. a cpoa ee apae popa. DS:DX aae

a cpo p oe EXEC. a cpoa - caapa cpoa

ASCIIZ, .e. eo oee, e caapa cea aa,

aepaea oo젠 ASCII 0. Hapep, o oe

B:NEWDATAFILER.EXE, e coo ooa- e o ASCII 0.

oce oo a c aaa opa oooea, ocaec

oce aaa. oco ce pecp ee ae- o

aae, o ao coxpa cee cea aae cea, c e o

o o occaoe, oa paee e opaeo

ae aae. x coxpae coae epeee. oco

aee pecpa DS ae e eeo, o epeee e o

ae, o ex op oa e oo- pe oepaop MOV

AX,DSEG MOV DS,AX. oce oo a SS SP coxpae, oece 0

AL, opa oepa "apa ac" (EXEC coec ae

oepee. ae oece 4AH AH oe pepae 21H. B

o oe ae e popa, pe popaa "poe"

axoc oca- oeo coco. MS DOS peocae oooc

popae oo epea poe o opaa, a opao o

epea o cac. o acaec cao aca, o

p ooe o caaaec a epeoca, a pecp AX

o cae e opaa 1 - epaoo oepa , 2 -

ec a e ae, 5 - p coo oe, 8 - p exae a,

10 - ec epaa cpoa cpe 11 - ec eepe opa.

po pep - poce oox, o aco oe eo

e ao. ec ocae e o apaepo e coaa cpoa

cpe. o oaae, o apaeo popae e e epeaac

oaa cpoa o cpea e ao e, a ae

popa. B o oo e pacpe- eee a, coa

(co) o apaepo coxpa- ae SS SP.

;--- ceee ax

FILENAME DB 'A:TRIAL.EXE',0 ;apae TRIAL.EXE

PARAMETERS DW 7DUP(0) ;eo o apaepo

KEEP_SS DW 0 ;epeea SS

KEEP_SP DW 0 ;epeea SP

;---epepacpeeee a

MOV BX,ZSEG ;o # apapaa oa

MOV AX,ES ;o # apapaa aaa

SUB BX,AX ;c paep popa


- 3 -

MOV AH,4AH ;oep

INT 21H ;epepacpeeee

;---aae a o apaepo

MOV AX,SEG PARAMETERS ; ES - cee

MOV ES,AX ;

MOV BX,OFFSET PARAMETERS ; BX - ceee

;---coxpa o SS SP

MOV KEEP_SS,SS ;coxpae SS

MOV KEEP_SP,SP ;coxpae SP

;---aae a cpo e aa

MOV DX,OFFSET FILENAME ;ceee - DX

MOV AX,SEG FILENAME ;cee - DS

MOV DS,AX ;

;---apa popa

MOV AH,4BH ; EXEC

MOV AL,0 ;pae "ap ac"

INT 21H ;acae aa

;---ocec, occaaae pecp

MOV AX,DSEG ;occaaae DS

MOV DS,AX ;

MOV SS,KEEP_SS ;occaaae SS

MOV SP,KEEP_SP ;occaaae SP

;--- oe popa coae cee

ZSEG SEGMENT ;c. [1.3.1]

ZSEG ENDS

2. Coxpaee popa a oce aepe.

popa, ocaee pee a, o c

aece px popa. Oo ae popa ac

epe ecoe eop pepa. MS DOS paccapae ae

popa a ac oepaoo cce, aa x o aoe

px popa, oope ape ocec. Peee

popa oo c ope COM. popa, acae ope EXE

oca- pee a eoo pee.

aepee popa pepae 27H ocae ee peeo

a. CS oe aa a aao PSP oo, o a

paoaa pao. B popaax COM, CS cpa caaaec

cooec젠 opao, oo ao poco aep popa

pepae 27H. B popaax EXE , CS epoaao aae a

ep a, ce a PSP (.e. 100H). p op- ao aepe

EXE popa oce cp RET aae cea epe

ooee a ae: PUSH DX / MOV AX,0 / PUSH AX. oco DS

epoaao aae a aao PSP, o p oe x ae

cea ce oa a- ae a ceee 0 PSP, e p -

aa acaec cp INT 20H. oo INT 20H

oec, a o caapa aepe popa

epea pae DOS. o aca pepae 27H paoa

EXE popae ao oec 27H o opo a PSP (ep coep

a o cp INT), a ae aep popa o RET.

oox o ao pee e o pepae 27H, DX oe

coepa ceee oa popa, ocaeoe o aaa PSP.

Cpe poe.

Beop pepa caaaec c oo 25H pepa

21H, oaoec, o poepa oaaac IRET. Kpoe cao

poep, caaaea popaa e oa ea e- o, poe


- 4 -

aa eopa pepa, pcoe DX ae- cee

oa poep aepe. COM ao poco oece oepaop

INT 27H oe popa. EXE ao oece o oepaop

epoe coo PSP aepe popa o oepaopo RET. oo

o o poep, oc- ec apea popaa oa

a INT 70H.

pee pep oox o ao (COM EXE). B oox

caoea ea FINISH oe oa poep pepa

(aoae, o a $ ae aee cea oa o oe).

COM ao FINISH ae ceee o aaa PSP, a peec

pepa 27H. EXE ao ceee ocaec o epoo aa,

ceeo a PSP, oo e eoxoo pa 100H, o

epeca a aao PSP. ae, o oec poep aao

popa, oe c caoo ac oa peeo

op. po oo oc coco cooa cp MOVSB

epec oa poep ecoe ac PSP, aa

co cee 60H, o ocooae 160 a a.

Ca aa COM:

;---ec poepa pepa

BEGIN: JMP SHORT SET_UP ;epexo a cao

ROUTINE PROC FAR

PUSH DS ;coxpaee pecpo

.

(poepa)

.

POP DS ;occaoee pecpo

IRET ;opa pepa

FINISH EQU $ ;oea oa poep

ROUTINE ENDP

;---caoa eopa pepa

SET_UP: MOV DX,OFFSET ROUTINE ;ceee poep DX

MOV AL,70H ;oep eopa pepa

MOV AH,25H ; cao eopa

INT 21H ;caaae eop

;---aepee popa, oca peeo

LEA DX,FINISH ;opeee pe. ceee

INT 27H ;aepee

Ca aa EXE:

;---ec peea poepa

JMP SHORT SET_UP ;epexo a cao

ROUTINE PROC FAR

PUSH DS ;coxpaee pecpo

.

(poepa)

.

POP DS ;occaoee pecpo

IRET ;opa pepa

FINISH EQU $ ;oea oa poep

ROUTINE ENDP

;---caoa eopa pepa

SET_UP: MOV DX,OFFSET ROUTINE ;ceee poep DX

MOV AX,SEG ROUTINE ;cee poep DS

MOV DS,AX ;

MOV AL,70H ;oep eopa pepa

MOV AH,25H ; cao eopa


- 5 -

INT 21H ;caoa eopa

;---aepee popa

MOV DX,FINISH+100H ;ce ceee oa

MOV BYTE PTR ES:1,27H ;ocae 27H PSP

RET ;aepae poep

31H pepa 21H paoae aaoo, a cee oo,

o DX oo coepac co 16-ax apapao, peex

poepe (cee paepa poep, aa o aaa PSP - c.

pepe [1.3.1]). peeco o ec o, o oa

epeae poeco popae o xoa, a opa o cace

poep. Poeca popaa oae o o c oo

4DH pepa 21H. Ko xoa ocac [7.2.5].

3. apa ac popax oepee.

Oepe - o ac popa, oope ocac a ce, o pe

a eo popa peeo a. Koa peec ,

oea a-o oepee, o o apaec a popaa

ae eo a poep. Pae oepe o apac oo

o e eco a, epepa pe o. Hapep, popaa

ee a ax oe ap poep coppo, a ae

epep ee poepo ee- pa oeo. a exa coec

oo a. Ho oa xopoa oo ex poep, oope e

coc oc- oo, ae ace opae c pe

o, o popaa e oc co eeo.

Cpe poe.

MS DOS coe EXEC ap oepee. a ,

oep 4BH pepa 21H, coec ae ap aca

oo popa po, ec oec o 0 AL. Ec AL

oec o 3, o oa e ape oepe. B o cae e

coaec PSP, oo oepe e ca- aaec a eaca

popaa. Taa poepa poco apae oepe, e epeaa e

pae.

eec a cocoa oece a oepe. Moe

cooaa o oac p ea popa, o ceao

oeea oac a a peea ooo popa. EXEC

epeaec oo cee apec, aece o, a e

ape oepe. Koa oepe apaec eo ooo popa,

o popaa oa c oep apapaa, a e apac

oepe, caa. C po copo, p ape ceao oee

a MS DOS oeceae popa oe- po apapaa.

B epeeo pepe coec apa oee a.

oco DOS oo popae c oc a, o caaa

eoxoo ocoo a c oo 4AH. 48H oo

o a ocaoo oo, o o o p ca oo

oepee. a opaae ae- e ceea oa AX, o

oep apapaa opeee a e ape oepe, a ae o

ao apec oepe e ac ooo popao.

Kpoe oa 3, acaeoo AL, B o cao o -

ee a apaepa. DS:DX o aa a cpo, a

a oepe, aepae ao ASCII 0. Heoxoo aa ooe

aa, a pacpee .COM .EXE, oco DOS ao

cae e cae, o o e popa a.

Haoe, ES:BX o aa a 4-a oꠠ apaepo,

oop coep (1) 2-a oep apapaa, a e apac

oepe (2) 2-a aop p, oop e cooac


- 6 -

p apeco oepee. B aece oepa apapaa ao

cooa co, opaaeoe AX, oepa apapaa oeeoo

oa a. aop p ae ceee, o oopo o -

ce apeca pex p apaepo oepee. coe

oep apapaa, a apaec oepe. oce oo a o

caoe, oe oepe e ape. poco e

oepeo a, oo o o a ,

apa ce oe oe oepe. Ec p opa- e caoe a

epeoca, o a oa ee o e opae AX. Ko pae 1,

ec aa eep oep , 2 - ec a e ae, 5 - p

cox oax 8 - p occ ocaoo a.

oce oo a oepe ape a, e oo o

oc a aeo (far) poepe. B ceee ax oe

caoe xco aae, opee o o. Ceea

ac aae poco paa ee ooo cee. Ceee

oepe oo ceo axoee pa e ceea oa

蠠 oepe oee peaa a 16 (epeo e

apapao a). B epeeo젠 pepe e epeee

OVERLAY_OFFSET CODE_SEG oee oa a po pao

cao aae. Oa ape, oepee ae oe -

ac cpe CALL DWORD PTR OVERLAY_OFFSET.

Oepe oe oo popao co co ceea ax

cea, xo a pao coec ceo cee ae

popa. p oe oepe aee ceea eo coceoo

ceea ax oo oeeo DS.

;---aepae popa ceeo

ZSEG SEGMENT

ZSEG ENDS

;--- ceee ax

OVERLAY_SEG DW ?

OVERLAY_OFFSET DW ? ;ceee oepe

CODE_SEG DW ? ;cee oepe - oe

PATH DB 'A:OVERLAY.EXE' ;ceoa a ceee

0BLOCK DD 0 ;4-a o apaepo

;---ocooae a

MOV CODE_SEG,CS ;coae o CS

MOV AX,ES ;ope aee ceea PSP

MOV BX,ZSEG ;apec ceea oa popa

SUB BX,AX ;ce paoc

MOV AH,4AH ;oep SETBLOCK

INT 21H ;ocooae a

JC SETBLK_ERR ;a epeoca oop o oe

;---oo a oepe

MOV BX,100H ;oo oepe 1000H a

MOV AH,48H ; oee a

INT 21H ;eep AX:0 aae a o

JC ALLOCATION_ERR ;a epeoca oop o oe

MOV OVERLAY_SEG,AX ;aacae apec ceea oepe

;---cee cee oepe ooo ceee

MOV AX,CODE_SEG ;ae aee ceea oepe

MOV BX,OVERLAY_SEG ; ae ceea oa

SUB BX,AX ;BX coep co apapao

MOV CL,4 ;cae o co a 4 a eo

SHL BX,CL ;o o e aax

MOV OVERLAY_OFFSET,BX ;aoae ceee

;---apa epoo oepe


- 7 -

MOV AX,SEG BLOCK ;ES:BX aae a o apaepo

MOV ES,AX ;

MOV BX,OFFSET BLOCK ;

MOV AX,OVERLAY_SEG ;oeae apec ceea oepe

MOV [BX],AX ;epoe coo oa apaepo

MOV [BX]+2,AX ;cee oepe - aop p

LEA DX,PATH ;DS:DX aae a a

MOV AH,48H ;oep EXEC

MOV AL,3 ;o ap oepe

INT 21H ;apae oepe

JC LOAD_ERROR ;a epeoca oop o oe

;---eep popaa aaec co ea

.

.

CALL DWORD PTR OVERLAY_OFFSET ;o oepe

. ;o aa DWORD PTR, a a oepe -

. ;aea poepa

;---ocope cpp, oa ee ca oepe

DSEG SEGMENT ;a oo, caaae cee ax

. ;ocae ceo cee (coec

. ;ce ae popa)

DSEG ENDS

CSEG SEGMENT PARA PUBLIC 'CODE'

OVERLAY PROC FAR ;cea "aea" poepa

ASSUME CS:CSEG,DS:DSEG

PUSH DS ;xpa DS ae popa

MOV AX,DSEG;caaae DS oepe

MOV DS,AX

.

.

POP DS ;occaaae DS p aepe

RET

OVERLAY ENDP

CSEG ENDS

END

4. peopaoae popa a .EXE .COM.

popac a acceepe e oooc peopaoa co

popa ooo opaa EXE opa COM. a EXE e

aooo, coepa opa p; DOS pae

eoope apeca popa p ape. C po copo, a COM

cec ao e, o pa e peec - o xpac e

o e, oopo apaea popaa oa a a.

o o pe a EXE o ee epe a 768 ao oe a

ce, e x COM ae (xo p ape a o

aa oaooe eco). a COM ae cpee apac,

oco e peec p. px peec x e, a

eoope popa co co co e, o x oo

o peopaoa COM.

pa - o poecc cao apeco, cax c cee

pecpo. Hapep, popaa oe aa a aao oac ax

ce oo:

MOV DX,OFFSET DATA_AREA

MOV AX,SEG DATA_AREA

MOV DS,AX

Ceee DX cao c caoo ceeoo pecpa DS. Ho aoe


- 8 -

aee oe pa ca DS? popaa pee aco- apec,

o oep apapaa, oopo e pacoaac DATA_AREA ac o

oo, aoe eco a e apea popaa - a o ac

o epc MS DOS, a ae o oo, ae peee popa

axoc ax apecax a. o o pe o pe

ooo popa oo oo cao eoope ceee

ae epe cee oo- ceo aaa popa. ae, oa

DOS ocece p, aee aaoo apeca popa

paec cee ae, aa acoe apeca, peee

ceeo pecpe.

a COM e ac pe, oco o xpac ao

e, o e ac ca ceea. Bce popae xpac

ooceo aaa oooo ceea, a ce ae ce. o

o pe c popaa e oe pea 65535 a o e, o

cooece acao cee, oopoe cece coeo

cxee apeca (oco epx ac oo oa aa ceo, o

peaoe pocpaco ocoe oa ax eoo ee e

65535 a, xo ceo cee p eoxooc oe ece

a pa 64K aoo oa). B aax COM ce ceee pecp

aa a aao PSP; cpae c aa EXE, e DS ES a-

pc aao opao, o CS aae a ep a ce

a PSP.

pecae popa e aa COM peec coee

cex pa:

1. He oope popa e poep. Beco oo, oece

caoe aao e, poe START, aepe popa oepaopo END

START.

2. oece aae popa oepaop ORG 100H. o oepa- op

aae aao oa (.e. caaae ce oa). popa

COM aac c 100H, o ec ep ao, ce a PSP,

oco CS aae a aao PSP, oopoe pacooeo a 100H a

e. oo o aa oee c oo poo eca oece

o apec 100H cp JMP.

3. Oepaop ASSUME oe caaa DS, ES SS a opao,

o o coaa co aee oooo ceea, apep,

ASSUME CS:CSEG, DS:CSEG, ES:CSEG, SS:CSEG.

4. ae popa o oeac o ece popa, o ex

op, oa o e epeea c oo. e aa popa c oac

ax, oco apoacceep oe aa cooe o oax

p epo poxoe, ec ec cc a eaop ax,

oop ee e oape. epexoa aa oa coe

aece epo oa popa cp JMP.

5. He cooa ca ceeo a MOV AX,SEG NEW_DATA.

ocaoo aa ooo cee e. B acoc, o oca

o o, coe aae popa cao ceea

ax, MOV AX,DSEG / MOV DS,AX.

6. Ceo cee ooc ocaec aao oe. aae

cea apec a ep apecoo pocpaca 64K, co-

eoo popao (aoae, o ce pace a). B

popaax COM o oe cea ee e 64K, SS SP o

ee. ee , o p oooe popa ooo ac

cooee o oe, aaee, o cee cea occe.

oppe eo.

7. aepe popa o cpe RET, o pepae 20H.

pepae 20H - o caapa aepe popa

opaa pae DOS. ae oa popaa a- epaec cp-

e RET, a cao ee coec pepae 20H. o pocxo

oo, o epa cea epoaao co- ep 0. p oe

aepae頠 cp popa RET, 0 aaec cea,


- 9 -

epeaaa ce oa a aao PSP. Haxoac o ee

20H, oec a ce- a cp popa, a

epea pae DOS. Bce o oaae, o Ba e ao p cape

popa oea a ce DS 0 (PUSH DS / MOV AX,0 / PUSH AX), a

o peec EXE ao.

oce oo aꠠ popaa cocppoaa a opao, ac-

cepe ooe ee a oo. ae peopae ee op

COM c oo EXE2BIN, eec MS DOS. Ec popa,

ocpoeo oooo MYPROG.EXE, o poco ee oa EXE2BIN

MYPROG. B peae B oe popa a c ee MYPROG.BIN.

Bce o Ba ocaec oce oo ce- a - epeeoa o a

MYPROG.COM. B oee ae cpa cooa oa EXE2BIN MYPROG

MYPROG.COM, oe- aa c pacpee COM.

H poe.

B ao pepe coepc oa opoa popaa, oopa o

caoe epeaee opeee oeco aoee ae

ae o cooee a pa. Oa oe c pepo opoo

oo copa, oopx opa COM eae. CSEG SEGMENT

ORG 100H

ASSUME CS:CSEG, DS:CSEG, SS:CSEG

;---ae

START: JMP SHORT BEGIN ;epexo o

MESSAGE1 DB 'The dip switches are set for $'

MESSAGE2 DB 'disk drive(s).$'

;---ea epo ac cooe

BEGIN: MOV AH,9 ; 9 pepa 21H - o

MOV DX,OFFSET MESSAGE1 ;cpo

INT 21H ;o cpo

PUSH AX ;coxpae oep a ee

;---oae cao epeaee opa A pocxe 8255

IN AL,61H ;oae a opa B

OR AL,10000000B ;caaae 7

OUT 61H,AL ;aee a

IN AL,60H ;oae cao epea.

AND AL,11000000B ;ee cape 2 a

MOV CL,6 ;oooa c AL pao

SHR AL,CL ;cae 2 a aao

ADD AL,49 ;oae 1, o ca c 1

; 48 epeoa ASCII

MOV DL,AL ;oeae pea DL

MOV AL,61H ;o occao op B

AND AL,01111111B ;cpacae 7

OUT 61H,AL ;opaae a

;---ea ca aoee

MOV AH,2 ; 2 pepa 21H

INT 21H ;eaae co DL

;---ea opo oo cooe

POP AX ;epe oep co cea

MOV DX,OFFSET MESSAGE2

INT 21H ;o cpo

INT 20H ;aepee popa

CSEG ENDS

END START


8

coe aoe.

1. paee pacpeeee ca.

Bce c, a e, a ece, opaoa oao

opao. oepxoc ca paeea a p oepecx o- e,

aaex opoa, a opo ec paao a ceo- pa. Bce -

co co paep ceopa 512 a MS DOS.

a pacpeee o ao oec ceopo, oopoe eoxoo,

o ec eo. Too ecoo ceopo a ee ooe ce

apeeppoa ceax . Ocae oc a ocoe

paa "ep ooe - epoo oca". o oaae, o o epe

aoe ca a蠠 ceopa oce- eo aoc o

apae ep ca. p oe aa ceopa ocooac

co peee cooe oac ca- oc papoca o c,

paa oe a ae oc e ac.

cpoae c蠠 e eoope ceae xapaepc.

aco o coco x oee apaex ac, ao

oopx ec e oo, o a oe x copo. Bce opo,

pacooee a ao pacco o epa, ece aac -

po. oco oo蠠 cex co ac aeo, o

ocaec oo epeee ec ao ce opo ooo -

pa, pee e epexo cee. p po o

oocc pa oepao cce- a. o paa

cpoa c a ecoo paeo (o epex) paoo paepa.

o o pe apaep cpoaoo ca o co oac.

coe ceopa opeec ao頠 opae, oop

acae a opaa ca. opa ae e-

ao oep aoo ceopa. BIOS epe ceopa 1-8, 1-9

1-15, acoc o eoc ca. opo e appc, eco

oo o opeec exaec o cee oo e/ac o

eeo pa ca. coe BIOS opaac opeeeo

ceop, aa oepa opo ceopa. Oao DOS

paccapa ce ceopa ca, a o e, oo- pa epec

op, aa o 0, oo a ceop ee co oec oep

ceopa.

ce ep ceop (opoa 0, ceop 1) coep ac

aao ap, oopa ec eoo popao, oo- -

e oep ca c cooo aoe ocae ac MS DOS.

ae e o a paee ao, oope coepa

opa o pacpeee cooo pocpaca (o- pa o

xpac coopae eoacoc). ae e op- eo aao,

oop coep cco ao cco a oa- ao, a ae

aae ao ece ca o aac. Haoe, aee e

eoe popa DOS IBMBIO.COM IBMDOS.COM, oope cac

p cape oecea oep oooc eoxo

axoe ap aa COMMAND.COM, oop ecoeo ec

ocoo ac oepa- oo cce.

cpoae c e a ac ap, oopa coep

a paeo, oo pae c e ec- o

oepao ccea. Taa paeo coep opa o o,

e a ce aaec pae DOS, a ae ep- ceop aoo

paea coep ac aao ap. B ocao젠 pae

opaoa a e, a cea.


- 2 -

ee a paee ao.

DOS FAT

.

FAT 12- (1.5 ) .

FAT ( ) ;

. FAT

FFFF. :

Ҡ

D - 8 FF

S - 8 FE

D - 9 FD

S - 9 FC

QD - 9 F9

QD - 15 F9

40 .

, ,

IBM/PC, / .

133- 89- (3,5

) 80 .

. , -

,

QD-9 QD-15.

_______________________________________________________________

堠  

⠠ ꠠ ()

_______________________________________________________________

QD-9 2 9 80 720

QD-15 2 15 80 1200

_______________________________________________________________

QD-9 D-9 .

QD-9 133- ,

89- (3,5 ) . -

IBM/PC -

, Ѡ .

,

.

QD-15, IBM/PC

, 80 15 , 512

. -

, .

.

FAT .

:

000 .

FF8-FFF ( ).

XXX ,

.

.


- 3 -

FF0-FF7 .

(FF7 ,

).

( ),

. ,

. FAT

, . FAT

DOS (

.); , -

FAT .

, :

1. 1.5 (.. FAT)

2. FAT, -

,

.

3. MOV.

4. , 12 ,

12 .

5. FF8, - -

, 12

.

INT 25 INT 26, DEBUG -

.

1. 2 .

2. .

3. -

.

p oe젠 paepe acepa apaco pacxoec cooe

pocpaco, o oa oe c e a paep acepa, o

aa paee ao caoc co oo. p paoe c

ca DOS apae o FAT a, o oooc coxpa ee

a, oo p oo paepe FAT oe pacxoo- ac oo

oepao a. oco oco AT e ocaoo oo

a, o x pee aoo oe FAT. oo 20M

ecepa ee paep acepo, e 10M, oecea

oo cooo pocpaca. ce eoc 1.2M pa

acep paepo 1 ceop, a a x ocooe aaee coco

xpae o ecoo ca, a ceoaeo oaoc oe

aa.

Cpe poe.

DOS 1CH ae opa o ae paee ao, o e

ae ca FAT. oece oep aoe DL, e 0 = aoe o

oa, 1 = A, .. p opae DX coep co acepo

FAT, a CX - co ao ceope. DS:BX a- ae a a,

coepa ep a FAT, .e. a o, aa ca.

H poe.

Haoo ee o oc FAT e acceepa. Oe- ,

o oee oepa acepa a 1.5 pooc opoa- e ca,

co o pao a 1 ee ooa coee o c

opao. o eo aoaec ope pea .


- 4 -

;--- ceee ax

BUFFER DB 1024 DUP(0) ;oo eco 2 ceopo

;---ae FAT a

LEA BX,BUFFER ;aae a ep ax

MOV DX,1 ;oec oep ceopa

MOV CX,2 ;2 ceopa

MOV AL,0 ;aoe A

INT 25H ;ae ceopa

POP CX ;occaaae ce

;---oae oep acepa

MOV AX,3 ;oep acepa AX

MOV CX,AX ;eae o

MOV DX,AX ;eae op o

SHR DX,1 ;e op o a 2

ADD CX,DX ;caae e coo

ADD BX,CX ;oae a ceee

MOV DX,[BX] ;oae 2 aa oo eca

TEST AX,1 ;oep acepa ee?

JNZ ODD_CLUSTER ;xo, ec a

AND DX,0000111111111111B ;oae oep

JMP SHORT CONTINUE ;xo epe opao eeoo

ODD_CLUSTER: MOV CL,4 ;oooa c pao

SHR DX,CL ;cae cape 12 o

CONTINUE:

-

:

1.

.

2. . -

16

, ,

.

" " (boot indicator)

,

. FDISK -

80H ; 00. 80H

, -

. -

,

.

0:7C00.

( -

):


- 5 -

1BE 1  | ..| | | |

1C2 | ..| | | |

1C6 . |  |  |

1CA ࠠ |  |  |

|______________________________________|

1CE 2  | ..| | | |

1D2 | ..| | | |

1D6 . |  |  |

1DA ࠠ |  |  |

|______________________________________|

1DE 3  | ..| | | |

1E2 | ..| | | |

1E6 . |  |  |

1EA ࠠ |  |  |

|______________________________________|

1EE 4  | ..| | | |

1F2 | ..| | | |

1F6 . |  |  |

1FA ࠠ |  |  |

|___________________|__________________|

1FE "" |__05_____|__AA_____|

IBM, 10-

512 , (interleave) 6,

17 , 4 .

.

FF

00 - ; .

, .

.

: 00 - ; 01 - DOS.

"" -

. -

"". 13H (

BIOS) 10- .

,

, MOV -

13 BIOS. ( ;

80H

).

, 1 .

: 2,

1 .

4-

".". , -.

4- "".

, - .

"" -

, 1FE.

, -

.

DS:SI .

:

1.

.

2. - / -

.

, -

.

3. -


- 6 -

, .

Opeeee ocoo cooo pocpaca.

popaa oa opopo- a ocoe cooe pocpaco

cooa ooae o exae eca. Ec eca e xaae, o

ooae oe popa cpa poe e oep

opa.

Cpe poe.

36H pepa 21H cooae coo eec coooo

pocpaca a ce. Ece xoo pecp DL, oop oe

coepa oep aoe. Haoe o oa ooaaec 0,

aoe A - 1 .. p opae BX coep co ocx

acepo, AX - co ceopo acepe, a CX - oeco a

ceope. Heooe paee oe ae eae pea. B

cee pepe poepec, o a xcopoe cee ocaoc o

ee epe 2K cooo pocpaca:

MOV AH,36H ;oep

MOV DL,1 ;aoe A

INT 21H ;oae opa

CMP BX,2 ;eec 2 coox acepa?

JL RUNNING_OUT ;ec e, o cooae o o

oee/caoa paepa aa.

popaa oe oea poep paep aa o pa pa.

Oa oox p coco opeee蠠 ca ace,

coepaxc ae. pa - opeee o oa aa, c e

o ao aae caoe epo oae a

ox ax, e ee cecx.

Koeo, paep aa caaaec aoaec e DOS.

oa popaa oe ac ⠠ peeppoa蠠 cooo

pocpaca aeeo cooa. B o cae ao op

a pee poo oca aca ao oep ac, o a

e ocao . ac e "o" peao oocc

a aoe e a, oope cao oac

cox ceopax, oeex aa p o oepa.

Cpe poe.

FCB 23H pepa 21H cooae co ace ae. Ec

pca a ac 1 a, o eo paep e opae

aax. DS:DX o aa a pa o opoo aa.

ae oe . Ec a e ae, o AL opaaec FF. B

poo cae AL opaaec 0, a co ace oeaec oe

oepa ac poo oca FCB (a 33-36). pao pao

oe ac FCB oo caoeo oce op aa, o

epe oo ; o xaoe oe pacooeo o cee 14

FCB. Ec paep aa eoo ec a ac, o cooaeoe

co ace opec epx. Bo pep, oopo coec

a ac paa 1:

;---opeeee paepa aa

LEA DX,FCB ;DS:DX aae a FCB

MOV BX,DX ;ope aae BX

MOV CX,1 ;paep ac CX


- 7 -

MOV [BX]+14,CX ;e oe paepa ac FCB

MOV AH,23H ; cooaa paep aa

INT 21H ;o

MOV AX,[BX]+33 ;oae a ac paepa aa

MOV CX,[BX]+35 ;oae cap ac paepa aa

Coae/aee oaaoa.

popaa oe coaa a oaao, p oe

eoopx co. coa oaaoa eoxoo, o o o

pae epe oo coe eco opeo aaoe. ae

oaaoa eoxoo, o o e coepa ao cco a

pe oaao. Kpoe oo, B e oee a- oaao,

oop ec Ba e aaoo (o, c oop o oa

oc ce oepa a aaoa). Oe ae, o eooo

a opeo aao.

Cpe poe.

oco pae o ao oca oo opeo

aao, o coa ae oaaoa ao coo- a

ecpop ao.

Coae oaaoa

DS:DX o aa a cpo, a aoe

aao, oopo oe coa oaao. Cpoa oa

aepac ao ASCII 0. op oaaoa c ee PRIMATES

opeo aaoe aoe A: ao aca cpo ⠠ e

"A:PRIMATES". op oaaoa po oaaoe c ee

MAMMALS ae "A:MAMMALSPRIMATES". aoe A: oe

oeo ec B paoaee c aoee, coe- o oa,

oe aac c eeo aaoa. oece AH 39H

oe pepae 21H; ec aa pa- , o e

coa o aao. B poo cae e caoe a

epeoca, a AX e coepa o o 3 ( eepe) 5 (e

oca). B pepe coaec oaa- o PRIMATES:

;--- ceee ax

PATH DB 'A:MAMMALSPRIMATES',0

;---coae oaao c ee PRIMATES

LEA DX,PATH ;DS:DX o aa a

MOV AH,39H ;oep

INT 21H ;coae oaao

JC ERROR_ROUT ;opaoa oo

aee oaaoa

ae oaaoa ao coppoa cpo, ooc

coaa c o, oop B aa p coa aaoa. ae

oece AH 3AH oe pepae 21H. O p eoe

AX opae o 3 5 (o 5 oe aa, o

aao eco).

ee/eee oaaoa.

oaao o oo oo opeo aao, a ce- e


- 8 -

oo, o o蠠 xpac aꠠ oe a, a e apaee

peopeeex ceopax. oaao eooo ca c o

aa, oco oe aaoa, oocc oaao- , ee

cea a apo (c caoe o 5) . oaao

aac c x ceax 32-ax oeo, ep oopx

ee oa, a opo - e o. O opep oaao cpe

opax aaoo. Cc a oaao eo po acac

a oe cc a a.

peoaaec, o oaao oe poa a o po

a, oo poe e cocae pa ap eo a. Ho,

coae, coae MS DOS oec 0 oe aa

eeo, oocxc oaaoa. B peae DOS cae, o

o a ee e oaaec a eo. He pocoo

cocoa peooe poe.

Cpe poe.

pao epe ecpop ao, oope cooa- c

oca opeo aao [5.2.1] o a e poco opaac

o oaao. o ec ce coepoe aaoa ao poco

cooa 4EH oca ao *.*, a ae oop

oc, co 4FH. Koa oe e e ao, o e

caoe a epeoca, a AL e coepa 18. Ka pa, oa

e oape oepeo e- e, DTA e acaa opa o

ae, a o eo (oeae cooae DTA x,

cox ecpop aa). Ce pep o oe

cex ox ao oaaoa.

;--- ceee ax

PATH DB 'A:MAMMALS*.*',0

DTAH DB 256 DUP(?)

;---caoa DTA

LEA DX,DTA ;DS:DX aa a DTA

MOV AH,1AH ; cao DTA

INT 21H ;caaae DTA

;---e ep a

MOV AH,4EH ;oep

LEA DX,PATH ;aae a cpo

MOV CX,0 ;oo opae ap

INT 21H ;e *.*

JC ERROR ;opaoa oo

;---o aa

NEXT_LINE: LEA BX,DTA ;BX aae a DTA

ADD BX,30 ;ceee e aa

NEXT_CHAR: MOV DL,[BX] ;oae co e

CMP DL,0 ;poepa a oe cpo

JE END_STR ;xo, ec oe

MOV AH,2 ;ae, o co

INT 21H ;

INC BX ;eae aae

JMP SHORT NEXT_CHAR ;ce co

;---opa ape/epeo cpo oe cpo

END_STR: MOV AH,2 ; oa coa

MOV DL,13 ;o opaa ape

INT 21H ;o

MOV DL,10 ;o epeoa cpo

INT 21H ;o

;---e ce a


- 9 -

LEA DX,PATH ;aae a cpo

MOV AH,4FH ;oep

INT 21H ;e ce a

JC FINISHED ;ec e, o xo

JMP SHORT NEXT_LINE ;ae o aa

FINISHED:

oee/caoa eeo aaoa.

Te aao o aao, oopo DOS e a, oopoo

e aa . Ec e caoeo pooo, o e aao -

ec ope aaoo.

Cpe poe.

3BH pepa 21H caaae e aao. DS:DX

o aa a aao caapo e a cpoa

oa aepac ao ASCII 0. Hapep, B:BIRDS- PARROTSPOLLY

eae POLLY e aaoo. B: oe oeo, ec o e

aoe o oa [5.3.1]. o cea e opeo aao

aoe A: ae A:. B pepe e aaoo caaaec

POLLY:

;--- ceee ax

PATH DB 'B:BIRDSPARROTSPOLLY',0

;---eae POLLY e aaoo

MOV AH,3BH ;oep

LEA DX,PATH ;DS:DX o aa a

INT 21H ;caaae e aao

o opee ao aao ec e ao coo- a

47H pepa 21H. DS:SI o aa a oac ax

paepo 64 aa, oop e aca . B DL aaec

aoe, pe 0 = "o oa", 1 = A, 2 = B .. p opae

opaae cpo e e aoe. Ec aa

ecec aoe, o AL opa- aec o o 15. Cpoa

aaec c e epoo oaa- oa eo, a e c opao oco

ep. a ASCII 0 cape o oe cpo. B ao pepe

eeo aaoa pcaaec epeeo "CURRENT_DIR":

;--- ceee ax

CURRENT_DIR DB 64 DUP(?)

;---o e aao

MOV AH,47H ;oep

LEA SI,CURRENT_DIR ;aae a oac ax

MOV DL,1 ;aoe A

INT 21H ;oeae cpo o apec DS:SI

oee/caoa pee a oceeo oca a

Ec oca o , o a 22-23 32-aoo eea

aaoa coepa pe oceeo oca a. a 24-25 -

coepa a. aee o ceee:

Bpe: 11-15 ac (0-23)

5-10 (0-59)

0-4 ce (0-29 c 2-ce epao)


- 10 -

aa: 9-15 o (0-119, ceee c 1980 oa)

5-8 ec (1-12)

0-4 co (1-31)

:= 1980 + _ div 512

:= (_ mod 512) div 32

:= _ mod 32

= ( - 1980) * 512 + * 32 +

= * 2048 + * 32 + / 2

Cpe poe.

Meo oca a c cooae paeo oa aa

ooe o a oceeo oca a, o e pe. Koa

FCB opaec e 0FH pepa 21H, o aoec xaoe

oe a epeeo opae. o oe pacooeo FCB co

ceee 14H.

C po copo, oc a c oo ecpopa aa

ooe a o, a cao a pe oceeo

oca a. 57H pepa 21H oe ce oepa- .

cao pee a oece oep aa BX, 0 AL.

oe a pee ao oec AL 1. B oox cax aa

coepc DX, a pe CX. aee o coa- ae c e, o

ocao ae. B execo pooce o MS DOS epaec,

o ae a opa axoc CH DH, aoopo. Ha cao

ee o e a. p ooe o caaaec a

epeoca, a AX opaaec 1, ec AL aao epaoe co

6, ec oxo ecpop aa. B cee pepe opeeec ac,

oop oce oc a:

;--- ceee ax

PATH DB 'B:NEWDATA.BAK',0

;---opae a

LEA DX,PATH ;aae a cpo

MOV AH,3DH ; op aa

MOV AL,0 ;opae e

INT 21H ;opae a

JC OPEN_ERROR ;epexo a opao o

;---oae a pe oca a

MOV BX,AX ;oeae oep aa BX

MOV AL,0 ;o e pee

MOV AH,57H ;oep

INT 21H ;oae pe oca

JC TIME_ERROR ;epexo a opao oo

;---cae , oocec aca, aao CH

MOV CL,3 ;oo c

SHR CH,CL ;eep CH coep ac oca

Cpae aee o ac a.

DOS coe ec pax apo ao, oope a

ao a opeee cac. a oe e ecoo x

apo oopeeo (o e ce). Ap caaac 12-

ao 32-aoo eea aaoa. Mae ec o⠠ e

aee, a ocae o pa . ae:

ec 5 = 1, o a ee co pee ocee

apxa

4 = 1, o a ec oaaoo


- 11 -

3 = 1, o o ee ec e ao, a eo

oa

2 = 1, o a ec "cce"

1 = 1, o a cpa p oce o aao

0 = 1, o a oe oo e

5 o apx , coe popaa BACKUP RESTORE

DOS. o cpacaec 0 oce apxa caaaec,

oa c ao coa paoa. p cee apxa eee-

e a o oape pooppoa.

Cpe poe.

43H pepa 21H oe a axo, a e

ap aa, o oo ec a op c oo eoa

ecpopa ao, a e c oo eoa paeo oa aa. He

aaoo FCB. a apo oe caoe p

coa aa [5.3.2], co pacpe pa o aa.

Ho ec B oceoaeo opoee FCB, ee cao apo

ae apoee a, o eo ocac epoaae ap. Xo,

oeo, B oee e- ap a- oxo e, o

aoo poe c- ooa , co eo ecpopa

ao.

o cooa 43H, oece 1 AL, o pc- o

a a apo, coepac CX (a cao ee CL, oco

CH pae 0). Moo aoopo oec AL 0, o CX opae

e a apo aa. B oox cax DS:DX o aa a

cpo, a a. Koe cpo oeaec ao ASCII 0

(oop e xo co 63-x coo). B pepe cac "hidden"

(cpa) pcaaec a OVERDUE:

;--- ceee ax

PATH DB 'A:ACCOUNTS',0

;---ae pa cpaoo aa

MOV AH,43H ;oep

MOV AL,0 ;ae a apo

LEA DX,PATH ;DS:DX aa a

INT 21H ;a apo CX

JC ERROR_ROUTINE ;opaoa oo

OR CL,10B ;ae 1

MOV AH,43H ;oep

MOV AL,1 ;aee a apo

INT 21H ;eep a ca cpa

a epeoca caaaec p ooe o. B o cae

AX opaaec 2 - ec a e ae, 3 - ec e ae 5 -

p px oax (e oca).

ee/eee e oa.

Mea oa ce - o ee aaoa, e ce- a

ap. Mea aae epe 11 ao eea, oo- cec

e pacpe aa. a apo o cee 11 coep

aee 8 ( 3 = 1). o pee a aoc o

opao. O coc oo apa ec o, o a

ee e oc o oae DIR.

Mea oe aa o aaoe. Oa ec epeopo

cex ao apo, oa e e aeo aee 8. o cepe


- 12 -

e ao poco oec E5 ep a cooeceo eea

- ca a apo oo e e. o e e ao

aca oe 11 coo (ocao ao ao poea). o

pco e oa c, oop e e ee, ao a coe eco

aaoe aca a e cooec ap, eo

oe e peec.

H poe.

B epeeo pepe peoaaec, o B coa ep

ax paepo 3584 a, xpae cex ce ceopo aa- oa

ce eoc 360K. ep aaec DIR_AREA. B epo pepe

ea oa ec oc, , ec oa e aea, o oc

cooee o ee occ. oca oac epa ceopo

ooc ceee ax; e oec a aa, a ae

ocoo ee.

;--- ceee ax

VOL_STRING DB 'The volume label is $'

NO_LABEL DB 'There is no volume label $'

DIR_AREA DB 3584 DUP(?)

;---ae 7 ceopo aaoa

MOV AX,SEG DIR_AREA ;cee epa

MOV ES,AX ;

MOV BX,OFFSET DIR_AREA ;ceee epa

MOV DL,0 ;oep aoe

MOV DH,0 ;oep oo

MOV CH,0 ;oep opo

MOV CL,6 ;capo ceop

MOV AL,7 ;co ceopo aaoa

MOV AH,2 ;oep e

INT 13H ;ae aao a

;---e e oa, cpaa a apo c 8

MOV CX,112 ;co eeo

ADD BX,11 ;ceee apo

TRY_AGAIN: MOV AL,[BX] ;epe 1- ee

CMP AL,8 ;o ea oa?

JE GOT_IT ;ec a, o xo

ADD BX,32 ;ae a ce. ee

LOOP TRY_AGAIN ;

;---o cooee o occ e oa

MOV AH,9 ; oa cpo

LEA DX,NO_LABEL ;aae a cpo

INT 21H ;o ee

JMP SHORT CONTINUE ;a oe

;---o cpo, a e oa

GOT_IT: MOV AH,9 ; oa cpo

LEA DX,VOL_STRING ;aae a cpo

INT 21H ;o ee

SUB BX,11 ;aae a e

MOV CX,11 ;e 11 coo

MOV AH,2 ; oa coo

NEXT_CHAR: MOV DL,[BX] ;co DL

INT 21H ;o co

INC BX ;epexo cee

LOOP NEXT_CHAR ;

CONTINUE:


- 13 -

o cepe e oece ce o GOT_IT:

GOT_IT: MOV AL,0E5H ;o oe coo eea

SUB BX,11 ;aae a aao eea

MOV [BX],AL ;ee ep a

o e e oa, ao eco oo cooa GOT_IT

ce o. peoaaec, o B ooo e-o 11-a

cpo NEW_LABEL.

GOT_IT: LEA SI,NEW_LABEL ;SI oe aa a cpo

SUB BX,11 ;BX aae a aao e

MOV DI,BX ;oeae aae DI

MOV CX,11 ;epeca 11 coo

REP MOVSB ;epecae cpo

o coa e oo cooa o e ca o, o ao

ae cao a apo pa 8 (B oee poco oa

ASCII 8 cpoe, coepae o e, a a a apo

eocpeceo cee a cao eo).

, aoe, o cex cax ee aaoa, eoxoo aca

aao opao a c. O p o epoce.

;---ac eex ceopo aa a c

MOV AX,SEG DIR_AREA ;pecp a p e

MOV ES,AX ;

MOV BX,OFFSET DIR_AREA ;

MOV DL,0 ;

MOV DH,0 ;

MOV CH,0 ;

MOV CL,6 ;

MOV AL,7 ;

MOV AH,3 ;oep ac ceopo

INT 13H ;

ee/ac opeeex ceopo.

ee ac opeeex ceopo ca ocoo c- o-

ec p oce aaoa ca eo ae paee-

ao, ceopa oopx cea pacooe oo o e ece.

B o pe a ee ceopo ocaoo eoo, ac acooo

ceopa pee o o aeo poe- pe epe ep

cooae. Oa oe cea aao a paee

ao eae, o aeo pape- cex ax a ce.

Ka DOS a BIOS peoca e ac

opeeex ceopo. Oao o aa ceopa o-pao. IBM

PC, XT PCjr poepa BIOS pee opa o oepe copo (0

1), oepe opo (0-39) oepe ceopa (1-8). -a opae

acaoo oepa ceopa paoo 8 o eo paec

ecoee x a. Oao AT oep ceopa oe ec

o 8, 9 15, a co opoe oe ec o 39 79.

DOS aa ceop o oe- po, oop aaec oec

oepo젠 ceopa. Haa c apoo ooa ca, ceopa

pcaac oceoaeo opacae oepa. o eo oe

cooa co poooo paepa a.

Oce ocex ceopo aaec co copo 0 opo 0 ceopa

1 pooaec a copoe 1 c opo 0, oce eo epexo a

copo 0 opo 1 .. (Ha ox cpoax cax caaa


- 14 -

poxoc ec e p.) B acoc o oo a

opapoa c, p epexoe a ce opo oec oep

ceopa eaec a opeee e. ce eoc

360K aa opoa (c eo oex copo) oae oeco

oep 18. Oao ce eoo coc e, o oce

aaec c . Ta opao ep ceop a opoe 3 copo 2

oe e oep pa 3*18 opoe 0-2 c 9 copo 0

opo 3 c ea, aaa a ep ceop opo 3 copo

1. a ca paa 64. oec oep ceopa a 1 ee oo

ca. Ha pc. 5-4 cpaaec eo aa ceopa DOS BIOS.

Cpe poe.

BIOS coe 2 pepa 13H e ceopo -

3 pepa 13H ac ceopo. B oox cax DL oe

coepa oep aoe o 0 o 3, e 0 = A, 1 = B .., DH -

oep oo (copo), 0-1. CH oe coepa oep opo o 0 o

39, a CL - oep ceopa o 0 o 8. AL coep co ceopo, oopoe

eoxoo ca. ocaec cpa a e oee oc ceopo,

o oee e ocaoo oca ee. ES:BX o aa

a aao epa a, a oeac ae oa o

pac. p opae AL e coepa co poax

acax ceopo. Ec oepa cea, o a epeoca e

pae . Ec o pae 1, o AH e coepa a caca

coo oepa.

;--- ceee ax

BUFFER DB 4000 DUP(?) ;coae ep

;---ae ceopa

MOV AX,SEG BUFFER ;ES:BX o aa a ep

MOV ES,AX ;

MOV BX,OFFSET BUFFER ;

MOV DL,0 ;oep aoe

MOV DH,0 ;oep oo

MOV CH,0 ;oep opo

MOV CL,1 ;oep ceopa

MOV AL,1 ;co ceopo e

MOV AH,2 ;oep e

INT 13H ;

pepa DOS 25H 26H a aca acoe ceo- pa

ca, cooeceo. Hao oec oec oep capo- oo

ceopa DX, a DS:BX o aa a ep. CX coep co

ceopo e ac, a AL - oep aoe, e 0 = A, 1 =

B .. poep op ce pecp, poe ceex. p opae

pecp ao ocaec a cee, oca ce epoe. He

ae o o aee co cea cpa oce opaa (

pepe o aee aaec CX).

;--- ceee ax

BUFFER DB DUP 5000(?) ;coae ep

;---ae ceopa

PUSH DS ;coxpae pecp

MOV AX,SEG BUFFER ;DS:BX o aa a ep

MOV DS,AX ;

MOV BX,OFFSET BUFFER ;

MOV DX,63 ;oec oep ceopa


- 15 -

MOV CX,9 ;ae c opo

MOV AL,0 ;aoe A

INT 25H ; e ceopo

POP CX ;aae co cea a

POP DS ;occaaae pecp

JNC NO_ERROR ;ec e o, o a pooee

CMP AH,3 ;poepa oox oo

.

.

NO_ERROR: ;pooee popa

Ec p opae a epeoca pae 1, o pooa oa

o cae AH AL coepa a oex aa caca o. Ec

AH = 4, o aa ceop e ae, a ec AH = 2, o c eepo

oopapoa. Ec AH = 3, o a oa ac a ce,

ae o ac. Bce ocae ae AH oo- p o aapao

oe.


9

Taep .

1. caoa ee aepa.

Bce IBM PC co pocxe aepa 8253 ( 8254)

coacoa co o pocxe ccex aco. co o

ccex aco peopaec o c, a oceoa- eoc

x co ocaec opeee pee, o o

oca a poooope oepa eepa a

opeeeo aco. Mpocxea 8253 ee p ex eacx

aaa, a oopx oe popapoac.

Mpocxea 8253 paoae eaco o poeccopa. poeccop

popape pocxe ae opaaec p ea. Ta

opao 8253 ece a ac peaoo pee - oa cae co

c eaco o oo, o pocxo oepe. Oao,

aca popape epa cocae peo 1/12

ce. ocea epao pee ac ae-o

pe cpeca. eo o o pe c o eoo aaa

pocxe aepa aaac epeeo, axoec oac

ax BIOS. o poecc oa- a a pc. 2-1. o aoee oo

aaec oceo pe- e co. 18.2 paa ce xo aaa

0 opaaaec aapa pepae (pepae aepa), oopoe

eaoo ocaaae poeccop eae ce pee co.

co 0 cooece oo 12:00; oa ce ocae ae

aeoo 24 aca, o cpacaec a o. poe pe

eee co eo opeeec eee oaae cea a 18.2

ao ce. Ce pee co c- oec oce

oepa, cax co peee.

2. popapoae pocxe aepa 8253/8254.

Ka pex aao pocxe aepa 8253 (8254 AT) coco

砠 pex pecpo. oc ao pe pex pecpo

ocecec epe o op; oepa opo o 40H o 42H

cooec aaa 0 - 2. op ca c 8- pecpo

oa/oa, oop ocae pae ae oo aa- a.

Koa aa apopapoa, o epe o op ocaec xaoe

aee, a a caaa. o co epeaec 16-

pecp a (latch register), oop xpa o co

oopoo o oeaec 16- pecp cea. B pecpe

cea co eaec a e a pa, oa c o

ccex aco pocaec epe aa. Koa aee oo ca

ocae , o aa ae xoo ca ae oa o

coepoo pecpa a epeaec pecp cea, oce

eo poecc oopec. e ee co pecpe cea, e

cpee p. Bce p aa- a cea a: poeccop e ae

e ae x. Teee aee oo pecpo cea oe

poao o oe pee, e a ce.

Ka aa ee e xoe o xo . Bxoa

o c, oae peae ocea. Haa- ee x

cao appec acoc o a IBM PC:

Kaa 0 coec cce aca pee co. O ca-

aaec BIOS p cape a opao, o ae c p-

eo 18.2 paa ce. 4-a ce x co xpac

a o apec 0040:006C (a a xpa- c ep). Ka

c pe pepae aepa (o- ep 8) eo o

pepae eae oaae cea. o aapaoe pepae,

oo oo opaaaec cea, eaco o oo, e a


- 2 -

poeccop, ec oo papee aapae pepa (c. ocee

[1.2.2]). Bxoa coec ae cxpoa

eoopx cox oepa, oo ec B e ee aee, o

Ba eoxoo occao- epoaaoe aee epe opaee

c.

Kaa 1 pae ooee a oo eo e e poa.

Bxoa oo aaacaa c pocxeo poo oca

a ee c acae pocxe DMA oo c a.

Kaa 1 coec ocea aopoax co aco

pee co, c e o oo o oo aee cea oce

aepe cox oepa.

Kaa 2 ca c poooopee oepa o poo

poce pooe c eepa a. popac e

o opo a op aao, e a oca. poce

o eeppoac oopeeo c p popa oepa, a

oee coe oe e o oc a ce

cooa poeccopa. Kaa렠 2 oe ocoee o

poooope cooac cxpoa- . Haoe,

xoa aaa 2 caa c ao oepa. Oao a

e e eeppoa o ex op oa e cea opeeee

cao pocxe epeca c epe- pe 8255.

e xoe aoo aaa coco aco, oopa

epeae ca o pocxe ccex aco , aaeo

opoa (gate), oopa ae ae ca o aco. Bopoa

cea op cao aco o aaa 0 1. Ho o o

ap aaa 2, o ooe eo- ope ceae a-

co o. Bopoa apac ca- oo aeo a opa c

apeco 61H, oop ec pe- cpo pocxe 8255; cpoc oo

a coa opae opoa. a pocxea ocaec [1.1.1].

Oe o - a xo aaa 2 - 1 opa 61H ca c ao

ae oe c- ooac eepa a. Ha pc. 2-2

peea apaa pocxe aepa 8253.

Mpocxea aepa oe cooac eocpeceo

peex oepa, o o peo ae o. Bo c aco

pooc 1.19318 oo pa ce (ae a AT, e ccee

ac cpee, pocxea aepa oae ca c acoo 1.19

M). oco acaoe co, oopoe oe xpac 16 ax,

pao 65535 oco o co ec a aco co o

aco, pa 18.2, o aca oo epa e ca

pae peo 1/12 ce. oo oco peex

oepa co ce pee co BIOS. ocea pee

aec aee pee- co cpaaec c eoop paee

aoe aee opeee ca co, poex c oo

oea. Ce- a coco ooe cooa ce pee

co oepa peao pee.

8253 peocae papaoa oopoa 6 peo pao

aoo aaa. popac oo opaac pe peo, a

aaa 0 p cxpoa, a aaa 2 cxpoa

eepa a. B o pee, a oo pecp a

oae co, o eeeo apae o pecp cea. Koa

aee cee ocae pe- cp a oeo

epeapae ce .. B eee oo ocea xoa

ea, a eee oo - ea. B peae oac

pooe o, oope oaoo po a eepa

a, a ocea.

8- oa pecp pae cocoo ap ce

aa. Apec opa oo pecpa pae 43H. Koao pe- cp

epeaec a, oop oop ao aa popapo- a, ao

pee, a ae o oa aa pecpa a o


- 3 -

epea. O oaae ae e co oo BCD

(ooopoao eco) ope. aee o oo pecpa

aoo:

0 ec 0, oe ae, ae BCD

3-1 oep pea, 1 - 5 (000 - 101)

5-4 oepa:

00 = epea aee cea a

01 = a/ca oo cap a

10 = a/ca oo a a

11 = a/ca cap a, oo a

7-6 oep popapeoo aaa, 0 - 2 (00 -10)

popapoa pocxe 8253 ao o p ocox

aa. oce oo a pe a aepe, apopapoa aa

eeeo aae opoa o oo popae.

1. oca oa pecp (43H) a, peca eo

o, oope pa aa, cac e/ac, pe oepa

op pecae ce.

2. aaa 2 ao pape ca o aco, cao 1 0

opa c apeco 61H. (Koa 1 oo pecpa caoe 1, o

aa 2 pae ao. Cpoce eo 0 oepa-

cxpoa.)

3. Bce aee cea o 0 o 65535, oece eo AX,

oe caaa a, a ae cap a pecp oa/oa

aaa (40H - 42H).

Kaa pocxe 8253 paoa cea. o o pe popa

cea o occaaa aae cao pecpo 8253 epe

aepee. B acoc, ec p aepe popa eeppec

, o o e pooac ae oce oo, a MS DOS o

paee ap p popa. ee o p aca

poep xoa o Ctrl-Break [3.2.8].

H poe.

B ao pepe aa 0 popapec a poe aee, e

caoeo BIOS p cape. pa ee cao coco o,

o e epa ee cea pee co a o

e, e 18.2 paa ce. acoa ooe cea

eec, cae, a 1000 pa ce, c e poee ox

aopaopx epe. aee a oo 1193 (1193180

ao ce / 10000). Ka a eee aee pecpa

cea c. pepe [2.1.8]. epe co oepa opaoe

aee a oo occaoeo, oco aa 0 co-

ec cxpoa cox oepa. Macao oooe

aee - 65535 ao aco e ca o aaa - oe

oco aco 0 pecp a (0 eeeo pepaaec

65535 p ee a e.

;---caoa pecpo oa/oa

COMMAND_REG EQU 43H ;apec oaoo pecpa

CHANNEL_0 EQU 40H ;apec aaa 0

MOV AL,00110110B ;caoa o aaa 2

OUT COMMAND_REG,AL ;aca oa pecp

;---oca cea a

MOV AX,1193 ;ce 100 co/ce.

OUT CHANNEL_2,AL ;oca aeo aa

MOV AL,AH ;oo oc cap a

OUT CHANNEL_2,AL ;oca capeo aa

3. caoa/ee pee.


- 4 -

p cape MS DOS apaae ooae eee pe.

Beeoe aee oeaec 4 aa, xpae ce pee co

(aa c 0040:006C, a a xpac ep). Ho caaa oo

peopaec op, oopo ocaec pe co, .e. pe

peopaec co oceaax oe ce- , poex c

oo. o co ocoo ooec 18.2 pa ce pepae

aepa. Koa oec oepeo apoc a pe, o eee

aee cea pee co peopaec opao p

opa ac--ce. Ec p cape e o eeo ae,

o ce caaaec o, a o ceac oo. Koep

caee pocxeo頠 aeap-aco⠠ o򠠠 aoaec

caaa ce pee co.

Cpe poe.

MS DOS peocae pepa e cao pee- ,

poo eoxoe peopaoa e aee cea pee

co aca-a-cea. Bpe aec c ooc o 1/100

ce, o oco ce pee co ooec c acoo

pa ee, o oaa cox ce- oe pee. -

2CH pepa 21H ae pe, a 2DH - caaae eo.

B oox cax CH coep ac (o 0 o 23, e 0 cooece

oo), CL - (o 0 o 59), DH - ce (o 0 o 59) DL -

coe o ce (o 0 o 99).

Kpoe oo p oe pee e 2CH, AL coep oep

ee (0 = ocpecee). aee e ep oo ec a

caoea aa. DOS ce oep ee o ae. Oe

ae, o p caoe pee e 2DH, AL oeae paoc

eeoo ae pee (0 = pa- o, FF = epao).

;---caoa pee

MOV CH,HOURS ;o ae pee

MOV CL,MINUTES ;

MOV DH,SECONDS ;

MOV DL,HUNDREDTHS ;

MOV AH,2DH ;oep cao pee

INT 21H ;caaae pe

CMP AH,0FFH ;poepe paoc ae

JE ERROR ;epexo a opao o

;---oee pee

MOV AH,2CH ;oep oe pee

INT 21H ;oae pe

MOV DAY_OF_WEEK,AH ;oae e ee AH

H poe.

Ec B e copoc co aaa 1 pocxe 8253

ceax poe, o Ba eoxoo aca co po- ep

eopoa oaa cea pee co. BIOS ooe aao

ae cea o 0 o 1.573 oa o oe eeo

oo e ee pepa aepa. oo ac, peao

oaae coe o ce, e o paoa 24 aca e

ceao acao popa. Oe ae, o a 0040:0070

caaaec o p cape, a ae eaec a 1 (e

oe) o xo aco.

4. caoa/ee a.


- 5 -

p e oepa MS DOS apaae ooae ee

a pe. Bpe acaec oac ax BIOS. aa e

coepc epeeo COMMAND.COM. Oa xpac opae pex

oceoaex ao, oope coepa cooeceo e eca,

oep eca oep oa, aa c 0, e 0 cooece 1980 o.

B o o cea pee co, apec a a eec c

eee epc DOS ooee a COMMAND.COM. o o

pe oe a cea ao cooa ooe

eca MS DOS, a e opa- ac o epeeo ap.

Ma, oopoae pocxeo aeap-aco, aoa-

ec caaa pe a c oo ceao popa

(oo acaeo p cape epe a AUTOEXEC.BAT). Ka

o oc pocxee aeap-aco, c. [2.1.4]. Oe-

ae, o oa ce pee co BIOS epexo epe

oe 24 aco, MS DOS ee a.

Cpe poe.

2AH 2BH pepa 21H oa caaa a.

oe a oece AH 2AH oe pepa- e. p

opae CX e coepa o e ca o 0 o 119, o

cooece aao e 1980 - 2099 (oo caa o aec

ceee ooceo 1980 .). DH coep oep eca, a DL - e.

MOV AH,2AH ;oep oe a

INT 21H ;oee a

MOV DAY,DL ;e DL

MOV MONTH,DH ;ec DH

ADD CX,1980 ;oae a o

MOV YEAR,CX ;oae oep oa

cao a oece e, ec o e e pec-

p oe 2BH. Ec ae, aae a

eep, o AL e opaeo FF, poo cae - 0.

MOV DL,DAY ;oeae e DL

MOV DH,MONTH ;oeae ec DH

MOV CX,YEAR ;oeae o CX

SUB CX,1980 ;epe ceee ooceo 1980

MOV AH,2BH ;oep cao a

INT 21H ;caoa a

CMP AH,0FFH ;poepe ceoc oepa

JE ERROR ;eepa aa, e a opao o

5. caoa/ee aco peaoo pee.

ac peaoo pee e co coce poeccop, oo- p

oe oca pe e a pe oepe oe- pa.

O e ae eac co a, coe oa o-

ep e. popao oo a a, a caaa ac

peoo pee. Oo eec ooeoe popaoe

oeceee, oopoe caaae ce pee- co BIOS

epee a DOS a opao, o o cooecoa e

oaa aco peaoo pee. Ho oo popao poep

cooece e p oape paoac p eoxo-

e ep.

Pae cao pee a ocecc epe砠 aop

apeco opo. Moe oooae a pacpe IBM PC

e ac peaoo pee, o, coae, e caapo


- 6 -

pocxe aaoa apeco opo. AT oopec aca peaoo

pee, ocoa a pocxee MC146818 p Motorola, oope

co e e pecp, o poc- xea, coepaa ae o

opa cce. oc pecpa oo o, oca

caaa oep peeoo pecpa op 70H, a ae poa aee

pecpa epe op 71H. Pecp, cae c aca, cee:

Hoep pecpa

00H Ce

01H Cea peoa

02H M

03H Ma peoa

04H ac

05H acoa peoa

06H e ee

07H e eca

08H Mec

09H o

0AH pecp caca A

0BH pecp caca B

0CH pecp caca C

0DH pecp caca D

epex cacx pecpo o pae ,

oopx epec popaco o peca cee:

Pecp A: 7 1 = e oa pee (ao a

ae 0, o a)

Pecp B: 6 1 = papeeo epoecoe pepae

5 1 = papeeo pepae peo

4 1 = papeeo pepae oa oa

1 1 = ac cac o 24, 0 = o 12

0 1 = papeeo aoae pee co

ac peaoo pee a AT o a aapaoe pepae

IRQ8. popaa oe cao eop oo pepa a

poep, oop peec o opeeeoe pe pepae

oe ac o pex cocoo, a oopx apee p

cape. epoecoe pepae pocxo epe砠 opeeee

epa pee. epooc peo paa oo cee.

pepae peo pocxo oa aee pex pe- cpo peo

coaae co ae cooecx peex pecpo. pepae

oa oa pocxo oce aoo ooe ae

pecpo pocxe.

pepae 1AH pacpeo BIOS AT, o oo ooo a

caaa ac peaoo pee. oco oaa oa e

coco oee e x x ecx p, o ae pee ac

oo-opoao eco ope (BCD), oa a ec a

e oo aa eca pa pecaec ep a.

Tao opa ooe eo epeo ca op ASCII. popae

o oo c oo aa a oe pecpa

oa 48 oe- oa ASCII, cooeceo ao c.

cex IBM PC 0 1 pepa 1AH a caaa

ce pe- e co BIOS. aco peaoo pee AT eec

ec ox :

2: ee pee aco peaoo pee

p opae: CH = ac BCD

CL = BCD

DH = ce BCD


- 7 -

3: caoa pee aco peaoo pee

p xoe: CH = ac BCD

CL = BCD

DH = ce BCD

DL = if daylight savings, else 1

4: ee a aco peaoo pee

p opae: CH = e BCD (19 20)

CL = o BCD (c 1980)

DH = ec BCD

DL = e eca BCD

5: caoa a aco peaoo pee

p xoe: CH = e BCD (19 20)

CL = o BCD (c 1980)

DH = ec BCD

DL = e eca BCD

6: caoa peo aco peaoo pee

p xoe: CH = ac BCD

CL = BCD

DH = ce BCD

7: Cpoc peo (e xox pecpo)

Tpeoa caaaec a ceee, ooceo eeo o- ea

pee. Maca epo pae 23:59:59. Ka e oo- poc e,

eop pepa 4AH oe aa a poep opao peo.

Oe, o ec ac e paoa (aoee epoo, -a occ

a), o oee 2, 4 6 caaae a epeoca.

6. aepa popax oepa.

Ec B ocecee aep popae ocpeco coo

a, o Ba oe opeoac oo pee oo, o

oc oo pee aep. ae ec B opeee pe- e

eoc, o e epe, o Baa popaa e aa

oe pe aep p cex cox. eoc a oe

ec acoc o coeoo oopa (, eca,

o oo, opec popaa e). A ae pe, oa

eec oo aop a coecx c IBM PC - ex po

aao copoc poeccopa - ae a e acceepa oe

po pa pee- a aep. oo pao opee

pe popao a- ep eocpeceo o aca. acoa ocea

18.2 paa ce, coea oa cea pee

co, oa oe oeop oco opeoce (a e-

aco oceo.

o oece aep ao pooeoc, popaa oa

oca peeoe co co cea pee co. o

aee oaec cao ee ae cea. ae

popaa ocoo cae aee cea cpaae eo c

aoe. Koa ocaec paeco, o peea aepa poa

oo pooa oee popa. epe aa, oopx

xpac aee cea pee co xpac, aa c apeca

0040:006C (a oo, aa c aeo aa). aepe ex

14 ce oo ooac oo a ao. a ax aa

oo aep o ooo aca (oee, a o-ce ee, e

ac).

Cpe poe.

poae aee cea pee co BIOS, co 0

pepa 1AH oae e eoxooe co co o 1/18


- 8 -

ce. oce oo cae ee ae- cea pee

co, ocoo cpaa c peeo eo. p oce

paeca ao oa aep. pepae 1AH opaae a ax

aa DX (oco aepe a- ac x peeax),

oo a capx aa, opaae- e CX, o oppoac,

o oo Ba ea 32-ax oepa. B ao pepe

caoea aepa a 5 ce, o cooece 91 oce.

;---oee ae cea caoa aep

MOV AH,0 ;oep "e"

INT 1AH ;oae aee cea

ADD DX,91 ;oae 5 ce. ae co

MOV BX,DX ;aoae peeoe aee BX

;---ocoa poepa ae cea pee co BIOS

REPEAT: INT 1AH ;oae aee cea

CMP DX,BX ;cpaae c co

JNE REPEAT ;ec epae, o oope coa

;ae, aepa ooea

AT ee oao pepa 15H, oopa ooe

ocec aep a aaoe pe. oece 86H AH, a co

poce aep CX:DX. oce oo oe pepae.

7. Oepa apopapoae o pee.

popaa opeee pe oe opeeeo oepa-

ooc a e, a eoe: epec aaoe oaae cea

pee co ae cpaaec c oce oa- a. Moo

oa ae opae ac--ce, o co xooo

c pa e a oaa, oco ccea cea e

eca. e po a ce pee co BIOS, ep

pooeoc 1/18 ce, a ae e epeo ee o

opa ::cc.

Cpe poe.

pepae 1AH ee e cao (AH = 1) oe

(AH = 0) cea pee co. e cea ao poco

o pepae c AH = 0. p opae aee cea

coepc CX:DX, pe aee coo CX. AL coep- 0, ec

ce e epexo epe pa 24 aco c oea ocee

cao. cao cea oece a coa e e pecp,

a AH - 1. B peeo pepe epc poe pee

peeax aca. p o oo a ax aa cea. Ho

o cae eoxoo poep, o e o epexoa epe pa,

oa aaoe aee o oe, e ceee. ;--- ceee

ax OLDCOUNT DW 0 ;xpa aaoe aee cea ;---oae

aaoe aee cea

MOV AH,0 ;oep

INT 1AH ;oae aee cea

MOV OLDCOUNT,DX ;coxpae aaoe aee

.

(ec e poecc, eoc oopoo epec)

.

;---oee ce eoc poecca

MOV AH,0 ;oep

INT 1AH ;oae aee cea

MOV BX,OLDCOUNT ;cae capoe aee

CMP BX,DX ;poepe a epeoee


- 9 -

JG ADJUST ;opaoa epeoe

SUB DX,BX ;ae epe paoc

JMP SHORT FIGURE_TIME ; epeo ee o

;---opaoa epeoe

ADJUST: MOV CX,0FFFFH ;oeae CX acaoe co

SUB CX,BX ;ae epoe aee

ADD CX,DX ;oae opoe aee

MOV DX,CX ;pea xpa DX

;---poepa epeoa pee o opa

FIGURE_TIME: ;e a 18.2 ce ..

8. paee paoo peao pee.

p oepax peao pee popaa oe cp

aa oe pee, a e p epo oooc. Taoo poa

oepa oo accopc c pooexo, o eec oeco

px poe. eec op oxoa oepa peao

pee. popa, oope e o eo ea poee

e cp, pe peeo p, oo poco

epoec蠠 poep ce pee co, oa ace

oo oea. Tao oxo paec coc aop cx

o, ocax [2.1.5].

Bopo oxo oee coe. O coec, oa popaa

ocoo aa ao-o paoo, o oa oa opeeee

oe pee pepa co oepa oe opeeeo

aa. B o cae pacp pepae aepa, oopoe oec

18.2 paa ce. Koa o pepae pocxo, ooe

o poepe ooe aee cea pee co ec ac

opeee oe pee, acae poep. o poecc

oaa a pc. 2-3. peee ec poce pep oaa, a

coa ⠠ coe頠 popae , oop頠 caaaec

ooaee oae o- o ca, oa ooo pe. (oee

co pep oo po [2.2.6] coe , o pe

oa poeccop a p ea.)

H poe.

BIOS coep ceaoe coe pepae (1CH), oopoe eo e

eae, oa B e ae eo poep. p cape eop oo

pepa aae a cp IRET (opa pepa); p

eo oe pocxo oea opa. Ho pepae 1CH epeco

e, o oo aec pepae aepa BIOS oce oo, a o

pepae ooo aee cea pee co. Moo caa, o

o aapaoe pepae, pocxoee aoaec 18.2 paa

ce. B oee e eop oo pepa a, o o

aa a poep Bae popae. oce oo Baa poepa

e ac 18.2 paa ce.

Hacaa Ba蠠 poepa oa poa oo o o-

poaoe aee cea pee co, cpa eo c oae

peee, o o o peec, oa oaeoe pe aoe

ac. Ececeo, o oa pe ee e o- oo, o poepa

poco opaae paee, eo e e- a. Ta opao,

poeccop e oe e pao.

B peeo pepe poepa (e oaaa ec) apaae

ooae co (o 60), oopoe oo po o oo, a

paacc ooꠠ a. o co, aaceoe MINUTES,

oaec a 1092 epeoa aeoe co co

cea pee co. epoa peeax ooo aca ocaoo

16 - oee e epo pe oee cox 32-ox


- 10 -

oepa. o co co oaec ae co eeo

ae cea pee co aoaec ALARMCOUNT.

ae eop pepa 1CH eec a opao, o o

aa a poep ALARM. oe, o a oo eop e

ee, ALARM e aoaec ac 18.2 paa ce. p

oe a poepa ae eee aee cea pee co

epe pepae 1AH cpaae c ALARMCOUNT. p coae x

e aec poepa BEEP (ae e oa- aa ec, oopa

ae oo ca. B poo cae pocxo opa. O

o opaa aapax pepa (MOV AH,20H / OUT 20H,AL)

a poe- p e o, a a o e pepa aepa.

e ae e ae coxpa eee pecp.

;--- ceee ax

MINUTES DW 0 ;xpa co o oa

ALARMCOUNT DW 0 ;xpa ce pee oa

;---caoa oaeoo ae cea pee co

CALL REQUEST_MINUTES ;apoc ca o oa

MOV AX,MINUTES ;epeca AX

MOV BX,1092 ;co co cea e

MUL BX ;oae - pea AX

;oae eee aee cea

MOV AH,0 ;oep e cea

INT 1AH ;ae aee, a a DX

;caae oa ae

ADD AX,DX ;

MOV ALARMCOUNT,AX ;oae oe aee cea

;---aee eop coo pepa

PUSH DS ;coxpae cee ax

MOV AX,SEG ALARM ;epe cee poep ALARM

MOV DS,AX ;oeae eo DS

MOV DX,OFFSET ALARM ;epe ceee poep

MOV AL,1CH ;oep eeoo eopa

MOV AH,25H ; ee eopa

INT 21H ;ee eop

POP DS ;occaaae cee ax

;

;---ae pooaec popaa

;

;--- oe popa opaae eop pepa

MOV DX,0FF53H ;opae ae

MOV AX,0F000H ;pepa 1CH

MOV DS,AX ;oeae cee DS

MOV AL,1CH ;oep eeoo eopa

MOV AH,25H ;oep

INT 21H ;occaaae eop

;---poepa a ooo caa

ALARM PROC FAR ;coae poep

PUSH AX ;coxpae eee pecp

PUSH CX ;

PUSH DX ;

;---ae ce pee co

MOV AH,0 ;oep e cea

INT 1AH ;ae aee cea

;---cpaae c pee aee

MOV CX,ALARMCOUNT ;epe peeoe aee

CMP DX,CX ;cpaae c e


- 11 -

JNE NOT_YET ;ec epa, o a xo

;---ae oo ca, ec ae coa

CALL BEEP ;a poepa e oaaa

;---ae opaaec pepa

NOT_YET: POP DX ;occaaae pecp

POP CX ;

POP AX ;

IRET ;opa pepa

ALARM ENDP ;oe poep


10

Coae a.

Ec B xoe o ae-o coe , o B o po

popapoa pocxe aepa 8253. Kaa 2 o pocxe po

ca c ao oepa. Koa o aa popapec

pee 3, o o ocae pooe o ao aco. -a

poco aa o ca- ae pa pooo o, oa

oee p cxa ccoa o. K coae, pocxea

8253 e oe e- a o, oo e oe e

pooc a, aaeoo ao.

a ee e o, a a xoa eepa a. acoa -

co ao pocxe oe eea, oo op

oec x x coo oe oa ceae oe

e.

1. eepa oa.

oo ocaoo apopapo- a pocxe aepa 8253,

oopa paoae eaco o poeccopa. B peeo ec eoe

poeccop eocpeceo pae ao, oo popae

pxoc o pao- , oop oe o pocxea

aepa. Xo o coco oee pe, o o ocae ceceo

o opo a ao coae oca ceax

ox eo ocoaec a e.

C(o) 523.3

D(pe) 587.3

E() 659.3

F(a) 698.5

G(co) 784.0

A() 880.0

B(c) 987.7

aco a oa e oo o, aa ae, a e

oa e - ee pa aa aco. aoopo, aco a oa

e pa peo ooe x ae (xopo- o acpoeoe

ao oo e cee apeec epa- a).

H poe.

eepa a c oo aaepa epeca c epepe 8255

coco o e e c eaeo acoo a opa B,

oop ca c ao ( 1). op B ee apec 61H (xo AT e

ee pocxe epeca c epepe 8255 a aoo, o co-

e o e o e apec opa o e ). Ec popaa

epeae aee a c acao ooo acoo, o acoa

co coa, o oeo. oo e epee-

ao ca co . oe, o 0 opa B pae

opoa aaa 2 pocxe aepa, oop co oepe ca c

ao. oo o oe cpoe, ocoec o aaa

aepa.

B cee pepe ee e epeee. Oa, ooaea

"FREQUENCY", coec aece cea co e e

ec e e. e ee ee aee, e cpee

pocxo eee a e oe acoa. epe- ea e

"NUMBER_CYCLES" caaae pooeoc oa. Oa oop

coo pa oe oope poecc e e. e

oe o co, e oe a .


- 2 -

Oe, o o poep aapae pepa o

apee. pa oo o, o pepae aepa pocxo c

ao acoo pepoc (18.2 paa ce), o oo e

ceceo a aco. ee , o oa pepa

apee, ce pee co BIOS e e paoa. Ec ae

poa eo aee, o oo e oac a eoop e

o peaoo, o ex op, oa e e ceao cooecee

eee.

NUMBER_CYCLES EQU 1000

FREQUENCY EQU 300

PORT_B EQU 61H

CLI ;ape pepa

MOV DX,NUMBER_CYCLES ;eoc oa DX

IN AL,PORT_B ;oae aee opa B

AND AL,11111110B ;oae a o aepa

NEXT_CYCLE: OR AL,00000010B ;ae a

OUT PORT_B,AL ;ocae oa op B

MOV CX,FREQUENCY ;aepa a o-a CX

FIRST_HALF: LOOP FIRST_HALF ;eae aep

AND AL,11111101B ;ae a

OUT PORT_B,AL ;ocae oa op B

MOV CX,FREQUENCY ;aepa a o-a CX

SECOND_HALF: LOOP SECOND_HALF ;eae aep

DEC DX ;ae e cea

JNZ NEXT_CYCLE ;ec 0, o ao oa

STI ;papeae pepa

2. eepa a oopeeo c p ec.

oco pocxea aepa 8253 paoae eaco o

poeccopa, o oe poco eeppoa , oop頠 aec

oopeeo c oee젠 px oepa. B o poco

apopapoa aa 2 o pocxe eepa opeeeo

aco, a ae epepopapoa pocxe e a.

H poe.

Mpocxea oa peapeo papeea epe op B pocxe

epeca c epepe 8255 (apec 61H). Bce peeoe aee

cea a, pae 1.19 oo a pee aco

epax. e pooac o ex op, oa e ap

opoa aaa 2. oo B o cpoc 1 opa B 0, ae

e pooac eco- eo oe pepae oo

epeapo oepa. ooo pepoa eoc a

oo cooa ce pee co BIOS, a aao [2.1.6]. B

ao pepe eeppec acoa 440 ep. pepaaec oce

aa o a a aape.

;---papeee aaa 2 caoo opa B pocxe 8255

PORT_B EQU 61H ;caoa apeca opa B

IN AL,PORT_B ;ee eo ae

OR AL,3 ;caoa x ax o

OUT PORT_B,AL ;ocae a op B

;---caoa pecpo oa/oa

COMMAND_REG EQU 43H ;apec oaoo pecpa

CHANNEL_2 EQU 42H ;apec aaa 2

MOV AL,10110110B ;eoa o aaa 2

OUT COMMAND_REG,AL ;aca oa pecp


- 3 -

;---aca cea a

MOV AX,2705 ;ce = 1190000/440

OUT CHANNEL_2,AL ;ocae a a

MOV AL,AH ;cae a a AL

OUT CHANNEL_2,AL ;ocae cap a

;---e aa a

MOV AH,1 ;oep pepa 21H

INT 21H ;ae pepae

;---ee a

IN AL,PORT_B ;oae a opa B

AND AL,11111100B ;cpacae a ax a

OUT PORT_B,AL ;ocae a opao

3. eepa aopa oo.

B o opaee oaao a eeppoa eo o, oa

oep e p e a; cee e oaao a

o e aa, oa oep a po paoo. Koa

oep e p e a, o oo o eo

poo ceae oe e; oa e oep a

po paoo, o e poo oe e.

Coae ox cpo ec oo oex oooc- e,

peocaex eco. ocpoee e cpo o ac- ceepe

pee oo pao. Moe cooa o x eoo

eepa a. oox eoo ao poco eeppoa o o

ee aaoo pee, ae ce .. Kaa oa

cpoa oppec x cpo ax, oa oopx coep

aco- oceoaex oo, a pa xpa x eoc (p

co, o pec pae eoc). pooeoc a

opeeec c cooae cea pee co BIOS [2.1.6].

H poe.

B pepe eepa a coec pocxea aepa 8253.

ec poco coc 8 o, o eoa oa oe co

pacp oooc o poep. eec p cpo ax. epa

caaae eoc ao o, a paoe poooo

epoa aep (e o epo a- ep, oo e e).

Bopa cpoa coep aco ao 8 o; ae o

oee ⠠ cac pao oae ooo

ecox coo poea a eo oae ooo

ecox coo "opa a a" coa opaa ape.

e ocecc epepo - e ocpae x a

cooece oceoaeoc a oo e ae. o ex

op, oa Baa popaa ae a- aoe ooee eaae oo

oa oe oae epe- oo cpo, poeo, a

opao a a opapo- a Ba o cooec c Ba

oea. pep, oope e o opa eepo cpo

o coo- ac a paoocpoe.

B paecx peax ooo epeeee oo a ae o

a. p ea eca B oee o paec pe- , o

oc pax poeo e coa.

eec cea頠 o, oop頠 acae oo cea


- 5 -

opaac pa e o epe ea oepeo cpo,

oe apae ea. Xo o aeo aee ea,

oao p o ocaec oee ooe oopoae oo. o

ocoeo oeo p paoe paec- o pee. o

ooapae ea ao oca o 27,85,1, a o epc

apaeo ea - o 27,85,0.

7. eee pa ea.

pa cpa 8 1/2 a ooe aeaa cpoe o 80-

ox coo, ec蠠 ce o蠠 e oao p.

poopoaa ea ooe oec cpoe ee ecoo

coo. C po copo, oa ea ooe ec cpoe

132 coa, ea c oo po - 40 coo, a oa ea c

oo po - 64 coa. ee , o cooae ea c

pao po oo cpoe pee poc c opapoae.

oco apx pepo peoca aop peo ea

cea pa. Bo epee caapx oooc- e

peocaex paec pepo IBM:

oa ea:

e pea oo ea ao oca ooa

pa o 15. e oo pea - o 18. Caapa

cpaa po 8 1/2 a ooe aeaa 132 coa cpoe

o pee.

ea c oo po:

oo, o pep aa eaa c oo po ao

oca a eo pa o 14. Pe ea c oo po

eoe e, o pep aoaec ae o pe, oa

cpeae co opaa ape epeoa cpo. oco ao

ea oo coec oocpox aooo, o o

coco oo. o o pe cepee cpo oe

o 20.

Beea ea:

p eeo ea a co eaaec a paa oo

o e o. o eae o eee, o coae e ee.

Copoc ea p o eaec oe. e oo pea

oe o 27,69. e - 27,70.

ea a a poxoa:

B pee ea a a poxoa aa caec a 1/216 a

epe op poxoo eaae oo. p o oac oee

aoee , oope o e pe. Copoc ea

eaec oe. o pe aec pa oo 27,71, a

aec oo 27,72.

ea c oepae:

ea c oepae젠 oe oc cocoa.

paec pep ee pe oepa, oopo oep

eaaec o a coo, a poe. paecoo

pepa IBM o pe aec oo 27,45,1, a aec oo

27,45,0. pep, e ee pea oepa o cea

oep蠠 p opo poxoe o o e cpoe, eaa co

oepa (ASCII 95) ex ecax, e oo o poe (ASCII

32) o cex ocax ox. Bopo poxo ocaec e, o

oce epoo poxoa oaec o opaa ape e oa epeoa

cpo. Bopo poxo e eae pe- p pao oca


- 6 -

cpo p ce paepa cpa.

ea c epx eca:

Ha paecx pepax ec c epx eca

caec epao. ea epxeo eca oe pa

o 27,83,0, a ea eo - 27,83,1. Moo po epexo o

ox eco p. e ea eco, c e, o

pep oaac a ee cpoe oe pa o 27,84.

Heoope pe e o cooac oa c p.

Ec B xoe cooa 4 pea oopeeo, o pooc-

pec co cee ae. B ao ec coo peea

oca oa.

Koa 1 2 3 4 5 6

opa頠 X X

ca頠 X X

ee頠 X X

a a poxoa X X X

c eca蠠 X X X

oo p X X X X X X

c oepae젠 X X X X X X

8. oca ax a pep.

oca ax a pep paa ax cooo po, a

popaca a e acceepa eec p oepa- oo

cce, oope ea򠠠 aa ae ocaoo poco.

popapoae a o poe pee oe pao, o ao

peocae oe oooce. Ka pao, poep ea

oo po oca co a pep, a ae ocoo poepe

pecp caca oa opa, oopo pcoee pep. Ce

co ocaec oo oa, oa pep cape, o o

oo (pep oe e eaa co cpa, a aaca eo coe

epe, o ex op oa e e oea ea cpoa coo

ea).

Kpoe oo, poep oo po o cooa pepae

pepa o poa ece oo pepa. C oo

ceaoo popapoa oo cea a, o pep e

ea pepae poeccopa, oa o oo pe ceeo

coa. poepa opao pepa ocae ce co,

oce eo poeccop oe pooa aac co ea. o

eo coec ooo ea (oop aa ae c-

o). oco ece a cpa

acaec ope 0,n, e n oe o 1 o 22 o.

caapo cpa ao oca oa 27,67,0,11.

6. paee ooee eaae oo.

eaae ec pacpeeec o cpae aco a ce

e a, a aco a ce e eaae oo.

ooa oe oopoaa oe eco, o e e aa

ee oopa. Beco oo aaec ee ceee, ooceo cao

eo o, oop oa oe oca. pepa e ao,

cooax eee ooee oo. Baa popaa oa ocea

ooee oo, ec oo oo ec. p o xopoe

pao ec aa ea c oa paeo oa 27,60,

oop cae oo ca e o, e ea epeoa

cpo (o e caoe eae o opaa ape).

p ea eca eec ecoo cocoo epe o- o

oe ooee. Oa oe B ;epe cac opa B

OR AL,00000011B ;papeae a aep

OUT PORT_B,AL ;ocae a opao

MOV SI,0 ;aae a cpo

MOV AL,0B6H ;aa aaa 2 aepa

OUT COMMAND_REG,AL ;ocae oa pecp

MOV FIRST_NOTE?,0 ;cpacae a epo o

;---e o, oae ee aco, ocae aa 2

NEXT_NOTE: LEA BX,MELODY ;epe ceee cpo eo

MOV SI,WHICH_NOTE ;aae a e o

MOV AL,[BX][SI] ;o ee o cpo

CMP AL,0FFH ;poepe pa oa

JE NO_MORE ;ec a, o a oe

CBW ;ae co opa

;oae aco

MOV BX,OFFSET FREQUENCY ;ceee a aco

DEC AX ;aae oce c

SHL AX,1 ;oae a 2, .. coa

MOV DI,AX ;apecec epe DI

MOV DX,[BX][DI] ;oae aco a

;aae coee o

MOV AL,DL ;oo a a aco

OUT LATCH2,AL ;ocae pecp a

MOV AL,DH ;oo cap a

OUT LATCH2,AL ;ocae eo

;---co , opee eoc o

TIME_IT: MOV AH,0 ; e cea

INT 1AH ;oae aee cea

MOV BX,OFFSET BEAT ;ceee cpo o

MOV CL,[BX][SI] ;eoc ee o

MOV CH,0 ;

MOV BX,DX ;aee coo ae cea

ADD BX,CX ;oae cax

MOV END_NOTE,BX ;aoae pe ooa

TIME_CHECK: MOV AH,0 ; e cea

INT 1AH ;ae ce

CMP DX,END_NOTE ;cpaae c

JNE NOT_NOW ;ec epao, o xo

MOV SI,WHICH_NOTE ;ae, epe ce o

INC SI ;eae oep o

MOV WHICH_NOTE,SI ;aoae eo

JMP NEXT_NOTE ;aae ce o

;---aepee poep

NO_MORE: IN AL,PORT_B ;epe cac opa B

AND AL,0FCH ;ae a

OUT 61H,AL ;opaae a

MOV SOUND_NOW?,0 ;occaaae epeee

MOV FIRST_NOTE?,1 ;

NOT_NOW: POP DS ;occaaae pecp

POP SI ;


- 7 -

POP DI ;

POP DX ;

POP CX ;

POP BX ;

POP AX ;

IRET ;opa pepa

MELODY2 ENDP

5. Coae aoo epexoa oo.

ae epexo oo pooc a ce epepoo e- e

aco. o oo e oo cea oee pae, ec

eoo ea eoc aoo ceea oa p oe

a cea ea eoc p oe.

H poe.

poe ceo cooa eo䠠 eepa蠠 a, pae

pocxeo epeca c epepe 8255. poco ee aee a

1 opa B e 0 1, co ocea pee co . p

aae aoo ooo coo a, ace ac ae CX,

cea ee o ae- e. ec o oaec:

;---ape pocxe aepa

PB EQU 61H ;apec opa B pocxe 8255

IN AL,PB ;oae eo a

OR AL,1 ;cpacae 0

OUT PB,AL ;opaae a op

;---caoa aco eoc a

MOV BX,9000 ;aaoe aee cea

MOV DX,3000 ;eoc a 3000 o

REPEAT: ;ca opaaec oce a

;---caoa a aa

OR AL,00000010B ;caaae 1

OUT PB,AL ;ocae a op B

MOV CX,BX ;caoa cea 1/2 a

CYCLE1: LOOP CYCLE1 ;co a 1000 oopo

;---cpoc a aa

AND AL,11111101B ;cpacae 1

OUT PB,AL ;ocae a op

MOV CX,BX ;caoa cea

CYCLE2: LOOP CYCLE2 ;co

;---epexo cee

DEC BX ;eae aco, ea

DEC BX ;ce

DEC DX ;eae ocac eoc

JNZ REPEAT ;ec DX e 0, o o

o poco頠 eo䠠 po o, o coe oa poxo

aeo cpee, e e. opox epao ao e

oe eae, a oa o e e, ao oa o, oop

p oe oa epecae DX oe ae a cee e.

6. Coae ox eo.

oe e oo ocac epep eee aco

oa.

H poe.


- 8 -

cceep ooe eeppoa ece oa, oa epa,

eee oopoo a e, e pae epa, eee

oopoo o e. Taoe apee cep oe po

a pa a. Koa ooee x epao

cocae, cae 50 1, o oae ae. Ec e

ooee ee 10 - 20 pa, o ae epexo oee

pae . B o cae eeppec pocxeo

epeca c epe- pe 8255.

Bo pep a:

NUMBER_CYCLES EQU 300 ;co epee aa

FREQUENCY1 EQU 50 ;pe, oa a e

FREQUENCY2 EQU 3200 ;pe, oa a e

PORT_B EQU 61H ;apec opa B pocxe 8255

CLI ;ape pepa

MOV DX,NUMBER_CYCLES;DX cae oa

IN AL,PORT_B ;oae cac opa

AND AL,11111110B ;oae a o aepa

NEXT_CYCLE: OR AL,00000010B ;ae a

OUT PORT_B,AL ;ocae oa

MOV CX,FREQUENCY1 ;aepa epo ac

FIRST_HALF: LOOP FIRST_HALF ;

AND AL,11111101B ;ae a

OUT PORT_B,AL ;ocae oa

MOV CX,FREQUENCY2 ;aepa opo ac

SECND_HALF: LOOP SECND_HALF ;

DEC DX ;eae co o

JNZ NEXT_CYCLE ;ec 0, o opa oa

STI ;papeae pepa

coa pax o oo cooa o e o, o

ao ae aee FREQUENCY2 a e ooo 40000.

7. Oopeea eepa pax o.

Too pocxea eepaopa a, eac PCjr, oo- e

oopeeo eeppoa pae . Oao acceep ooe

oe a cocoa ee- pa a, o coae a

oopeeo eepa x pax o. epepe x x

cao po coo ope oo o. Ka x o

ee e pooc, oo peae oaec copee

ae, e a pax ooca. o pe peao oee oo

coa ox eo.

H poe.

Hao poco oe a eoa eepa a. Hae

epe aa 2 pocxe ae- pa. ae ope xo aa,

a ce a 1 opa B pocxe epeca c epepe. Bopoe

ece opeee pooeoc a. He ae

pocxe aepa p aepe.

;---aae eepa a epe aa 2 aepa

IN AL,61H ;oae a opa B

OR AL,3 ;caaae ae a aa

OUT 61H,AL ;ocae a opao

MOV AL,10110110B ;eoa oaoo pecpa 8253

OUT 43H,AL ;ocae pecp

MOV AX,600H ;ce aaa 2


- 9 -

OUT 42H,AL ;ocae a a

MOV AL,AH ;oo cap a

OUT 42H,AL ;ocae cap a

;---eeppe op aco pocxeo 8255

NUMBER_CYCLES EQU 9000 ;co epee

FREQUENCY EQU 150 ;aepa oo a

CLI ;ape pepa

MOV DX,NUMBER_CYCLES ;DX cae oa

IN AL,61H ;oae cac opa

AND AL,11111111B ;oae a o aepa

NEXT_CYCLE: OR AL,00000010B ;ae a

OUT 61H,AL ;ocae aa op

MOV CX,FREQUENCY ;aepa a 1/2 a

FIRST_HALF: LOOP FIRST_HALF ;

AND AL,11111101B ;ae a

OUT 61H,AL ;ocae oa op

MOV CX,FREQUENCY ;aepa a 1/2 a

SECOND_HALF: LOOP SECOND_HALF ;

DEC DX ;ee ce o

JNZ NEXT_CYCLE ;ec 0, o opa oa

STI ;papeae pepa

;---ee aaa 2 pocxe aepa

IN AL,61H ;oae cac opa

AND AL,11111100B ;cpacae 2 ax a

OUT 61H,AL ;ocae a opao


11

pep.

1. paee paoo pepa.

MS DOS oe paoa c pe apae cpoca (LPT1 -

LPT3). oceoaee pep pac ooc a e, a

apaee, a cee cocoa, oop ae ocac a

pep. Kaoe apaeoe cpoco ee co aaep. Aaep

paec pe pecpa oa/oa apeca opo⠠ x

pecpo pa aoo aaepa. Oac ax BIOS coep

aoe apeca aoo aaepa. ao apec cooece

ae apec p pex apeco opo. ao apec LPT1 -

0040:0008, LPT2 - 0040:000A .. Kao aaep aae ao

oep LPT - e opeeeo , a o epeeo a. o

o pe popaa, opa po apecec apae op,

oa ca apeca, oope o co

2. caoa cea ea.

cao pax cea, oocxc opa cpa-

, c pa .., a pep ocac ceae pae

o. o ocac a pep a e pe ae.

pae o p ae poce ec pepa, a

epeo cpo epeo opaa (poo cpa). Oao o-

co cea頠 ea蠠 caaaec oco頠 Esc-oc-

eoaeoce, oopx o oee oox ao ce a

coo Esc, o oopoo ASCII 27. Haa o Esc op- pe

pep, o co() oop cee a cee eppepoa

a oa, a e a ae. Tae Esc-oceo- aeoc oo e

e coa-opae, oco pep "ae" ao

oceoaeoc. Too ⠠ eoopx cax, oa

oceoaeoc oe e pa , pe- ec opaa

co, aece oopoo cea coec o ASCII 0.

o o cex cax cea caoee oa

ec o ex op, oa o e o oee. Ka oo e

oe o, apep, oepa, o oo e ocecc o

ex op, oa e e oca o oe oepa. ep pepa

oe oe e oe caoex cea. Ho ec

pooa oa a pepe pep e e, o

eoxoo coa caaa ce cea.

oco oo caaax cea pepa epe- ea

c a, a oope o ec. Hapep, ae coa,

oopoe oo eeo p po, o peapc

Esc-oceoaeoc, ae頠 p頠 p, aepac

Esc-oceoaeoc, ae eo. oco epca

caap a o occe, o ea c c- ooae ox

oooce pee, o aoo oepaeoo pepa

aca paep. Ka paep peopae cp, eeppee

poepo ea, poo- o, coe a pepo.

B acceepe oca oo ocecec ca o opa- o. B

poo cae oepaop aoaec oa ocae

oa ap opa ape/epeo cpo.

3. caoa ecooo paecoo peo.

pep cea axoc ecoo pee, o ex op oa o

ceao e epeee paec pe. Koaa, caaaa

paec pe, oa cooa aoe co ao paecx


- 2 -

ax e epeao (o e oe oo cpo) oce oo, a o

co ao e eppepoao a pa- ecoe opaee,

pep epec eco pe. o o pe e oa,

oopa epeo pep eco pe.

co paecx peo pax pepo paoe. Bo cex

cax, a oo caaa paec pe ce 2 aa,

aae aoe co paecx ao e epeao (caaa

a a). o c aee x x ao, paee

co ao ax a 256 oece pea o opo a, a

ocao - ep a. a aa o cpa ceoa

a ax.

Ka a opeee eo o, cooecx oc

epa oa oo o ⠠ cpoe. Ma頠 (1)

cooece oo, a cap (128) - epx. Hapep,

o aeaa pa, oe caaa a, oopoo ca-

oe oo , ae a oopoo caoe 2 x

a .. oce ocoo aa pacooe e e a opao

ope. aee epoo aa e 1, opoo - 3 (1+2), ae 7

(1+2+4), ae 15 (1+2+4+8) ..

paec pep IBM ee epe paecx pea, oope

oee eee "caap". O ae:

27,75 480 oe cpoe.

Hopa pe. Mac 480 ao ax a oepaop.

27,76 960 oe cpoe. oeoe opoaoe papeee,

o ea oe eeee (oa ooc). Mac

960 ao ax a oepaop.

27,89 960 oe cpoe, ea c opao copoc (o-

a ooc c coo copoc). e o, pea-

e o opoa, e o aeaa, oco

e cea o eaae oo. Ec eaec

oa x aeaa, o opa oa e oppoa-

c. Mac 960 ao ax a oepaop.

27,90 1920 oe cpoe, ea oe eeee (eepa

ooc). Cocee o o opoa o oco

o pae epe a 3 o (.e. 1 eaae, 2 poca-

e). Mac 1920 ao ax a oepaop.

B oee ox peax e peae o opoa o e

o aeaa. o ao poc e oa, epe

ape eo o, eoo ce eaa oo pao

ceae opo poxo, co e e ae. Bo cpaee

ooce ea aex o e e pa oa a

pax pepax:

Ko paec eo Koa popep

27,75 480 oeꠠ 1108 560 480

27,76 960 oeꠠ 2216 - 960

27,89 960 oeꠠ 2216 - 960

27,90 1920 oeꠠ 4432 - 1920

eo pep ae pepo IBM e, o o oe

caaa aca oe (aspect ratio) paec- x

opae. o oe opaae pa opoax

epax pacco e oa. Oo eaee oe

1:1, oco poo cae po poo paece -

ce. Ho p opoa paecoo paa ao o aca

oe a e, a ce. B pao pee epeoo

papee 5 oe o epa aa o e paep, o 6 oe o


- 3 -

opoa. o cooece acao oe 5:6 eo

o aee coec o oa e pepo. ocac

oo oe 1:1 5:6.

4. paee paccoe e cpoa.

Ec e pa o ae pep, ee ceae

oooc paoocpoe, o c ea ocecec cpo- a.

ae paece opae pcc ocpoo, xo o cae e

cx ec e cpoa. Ko ASCII 10 - caap pa o

epeoa cpo. oca eo a pep (e peeceo oa Esc)

po o, o aa e poa epe a aa

epa. Oo, ec epeo cpo e ocaec a oo opaa

ape, o eaaa ooa opaaec eo pa a

oo coa eaa a o e cpoe. Oao oo cea a, o

epeo cpo eac aoaec p ao opae ape.

pa epeae a pepe. o e oo cea cao

1 pecpa pae oo. Moe pep o a -

a aoaec epeo cpo c oo pax oo 27,53,

a eoope o ea opa epe- o cpo c o oo

27,93.

o oa paec pep coe epa ea pa

1/6 a (.e. o 6 cpo a ) o pe cea oo

epc, oca pae o 27,50 ( o coc ae

coea c o ee epaa e cpoa, ocae

e). oo pepa ec ee a peopeeex ecpox

epaa, 1/8 a 7/72 a. Cooece pae o

27,48 27,49.

Booa 蠠 oee oa paa ecpox epao. pa-

ec pep coe p oa, ooe e ep- a

a oe a e. Bce p pax oa co 2-xa

Esc-oceoaeoc, a oopo cee co 72-x 216-x oe

a, opeex ecpo epa. Bepaoe paccoe e

epa x oe pao 1/72 a. epa 8/72 a e ocae

poea e cpoa (9 cpo a ). Caap epa 6

cpo a aaec co 12/72 a. Haoe, 1/216 paa 1/3 o

1/72. eee a a e ooe eaae ooe cea

cc o epa cpo, c e o o p opo poxoe

ao poe, oecea ea oee cooo aeca. Bo

Esc-oceoaeoc:

eee Esc-oceoaeoc

72-e a 27,65,n (e n o 1 o 85)

216-e a 27,51,n (e n o 1 o 255)

216-e a 27,74,n (e n o 1 o 255)

Koa ee epaa 72-x a e ca a o

ex op, oa e cpec opo pa o: 27,50. o o

oe ae cooac oeo occaoe caapoo

epaa 1/6 a. Ec paee a cooaa oaa 27,65,n, o

occaoe epa- a 1/6 a ao oca oa

27,65,12,27,50. a pax oa epao 1/216 a e

e. ep o caaae, o ce ocee epeo

cpo oc c aa epao; opo e ece

oo a o epeo cpo, a ae opaae epa, oop

ecoa o oo.

5. paee ee a.


- 4 -

aa a pepe epeaec oaa蠠 epeoa cpo,

epao a epeoa opaa. caoo epea- ee

a pepe opeeec e pep aoaec epexo a

o cpa p oape epopa e cpaa. Ec

epopa e e pocac, o ea oe aepc po a

epe pa oepeo cpa. po- c epopa ocae o p

cx cpo cepx c ao cpa. Ha cao ee pep e

pacoae epopa, eco oo o cae, o aa oe

aa paea a aao cpa cae co epeoo cpo.

Moo popao epeopee cao epeaee, oca a

pep pae o 27,56, o pep e ea poca ep-

opa 27,57, o ea poc epopa.

paec pep coe o, oop opee co cpo,

pocaex e cpaa. o o 27,78,n, e n - co cpo o

1 o 127. Hapep, o 27,78,10 pee o, o pep e

poca o 10 cpo. Ec ecpo ep- a pae 1/6 a, o

11-oa cpaa e coepa 66 cpo oce ea ax

56- cpo pep e ea poc 10- cpo. popaa oa

oaoc, o cao aae poa a a 5 cpo, c e

o 55 cpo eca eppoa a ao cpae.

Ec coec aa, paep oopo oaec o caapoo

11-ooo, o oo e cpa, c e o poc

epopa蠠 pocxo蠠 o ece o epeo opaa

caaa a pa o. Paep cpa oe

caaac o co cpo a cpae, o paepo ax.

o cao co cpo a cpae, oe o 27,67,n, e n -

co cpo. Ta e oceoaeoc coec cao -

cpa ax, a cee oo, o a cpa

acaec ope 0,n, e n oe o 1 o 22 o.

caapo cpa ao oca oa 27,67,0,11.

6. paee ooee eaae oo.

eaae ec pacpeeec o cpae aco a ce

e a, a aco a ce e eaae oo.

ooa oe oopoaa oe eco, o e e aa

ee oopa. Beco oo aaec ee ceee, ooceo cao

eo o, oop oa oe oca. pepa e ao,

cooax eee ooee oo. Baa popaa oa ocea

ooee oo, ec oo oo ec. p o xopoe

pao ec aa ea c oa paeo oa 27,60,

oop cae oo ca e o, e ea epeoa

cpo (o e caoe eae o opaa ape).

p ea eca eec ecoo cocoo epe o- o

oe ooee. Oa oe cac pao oae ooo

ecox coo poea a eo oae ooo

ecox coo "opa a a" coa opaa ape.

e ocecc epepo - e ocpae x a

cooece oceoaeoc a oo e ae. o ex

op, oa Baa popaa ae a- aoe ooee eaae oo

oa oe oae epe- oo cpo, poeo, a

opao a a opapo- a Ba o cooec c Ba

oea. pep, oope e o opa eepo cpo

o coo- ac a paoocpoe.

B paecx peax ooo epeeee oo a ae o

a. p ea eca B oee o paec pe- , o

oc pax poeo e coa.

eec cea頠 o, oop頠 acae oo cea


- 5 -

opaac pa e o epe ea oepeo cpo,

oe apae ea. Xo o aeo aee ea,

oao p o ocaec oee ooe oopoae oo. o

ocoeo oeo p paoe paec- o pee. o

ooapae ea ao oca o 27,85,1, a o epc

apaeo ea - o 27,85,0.

7. eee pa ea.

pa cpa 8 1/2 a ooe aeaa cpoe o 80-

ox coo, ec蠠 ce o蠠 e oao p.

poopoaa ea ooe oec cpoe ee ecoo

coo. C po copo, oa ea ooe ec cpoe

132 coa, ea c oo po - 40 coo, a oa ea c

oo po - 64 coa. ee , o cooae ea c

pao po oo cpoe pee poc c opapoae.

oco apx pepo peoca aop peo ea

cea pa. Bo epee caapx oooc- e

peocaex paec pepo IBM:

oa ea:

e pea oo ea ao oca ooa

pa o 15. e oo pea - o 18. Caapa

cpaa po 8 1/2 a ooe aeaa 132 coa cpoe

o pee.

ea c oo po:

oo, o pep aa eaa c oo po ao

oca a eo pa o 14. Pe ea c oo po

eoe e, o pep aoaec ae o pe, oa

cpeae co opaa ape epeoa cpo. oco ao

ea oo coec oocpox aooo, o o

coco oo. o o pe cepee cpo oe

o 20.

Beea ea:

p eeo ea a co eaaec a paa oo

o e o. o eae o eee, o coae e ee.

Copoc ea p o eaec oe. e oo pea

oe o 27,69. e - 27,70.

ea a a poxoa:

B pee ea a a poxoa aa caec a 1/216 a

epe op poxoo eaae oo. p o oac oee

aoee , oope o e pe. Copoc ea

eaec oe. o pe aec pa oo 27,71, a

aec oo 27,72.

ea c oepae:

ea c oepae젠 oe oc cocoa.

paec pep ee pe oepa, oopo oep

eaaec o a coo, a poe. paecoo

pepa IBM o pe aec oo 27,45,1, a aec oo

27,45,0. pep, e ee pea oepa o cea

oep蠠 p opo poxoe o o e cpoe, eaa co

oepa (ASCII 95) ex ecax, e oo o poe (ASCII

32) o cex ocax ox. Bopo poxo ocaec e, o

oce epoo poxoa oaec o opaa ape e oa epeoa

cpo. Bopo poxo e eae pe- p pao oca


- 6 -

cpo p ce paepa cpa.

ea c epx eca:

Ha paecx pepax ec c epx eca

caec epao. ea epxeo eca oe pa

o 27,83,0, a ea eo - 27,83,1. Moo po epexo o

ox eco p. e ea eco, c e, o

pep oaac a ee cpoe oe pa o 27,84.

Heoope pe e o cooac oa c p.

Ec B xoe cooa 4 pea oopeeo, o pooc-

pec co cee ae. B ao ec coo peea

oca oa.

Koa 1 2 3 4 5 6

opa頠 X X

ca頠 X X

ee頠 X X

a a poxoa X X X

c eca蠠 X X X

oo p X X X X X X

c oepae젠 X X X X X X

8. oca ax a pep.

oca ax a pep paa ax cooo po, a

popaca a e acceepa eec p oepa- oo

cce, oope ea򠠠 aa ae ocaoo poco.

popapoae a o poe pee oe pao, o ao

peocae oe oooce. Ka pao, poep ea

oo po oca co a pep, a ae ocoo poepe

pecp caca oa opa, oopo pcoee pep. Ce

co ocaec oo oa, oa pep cape, o o

oo (pep oe e eaa co cpa, a aaca eo coe

epe, o ex op oa e e oea ea cpoa coo

ea).

Kpoe oo, poep oo po o cooa pepae

pepa o poa ece oo pepa. C oo

ceaoo popapoa oo cea a, o pep e

ea pepae poeccopa, oa o oo pe ceeo

coa. poepa opao pepa ocae ce co,

oce eo poeccop oe pooa aac co ea. o

eo coec ooo ea (oop aa ae c-

o). oco ece epeee eae pepa aoo

eeee, e copoc epo oepa, o o coo a

pep aae a o poeccopoo pee. cooae

pepa ooe cooa o pe eo.

p oce ax a pep peec cpaeo eoe

c, o oc aco cooo oa. Bce coe ap- ,

oope oe o pep, ocac a ce opoa

ecox paecx ax, a ae oocex oo pae

pepo, ocaxc paee o ae. Kop oo cpoe

eco paec pe, oo oc paa paoo

o poopoao ea. Kpoe oo o paec pep

oe coaa ceae co poooo a, a a ce

apaoo apoa aea ecpooo epaa o

oc e co- ceopa.


- 7 -

9. Bo ecox paecx ax a pep.

poeccop oe aac oo oco ax a pep o

oe eaa ooo pee, a ce cooa pepa

pepa. Booa pe aepaa, oa popaa ocae

co a pep epe砠 opeeee epa, o oo

paccapa a "ceopepae". o eo e a eco oop-

pec c paoo pepa, a acoee pepa- e, o o co

cae paoa pepa e pa o pee.

Heaco o oo a oc ae, a pa a pep

ocaec oo 1 a ax. cooo po peoca

, oope poe o cpa ee cpo, oao a cao

ee paa cpo a oee co. Oo

cooo po oca a pep ap opa ape/epeo cpo

oe ao cpo. C po copo, popa a acceepe o

ca oa ap oo. -a oo pxoc eoo oe

popapoa, o ae B oaee aoo o oc,

ocoeo ooe po- ep oo.

Cpe poe.

0 pepa 17H ocae o co a pep. oece

co AL, a oep pepa DX. p opae AH e coepa

pecp caca, oop ao ocoo poep oape

oo. B [6.1.3] ocec a o ea. oa ooa ax

caoe aae a ep, coepa ae, ae poep

a cee:

;---o ax a LPT1

MOV CX,NUMBER_CHARS ;CX coep co a oa

MOV DX,0 ;pae LPT1

NEXT_CHAR: MOV AH,0 ; oc coa a pep

MOV AL,[BX] ;BX aae a ep ax

INT 17H ;ocae co

TEST AH,8 ;poepe o

JNZ PRNTR_ERROR ;a opao o

INC BX ;eae aae

LOOP NEXT_CHAR ;o ce co

Caapoe pepae MS DOS oa a pep o 5

pepa 21H. poco oece co DL oe pepae.

a cea o a LPT1 ee e opaaex pecpo.

;---o ax a LPT1

MOV AH,5 ;oep

MOV DL,CHAR ;oo eaae co

INT 21H ;ocae eo a pep

po coco oa ax a pep o 40H pepa

21H. o caapoo oa, c cooae젠 eoa

ecpopa ao oca a cpoc [5.3.0]. B ao

cae a coe cea pe- opeee oep

aa pepa. o oep #4 eo ao oec BX.

ee oc oo LPT1, oo oa a po pep Ba

ao oe aoe apeca [6.1.4]. DS:DX o aa a o-

e ae, a CX coep- a co ocaex ao. Hapep:


- 8 -

;---o 120 ao ax a LPT1

MOV AH,40H ;oep

MOV BX,4 ;oep aa pepa

MOV CX,120 ;co ocaex ao

LEA DX,PRTR_DATA ;DS:DX aa a ae

INT 21H ;ocae ae

JC PRTR_ERROR ;a opao o

p opae caoe a epeoca pe o, p

o AX e coepa 5, ec pep e ca c ao 6 - ec

aa eep oep aa. Oe, o p蠠 cooa

peopeeeoo oepa aa eo opa cpoco.

H poe.

a ax ocaec a pep, e oc eo pecp

ox ax, apec opa oopoo coaae c ao ape- co

pepa. oe, o aoe apeca LPT1-3 xpac co cee

8, 10 12 oac ax BIOS (aaec c 0040:0000). oce oo

a ae oca pecp a opooe pe aec cpoa

pecpa pae oo, apec opa oopoo a 2 oe, e

pecpa ax. Hoep a cpoa pae 0 o oe caoe

oo a oe opooe pe, o poa epea ax,

axoxc pecpe ax. poepa ea oe eeeo

cpoc cpoa opao 0.

oce oo a a ax oca, popaa oa oa, oa

pep e coo, o o oo pe ceeo. o eaec -

cocoa. p oooc pep ae c oepe

pecpa caca oa, apec opa oopoo a 1 oe aooo

apeca pepa. Hoep a oepe pae 6 oo o

caoe 1. c oepe cpacae o 0 a

ocaoo ooe pe, o popaa a e acceepa oa

e o, ec oa ocoo ce a pe- cpo.

po coco a, o pep oo pe ceeo aa

ax coco epepo poepe a 7 pecpa ca- ca,

oop cpacaec 0, oa pep a caaaec 1,

oa o oo p ae. Ec B e poe- p ea

oo po, oopa oa paoa eppepeo ece

po oe eeo e, o ao cooa o eo.

Ce pep oae ao apec LPT1 oac ax BIOS

ae o ae epa, a oop aae pe- cp BX.

popaa ocoo poepe pecp caca a aoc

oopeeo poepe 3, o poep ae o a

pepe.

;---oooa

MOV AX,40H ;ES aae a oac ax BIOS

MOV ES,AX ;

MOV DX,ES:[8] ;ao apec LPT1 DX

MOV BX,DATA_START ;BX aae a ep ax

;---ocae co

NEXTCHAR: MOV AL,[BX] ;oeae co AL

OUT DX,AL ;ocae co

INC DX ;DX e aa a pecp

INC DX ;pae oo

MOV AL,13 ;eoa o ca cpoa

OUT DX,AL ;ocae ca cpoa

DEC AL ;opaoe ccooe pecpa

OUT DX,AL ;ocae eo


- 9 -

;---poepa a o oae oooc pepa

DEC DX ;DX aae a pecp caca

NOT_YET: IN AL,DX ;oae a caca

TEST AL,8 ;oa?

JNZ PRTR_ERROR ;epexo a opao o

TEST AL,80H ;pep a?

JZ NOT_YET ;ec a, o aa

INC BX ;eae aae epe ax

DEC DX ;DX aae a pecp ax

JMP NEXTCHAR ;e a ea ceeo coa

Koa caoe 4 paeo pecpa pepa, o papeeo

pepae pepa. Koa coec pepae, o popaa e

oa oa caa oooc o pepa, epepo opaa

pecp caca pepa. Beco oo, popaa oe oca co

aac p ea; oa pep e oo pea

ceeo coa, o o oe ca oepe ( 6 pecpa

caca a opooe pe e caoe 1) aoaec e

ao pepae pepa. poepa opao pepa oe a

pep ce- co epe paee popa, o oa

oa pooa co pao, o ex op oa e pooe ceeo

pepa. Koa ce ae ee, o pepae oo

o ce.

10. Kopoae paa a pep (a paa).

a ecooo paa cea ocaoo poco, ec ce co-

ee co coepac pepa o x e oc

co cea apa, a a oepae eaoe

opaee. B o pocee cae popae o cao

p pepa pao 80 coa, a ae ca co

ooepeo eoepa, oca x a epep oo ax a

pep. Ec pepa occ ceae co, ae a

co ceopa, o popaa oa ooo co a

ax x coo o x a pep paeco pee.

oco co- o axo ecpoe epa, o

oe opeoac ceaoe popapoae.

Ka ceax apo coo coae co poe- .

poepe ap aoo coa p ca eo eoepa.

Koa co ee c oo oep- a 蠠 oeo

ecoc, o ao a oepae ea p po

a pepe. Oao ec co oc eao opae, o

oa e e poe, o c eoop paec coa:

oac eaoo opae oa pocpac o epxeo pa

cee cpo- . B o cae ao ao ep c oac p

opo poxoe. B acoc o pepa, Ba oe oaoc

coa cea a ax oa coo eae,

oco oa o eaac, o opae o o

axoc co o oa po, ae opaae co.

B o cae e oe pe o ea a poxoa. poc

peee poe c ea opaee ec cooae

paecoo pea paa oa eca, a ae cea a

paecoo paa.

paece a coa co poe. a ax pepa

cooece oc epa oa, o pe a a pa- e

a pecae 8 opoax oe. oo peec poepa

peopaoa, oaaa a pc. 6-4. Hao cpa oa o 8 ao

a paa, pa ae, oope cooec oac oe 8*8.

ae ao cooa oece oepa epecao o, a


- 10 -

oaao pepax.

oco apx pepo caa paoe opaee. o

pocxo oo, o o co aca oe 1:1, o

pe a pa coe oe 5:6 (aca oe

cpaae co opoax oe a c co epax

oe a ). Toee oop, caee opae a cao ee

oae -a acaoo oea paa, oco popa

o ceao e ae opae, o oo eo

a, a a xoec (apep, opaee opoc a pae

coaec oo a eo ca). Koa ae c paa oc a

pep, o caee o opaac. Heoope paec- e

pep e ceae pe, oopx oo o o

paa e cae, a eo pep IBM oe e aca

oe o cox paecx peo.

H poe.

acceepa eae oe peopaoa aoo cpee. Bo

poepa, oopa eae peopaoa aco cpo, oco

oa ep ce popoeccope (oa eoo eoa- a, o B

oee cooa ae aop, oaa ece). poepa

paoae, xpa 8 pepx ao pe- cpax CX, DX, BP DI.

a pax ax oeaec AL, a ae AH epeac

oceoaeo CL, CH, DL DH. Ka pa AL AH caec o

oa cea 4 ca, o CX DX oeac c DX BP, oce

eo ce o oopec coa. o poecc oopec aoo

8- pax ao oa o aepe, o peopaoaoe

opaee xpa- c pecpax popoeccopa, pe ca e

a ax ea CL. Coepoe pecpo oc a pep

oec, oce eo poecc oopec cex oc

ao paa. Caaa oe 8 ao eoepa oec- e

x ep c ee BUFFER. oece 0 AX, CX, DX, BP DI. ae:

LEA BX,BUFFER ;aae a ep eoax

MOV SI,0 ;ceee o epe

GET_BYTE: MOV AL,[BX][SI] ;epe a

DO_HALF: XCNG AH,CL ;oae CL, CH, DL DH

SHL AX,1 ;ca AL

XCNG AH,CL ;

XCNG AH,CH ;

SHL AX,1 ;

XCNG AH,CH ;

XCNG AH,DL ;

SHL AX,1 ;

XCNG AH,DL ;

XCNG AH,DH ;

SHL AX,1 ;

XCNG AH,DH ;

;---aae op oo epeee o

XCNG CX,BP ;oeae coepoe CX DX

XCNG DX,DI ;

CMP SI,7 ;ec ce a peopaoa, o eaae

JE PRINT_BYTES ;

INC SI ;ae epexo cee a

JMP SHORT GET_BYTE ;

;---eaae a

PRINT_BYTES: PUSH DX ;coxpoae DX

MOV AH,5 ; oa a pep


- 11 -

MOV DL,27 ;o Esc

INT 21H ;ocae eo

MOV DL,75 ;o paecoo pea

INT 21H ;ocae eo

MOV DL,6 ;e ocao 6 ao

INT 21H ;

MOV DL,0 ;

INT 21H ;

CALL PRINT_2_BYTES ;ocae coepoe CX

POP CX ;

CALL PRINT_2_BYTES ;ocae coepoe DX

MOV CX,BP ;

CALL PRINT_2_BYTES ;ocae coepoe BP

MOV DX,DI ;

CALL PRINT_2_BYTES ;ocae coepoe DI

.

(e cee pe oc ao)

.

PRINT_2_BYTES: PROC NEAR

MOV AH,5 ; ea

MOV DL,CL ;caaa CL

INT 21H ;eaae

MOV DL,CH ;ae CH

INT 21H ;eaae

RET

PRINT_2_BYTES ENDP


12

Kaapa.

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

, 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


13

Bo/o.

1. oc oceoaeo op.

p acxpoo c aa ocae pae a opa

o oo . Bpeee epa e aa蠠 p蠠 o

ecece, o peea e oe a aa oe a.

Ca a oe cooo 蠠 oo po, o

cooece oec ee, oop, o oeea

(marking), oa poe co, ca (spacing), oa poe

.

oepaec oeeo coco, oa o e e

epea ax. p aae epea aa ax ca aae 0,

oea capo . ae ce oce o ax (oa

ee) e aopa cox x poe. oce ax

oe copooac o eoc, coe oape

oo, a ae oceoaeoc ac 1 oee co-o,

oop cooece co頠 poe. 蠠 co- aa

oeeoe cocoe, oopoe e coxpac o ex op, oa e

aec epeaa ceeo aa ax; co coex

co-o ceceo, oco o caaa aoe pe,

oopoe oo po epe ce capo o.

Koeo, epeaa pea ca o cooa o

o e pooo x eoe o o o pao- a c oo

o e copoc oea (epeo ax ce, aaex

ae oa). p oee o eo oa o, oo o-

aooe oopoae peocae paoopa opa o

cace a caoo opa, a pcoeeoo e oea. aae

oea ec peopaoa- e caa, eeppeoo opo o-

a, acec ca, oop oe ae epea o

eeoo󠠠 aa. oco oeo⠠ peoca ae

ooee oa- oe oooc, ae a aoaec

o oe, oope e oepac ca opo oa.

2. popapoae pocxe UART 8250.

oceoaea c acoo coa, o papaoa

ceae pocxe, oe pao o oppoa

cxpoa cpo o, cocax oceoaee ae. Tae

pocxe aa epca acxpo peo-epeao

(universal asynchronous receiver transmitter UART). IBM PC co-

e UART 8250 p Intel.

Oepaoa ccea oepae 2 opa oa, oo-

ae ec 2 pocxe. x aoe apeca xpac ee

0040:0000 COM1 0040:0002 COM2. (ao apec o 2-xao

apec opa, oop ec a p apeco opo, ax

oc UART.) Ha cex aax COM1 ee ao apec 3F8H, a COM2 -

2F8H;

Mpocxea 8250 ee 10 popapex ooax pecpo, c

oo oopx paec opopec op oa. o-

co x aac aae opa, po- ecco, oop

oe oe co. oc 10 pe- cpa ocecec

epe ce apeco opo c oepa 3F8H - 3FEH ( 2F8H - 2FEH). B

cax pecp, oopo oae oc epe a op,

ac o oo, a caoe 7 pecpe opo ,

oop ec ece pecpo c apeco opa 3FBH. Bo

pecp:


- 2 -

3F8H (OUT, 7 = 0 3FBH) Pecp xpae epeaa

3F8H (IN, 7 = 0 3FBH) Pecp ax pea

3F8H (OUT, 7 = 1 3FBH) ee copoc oea (a)

3F9H (IN, 7 = 1 3FBH) ee copoc oea (cap)

3F9H (OUT, 7 = 0 3FBH) Pecp papee pepa

3FAH (IN) Pecp ea pepa

3FBH (OUT) Pecp pae

3FCH (OUT) Pecp pae oeo

3FDH (IN) Pecp caca

3FEH (IN) Pecp caca oea

ec pecpo oo ec eoxo poco oce-

oaeo c. Pecp xpae epeaa coep a ax,

oope oca, a pecp ax pea - oce

oe a ax. Pecp pae caca a-

p pa e頠 c, co copoc oea,

coepac x pecpax ee copoc oea. ocaxc

epex pecpo pecp pae- caca oea coc

oo c epe oe , a a pecpa, cax c pepa

coc oo poepax, paex pepa.

pepa coc p c ex eoc. Oa

oaoa poepa epepo poepe pecp ca- ca -

, oa ooo coa aa, o ce oo- o

epea ceeo aa ax. oco poeccop aoo cpee,

e oe copoc c oop epeac oc- eoaee ae,

o o eo apaco pacxoe poeccop- oe pe, oopoe oe

cooac opao ocax epeaaex ax. o

o pe pocxea 8250 oe caoea pe, a

pepae p oe coa, ooe o .. o

pepae oeao oe poep Bae popa, oopa,

cae, e epea- a ce co oaooo

epa.

3. aa oceoaeoo opa.

p aa opa oa ("op") caaac

ce eo apaep. apaep coa, co co-o,

cao eoc copoc oea. a coa o co o,

oopoe opae oco e ax. Ec paoae c p

op o 8 o, o 7 o ocao caapx ao ASCII

( oopx ce co e o, e peae ASCII 128), o

pe a epea cex ax ocaoo op o 4 a.

Cpe poe.

0 pepa 14H BIOS ape op oa- . B

DX oe aac oep oaooo aaa (COM1 = 0, COM2 = 1).

B AL oe coepac a aaox ax, aee o

oopoo ceee:

1-0 a coa. 10 = 7 o, 11 = 8 o.

2 co co-o. 0 = 1, 1 = 2.

4-3 eoc. 00 10 = e, 01 = ee., 11 = e.

7-5 copoc oea. 000 = 110 o

001 = 150 o

010 = 300 o

011 = 600 o

100 = 1200 o

101 = 2400 o


- 3 -

110 = 4800 o

111 = 9600 o

B ao pepe op apec co coo 8 o, o

co-o eo eoc. Copoc oea 1200 o.

;---pcaae ae apaepo epee

MOV WORDLENGTH,00000011B ;a coa 8 o

MOV STOPBITS,00000000B ;1 co-

MOV PARITY,00011000B ;ea eoc

MOV BAUDRATE,10000000B ;copoc 1200 o

;---ape COM1

MOV AL,0 ;c AL

OR AL,WORDLENGTH ;caaae e

OR AL,STOPBITS ;

OR AL,PARITY ;

OR AL,BAUDRATE ;

MOV AH,0 ; aa opa

MOV DX,0 ;pae COM1

INT 14H ;ape op

H poe.

Heaco o oo, aaec oo oo, a

4 pecpa pocxe 8250 o apoa oepa

oea. o pecp ee copoc oea, pe- cp opo

pecp papee pepa.

ee copoc oea o co, a oopoe ao pae

aco ccex aco (1190000 ep), o o eae

copoc oea. Hapep, copoc oea 1200 o ee

copoc oea oe pae 96, oco 1190000/96 peo

pao 1200. e oe ee, e ee copoc oea. Copoc

oea 300 ee pe xaoo ca ee. Cap

a ocaec 3F9H ( 2F9H), a a 3F8H (2F8H). B oox

cax 7 pecpa pae oe caoe 1

epe aco ae; po- o cae o apeca

ae apecoa pe pecp (c. [7.1.0]). Bo

eoope ae, peee ox copoce oea:

Copoc oea 3F9H 3F8H

110 04H 17H

300 01H 80H

600 00H C0H

1200 00H 60H

1800 00H 40H

2400 00H 30H

3600 00H 20H

4800 00H 18H

9600 00H 0CH

Bcea caaae pecp copoc oea ep, a a o

ecee, oope pe, o caoe 7 pecpe

opo . oce oo ao e coepoe pecpa opo

, cpaca 7- , o ce ocae oc pecpa

pa. oco pecp opo ec pecpo oo

ac, o e cocoa ep- 7 opao 1 e

oopeeo cao cex ocax o oo pecpa.


- 4 -

aee o pecpa opo , apec opa oopoo pae

3FBH ( 2FBH), ceee:

1-0 a coa. 00 = 5 o, 01 = 6 o

10 = 7 o, 11 = 8 o

2 co co-o. 0 = 1, 1 = 1.5, ec a

, ae 2.

3 eoc. 1 = eeppec eoc, 0 = e.

4 T eoc. 0 = eea, 1 = ea

5 ca eoc. acae eoc cea

0 1. 0 = oeea

1 = cea 1, ec 3 = 1 & 4 = 0

1 = cea 0, ec 3 = 1 & 4 = 1

1 = e eoc, ec 3 = 0

6 caoa epepa. Bae o cpo e

aece caa oaeo ca.

0 = apeeo, 1 = epep

7 Mee apeca opo px pecpo

Oo 5-7 cpoe 0. Ocae oca ae, ope-

eee poooo oea.

ae ec B e coee pepa, ce pao B o

poec蠠 ac ⠠ pecp papee pepa, o

epe, o pepa apee. poco oece o pecp 0.

Pecp ea pepa oo oppoa.

aa ocax pecpo caa c oea. co, o

oe oo c c ae cpoca, a e

pae ea cpoca, a a oceoa- e

pep.

B ao pepe oac ax BIOS epec ao apec COM1,

oce eo pae pecp apc copoc oea 1200

o, cex ax, eo eoc ooo co-a.

;---oae ao apec COM1

MOV AX,40H ;ES aae a oac ax BIOS

MOV ES,AX ;

MOV DX,ES:[0] ;oae ao apec COM1

;---ape pecp ee copoc oea a 1200 o

ADD DX,3 ;aae a pecp opo

MOV AL,10000000B ;caaae 7

OUT DX,AL ;ocae a

DEC DX ;aae a cap a ee

DEC DX ;copoc oea

MOV AL,0 ;cap a 1200 o

OUT DX,AL ;ocae cap a 1200 o

DEC DX ;aae a a a ee

MOV AL,60H ;a a ee 1200 o

OUT DX,AL ;ocae a a

;---ape pecp opo

MOV AL,0 ;oe AL

OR AL,10B ;a ax 7 o

OR AL,000B ;1 co-

OR AL,1000B ;eeppec eoc

OR AL,10000B ;ea eoc

ADD DX,3 ;aae a pecp opo

OUT DX,AL ;ocae aaooe aee

;---ape pecp papee pepa

DEC DX ;aae a pecp papee


- 5 -

DEC DX ;pepa

MOV AL,0 ;apeae pepa

OUT DX,AL ;ocae a

4. caoa eeo oaooo opa.

ec a cocoa, oop popaa oe opee, ao

oaox opo oe cooac. O cocoo coco

aa oepa aaa oepaope popa. Bopo coco coco

aca popa oea epe op COM1, o ee o-

aooo aaepa, oc oopo e epe COM1.

Oac ax BIOS coep eco epex 2-xax

epeex, oope coepa aoe apeca oaox aao

(MS DOS oepae oo epe a x). ao apec opa o

a p apeco opo, epe oope oo o oc

ao oaoo aa. ao apec COM1 xpac

ee 0040:0000, a COM2 - ee 0040:0002. ce o-

aox opo ao poco oe a ae. oopa

cea ae pee epoa- ao aae opo.

Cpe poe.

Ec popaa opaaec oaoo op epe pepae

14H BIOS, o COM op opeeec coep DX, oopoe pao 0 1

( COM1 COM2). Beco oo, o pcaa DX eocpeceoe

aee, aoe eo epe- eo, oopo oe pcoeo

aee 0 1. popa, coe oaoe 3

4 pepa 21H cea apecc COM1. B o cae ao oe

aoe apeca:

;---oe aox apeco COM1 COM2

MOV AX,40H ;ES aae a oac ax BIOS

MOV ES,AX ;

MOV DX,ES:[0] ;oeae 1- ao apec DX

MOV AX,ES:[2] ;oeae 2- ao apec AX

MOV ES:[0],AX ;oeae apeca

MOV ES:[2],DX ;

5. Opeeee caca oaooo opa.

Pecp caca pocxe UART 8250 opeee pooo c-

. o pecp ee apec opa a 5 oe, e ao apec

aoo aaa. Oo o ocoo pocapaec po- ecce o-

aooo oea. p epeae ax pecp cooae, o pe-

co e oca, oo popae aca o co oepx

eo. p pee ax pecp oppe popa o oce

ceeo coa, c e o popaa oa poa eo pee

e o e oe ce- p. aee o oo

pecpa ceee:

0 1 = a ax oe

1 1 = oee ae epeaca (pe

co e ope ca)

2 1 = oa eoc (epoo, -a a )

3 1 = oa ope (epeaa e cxpooaa)

4 1 = oape epep (oea a cpoa e,

pa, o pa ca apaae

oe epea)

5 1 = pecp xpae epeaa c ( o pecp


- 6 -

o oeac epeaaee ae)

6 1 = pecp ca epeaa c (o pecp o-

ae ae pecpa xpae peopae

x oceoae )

7 1 = aa (cpoco e cao c ao)

Cpe poe.

3 pepa 14H BIOS opaae AH pecp caca

(AL oae pecp caca oea [7.1.5]). p xoe DX oe

coepa oep oaooo opa, oopo ocecec

oc, e COM1 = 0, a COM2 = 1. Ka pe pep, o

poepe ae epepa:

MOV AH,3 ;oep

MOV DX,1 ;pae COM2

INT 14H ;oae a caca

TEST AH,10000B ;oape epep?

JNZ BREAK_DETECT ;ec a, o a poep opao

H poe.

oac ax BIOS caec ao apec oaooo

aaa, e oaec 5, a ae oeoo apeca opa c-

aec a caca.

MOV AX,40H ;ES aae a oac ax BIOS

MOV ES,AX ;

MOV DX,ES:[2] ;oae ao apec COM2

ADD DX,5 ;oae 5 pecpa caca

IN AL,DX ;oae a caca

TEST AL,10000B ; 5 caoe?

JNZ BREAK_DETECT ;ec a, o a opao epepa

6. aa paee oeo.

eec 6 , o oop oe cac c oepo

(coepecoae oe o e oaoe o epec

RS232). Bo x aa, copae :

O oepa oe:

Data Terminal Ready (DTR) oppe oe, o oep

oooc oepa e oo c.

Request To Send (RTS) oppe oe, o oep

apoc a oc󠠠 oae oc ax.

O oea oep:

Data Set Ready (DSR) oppe oep, o oe

oooc oea e oo.

Clear To Send (CTS) oppe oep, o oe

oooc oce oo aa epea ax.

Data Carrier Detect (DCD) oppe oep, o oe

Oape oce ax ca c p oeo.


- 7 -

Ring Indicator (RI) oppe oep, o ee-

aop oa oa , o oopo pcoe-

e oe ee oo.

Caaa oep caaae ca DTR, a ae cpe

oe cac c aeo cae. oce oo, a oe cao

c o caaae ca DSR. o ca oppe oep,

o oe oo c o oe oep oe cao

ca RTS. Koa oe oe cao CTS, o epeaa aaec.

e caape , o oop oep pae oeo,

oc epe pecp opo oea pocxe UART 8250. o

pecp ee apec opa a 4 oe, e ao apec coeoo

oaooo aaa. Bo aee eo o:

Pecp opo oea:

7-5 (cea 0)

4 1 = xo UART a a xo

3 oao ooae aae a o #2

2 oao ooae aae a o #1

1 1 = "apoc a oc" ae

0 1 = "oooc oepa" aa

Oo caoe 0 1 pecpa opo oea, a ocae

pa 0. 2 pae 0, a cee cae, oa pooe

oea peaa eo ceaoo coo- a. 3

caoe oo cae, oa coc pe- pa [7.1.8].

Haoe, 4 peocae oooc ecpoa oaox

popa e caoe peao c. Bxoo ca pocxe

UART oaec a xo, a o UART pae oceoaee

ae. o coco oo c- ooa ecpoa paoc

pao cao頠 pocxe. Oo eoco p cooa o-

aox poep pepa 14H BIOS.

epe , o oop oe oca opa oep,

pac pecpo caca oea. o pecp pacooe o apec

opa a 6 oe, e ao apec coeoo oaooo

aaepa. Bo aee eo o:

Pecp caca oea:

7 1 = DCD

6 1 = RI

5 1 = DSR

4 1 = CTS

3 1 = eee DCD

2 1 = eee RI

1 1 = eee DSR

0 1 = eee CTS

popaa epepo poepe xoe oaox

oepa. Oe, o 4 ax a apae cap epe

a. caaac 1 oo oa, oa pocxo

eee cace cooeceo capeo a c ex op, oa

pecp ac oce pa. Bce 4 ax a aoaec

cpacac p e pecpa. popa oo po o po

a o pecp. po oooc ec cooae

3 pepa 14H BIOS, oopa opaae pecp caca oea AL

(p o AH e coep- ac pecp caca ). p xoe DX

oe coepa oep oaooo aaa (0 1).


- 8 -

oco oeo ee aoo oe oooce, o cpae

c e, o opae x cax c oeo pecpax. ec

oooc aoaeco c aoaecoo oea, oope

opopc pae cpoo. a cpoa ocaec oe, a

o epeac oe ae. Moe ee cpo ax o

ceao co, coe- o oo aa aaa

pae cpo. o co oe peopeee (aco

coec o Esc - ASCII 27) pae ooaee. Moe

cocoe opee ac- oo o oa aa cpoa,

oo o ooa cpo o o paccapae xo oo

opa a ae. Ka oe ee co aop oa.

H poe.

Bo a e caa cxea a e acceepa:

;---caaae ca DTR

MOV DX,BASE_ADDRESS ;aae c aooo apeca

ADD DX,4 ;aae a pecp opo oea

MOV AL,1 ;caaae 1

OUT DX,AL ;ocae op

;---ocae pa cpo oe oa

.

(o o pa pax oeo)

.

;---oae oa e caoe ca DSR

INC DX ;aae a pecp caca oea

INC DX ;

TRY_AGAIN: IN AL,DX ;oae coepoe

TEST AL,10B ;poepe opo

JZ TRY_AGAIN ;e oa o e e pae 1

;---caaae RTS

DEC DX ;opaaec pecp pae

DEC DX ;

MOV AL,3 ;caaae ca RTS

OUT DX,AL ;ocae op

;---oae caa CTS

INC DX ;opaaec pecp caca

INC DX ;

ONCE_MORE: IN AL,DX ;oae a caca

TEST AL,1 ;poepe CTS

JZ ONCE_MORE ;e pooae oa o e caoe

;---eep oo oca ae

6. epeaa ax.

epeaa ax poe e pe, oco popaa ee o

opo a cocao ax copoc, c oopo o o

ocac. Te e eee poep epea o ocaoo

co, ec蠠 o opaaa ae o epe oo, a o

ocac. Mo ae poe c cxpoae p

cooa poooa XON/XOFF. o pooo coe o ASCII

17(XON) 19(XOFF), oo o capoa pae ca,

o epea xoe poo epea peeo pepaoo ooa

ax. o p ca, popaa oa epepo aa-

poa paee co p epeae ( ooeco pee,

oopo oo paoa oe, ca oopeeo oe copo

o eeoo aa). Kpoe oo, o oap, o aea


- 9 -

ca ocae cpo e, aece caa epepa, oe

epe- po aapoac cac a epepa (oep 4) pecpa

caca .

Cpe poe.

1 pepa 14H BIOS ocae co, coepac AL

oao aa. p xoe DX coep oep opa (0 1).

p opae AH coep a caca, oopo 7 = 1, ec

oepa ecea. B o cae e aee cee :

4 oape epep (ca "co" o pae ca)

5 pecp ca epeaa c

6 pecp xpae epeaa c

MS DOS ee epea o oaoo aa

coa, oeaeoo DL. o oep 4 pepa 21H, o oa

e ee ax peec epe e BIOS; oa e opaae

caco opa e ooe aaa ao oaox

opo ao cooa (cea coec COM1).

o ec cpo a coe 40H pepa 21H.

o oa oa cex ao⠠ 蠠 cpoc⠠ p

cooa eoa oca ecpopa ao. COM1 ee pe-

opeee oep #3. oece oep aa BX, a co epe-

aaex ao CX. c DS:DX aa a ep ox ax

ae .

MOV AH,40H ;oep

MOV BX,3 ;peopeee oep aa COM1

MOV CX,50 ;o 50 ao

LEA DX,DATA_BUFFER ;DS:DX aa a ep ax

INT 21H ;ocae ae

JC COM_ERROR ;xo a opao o

H poe.

Koa a ax oeaec pecp xpae epeaa, o o

aoaec oc oceoae aa epe pecp ca

epeaa, oop cepae ae. He eoxooc ce

a cpoa, a o eaec cae a- paeoo aaepa. 5

pecpa caca oaae cooe pecp xpae

epeaa pea ax. Pe- cp ocoo poepec o ex

op, oa 5 e cae pa 1. oce oo pecp xpae

epeaa ocaec oepeo a oo eca, oa o

epc. B poecce epea 5 pae 0 oo oa o o

cae pa 1, o pecp xpae epeaa oe oca

ce co. o poecc oopec o ex op, oa o o.

B cee pepe a ocoe o o o頠 poepe.

Koeo, oa oe ceaa eoao coo ( acoc,

popapoae c pee ocoo aex poep oape

oo occaoe p cox). B pepe peoaaec, o

oao op oe e apoa.

;---e oa ce e ooo oc coa

KEEP_TRYING: MOV DX,BASE_ADDRESS ;ao apec

ADD DX,5 ;aae a pecp caca

IN AL,DX ;oae a caca

TEST AL,00011110B ;poepe a o

JNZ ERROR_ROUTINE ;ec ec, o a poep opao

TEST AL,00000001B ;poepe oe ae


- 10 -

JNZ RECEIVE ;ec a, o a poep pea

TEST AL,00100000B ;poepe oooc epeae

JZ KEEP_TRYING ;ec e, o opaaec aa

;---epeae co pae c aap

MOV AH,1 ; poep aa a

INT 16H ;pepae aap BIOS

JZ KEEP_TRYING ;opa, ec e o aa

MOV AH,0 ; oe oa c aap

INT 16H ;eep co AL

SUB DX,5 ;apec pecpa xpae epeaa

OUT DX,AL ;ocae co

JMP SHORT KEEP_TRYING ;opaaec aa a

7. oee ax.

Koaoa popaa ooa pa ae a oo -

apoa oao op caoea c c aeo

cae. pe ax oa ooc e oee o epea ax,

oco popae oe opeo- ac oca ca XOFF (ASCII

19), o ocao oo ax, ec o oca co cpo

oa e ceae x opaaa. Ko XON (ASCII 17) cooae aeo

ca, o oo poo epea.

B acoc蠠 o cooc蠠 coeoo poooa oea,

paee ae o peoa poco coo opao. Te

x, oope c opae ax ae oapac p

cxpoo oee. p oe oaex coo a pa ae

e coo epeoa cpo (ASCII 10), oco eoope

(a ec) aoaec ca epeo cpo oce opaa

ape; o cae cae epeo cpo paex

ax, o ea cx cpo p oe.

Cpe poe.

2 pepa 14H BIOS oae co oceoaeoo

opa, oeae eo AL p oe ae opaaec

popa. p xoe ao oec oep opa (0-1) DX. p

opae AX pae , ec e o o. Ec AH e pae 0, o

oe opae a caca, oopo e aee oo 5

o. o cee :

1 oa epeoe (o co oc pae, e

ae cap)

2 oa eoc (epoo, -a poe )

3 oa oope (capo co- eep)

4 oape epep (oea a cpoa o 0)

5 oa aaa (e oe ca DSR)

MS DOS ae peocae oao pea

ooo coa, o 3 pepa 21H. oae co

COM1 oeae eo AL. Oe, o p o e -

aa蠠 opa, oop ao ea epe poep BIOS

eocpeceo, a oaao [7.1.2]. o oa op a-

pec co ae 2400 o, e opo eoc, o co-

8 o a co. a e ee ax ococ o cpae

c e BIOS e opaae opa o cace.

H poe.

p oe蠠 ax e cooa oaooo pe-


- 11 -

pa popaa oa ocoo poep pecp caca ,

apec opa oopoo a 5 oe aooo apeca coeoo o-

aooo aaepa. 0 oo pecpa e pae , o ex

op oa e e oe co pe- cp ax pea. Koa

0 caoc pa 1, o ao eeeo ca eo pecpa,

c e o a eo e ao- c ce pae co. oce

oo a co ca, 0 o caoc pa 0 ocaec

ao, oa e pe o co.

Xo ec o o e oopoc, o oaoe poep

oo coa ec ep copa ocax co- o. B

o ae a, o ec ocae ae oaa a pa co

copoc 1200 o, o poepa ca paa BIOS e e ce- a

pooe epeoee. pocoe peee x poe coco

cooa oaooo pepa.

Ce pep aco pe coepoe peeo paea,

ooceoc epeae coo. Ka o cae o aaec c

ecoeoo a.

KEEP_TRYING: MOV DX,BASE_ADDRESS ;ao apec

ADD DX,5 ;aae a pecp caca

IN AL,DX ;oae a caca

TEST AL,00011110B ;poepe a o

JNZ ERROR_ROUTINE ;ec a, o a opao o

TEST AL,00000001B ;poepe oe ae

JNZ RECEIVE ;a poep pea ax

TEST AL,00100000B ;poepe oooc epeae

JZ KEEP_TRYING ;ec e, o aa a

.

(ec pacooea poepa epea - c. [7.1.6])

.

;---oae ae o x a pa

RECEIVE: MOV DX,BASE_ADDRESS ;ao apec

IN AL,DX ;ae oe co

CMP AL,19 ;poepa a XOFF

JE XOFF_ROUTINE ;

.

( ..)

.

MOV DL,AL ;oo co oa a pa

MOV AH,2 ; oa coa

INT 21H ;o eo

JMP SHORT KEEP_TRYING ;opaaec a aao a

8. oca/oee ax c oo oaooo pepa.

Xopoa oaoa popaa ee co oo pao, o

oc ce eo o/o. ocae ae o aa-

poac, epeaaee ae o copac, a oe o

ax o acac a c cac c eo. Ko-

aooe pepae ooe popae e pa a o/o

oe pee, e o oo pee. Hapep, oce cao

pepa, paee epeaec poepe epe- a a oo

o cae, oa pecp xpae epeaa c opaaec

popae, a oo oca a ax, oo e pooa co

pao o ex op, oa pecp xpae epeaa e e coa

oo.

IBM PC oo a aapax pepa oaox

aao, oep 3 (COM1) 4 (COM2). Mpocxea UART 8250 ocae 4


- 12 -

acca pepa aoo aaa, co ce- e oe

ooe ca:

00 eee pecpe caca oea

01 pecp xpae epeaa c

10 oe ae

11 oa pea, oeo coe epepa

o coepac ax 2-1 pecpa ea pepa- ,

apec opa oopoo a 2 oe, e ao apec coeoo

oaooo aaepa. 0 oo pecpa caaaec p

ooe pepa, a ocae e c- oc cea

pa 0.

o pa oo oee pepa, ao apopapo- a

pecp papee pepa, apec oopoo a 1 oe aooo

apeca. aee eo o aoe:

0 1 = pepae p oe ax

1 1 = pepae oa pecp xpae epeaa c

2 1 = pepae p oe pea ax

3 1 = pepae p ee pecpa caca oea

7-4 e coc, cea 0

Koa oo x co pocxo, o pec aapaoe

pepae, oaee pocxee opao pepa 8259 o

aa 3 COM1 o aa 4 COM2. poepa opao

pepa頠 epeae paee o o, a oop aae

cooec eop pepa. oco o aapaoe pe-

pae, o oo oe acpoao. oe, o poepa

opao pepa oa aepac caap oo xoa

aapaoo pepa MOV AL,20H/OUT 20H,AL. Ha pc. 7-3 oaao

oaooe pepae.

oe co o pepa oe papeeo oopeeo. Ho

ec papee oee e o , o poepa opao pepa

oa caa opee ao o pepa pooe, poep

pecp ea pepa. Oopeeo o pocxo oee

e oo pepae, oo 0 pe- cpa ea cooae o

o, o oco ee oo pe- pae. Koa a oee

pepa頠 oco o o e oe pee, o o

opaaac ope, aao젠 ⠠ epeeo頠 ae.

oaoe pepa o opa- oa o aepe poep

opao pepa. co peecx pepa "oec" c

oo ec, peex pao coe cee a:

Ko䠠 T ec "cpoca"

11 oa epep⠠ ee pecpa caca

10 oe ae ee pecpa pea ax

01 epea oo⠠ o coa pecp xpae

epeaa

00 eee caca oea ee pecpa caca oea

H poe.

Bo oa opa popa, opaaae oaoe

pepa:

;---caoa eopa oaooo pepa

PUSH DS ;coxpae DS


- 13 -

MOV DX,OFFSET IO_INT ;DS:DX aa a poep

MOV AX,SEG IO_INT ;

MOV DS,AX ;

MOV AL,0BH ;oep eopa COM1

MOV AH,25H ; ee eopa

INT 21H ;ee eop pepa

;---aa pecpa papee pepa (COM1)

MOV AX,40H ;DS aae a ae BIOS

MOV DS,AX ;

MOV DX,DS:[0] ;oae ao apec COM1

INC DX ;aae a pecp papee

MOV AL,3 ;pepa papeae pepa

OUT DX,AL ;pea epea

POP DS ;occaaae pecp

;---poepa opao pepa - caaa opeee eo

IO_INT PROC FAR

NEXT_INT: MOV DX,BASEADDRESS ;ao apec

INC DX ;aae a pecp ea

INC DX ;pepa

IN AL,DX ;ae eo aee

TEST AL,10B ;o pepae epeaa?

JNZ TRANSMIT ;ec a, o a epea

RECEIVE: ;ae a pe

.

.

JMP SHORT ANOTHER ;poepe e poo pepa

TRANSMIT: ;ec o epea

.

.

;---epe xoo, poepe e poo pepa

ANOTHER: MOV DX,BASEADDRESS ;ao apec

INC DX ;aae a pecp ea

INC DX ;pepa

IN AL,DX ;ae eo aee

TEST AL,1 ;poepe 1

JNZ NEXT_INT ;ec o caoe, o a aao

MOV AL,20H ;ae o aepe aapaoo

OUT 20H,AL ;pepa

IRET

IO_INT ENDP


14

1. Coae paepa cpoca.

paep cpoca o ceaa popaa, oopa pae

oeo c epep cpoco, a a pep co

aoe. oco apaep x epepx cpoc ec o

pooe pooe, o pa ooae popa oe

opeoac a pax pae- po, o o o paoa a

eec eo oopoa. eec 4 cocoa e paepo

cpoc popa:

1. Moo oec o cex paepo po popa.

Hapep, o oepa pae pep, oo coa a

pax oceoaeoce ca e o a pa

oa o opeec. o oxo pa oo a oe

ocaoo ee.

2. Coa p paepo cpoc opeoa, o popaa

apaa eoxo aece oepe (.e. oea eo oac

popa, ceao ocae o e.

3. Coa paep cpoca a oe popa, oopa

aaec oao ae, oeo p ape cce.

popaa acaec caaae paep cpoca a popa

opao pepa. oce oo popaa aepaec, o ocaec

peeo a.

4. Coa ooe paep cpoca, oop e apac

p cape c oo aa CONFIG.SYS. MS DOS oepae ao

paepo cpoc oa ape o oe cooa ce

oooc oa DOS, a poep oo. Ceaa oaa

IOCTL (Kopo oa/oa) ooe popae a cac

paepa oca e pa cpo, oo ooo ooa

ax.

epe p cpae eo peac c oo opa,

peeo頠 ocax acx ao . Ho caaaee

paep cpoc oe co. ao oa o ec, o o oe oe.

B o cae ccea e paoa c cpoco ac- oo e

eco, a c aapo co aoee. cpoc oe

pcoeo , apep, SERIALPR oc- eoaeoo

pepa, ae o cpoco oe opo oca

oo a. B ece oepaop OPEN "SE- RIALPR" FOR OUTPUT AS #2

ooo oceoae pep oa. B e acceepa B

coee o oc pep a c oo eoa paeo

oa aa, a c oo eoa ecpopa aa, a oe

o IOCTL. p o ooae ee oooc oca

cpoc a poe oepaoo cce oe poco ec oa

COPY A:MY- FILE SERIALPR:, o copoa coepoe aa a

pep.

caaaee paep cpoc o aca oo a

e acceepa. O o oca a a cpoc: coe

蠠 oe. 蠠 ea oca e, oop cpoco

opaaae ae. Oo paep ox cpoc oca

coe aoe, a paep cox - ce ocaoe, aa o

oceoaex pepo oa pooa- . oe cpoca

oeac oa ax, oo o aac aoee ax.

Coe cpoca oeac a oao, oo o e

oxo pax cpoc, a ae cpoc, oope e

o oece co copoc oea a. paep ox

cpoc oe co ec e ocaoo eca, o oc x

cpp. Oe peo o peec aca ao paep. Texec-

oe pooco o MS DOS peocae c eoxo opa-

coep o pep paepa paoo ca oepa- o


- 2 -

a. B oee pocope opa oce oo a e

ocee paepo cox cpoc, peeoe ec.

caaaee paep cpoc ecoa popacc-

oa. oco paep aoaec apac cce- o p

ape, o eooo cooa oa e p

eoao. oo e peeo ae p x aca.

popaa paepa cpoca paaec a p ac, aa

oopx ocaec oeo cex paeax. o (1) aooo

paepa, oop ee cpoco coep op- a o oca-

x acx paepa, (2) cpae paepa, oo- pa xpa

opa o oac ax, coaaeo MS DOS, oopa aae

aooo apoca, (3) opao pepa cpoca, oop

coep o, pa cpoco.

2. Coae aooa paepa.

paep cpoc o coaac e COM ao. Oao o

e c aco popaa, oco x occe pec

popaoo ceea. o oc oo e ao a oepaop

ORG 100H aae popa, a o eaec COM ao. o

ae ORG 0, o ooe eo e e. paep oe

oca a aea (far) poepa, a o popae. B

epeeo pepe pee aa o paepa cpoca

c ee DEVICE12. Oo aee caapoe cpoco AUX, co-

eoe MS DOS, pa o 4 pepa 21H. Bec paep

cpoca coco oa oo paea ece c oo, peeo

ce- x x paeax; oece x op o a p, o

o o popa.

paep cpoca oe aac c aooa paepa. O ee

18 ao, paeex a 5 oe. epoe oe (DD) cea

coep aee -1 (FFFFFFFFH), oa MS DOS apae paep, o

oo aeec a capo apec ceeo pae- pa. Ta opao,

ccea oe ca ce paep o eoe. Ӡ oceeo

apeoo paepa o oe ocaec aee -1.

Bopoe oe o a apo paepa. e aee oo

7 o oo coa:

15 1 = cooe cpoco, 0 = ooe cpoco

14 1 = oepae IOCTL, 0 = e oepae IOCTL

13 1 = opa oo IBM, 0 = po opa oo

3 1 = ac, 0 = e ac

2 1 = eoe cpoco, 0 = e eoe cpoco

1 1 = cpoco caapoo oa, 0 = e

0 1 = cpoco caapoo oa, 0 = e

Oo caoe oo 15, 15 14, ec cpoco

oepae IOCTL. 13 ca- aaec oo ox

cpoc. Ocae coc ae cpoc, co-

ex MS DOS o oa (cpoca caapoo oa oa

c aapa eoce; cpoco aco oee ac

peaoo pee c aca pee co BIOS; a eoe cpoco

(NULL) - o ceocpoco, coeoe ecox ee).

Tpee eepoe o coepa cee poep cpae-

opao pepa, oope paccope cex

paeax. Haoe, oceee oe coep cpoca.

oe coepa o 8 coo oo oo paeo o

eo pa c aepa poea. ae cecx

DOS cpoc, ax a LPT1 COM1, coe o e

cpoca, a ao pepe.


- 3 -

H poe.

B ao pepe coaec paep oceoaeoo cpoca.

"DEVICE12" - aa, oop oe aa ae opa

cce, o o paep ape. B ae apo caoe

oo 15, aa o o cooe cpoco o oo e

oepae IOCTL. DEV_STRATEGY DEV_INTERRUPT - ea poep,

ocaex cex pae- ax. cpoco aao AUX, c e o

ae ooe cpoco MS DOS c ee. o ooe oe

poco opa- ac o cpoc, oco ccea ee

peopeee頠 oep aa opae cpoc AUX

(oceoaeo- ). B pep e aa o paepa,

opee eo a COM popa.

CSEG SEGMENT PUBLIC 'CODE' 'caaae oo cee

ORG 0 'a cpoa eoaea

ASSUME CS:CSEG,DS:CSEG,ES:CSEG

DEVICE12 PROC FAR 'paep o aea poepa

DD 0FFFFFFFFH 'apec ceeo paepa

DW 8000H 'a apo

DW DEV_STATEGY 'apec poep cpae

DW DEV_INTERRUPT 'apec poep pepa

DB 'AUX ' ' cpoco (ooeoe poea)

3. Coae cpae cpoca.

poepa cpae cpoca pee oo cpo. Koa

ccea apae cpoco, o oa coae o ax, aae

aooo apoca. O ee e . Bo-epx o c oac

ax pex oepa cce. oee ao o, o aooo

apoca c oac, epe oop pocxo oe opae

e paepo ae eo popao. Hapep, oa paep

o ae, o e aec apec ax epe aooo apoca.

Koa e paep aepae co pao, o o caaae aooe

apoca a caca, oop oce ae popae, e ca

aa oooc e a o oe.

MS DOS coae aooo apoca p caoe paepa cpoca

(oa ccea apaec). poepa cpae cpoca oec

oo o pa o oe. p o ES:BX aa a o

coa aooo apoca poepe o poco copoa x,

o ocec o o oape p opae paep.

Apeca cee ceea aooa oeac e epeee. B

cee paee B e, o p opae paep, epoe o

o eae - occaaae ae ES:BX, o oo o o

opa aooa apoca.

Paep aooa apoca oe ec, acoc o a

ceaoo apoca paep (ap. aa, o ax

opa caca). Oao epe 13 a aooa cea o e e.

x opa ao:

1. a aooa apoca (DB).

2. Ko cpoca (DB). Opeee oep ox cpoc.

3. Ko oa (DB). ec xpac oep ocee ocao

paep oa. o epece [7.2.3].

4. Cac (DW). Cac caaaec a pa p oe

paepa. Ec caoe 15, o ax oc ax axo-

c o o. Ko oo epece [7.2.3].

5. Peepa oac (8 ao). coec MS DOS.


- 4 -

6. ae eoxoe pao paepa (epeeo ).

H poe.

Bo 5 cpo poep cpae cpoca. Oeae, o e

coe epeee, xpae ae ES BX, ce a cpe

RET, a ooeo opae COM.

DEV_STRATEGY: MOV CS:KEEP_ES,ES

MOV CS:KEEP_BX,BX

RET

KEEP_CS DW ?

KEEP_BX DW ?

7.2.3 Coae opaoa pepa cpoca.

paep cpoca aaec c x op oa, peex

pex paeax. a oa ceoa cooeca poepa

opao蠠 pepa. Ha cao ee, o eepo, aa

poep poepo opao pepa, a a oa oce e oc-

ae pepae aepaec oo cpe RET.

eec 13 o , oope oe o caaae

paep cpoca. Koa paep aec e DOS (cae -

e 3FH pepa 21H, oopa ae ae 砠 aa

cpoca), o oeae oo oep o 1 o 13 ooaoe

oe o cee 2 aooe apoca ( oa - oo oep 5).

ae paee epeaec poepe opao pepa paepa,

aoec oopo opeeec p pocope aooa paepa [7.2.1].

a poepa ep oepe occaaae ES:BX, c e o o

aa a ao- oo apoca, a ae ae oo oep oa.

o o o poepa opao pepa ae poep,

oopa o pee . poepa ec c oo

13-coo a, coepae cee 13 o .

cea epecc cee ope:

1. INITIALIZE (aa)

2. CHECK_MEDIA (poepa oce)

3. MAKE_BPB

4. IOCTL_IN

5. INPUT_DATA (o ax)

6. NONDESTRUCT_IN

7. INPUT_STATUS (cac oa)

8. CLEAR_INPUT (oca oa)

9. OUTPUT_DATA (o ax)

10. OUTPUT_VERIFY (poepa oa)

11. OUTPUT_STATUS (cac oa)

12. CLEAR_OUTPUT (oca oa)

13. IOCTL_OUT

oce aepe poep, poepa opao蠠 pepa

aepaec cpe RET paee opaaec a

popa. paep cpoca oe a o opao oo

eoopx , acoc o cpoca pe- eo cee

opo oo pae cpoco. Hoepa , oopx

e aca poep, o aepac xoo paepa e

oe eo-o. B o cae ao oo epe䠠 xoo

cao 15, 8, 1 0 aooe apoca, o oppoa

a aa, o a apeo- aa ececa (

15 pe o, 8 oaae, o paep paoae opao,


- 5 -

a 0 1 a o o 3, o cooece "eeco

oae").

Ho oa oa pccoa o cex paepax cpoc,

o oep 1 - aa. a ao- aec

oec p ape paepa, a ae e. Oa ax aa,

oea o poepo, coco caoe apeca oa paepa

epex aax, aaxc co cee 14 aooe apoca. B

epeeo pepe oe popa oee eo eop:. Kpoe o

aa, poepa aa oa ae o c eoxo

aoo cpoca aa.

Kae ocaxc 12- e ⠠ paep

cpoca ac o oo, o paep oe ea. Heoope, ae

a CHECK_MEDIA MAKE_BPB, oocc oo o cpoca (o

caaa ca, paep ceopo ..). cox

cpoc aoee a c e : INPUT_DATA

OUTPUT_DATA (oe, o ea ecece - aa o

ae , oopa eea). B oox cax aooo apoca

ee ce cpp:

13 ao⠠ caap opa aooa apoca

1 a򠠠 a oca cpe (oo ox cpoc)

4 aa ceee/cee epa oea ax

2 aa co ao, oopoe ao epea

2 aa capo oep ceopa (oo ox)

B epeeo pepe coec oa. poepa,

oa o oae aooa apoca apec epa, oopo

axoc oe ae (ceee 14). Oa ae cae co

ao, oopoe ao ec (ceee 18). Koa poepa aep

o ax, o oa cao coo caca aooe apoca

(ceee 3) opa paee. Ec oe- pa cea, o ao

cao 8 coa caca. pe oooc oce

oee.

H poe.

B ao pepe peea oa opa poep opao

pepa, e a peaoo oa, paeo cpoco.

;---aa opaoa pepa cpoca

DEV_INTERRUPT: PUSH ES ;coxpae pecp

PUSH DS

PUSH AX

PUSH BX

PUSH CX

PUSH DX

PUSH SI

PUSH DI

PUSH BP

MOV AX,CS:KEEP_ES ;ES:BX aa a aooo apoca

MOV ES,AX ;

MOV BX,CS:KEEP_BX ;

MOV AL,ES:[BX]+2 ;oae o oa aooa

SHL AL,1 ;oae a 2 (.. aa coa)

SUB AH,AH ;oe AH

LEA DI,FUNCTIONS ;DI aae a ceee o a

ADD DI,AX ;oae ceee ae

JMP WORD PTR [DI] ;epexo a apec a


- 6 -

FUNCTIONS LABEL WORD ;o aa

DW INITIALIZE

DW CHECK_MEDIA

DW MAKE_BPB

DW IOCTL_IN

DW INPUT_DATA

DW NONDESTRUCT_IN

DW INPUT_STATUS

DW CLEAR_INPUT

DW OUTPUT_DATA

DW OUTPUT_VERIFY

DW OUTPUT_STATUS

DW CLEAR_OUTPUT

DW IOCTL_OUT

;---xo paepa, ec e oepaec

CHECK_MEDIA:

MAKE_BPB:

IOCTL_IN:

INPUT_DATA:

NONDESTRUCT_IN:

INPUT_STATUS:

CLEAR_INPUT:

OUTPUT_VERIFY:

OUTPUT_STATUS:

CLEAR_OUTPUT:

IOCTL_OUT:

OR ES:WORD PTR [BX]+3,8103H ;ope cac

JMP QUIT

;---poep x oepaex oo

INITIALIZE: LEA AX,E_O_P ;ceee oa popa AX

MOV ES:WORD PTR [BX]+14,AX ;oeae eo aooo

MOV ES:WORD PTR [BX]+16,CS ;

.

(ec e aa cpoca)

.

JMP QUIT

OUTPUT_DATA: MOV CL,ES:[BX]+18 ;oae co coo

CBW CX ;CX coe a ce

MOV AX,ES:[BX]+16 ;oae apec epa ax

MOV DS,AX ;

MOV DX,ES:[BX]+14 ;

.

(ec oepa o o)

.

JMP QUIT

;---xo, op a caca aooe apoca

QUIT: OR ES:WORD PTR [BX]+3,100H ;caaae 8

POP BP ;occaaae pecp

POP DI ;

POP SI ;

POP DX ;

POP CX ;

POP BX ;

POP AX ;


- 7 -

POP DS ;

POP ES ;

RET

E_O_P: ;ea oa popa

DEVICE12 ENDP

CSEG ENDS

END DEVICE12

epe opao paep caaae coo caca aooe

apoca. B ao pepe o eaec x ecax, acoc o

oo aac oeceaea paepo e. cpo

a: OR ES:WORD PTR [BX]+3,XXXXH. ae- e o XXXX ce-

ee:

0-7 o o (ec 15 = 1)

򠠠 8 caaaec 1, oa aepea

򠠠 9 caaaec 1, oa paep a

10-14 apeeppoa MS DOS

15 caaaec p ooe o

Ma a oo coa coep cee o oo, ec

caoe 15, p o:

0 oa ac a aeoe o ac cpoco

1 eecoe cpoco

2 cpoco e ooo

3 eeca oaa

4 oa poep o opoo ce

5 eepa a apoca cpoc

6 oa oca

7 eec oce

8 ceop e ae

9 e a pepe

A oa ac

B oa e

C oa oa

4 oc paep cpoca.

paep cpoca caaaec e e e oo- o

popa a opa cce. cao poo popa

oece a CONFIG.SYS cpo DEVICE = DEVI- CE12.COM. ae

epeape cce cao paepa. Ec aa e e

apac, o copee ceo eec oa oe aa

paepa.

oce oo a paep caoe, oca e oec

o MS DOS pepa 21H. Kae 蠠 oo

cooa ac o oo, aee cpoco caapoe

cpoco DOS (a peeo pepe) oo oaec a

coepeo ooe cpoco. ae caapoo oceoaeoo

cpoca, aoe paep AUX, oce eo 3 pepa 21H

ocec cooeceo o o. Ec cpoco

apaeoe, o aoe eo PRN, oce eo 5 e o

ae a pep. po oooc ec cooae

3FH oa oa. B o cae coe oep aa 3 -

oceoaeoo cpoca 4 - apaeoo. Haoae,

o p蠠 cooa蠠 peope- eex oepo⠠ aa e

eoxooc opa cpoco.

Ec cpoco e aee oo caapx cpoc MS DOS


- 8 -

(.e. ec oo e aao o peepx co, a a PRN, AUX

..), o B oee op cpoco c oo oo

op aa. B oee cooa a eo oca c oo

paeo oa aa, a eo ecpopa aa, xo oce

peoeee. o epe, o B o oe e opoee

co a, oece oep aa BX, 0 - AL, oce eo

oe 44H pepa 21H. o IOCTL ec 7

ae, opaaeoo DL caoe, o paep cpoca

ape.

IOCTL pee, o ae apo paepa a cooeca

caoa o o o pae epe oco poe- p opao

IOCTL ec poepe opaoa pepa paepa.

IOCTL ee 8 o, poepoax o 0 o 7, p o

cooec oo oep oeaec AL p oe :

0 Bopa opa o cpoce DX

1 cao opa o cpoce, co DL (DH=0)

2 Ca CX ao o paepa cpoca epe pa-

aa oec x aa c DS:DX

3 aca CX ao paep cpoca epe pa

aa, x aa c DS:DX

4 To e, o 2, o cooa oep aoe BL,

e 0 = aoe o oa, 1 = A ..

5 To e, o 3, o cooa oep aoe a 5

6 o cac oa

7 o cac oa

B oe opaaec paa opa, acoc o oo,

aa aa. o 0 1 aee o pecpa DX

ceee (p co, o 7 = 1, o oaae, o oc oe

cpoc, a e a):

0 1 = cpoco ocooo oa

1 1 = cpoco ocooo oa

2 1 = eoe cpoco

3 1 = cpoco ac

4 peep

5 1 = e poep a Ctrl-Z, 0 = ec poepa a Ctrl-Z

6 1 = e oe aa, 0 = oe aa

7 1 = cpoco, 0 = co a

8-13 peep

14 1 = ec oo cooa o 2 3, 0 = e

15 peep

o 2-5 oo popae cpoc oeac

poo pa cpoa. o ooe epeaa pa-

e cooe oeo o ocooo ooa ax, o ceceo

poae eo. p opae AX e coepa co epeax ao.

o 6-7 oo popae poep, ooo cpoco

oa oa. cpoc AL opaaec FF, ec cpoco

ooo 0, ec e. p c- ooa c op ao ( 7 = 0)

AL opaaec FF o ex op, oa e e oc oe aa.

5 Oapee aa oo cpoca.

cpoca o oac o oo pex p. cpoco oe

ec opeeo axoc e o coco. Moe

ox popaoe oeceee, paee cpoco. , aoe,

popaa oe oca cpoc eoc- apoc (apep,


- 9 -

oa ca a aoe, e axo- c cea aea o

ac). MS DOS oapae aape oco ax oo

oeceae oooc occaoe.

H poe.

oa paep cpoc coepa ae cepee o, o

popaa poco e oe pooac, oa o e cpae.

Koa ae o pocxo, o ccea ae opao

pecx oo. O oe ca ece a caapx

cpoc, a caoex paepo. oo- ae aoee

aco caaec c , oa aec poec co oepa c

cooo, oopoo opa epa. B o cae oec

cooee: "Not ready error reading drive A - Abort, Retry, Ignore?"

Opao pecx oo oe epeca, o o e

opaaa렠 cpoca, oopx B coa caaaee

paep. Beop pepa 24H aae a caap poep MS

DOS, o B oee epeapa eop a co po- ep. p oe

o poep cap AH coep 0 ec oa pooa a

oo cpoce 1, ec a coo. BP:SI aa a

aooo paepa ooo cpoca, oo- p頠 oe a

ooe opa. Boce ao, aa co cee AH

aooe coepa cpoca, a opao pex oo

oeae o o o coo DI. Bo ooe oepa (o e

peca ox o):

Ko䠠 poea

0 oa ca a c, ae o ac

1 eecoe cpoco

2 aoe e oo

3 eeca oaa

4 oa oea a

5 eepa a apoca

6 oa oca

7 eec oce

8 ceop e ae

9 e a pepe

A oa p ac

B oa p e

C oa oa

B cae coo o AL coep oep aoe, a oopo

pooa oa (0 = A, 1 = B ..), a 2-0 AH p

o. 0 caaaec, ec oa pooa o pe oepa

ac, cpacaec - ec p e. 2-1 co- epa

opa o o, ao ece ca pooa oa, aa 00 -

aax ceopo DOS, 01 - FAT, 10 - aaoa 11 -

ceo ocaoo ca.

eec p cocoa, oop popaa oe occaoc oce

peco o:

1. Moo opoc ooae cpa p o (apep,

ap ep aoe), oce eo ccea peoca cpoc

oooc oop oepa.

2. paee oe opaeo cp, cee a INT 21H,

oopa ceaa o opac paep. 3. popaa oe

aepc ep paee ccee.


- 10 -

Baa poepa opao oo oe occao ca, a

cp IRET, oce oo, a oa oeca 0 AL, o

oppoa o, 1 - o oop oepa 2 - o aep

popa. Ec B xoe, o Baa poepa poea occaoee

caa, o oa oa occao pecp oeo popa

cea, a ae a co cea ce, poe ocex pex co. oce

oo cp IRET opa paee popae, xo caa ccea

ocaec ecao coco o ex op, oa oa e ceae

o c oepo o, e 12. Bo opa cea

(aa cepx o a) oa aec opao pecx

oo:

Apec opaa opaoa oo: IP, CS, a

ooaece pecp aa, AX, BX, CX, DX, SI, DI, BP,

oopo a paep: DS, ES, IP, CS, a

MS DOS opaaae ae oe epece o. Ca

ac o oo, oope o opaac pecpax, oa

aac DOS. o ocac ao e ex

ecax, oopx ocac cooece . Oao ee

, o aa c epc 3.0 MS DOS opaae pacpee o

oo , cox FCB ecpop ao. Koa p

oe oo x ca- aaec a epeoca, o

AX opaaec o o o. ooe pacpe o

oce epe pepae 59H, ec BX oec 0. a

cooae ae o pecx oax oa oe cooaa

opaoa pecx oo, aeoo epe pepae 24H.

oeae AX o o, ooo cca aox

oo oo (apep, "eocaoo a") o ox oo

(apep, "opaee oca" oooo- aeco cce).

BH opaae o acca o, aa aoo a oa pooa.

Hapep, o 1 aae, o cepa pecpc, .e. o a,

aoe epa o-o ee pacxooao. pe acc o

aa a popae o, poe c oce, opapoae

.. BL coep o, peoaa ece occaoe,

aoe a "oop", "pepa" "apoc ooae".

Haoe, CH opaae co, opeeee eco e o poe:

a oo cpoce, a coo, a?

ae x oo oo eca op. o opa o x

c. Texeco pooce o MS DOS 3.0. oco peoaaec,

o MS DOS 3.0 e e cooac a aax, oee pax, e

AT, o cooae x oo opaae coecoc Bax

popa. Te e eee, aop poep, peaae oo MS

DOS 3.0 oe ooc oepx ox poep opao oo.

Haoe, ee , o poecc oe epeaa o aep- e

ae eo poecc. Tep poecc oocc ao- ec

popaa. Hapep, oa oa popaa apae acae p

c oo EXEC, o acaea popaa aaec ooo, a

acaa popaa - poee. Poe oe opeoac

opa o o, a aepc ooo. o cooa

oooc, oece eae o aepe AL oe

4CH pepa 21H aepe popa. Koa paee e

opaeo poe, o o o 4DH pepa 21H (e

xox pecpo) AL e oe o aepe, oop oe

ae poaapoa. Kpoe oo, AH e coepa opa o

o, a aepc ooo: 0 - opaoo aepe, 1 - o

Ctrl-Break, 2 - o peco oe cpoca 3 - c oo -

31H, ocae aa peeo.


- 11 -

Ec popaa aepac c oo o (a e 20H ), o MS

DOS oae o xoa o oe e opao oa

ao c oo oo- a IF. a ooaa ooe cooe

cee px oa䠠 砠 oaoo aa. Ko䠠 xoa

paccapaec a oep ERRORLEVEL coe oepa oc

acoc o oo, oe o e opeeeoo ca. C oo

o oooc oae a o pepaa opao o

cooee o ooe o oo aex popa. oee

opoa opa peea paee "Koa aeo opa- o"

pooca o oepaoo ccee.

6. cooae ceax cpoc oa/oa.

eec opooe oeco cpoc oa/oa, oope o

pcoee IBM PC, a , oc, pao- ocpoe

.. B ao paee ocac oo e cpoca, oope

ceao oepac oopoae IBM PC. Ca oocc

accee aoo, ceooe epo pe cpoca, oope o

pcoee epe poo op. Apeca opo, oocec

p젠 cpoca, ocac px paeax o ,

oocxc eo a cpoca. Pacpeeee apeco opo

ocoo oo o e cex o IBM PC:

Apec opa

00-0F pocxea DMA 8237

20-2F pocxea pepa 8259 (AT opoep #1: 20-3F)

40-4F pocxea aepa 8253/8254

60-6F pocxea PPI 8255 (AT coe oo apeca

aap

70-7F ac peaoo pee (oo AT)

A0-BF pocxea pepa #2 (oo AT)

F0-FF PCjr - opoep HM, AT - paee aeae-

c copoeccopo

1F0-1F8 cpoa c AT

200-20F poo aaep

278-27F AT oao op #2

2F8-2FF oao op COM2 (

320-32F cpoa c XT

378-37F aaep apaeoo pepa PC, XT, AT

3B0-3BF ooxpo/apae aaep

3D0-3DF eo paec aaep

3F0-3F7 opoep HM

;****************************************************

;* PROLOG *

;* THIS IS AN INSTALLABLE DEVICE DRIVER FOR AN *

;* IN STORAgE DISKETTE (VIRTUAL) WITH 180K CAPACITY *

;****************************************************

CSEG SEGMENT PARA PUBLIC 'CODE'

;

; M A C R O ( S )

;

STATUS MACRO STATE,ERR,RC

IFIDN ,

OR ES:WORD PtR SRH_STA_FLD[BX],0100H

ENDIF

IFIDN ,

OR ES:WORD PTR SRH_STA_FLD[BX],0200H


- 12 -

ENDIF

IFIDN ,

OR ES:WORD PTR SRH_STA_FLD[BX],1000H

INDIF

IFNB

OR ES:WORD PTR SRH_STA_FLD[BX],RC

ENDIF

ENDM

;

; E Q U A T E S

;

; READ/WRITE

;

SRH EQU 0 ;STATIC REQUEST HEADER START

SRH_LEN EQU 13 ; " " " length

Srh_LEN_FLD EQU SRH ; " " " " FIELD

SRH_UCD_FLD EQU SRH+1 ; " " " unit code field

srh_CCD_FLD EQU SRH+2 ; " " " command code field

srh_STA_FLD EQU SRH+3 ; " " " STATUS FIELD

SRH_RES_FLD EQU SRH+5 ; " " " reserved area field

;

MD EQU SRH+SRH_LEN ;MEDIA DESCRIPTOR BYTE

MD_LEN EQU 1 ; " " " lenGth

dta equ md+MD_LEN ;DISK TRANSFER ADDRESS

DTA_LEN EQU 4 ; DTA LENGTH

COUNT EQU DTA+DTA_LEN ;BYTE/SECTOR COUNT

COUNT_LEN EQU 2 ; " " LENGTH

SSN EQU COUNT+COUNT_LEN;STARTIND SECTOR nuMBER

SSN_LEN EQU 2 ; " " " length

;

; MEDIA CHECK

;

RET_BYTE EQU MD+MD_LEN ;BYTE RETURNED FROM DRIVER

;

; BUILD BPB

;

BPBA_PTR EQU DTA+DTA_LEN ;POINTER TO BPB

BPBA_PTR_LEN EQU 4 ; " " " LENGTH

;

; INIT

;

UNITS EQU SRH+SRH_LEN

UNITS_LEN EQU 1

BR_ADDR_0 EQU UNITS+UNITS_LEN

BR_ADDR_1 EQU BR_ADDR_0+2

BR_ADDR_LEN EQU 4

BPB_PTR_OFF EQU BR_ADDR_0+BR_ADDR_LEN

BPB_PTR_SEG EQU BPB_PTR_OFF+2

;

;

VDSK PROC FAR

ASSUME CS:CSEG,ES:CSEG,DS:CSEG

BEGIN:

START EQU $

; S P E C I A L D E V I C E H E A D E R

NEXT_DEV DD -1 ;POINTER TO NEXT DEVICE

ATTRIBUTE DW 2000H ;BLOCK DEVICE (non-ibm fORmat)

STRATEGY DW DEV_STRATEGY ;POINTER TO DEVICE STRATEGY


- 13 -

INTERRUPT DW DEV_INT ;POINTER TO DEVICE INTERRUPT HANDLER

DEV_NAME DB 1 ;NUMBER OF BLOCK DEVICES

DB 7 DUP(?) ;7 BYTES OF FILLER

RH_OFF DW ? ;REQUEST HEADER OFFSET

RH_SEG DW ? ;REQUEST HEADER SEGMENT

; BIOS PARAMETER BLOCK

BPB EQU $

DW 512 ;SECTOR SIZE

DB 1 ;SECTORS/ALLOCATION UNIT

DW 1 ;NUMBER OF RESERVED SECTORS

DB 2 ;NUMBER OF FATS

DW 64 ;NUMBER OF DERECTORY ENTRIES

DW 360 ;TOTAL NUMBER OF SECTORS

DB 0FCH ;MEDIA DESCRIPTOR

DW 2 ;NUMBER OF SECTORS OCCUPIED BY FAT

;

BPB_PTR DW BPB ;BIOS PARAMETER BLOCK POINTER ARRAY (1 ENTRY)

; CURRENT VIRTUAL DISK INFORMATION

TOTAL DW ? ;TOTAL SEKTORS TO TRANSFER

VERIFY DB 0 ;VERIFY 1=YES, 0=NO

START_SEC DW 0 ;STARTING SECTOR NUMBER

VDISK_PTR DW 0 ;STARTING SEGMENT OF VIRTRUAL DISK

USER_DTA DD ? ;POINTER TO CALLERS DISK TRANSFER ADDRESS

BOOT_REC EQU $ ;DUMMY DOS BOOT RECORD

DB 3 DUP(0) ;3 BYTE JuMP TO BOOT CODE (NOT BOOTABLE)

db 'IBM 2.0' ;VENDOR IDENTIFICATION

DW 512 ;NUMBER OF BYTES IN A SECTOR

DB 1 ;1 SECTOR PER ALLOCATION UNIT

DW 1 ;1 RESERVED SECTOR

DB 2 ;2 FATS

DW 64 ;NUMBER OF DIRECTORY ENTRIES

DW 360 ;360 TOTAL SECTORS IN IMAGE

DB 0FCH ;TELLS DOS THIS IS A SINGLE SIDED 9 SECTOR DISK

DW 2 ;NUMBER OF SECTORS IN FAT

;

; FUNCTION TABLE

;

FUNTAB LABEL BYTE

DW INIT ;INITIALIZATION

DW MEDIA_CHECK ;MEDIA CHECK (BLOCK ONLY)

DW BUILD_BPB ;BUILD BPB " "

DW IOCTL_IN ;IOCTL INPUT

DW INPUT ;INPUT (READ)

DW ND_INPUT ;NON_DESTRUCTIVE INPUT NO WAIT (CHER ONLY)

DW IN_STAT ;INPUT STATUS " "

DW IN_FLUSH ;INPUT FLUSH " "

dw output ;OUTPUT (WRITE)

DW OUT_VERIFY ;OUTPUT (WRITE)WITH VERIFY " "

DW OUT_STAT ;OUTPUT STATUS " "

DW OUT_FLUSH ;OUTPUT FLUSH

DW IOCTL_OUT ;IOCTL OUTPUT

;


- 14 -

; L O C A L P R O C E D U R E S

;

IN_SAVE PROC NEAR

MOV AX,ES:WORD PTR DTA[BX] ;SAVE CALLERS DTA

MOV CS:USER_DTA,AX

MOV AX,ES:WORD PTR DTA+2[BX]

MOV CS:USER_DTA+2,AX

MOV AX,ES:WORD PTR COUNT[BX] ;SET NUMBER OF SECTORS TO READ

XOR AH,AH

MOV CS:TOTAL,AX ;MOVE NUMBER OF SECTORS TO TOTAL

RET

IN_SAVE ENDP

;

CALC_ADDR PROC NEAR

MOV AX,CS:START_SEC ;GET STARTING SECTOR NUMBER

MOV CX,20H ;MOV 512 TO CX SEGMENT STYLE

MUL CX ;MULTIPLY TO GET ACTUAL SECTOR

MOV DX,CS:VDISK_PTR ;GET SEGMENT OF VIRTUAL DISK

ADD DX,AX ;ADD THET SEGMENT TO INITIAL SEGMENT

MOV DS,DX ;SAVE THAT AS TNE ACTUAL SEGMENT

XOR SI,SI ;IT,S ON A PARAGRAPH BOUNDERY

MOV AX,CS:TOTAL ;TOTAL NUMBER OF SECTORS TO READ

MOV CX,512 ;BYTES PER SECTOR

MUL CX ;MULTIPLY TO GET COPY LENGTH

OR AX,AX ;CHECK FOR GREATER THEN 64K

JNZ MOVE_IT

MOV AX,0FFFFH ;MOVE IN FOR 64K

MOVE_IT:

XCHG CX,AX ;MOVE LENGTH TO CX

RET

CALC_ADDR ENDP

;

SECTOR_READ PROC NEAR

CALL CALC_ADDR ;CALCULATE THE STARTING "SECTOR"

MOV ES,CS:USER_DTA+2 ;SET DESTINATION TO POINT

MOV DI,CS:USER_DTA ;TO CALLERS DTA

;

; CHECK FOR DTA WRAP IN CASE WE CEME THROUGH UIA VERIFY

;

MOV AX,DI ;GET OFFSET OF DTA

ADD AX,CX ;ADD COPY LENGTH TO IT

JNC READ_COPY ;CARRY FLAG = 0, NO WRAP

MOV AX,0FFFFH ;MAX LENGTH

SUB AX,DI ;SUBTRACT DTA OFFSET FROM MAX

MOV CX,AX ;USE THET AS COPY LENGTH TO AVDID WRAP

READ_COPY:

REP MOVSB ;DO THE "READ"

RET

SECTOR_READ ENDP

;

SECTOR_WRITE PROC NEAR

CALL CALC_ADDR ;CALCULATE STARTING "SECTOR"

PUSH DS

POP ES ;ESATABLISH ADDRESSABILITY

MOV DI,SI ; ES:DI POINT TO "DISK"

MOV DS,CS:USER_DTA+2 ; DS:SI POINT TO CALLERS DTA

MOV SI,CS:USER_DTA

;

; CHECK FOR DTA WRAP


- 15 -

;

MOV AX,SI ;MOVE DTA OFFSET TO AX

ADD AX,CX ;ADD COPY LENGTH TO OFFSET

JNC WRITE_COPY ;CARRY FLAG = 0, NO SEGMENT WRAP

MOV AX,0FFFFH ;MOVE IN MAX COPY LENGTH

SUB AX,SI ;SUBTRACT DTA OFFSET FROM MAX

MOV CX,AX ;USE AS NEW COPY LENGTH TO AVOID WRAP

WRITE_COPY:

REP MOVSB ;DO THE "WRITE"

RET

SECTOR_WRITE ENDP

PAGE

;

; D E V I C E S T R A T E G Y

;

DEV_STRATEGY:

MOV CS:RH_SEG,ES ;SAVE SEGMENT OF REQUEST HEADER POINTER

MOV CS:RH_OFF,BX ;SAVE OFFSET OF " " "

RET

;

; D E V I C E I N T E R R U P T H A N D L E R

;

DEV_INT:

; PRESERVE MACHINE STATE ENTRY

CLD

PUSH DS

PUSH ES

PUSH AX

PUSH BX

PUSH CX

PUSH DX

PUSH DI

PUSH SI

;

; DO THE BRANCH ACCORDING TO THE FUNCTION PASSED

;

MOV AL,ES:[BX]+2 ;GET FUNCTION BYTE

ROL AL,1 ;GET OFFSET INTO TABLE

LEA DI,FUNTAB ;GET ADDRESS OF FUNCTION TABLE

XOR AH,AH

ADD DI,AX

JMP WORD PTR[DI]

;

; INIT

;

INIT:

PUSH CS

POP DX ;CURRENT CS TO DX

LEA AX,CS:VDISK ;GET ADDRESS OF VIRTUAL DISK

MOV CL,4

ROR AX,CL ;DIVIDE BY 16 (PARAGRAPH FORM)

ADD DX,AX ;ADD TO CURRENT CS VALUE

MOV CS:VDISK_PTR,DX ;SAVE AS STARTING SEGMENT OF VIRTUAL DISK

MOV AX,2D00H ; ADD 2D00H PARAGRAPHS TO STARTING

ADD DX,AX ; SEGMENT OF VIRTUAL DISK

MOV ES:WORD PTR BR_ADDR_0[BX],0

MOV ES:BR_ADDR_1[BX],DX ;MAKE THET THE BREAK ADDRESS


- 16 -

MOV ES:BYTE PTR UNITS[BX],1 ;NUMBER OF DISKETTE UNITS

LEA DX,BPB_PTR ;GET ADDRESS OF BPB POINTER ARRAY

MOV ES:BPB_PTR_OFF[BX],DX ;SAVE OFFSET IN DATA PACKET

MOV ES:BPB_PTR_SEG[bx],cs ;SAVE SEGMENT IN DATA PACKET

MOV ES,CS:VDISK_PTR ;GET STARTING SECTOR OF VIRTUAL DISK

XOR DI,DI ;ZERO OUT DI (BOOT RECORD)

LEA SI,BOOT_REC ;ADDRESS OF BOOT RECORD

MOV CX,24 ;

REP MOVSB ;COPY 24 BYTES OF BOOT RECORD

MOV CS:WORD PTR START_SEC,1

MOV CS:WORD PTR TOTAL,2

CALL CALC_ADDR ;CALCULATE ADDRESS OF LOGICAL SECTOR 1

PUSH DS

POP ES

MOV DI,SI ;MOVE THET ADDRESS TO ES DI

XOR AL,AL

REP STOSB ;ZERO OUT FAT AREA

MOV DS:BYTE PTR [SI],0FCH ;SET THE FIRST FAT ENTRY

MOV DS:BYTE PTR 1[SI],0FFH

MOV DS:BYTE PTR 2[SI],0FFH

PUSH DS ;SAVE POINTER TO FAT

PUSH SI ;ON THE STACK

MOV CS:WORD PTR START_SEC,3

MOV CS:WORD PTR TOTAL,2

CALL CALC_ADDR ;CALCULATE ADDRESS OF LOGICAL SECTOR 3

PUSH DS

POP ES

MOV DI,SI ;MOVE THET ADDRESS TO ES:DI

POP SI

POP DS ;RESTORE ADDRESS TO FIRST FAT

REP MOVSB ;COPY FIRST FAT TO SECOND FAT

MOV CS:WORD PTR START_SEC,5

MOV CS:WORD PTR TOTAL,4

CALL CALC_ADDR ;CALCULATE ADDR OF L.5. 5 (START OF DIR)

XOR AL,AL

PUSH DS

POP ES ;SET UP ES.DI TO POINT TO IT

XOR DI,DI

REP STOSB ;ZERO OUT DIRECTORY

MOV ES,CS:RH_SEG ;RESTORE ES:BX TO REQUEST HEADER

MOV BX,CS:RH_OFF

; STATUS DONE,NOERROR,0 ;SET STATUS WORD (DONE, NOERROR)

JMP EXIT

;

; MEDIA CHECK

;

MEDIA_CHECK: ;MEDIA CHECK (BLOCK ONLY)

;

; SET MEDIA NOT CHENGED

;

MOV ES:BYTE PTR RET_BYTE[BX],1 ;STORE IN RETURN BYTE

; STATUS DONE,NOERROR,0 ;TURN ON THE DONE BIT

JMP EXIT

;

; BUILD BIOS PARAMETER BLOCK

;

BUILD_BPB:


- 17 -

PUSH ES ;SAVE SRH SEGMENT

PUSH BX ;SAVE SRH OFFSET

MOV CS:WORD PTR START_SEC,0

MOV CS:WORD PTR TOTAL,1

CALL CALC_ADDR ;CALCULATE ADDRESS OF FIRST SECTOR

PUSH CS

POP ES

LEA DI,BPB ;ADDRESS OF BIOS PARAMETER BLOCK

ADD SI,11 ;ADD 11 TO SI

MOV CX,13 ;LENGTH OF BPB

REP MOVSB

POP BX ;RESTORE OFFSET


15

Bo a epa.

1. paee oo a epa.

Bce eocce co epa, oope oopaac ae

opae a pae. pa epoec ooec capoae

x ax. Paep pacooee x epo eec c cceo,

peo paa, a ae oeco apaee oeeo a. Koa

epe xpac ecoo opao paa, o a oe opa

aa ceo cpae. He peea opoa coa:

Mooxpo aaop

Mooxpo aaop ee 4K a a a ae, aa c apeca

B0000H (.e. B000:0000). o a xaae oo xpae oo

80-coo cpa eca.

eo paec aaop.

eo paec aaop ee 16K a a a ae, aa

c apeca a B8000H. oo ocaoo oopae ooo

paecoo paa, e cpa, o epex o oc pao

eca, acoc o ca coo cpoe - 40 80.

EGA

EGA oe cae 64K, 128K 256K a. Kpoe c-

ooa aece eoepa a a oe ae xpa

oe oca o o 1024 coo. Capo apec epa

ce popape, oo ep aaec c apeca A000H

ex paecx peo, c B000H B800H coecoc co

caap oox- po e paec pea. B o-

ce cae EGA aae a ceea c apeca o A000H o BFFFH,

ae oa eec 256K a. o ooo, oco eoopx

peax a oee ao a ce cac ox ex

e apeco. ocoe co cpa ac a o pea paa, a

o oeca eec a. Bcece coe cooc EGA ee

a 16K a, oopoe aee pacpe poep pao c

epao BIOS. Haao oac - apec C000:0000.

B ecox peax epa aac c ax epxe cpo

paa, aa c eoo a. aee ae epeo- cc c

paoo oa oo cpo a e oe cee, a o pa

pecaec oo oo cpoo - c o pe eoepa a

oo ec. Oao paecx peax ep oe paee a 2

4 ac. eoo paec- oo aaopa pae ac epa

coepa opa, oocc ao opo ao eepo

oe a pae. EGA aa ac epa coep o

x epex, oope opee e ao o paa.

p oe eca pae eocce paoa oaoo.

paa ooc 4000 ao, a o a a 2000 o paa

pxoc 2 aa (25 cpo * 80 coo). ep a coep o

ASCII. Aapapa ce peopae oep oa ASCII ca c

co ocae eo a pa. Bopo a (a apo)

coep opa o o, a oe ee a co.

ooxpooo ce o c- aaae e a co

oep, ee poc eao, coe oa

x apo. B eo- x cceax a apo caaae

ocoo oo ea coa. B o cae Baa popaa oe


- 2 -

ca ae po ep epaa, o aeo oae

copoc oa a pa.

Bce cce, poe ooxpoo, peoca aop ex

paecx peo, oope oac a papeee, a co

oopeeo ox eo. EGA o oope- eo o 16

eo, pe EGA oe pa 16 aopa 64 eo. p

cooa 16 eo aa oa paa pee epex a,

oco 4 a o xpa ca o 0 o 15. o aao,

epexea paa pee oo 2 a a o. xea

paa oe aoa pecaee oc oe o a

eoepa. Koeco a, pee- oe aoo pea paa

oe eo ceo, ec eco oeco ox o

pee oe oeco , eoxooe oca oo o.

Tec eo opec c pao (BIOS pce co a

paeco pae) B oee coaa co ceae co.

2. popapoae opoepa ce 6845.

Bce eocce cpoc op pocxe opoepa eo-

epaa Motorola 6845 (EGA coe aa pocxe, ocoa

a 6845). Mpocxea coec o oo aaoo ooxpoo

aaope, eo aaope; o EGA e acoo coec o o

pe peoee젠 Ba젠 ea poo popapoa

pocxe, oa BIOS oe o pao a Bac. oop o

coa, pocxea 6845 caaae eoce o eco-

x aaopox paecx peo. Oa oe oco

pao o eppea- oepo oo ASCII oc ax

oa cooecx coo pocxee Ӡ (a oa

oepao頠 a). Oa eope ae apo ea

cooeceo caaae pa. Oa ae coae pcop

pae . B apxepe EGA ac x pacpeeea e

p pocxe- a.

Mpocxea 6845 ee 18 pax pecpo, poepoax o 0

o 17. epe 10 pecpo cp opoae epae

apaep ce. 蠠 pecp, a pao, eepec

popaco, oco o aoaec caaac BIOS p

ee蠠 pea paa. He coee cepepoa c

pecpa, oco eec oooc cop- epa.

Pecp e paep 8 , o eoope ca ap, o xpa

16-e e. ap #10-11 #14-15 caaa op

ecoooee pcopa. apa #12-13 pae cpaa ce . apa

#16-17 cooae o ceooo epa. co pecpo oco

oo ac; oo pecp apeca pcopa oo a

ca, a pecp ceooo epa peaae oo e. EGA

ee 6 oaox pecpo, oope ca c ex- ec ea-

. Pecp 20 aoee epece; o opeee aa

capoa cpoe coa coec oepa.

oc o ce 18 pecpa ocecec epe o o e op,

apec oopoo ooxpooo aaopa pae 3B5H. o apec pae

3D5H eoo aaopa. EGA coe o x x apeco,

acoc o oo, pcoee e eo ooxpo

oop. ac pecp ooxpooo aaopa ao caaa

pecp apeca, pacooe ope 3B4H (3D4H eoo), oca

oep peeoo pecpa. Toa ce a, oca op c

apeco젠 3B5H e aca o pecp. oco pecp,

epece popaca, coc oapo, o ao caa- a

aca apec pecp, oo ep pecp ap, oo coa

apec pecp , aoe, o opo pecp ap. oco apeca

opo cee, o ee ceo apecoa x, co cp INC


- 3 -

DEC, a cee pepe:

;---ac pecp 11 12 pocxe 6845 (ae BX)

;---pae pecp aeo aa

MOV DX,3B4H ;op apecoo pecpa

MOV AL,11 ;oep pecpa aeo aa

OUT DX,AL ;ocae oep pecpa

;---ocae a

INC DX ;eae apec opa

MOV AL,BL ;epe a a

OUT DX,AL ;ocae eo pecp 11

;---pae pecp capeo aa

DEC DX ;occaaae apec opa

MOV AL,12 ;oep pecpa capeo aa

OUT DX,AL ;ocae oep pecpa

;---ocae a

INC DX ;eae apec opa

MOV AL,BH ;epe cap a

OUT DX,AL ;ocae eo pecp 12

ooxpooo eoo aaopo ec ee p opa, oope

a popaco. O e apeca 3B8H, 3B9H 3BAH

ooxpooo 3D8H, 3D9H 3DAH - eoo aao- pa. ep

caaae pe paa, opo - ca ocoo c caoo

eo paa, a pe cooae oe opa o cace ce.

EGA pacpeee e pocxeo opoepa apo

(apec opa 3C0H) pocxea opoepa pa (apeca

opo 3CCH-3CFH). Kopoep apo coep 16 pecpo ae

EGA, poepoax o 00 o 0FH. pe- cp o coepa

6-e o eo, oa EGA ca c e e cee,

oo o cooa e 16 eo aopa 64-x.

3. caoa/poepa pea ce.

Mooxpo aaop oepae o pe epaa, eo

paec - ce, a EGA - eaa.

EGA papeae e 8 cpa pee 7 - caapo oox- poo

ecoo pee. Pe 0-6 ooc coec, co a

oao opao. p co, o epeae a EGA caoe

pao c e e cee p IBM, paoe

ecoe pe oc c co papee- e, co pco

coo, coco 8*14 oe, a e oe 8*8.

BIOS xpa ooa epee o apec 0040:0049, oopo

coepc oep eeo pea. a o apec 0040:004A ae co

coo cpoe ecoo pee.

Cpe poe.

0 pepa 10H caaae pe ce. B AL oe

axoc oep pea o 0 o A. o cao eo paec

pe cpeeo papee ao:

MOV AH,0 ;oep

MOV AL,4 ;oep peeoo pea

INT 10H ;caaae pe

opeee eeo paecoo pea ao cooa

F pepa 10H. pepae opaae oep pea AL. Oo ae

ae oep ee cpa ce BH co coo cpoe


- 4 -

AH.

MOV AH,0FH ;oep

INT 10H ;oee opa o pee ce

MOV MODE_NUMBER,AL ;oep pea AL

MOV NUMBER_COLS,AH ;co coo cpoe AH

MOV CURRENT_PAGE,BH ;oep ee cpa BH

MS DOS oeceae ae Esc-oceoaeoc cao

cpoca peo ce. oo eoxoo, o B pea- peo

ap paep ANSI.SYS, a oceo poe . paa

cpoa ee ESC [=#h, e # - oep pea, aa a o

ASCII, a ESC ooaae o co c oo ASCII 27. Hapep:

;--- ceee ax

MED_RES_COLOR DB 27, '[=4h$'

MED_RES_B&W DB 27, '[=5h$'

;---caoa eoo paecoo pea cpeeo papee

MOV AH,9 ;oep oa cpo

LEA DX,MED_RES_COLOR ;DS:DX o aa a cpo

INT 21H ;eee pea

H poe.

4. caoa apo/eo coo.

Koa ce caoe eco pe o eo cce,

o ao o coa a pae ooc a aa a. ep

a coep oep oa ASCII oa coa, a opo - ap

coa. eo aaop o o ee, a ca co, a

c oac, oee ao co (oo e). Mooxpo

aaop opae oo ep e eo, o o oe

eeppoa oepe co, eo e o ea eo

aaop. Bce p cce o aa ae co eaoe

opaee. Bce p cce o ae coaa co c coo

ecoc, xo eoo aaopa oea ecoc

coa a cao ee po po e (oce ocox eo

e epc c oeo ecoc, o ae aop 16 eo).

EGA ee ea ce, o o ce oc- ae cce ooe

poe. B acoc, a eo cee o oe o oep-

e ee co, oco apa opae coo 8*14 ae

a oooc.

Ap ea:

aa eo paa o e e oepa oo coc

ece pepa oepaoo cce. O ae:

0 - ep頠 8 - cep

1 - c頠 9 - oo

2 - ee頠 10 - ceoee

3 - a 11 - ce a

4 - pac頠 12 - ceopac

5 - aea 13 - cea aea

6 - ope頠 14 - e

7 - e頠 15 - poe

Mae epe a aa apo caaa e caoo coa

( 3 ae co ecoc). Cee p蠠 a

caaa o coa. p ox ocoecax cap


- 5 -

ae ae ae. Ta opao:

oa 0 = 1, c aec ocoo e

1 = 1, ee aec ocoo e

2 = 1, pac aec ocoo e

3 = 1, co oc c coo ecoc

4 = 1, c aec oo e

5 = 1, ee aec oo e

6 = 1, pac aec oo e

7 = 1, co a

0-2 4-6 coepa o e e ooe eo cax

coo oa. pexe p oo 8 oox

oa. Koa aec coo ecoc, o oac

ee 8 eo. ecaa oox eo oac x caoo

o ce opao:

Kpac ee C Ha ecoc Bcoa

0 0 0 ep頠 cep

0 0 1 c頠 ceoc

0 1 0 ee頠 ceoee

0 1 1 a ce a

1 0 0 pac頠 ceopac

1 0 1 aea cea aea

1 1 0 ope頠 e

1 1 1 e頠 poe

Moo e 16 eo oooo ea. B o cae 7 oe

c aaee coo ecoc oa, a e aaee

a coo. eoo aaopa ao e 5 opa c

apeco 3D8H 0, a oaao e. oco o op oce

oo ac, o ce ocae o epecaoe.

a oooc oca oo x cax: ecox peo c 40

c 80 coa cpoe. pea c 80 coa ao oca

op co 9, a pea c 40 coa - co 8. o ep

ae ao oa oo ae 32.

EGA ae oe papea/apea ae, xo o cae

apec opa 3C0H. Caa ao poa op 3DAH, o o

oc apeco pecp 3C0H. ae ao oca 3C0H 10H,

o aa cooec pecp. Haoe, ao oca ae o

o e apec. oco o pecp oo ac, o ce

o pao caoe. Ma- e aec caoo a

3, a aec cpoco oo a. Bce ocae eo

ecoo pee o pa 0.

eoo aaopa, oa co oc a ce eo

paeco pee, o o opaac ee ooo ee.

Oepaop, oope o a pa, a ece, a MS DOS

(pepae 21H) opae oo coo pee ee co-

eo ae. B aee 0 co ee/opee, a aee 1

o ee. poep oa coo BIOS (pepae 10H), oao,

o aa o pex eo ae. C po copo, PCjr,

e aae opeeeo o ae oe ee,

oo oa coo o cooa- e ea.

EGA ae coe 16 pecpo ae. O pacooe ope c

oepo 3C0H, a oepa x ec o 00 o 0FH. Hao caaa poa

opa 3DAH, o epe op a eo apec pecp, ae

oca oep pecpa ae 3C0H, a ae oca ae. Koa

epeae a EGA caoe a e pe ( eoo

eoo ce IBM), o a- ea oe paa 64 eo. B


- 6 -

o cae caoa pecpa ae ee 6 o opae

R'G'B'RGB. RGB a ee e, a R'G'B' - ea oeo

poc. Koa caoe R' R, apep, o o po oe

po paco e. o ceac aa oe oe. Ec

pecp ae, peaaee 64 eo, coc e

eo pee, o 4- 5- pecpa oppc coepoe

pecpo paccapaec o oo cxee RGB. oco EGA co-

pecp ae, o op oooo ea e opae

cooae a 7 aa apo aece a a.

Mooxpoe co:

Mooxpoe co co a apo ecoo oee

cpa opao. Ka c apa ea, 0-2 caaa

ocoo e, a 4-6 - oo. ea o oo e

ep, co ce cooece a:

򠠠 򠠠 򠠠 Ocoo ap򠠠 oo

6 2 5 1 4 0

0 0 0 ep頠 ep

0 0 1 oep e頠 e

0 1 0 e頠 e

0 1 1 e頠 e

1 0 0 e頠 e

1 0 1 e頠 e

1 1 0 e頠 e

1 1 1 e頠 e

Hopa pe e a epo, oa 0-2 caoe 111, a

4-6 caoe 000. Heaoe opaee coaec opa

ae o. Co oc c oeo poc, oa 3

caoe 1; e cece cocoa pa oe poc o,

oa co oc eao opae, a ae eoco

oepae eae. Bo cex cax, caoa 1 a 7 ae

ae coo. Bceo ooo oo 10 oa, oa co

. O o peaoa pa caoa o. He

poc o oo oox caoo aoo ca:

Ap򠠠 eoa o⠠ ec 10-oe

opa頠 00000111 7 7

ec頠 00001111 F 15

opa oep頠 00000001 1 1

ec oep 00001001 9 9

ea頠 01110000 70 112

opa a頠 10000111 87 135

ec a頠 10001111 8F 143

opa a o. 10000001 81 129

p a oep. 10001001 89 137

p ea頠 11110000 F0 240

Cpe poe.

pepa DOS BIOS peoca oe ee oooc

pao c e eco. Too 9 pepa 10H pae

a apo p oe coa. A pepa 10H o

co e aa ea apa; oa poco oeae co

eoep, e poa a apa, a opao ap coxpa

coe capoe aee. D pepa 10H ae ocae epo-


- 7 -

a apo.

oa a pa DOS pepa 21H cea o eoe a

epo. ae ec ceo paa caoe eoop oo e,

o DOS caaa ap opa ep p oe

aoo coa. Oao eec coco peoo- e o opaee. MS

DOS peocae paep cpoca ANSI.SYS, oop oe

eppepoa ceae Esc-oceo- aeoc. B poe

occ oco eo cooa. Esc-oceoaeoc oc

epe 9 pepa 21H, oope oo o cpo coo

a pa. B o cae cpoa coco coa Esc, a oop

cee [, a aee oo oee oox ce epeeoo

cca. Cpoa oa oac coo m o opaee $.

Bo ooe oe- pa:

0 ce ap e (ep a eo)

1 ea oea ecoc

4 eo oepae

5 eo ae

7 eo eaoe opaee

8 ce eo (p o co e)

30 ep ocoo e򠠠 40 ep o

31 pac ocoo e򠠠 41 pac o

32 ee ocoo e򠠠 42 ee o

33 e ocoo e򠠠 43 e o

34 c ocoo e򠠠 44 c o

35 ocoo e aea 45 o aea

36 ocoo e a 46 o a

37 e ocoo e򠠠 40 e o

Oe, o oa MS DOS o co paeco pee,

o o蠠 oo co o䠠 3 ee ae. C oo

Esc-oceoaeoce oo cao e coa cooec

o eo ae. Hao aa 30 31 oooo ea,

32 33 - oa 1, 34 35 - oa 2 36 37 - oa

3. B o cae e ao aa oo e.

B cee pepe a pa oc e cpo c oo

9 pepa 21H. epa oc c a paco, a opa -

a ao a paco. He ao epeopee pac- aece

oooo ea opo cpo, oco aa- e eo

ec a ce ocee oa oa (a BIOS

pepa 10H), o ex op, oa e cea pe aae.

Oe, a poco epeea oa pae eo c oo

cax cpo.

;--- ceee ax

STRING_1 DB 'The rain in Spain',0AH,0DH,'$'

STRING_2 DB 'Falls mainly on the plain$'

BLUE_RED DB 27,'[34;41m$'

BLINK_CYAN DB 27,'[5;36m$'

;---o cpo

MOV AH,9 ; oa cpo

LEA DX,BLUE_RED ;apec pae cpo DX

INT 21H ;ce e aac c a paco

LEA DX,STRING_1 ;aae a ep cpo

INT 21H ;eaae cpo

LEA DX,BLINK_CYAN ;apec opo pae cpo

INT 21H ;ee e a a a

LEA DX,STRING_2 ;aae a op cpo


- 8 -

INT 21H ;eaae cpo

B cea o oaoc o o, o cpoc ap ea

opaoe cocoe epe aepee popa, oc- o

poo cae o ecoa a o oce- x

popa. B oe cee ec Esc-oceoaeoc, co

o oep 0, a aao e.

EGA e cea BIOS cao coep- oo

pecpo ae. o o 0 10H pepa 10H. Hao

oec oep pecpa ae (o 0 o 15) BL, a aee oa

ea (ae o 0 o 15) BH, a ae o pepae. o

2 10H caaae ce pecp ae, a ae e pa,

co 17-a acc, a oop o aa ES:DX. a

0-15 acca oeac pecp ae 0-15, a a 16

caaae e pa.

H poe.

o poco

oec peeoe aee aa apo eoep, a e

coo, oopo ap o oocc. pee pep

eoo aaopa. B pepe caaaec eco pa 80*25

c 16 oo ea, a ae pa apec pac e

ceoce oe:

;---caoa 16 oox eo ecoo pee 80*25

MOV AL,00001001B ;caoa 0 a a

MOV DX,3D8H ;apec pecpa

OUT DX,AL ;ocae pecp

;---ape ec pa pac a ceoce oe

MOV AX,0B800H ;aae a eoep

MOV ES,AX ;

MOV CX,2000 ;acae ap 2000 ee

MOV BX,1 ;BX aae a a apo

MOV AL,10010100B ;aee aa apo

NEXT_CHAR: MOV ES:[BX],AL ;ocae ap ep

INC BX ;eae aae a ap

INC BX ;

LOOP NEXT_CHAR ;e ce o

5. caoa ea pa paa.

paa cooo paa oe e e, o o oo- oo

ea epao ac paa. Moe cooa o 16

eo. C po copo, paece pa exec e e

oac pa. Koa e oa caaaec paeco pee,

o ec pa, a oac pa, opaaec o e.

Oao, oepa oa oe a pa e e oca oac

pa; ec o ac apecex oe paa e

eoo e, o e coaa oc pa paa.

Cpe poe.

cex eocce oo e oe caoe e BH,

pepa 10H. a caaae ae ocoe ea. o

aa, o ao e oo e, ao oec- 0 BH, a o

ea BL o pepae. Kpoe oo, EGA e

cea cao oooo e- a. o o 1

10H pepa 10H. Hao oec 10H AH, 1 AL o ea


- 9 -

BH. Hax ae e opa- aec.

H poe.

eoo paecoo aaopa 0-3 opa 3D9H (Pe- cp

opa ea) caaa e pa, oa pa a- xoc

ecoo pee. Ka oo, aaee o ocxo- e ope -

c (B), ee (G), pac (R) ecoc. oco o

apec peaae oo ac, ce ocae oo pecpa

o pao caoe. o 4, oop, ec eo

cao 1, po o, o ce ooe ea oc

c coo ecoc.

;---caoa ceoceo ea pa

MOV AL,00001001B ;ap ceoceo ea

MOV DX,3D9H ;apec pecpa opa ea

OUT DX,AL ;caaae e pa

EGA e pa caaaec pecpo젠 capoa

(overscan). o pecp oep 11H opa c apeco 3C0H. Hao caaa

poa o op, o epe eo a apec pecp, ae

oca a oep 11H aece eca, a ae oca ae.

e aee oo ae 4 a ax, ec oo EGA e ca

c e e cee IBM, a o cae e aee

ae 6 o, oope caaa e pa.

6. Oca ac/ceo paa.

Oca paa coco poco ac poea a o

paa (o ASCII - 32). Oao, ec p oe a pa

cooa eopae ap, o o ae ee

a apo. Oepaoa ccea oeceae poco coco

oc oo ac paa.

Cpe poe.

Oepaoa ccea peocae ecoo cocoo⠠ oc

paa. Kao x B epee ac o oo, ae cpeca pe-

c popae oce px ee. ep eo - o poco

cpoc pea ce, co 0 pepa 10H.

cooo paa aa o aoec poeo (ASCII 32), a

ce ap caaac opa (ASCII 7). Oo o eo

xopo oo aae popa, oa ce pao ao caaa

pe pao ce. eoo paecoo aaopa PCjr pe-

aa pea ce po aaac a pae. o e

occe ooxpooo aaopa EGA.

;---oca paa e cao ooo pea

MOV AH,0 ;oep cao pea ce

MOV AL,2 ;o pea 80*25 epo-eoo

INT 10H ;oca paa

Bopo eo coco cooa 6 7 pepa 10H,

oope ca pa. co cpo, a oopoe ao c pa

oeaec AL oa o co pao pa oaec.

pepae ooe ca oo ac paa, oo a

opao oo oc oeoe oo a pae. Hao oec

oopa eoo epxeo a oa CX, a oop- a paoo

eo a DX (oep cpo CH/DH, a oep coa CL/DL).


- 10 -

oece ap, c oop oe cc pa BH. Koopa

ocac o 0.

;---oca oa e 3,4 13,15

MOV AH,6 ;coe poep ca

MOV AL,0 ;co cpo ca eae pa

MOV BH,7 ;a apo aoe

MOV CH,3 ;cpoa epxeo eoo a

MOV CL,4 ;coe eoo epxeo a

MOV DH,13 ;cpoa eo eoo a

MOV DL,15 ;coe eo eoo a

INT 10H ;c oo

Tpe eo aaec cooa 9 pepa 10H;

oopa o co ap coo pa, coo a- ao CX.

aee 2000 c ec pa, ec pcop ca- oe 0,0,

co eo oaa [4.2.1]. AH oe coepa co

poea, AL - a apo, a BH - oep cpa- ce.

;---caoa pcopa e epx o paa

MOV AH,2 ; cao pcopa

MOV BH,0 ;oep cpa

MOV DX,0 ;oopa 0,0

INT 10H ;caaae pcop

;---o coa poea 2000 pa

MOV AH,9 ;oep

MOV CX,2000 ;co oope oa

MOV AL,' ' ;co poea AL

MOV BL,7 ;ap BL

INT 10H ;oca paa

Haoe, DOS oeceae oc paa c oo ceax

Esc-oceoaeoce, oope paoa c paepo젠 ANSI.SYS.

Ocoe cee o e pee poe . oceoa-

eoc - o cpo, aaec c coa Esc, a aepaec

opaee $. Tae cpo oc e 9 pepa- 21H,

p o DS:DX o aa a ep co렠 cpo. DOS

eppepe cpo e o ee a ce. o cepe ec pa

cpoa oa [2J. o cepe oe cpo, aa o o

pcopa (a o), cpoa [K.

;--- ceee ax

CLEAR_LINE DB 27,'[K$'

;---oca oa cpo, aa o o pcopa

MOV AH,9 ; oa cpo

LEA DX,CLEAR_LINE ;DX oe aa a aao cpo

INT 21H ;cpae oe cpo

H poe.

Ha o poe ao poco oec co poea pe- e

a apo a ce, co cp STOSW. Bo pep

ooxpooo ce:

MOV AX,0B000H ;aae a a ce

MOV ES,AX ;

MOV DI,0 ;DI aae a aao epa

MOV AL,32 ;co poea

MOV AH,7 ;opae ap


- 11 -

MOV CX,2000 ;co oope

REP STOSW ;ocae AX ES:DI 2000 pa

7. paee pcopo.

Kpcop c e. Bo-epx, o c aaee eca a

pae, oopoe oepaop popa oca co o. Bo-opx,

o oeceae o ocea a pae ooae

popa. Too opoo pee pcop oe .

Koa pcop e (e), o o ce pao aae a o

paa. o ao, oco o o a pa, oepae

oepaoo cceo, aaec c ee o pcopa.

Kpcop eeppec pocxeo opoepa ce 6845. a

pocxea ee pecp, caaae paep ooee pcopa.

Mpocxea 6845 eae oo epa頠 pcop, xo ec

popae coco coa e- epaeo pcopa. acoa epa

pcopa e oe eea. B paecx peax pcop e

oc, xo co oopc a pae e e ca

poepa cao pcopa, o ecox peax.

Koa eoccea paoae ⠠ pee, ocae ecoo

cex cpa, o aa cpaa ee co coce pcop

p epee e cpaa occaaaec o pcopa,

oop o aa, oa o oceee opae- e

occaaaeo cpae. Heoope pe ce oo- e

o 8 cex cpa cooece o pcopa xpac

aope oc 2-ax epeex oac ax BIOS, aa c

apeca 0040:0050H. B ao epeeo a a coep oep

coa, oca o 0, a cap a coep oep cpo, ae

oca o 0. Koa coec ee e 8 cpa, o co-

c epeee, pacoo- ee oee ax apecax a.

8. caoa pcopa aco o.

pcopa o caoe acoe oopa

oopa ooceo eo ee o蠠 [4.2.2]. Acoe

oopa o ec peeax 25 cpo 80 (oa 40)

coo. cooo po oo oca oopa paa,

aa c 1, a opao o eoo epxeo a 1,1.

acceepa cea aae oce c o eoo epxeo a

0,0.

Cpe poe.

Oepaoa ccea peocae a cocoa oopoa-

pcopa aco o a pae. 2 pepa 10H

caaae pcop, oocc aao cpae a. Cpa

epc aa c ooxpooo ce oep cpa

(axoc BH) oe cea pa 0. DH:DL coepa cpo

coe, oope oe epc c 0. Kpcop ee coe ooee a

pae oo ec caoa pcopa oocc ee ao

cpae.

;---caoa pcopa cpo 13, coe 39

MOV AH,2 ;oep

MOV BH,0 ;oep cpa

MOV DH,13 ;cpoa

MOV DL,39 ;coe

INT 10H ;oope pcop

Bopo eo oopoa pcopa coco ⠠ cooa


- 12 -

ceaoo paepa cpoca ANSI.SYS, oop oe ape

p cape cce. B poe Ġ a eoxoe cee.

oa cpo, coepae opa o cpoe coe coec

9 pepa 21H. Cpoa aaec c coa Esc (ASCII 27), a

aepaec coo젠 opaee젠 $. opa򠠠 cpo

Esc[cpoa,coeH$, e cpoa coe e- pc o , a Esc

ooaae o ASCII 27. Hapep, cpoa 27,'10;60H$' caaae

pcop cpo 10, coe 60.

Xo ao eo aec e co, o o oaaec oe

o젠 p蠠 oe pa cpo a pa, a a Esc-oce-

oaeoc opaaaec a oa cpo aopa. B ao pepe

p cpo cooe papoca o ce pa.

;--- ceee ax

POSITION_1 DB 27,'[10;30H$'

STRING_1 DB 'There are two options:$'

POSITION_2 DB 27,'[13;32H$'

STRING_2 DB '(1) Review part 1$'

POSITION_3 DB 27,'[15;32H$'

STRING_3 DB '(2) Move on to part 2$'

;---ea cpo

MOV AH,9 ;oep oa cpo

LEA DX,POSITION_1 ;1- cpoa oopoa pcopa

INT 21H ;oope pcop

LEA DX,STRING_1 ;1- ecoa cpoa

INT 21H ;o cpo

LEA DX,POSITION_2 ; ..

INT 21H ;

LEA DX,STRING_2 ;

INT 21H ;

LEA DX,POSITION_3 ;

INT 21H ;

LEA DX,STRING_3 ;

INT 21H ;

H poe.

Pecp 14 15 pocxe 6845 xpa ooee pcopa. B oee

e x aee pcop epeec cooec o

paa, o pepa oa a pa DOS BIOS oppoa

Ba cao ep pcop capoe oo- ee. o pocxo

oo, o a pa p oe x pepa, o occaaa

pecp pcopa, co 2-aoe aee, xpaeec oac

ax BIOS. B o oac, aa c apeca 0040:0050, o

axoc o oc ax ae, aa eee ooee pcopa

ao cpa ce. poepa oo po oa o-

poa ae, o e cocoe pcopa ooc.

o pcopa xpac pecpax 14 15 a co o 0 o 1999,

o cooece 2000 (25*80) o paa. He cae cce

epa c o eoepa o 0 o 3999, e a co

copooaec ee ao apo ( oe aeoo

aae a o pcopa ao c aa- e eoepa a 1

pao). Opaae ae Bae ae, a o, o e ao e

eca cap a a: pecpe 14 - cap, a 15 -

a.

;--- popae

MOV BL,24 ;cpoa BL (0-24)


- 13 -

MOV BH,79 ;coe BH (0-79)

CALL SET_CURSOR ;o poep

;---poepa cao pcopa

SET_CURSOR PROC

;oae oc pecp aeo aa

MOV DX,3B4H ;op apecoo pecpa 6845

MOV AL,15 ;pae pecp 15

OUT DX,AL ;ocae apoc

;cee o pcopa

MOV AL,80 ;oae oep cpo a 80

MUL BL ; AX - oep cpo, oe a 80

MOV BL,BH ;epeoc oep coa BL

SUB BH,BH ;pacpocpae BL a BX

ADD AX,BX ;ce o pcopa

;ocae a a peaa

INC DX ;apece pa pecp

OUT DX,AL ;ocae a a

;oae oc pecp capeo aa

MOV AL,14 ;oep peeoo pecpa

DEC DX ;occaaae op apecoo pecpa

OUT DX,AL ;ocae apoc

;ocae cap a peaa

INC DX ;apece pa pecp

MOV AL,AH ;oeae cap a AL

OUT DX,AL ;ocae cap a

RET

SET_CURSOR ENDP

1 : 1. 2. IBM 3. ꠠ : -

 

 

 

! , , , .
. , :