Вы находитесь на странице: 1из 420

.

IBM PC

IBM PC

.


IBM PC
1.

IBM PC
2.

3.

4.


5.

6.
COM-
7.

8.
I:

9.
II:

10.
III:

11.

12.

I:

13.

II:
14.

15.
I:
16.
II:
DOS
17.
III:
DOS
18.
IV:
BIOS
19.
20.

IBM PC 2

1. IBM PC


ASCII




2.



:
:

:



3.






4.










5.


(DB)
(DW)
(DD)
"" (DQ)
(DT)

() EQU


6. COM-

EXE- COM-
COM-
COM-



7.

JMP
LOOP


(CALL)

:
: AND, OR, XOR, TEST, NOT
:



8. I:

: INT


: DOS
: DOS
: ASCII
: DOS
:
: DOS
: DOS
: DOS
CR, LF, TAB


9. II:


BIOS
: , ,
ASCII
/ DOS
BIOS INT 16H



10. III:

(-)


:


11.


REP:
MOVS:
LODS:
STOS:

CMPS:
SCAS:


()
:


12. I:

DX:AX


Intel 8087 80287


13. II: ASCII BCD

ASCII
- (BCD)
ASCII
ASCII

:


14.




() (XLAT)
: ASCII
:
TYPE, LENGTH SIZE


15. I:

(FAT)



16. II: DOS

: FCB
FCB
: FCB

: FCB

:

:
/

:


17. III: DOS

ASCIIZ


:
ASCII
DOS


18. IV: / BIOS

BIOS

: BIOS


19.


DOS
:
ASCII
DOS

BIOS INT 17H




20.


LOCAL

(&)
: REPT, IRP IRPC

EXITM
, IF IFNDEF
, IFIDN


21.


EXTRN PUBLIC
: EXTRN PUBLIC
: PUBLIC
:

- -
-
C -


22.

COMAND.COM

COM-
EXE-
EXE-

23. BIOS DOS


BIOS
DOS

DOS INT 21H



24.




25.

1. ASCII
2. -
3.
4.

IBM PC 9

60- c
().
"". ,
. 70-
Intel 8008
.
1974 o Intel
8080.
.
1978 Intel - Intel 8086,
8080
.
/ Intel
8086 - 8088, 1981 i
.
8088 c 80188, 8086
- 80186, 80286 80386,
c . 80286,
IBM AT 1984 .
Intel iAPX 86, iAPX 88, iAPX 86, iAPX286
iAPX386, APX - Intel Advanced Processor Architecture.
p
. -, ,
, . -,

, .

, , ,

.
,
. , ,
.
, ,
,
. c
:

IBM PC 10

IBM PC
c - 64
. , ,
.
IBM PC.
, ,
, , .
PC-DOS MS-DOS,
.
C :
.
,
.
.

PC,
.

- y
: ,
(), .
PC - MS-DOS
Microsoft, PC-DOS IBM PC. : 2.0
(), 3.0 AT,
4.0 .
UNIX PC XENIX .

: , a
.
,
, p .
, .
, .

IBM PC 11

. 9, 11, 12, 14, 15, 19, 20 21.
8 10, 12 13, 15 18, 22 25 c
.
, :
- ;
-
;
-
, ;
-
, , ASCII
,
, /;
- ,
;
- ;
- .
-
. .

,
.

IBM PC 12


, IBM PC,
.
,
.
. , ,
. , , -
.
.. "
" (1988), ., . "-
IBM PC" (1987), .. "
" (1987), .. "-
" (1987).
" "
. -,
,
.
, ,
IBM PC.
.
Framework.
,
. .

IBM PC 1

1.
IBM PC
IBM PC
:
.


. . ,
.
,
, , .
,
.
, 2
.


. , , ,
, , 512 . p,
.
.
, , , .
.
;
- .
, A *.
256 : "
" (00000000) " " (11111111). ,
A 01000001, c * 00101010 ( ).
, .
,
. A
- , * - .

IBM PC 2
, .
, .
, , .
, "", 01000001
A. A,
.
01000001. , ,
A.
0 7 ,
A:
: 7 6 5 4 3 2 1 0
: 0 1 0 0 0 0 0 1
2 1024,
. , 512 512 1024, .. 524288 .
PC 16- ,
16- , . 16-
() . 0 15
, PC:
: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
: 0 1 0 1 0 0 0 0 0 1 0 0 0 0 1 1
ASCII

a
ASCII (American National Standard
Code for Information Interchange). "" (. ).
01000001 A.
. 8-
ASCII-, PC 256 ,
. 1
ASCII , 8 256 .

IBM PC 3
,
2 .
c "BInary digiT" ( ).
() .

. :
: 128 64 32 16 8 4 2 1
: 1 1 1 1 1 1 1 1
1, - 2, - 4
.. 1 + 2 + 4 + ... + 128,
255 (2 - 1).
01000001 1 64, .. 65.
01000001 A! , ,
. 01000001 65, A:
-
, 01000001
65;
- (
), ,
, , , 01000001
"".
,
.
. 8088
16- , o 16- . 2
16 1 65535,
32 (2 32 1 4294967295)
.

.

:
0+0=0
1+0=1
1 + 1 = 10
1 + 1 + 1 = 11

IBM PC 4
. ,
01000001 00101010. A *? , 65 42:

01000001 65
00101010 42
01101011 107
, 01101011 107.
:

00111100 60
00110101 53
01110001 113

,
() .

. ..,
1. :
65: 01000001
: 10111110
1: 10111111 ( -65)
10111111, 65 .
, 1.
,
: 1:
: 10111111
: 01000000
1: 01000001 ( +65)
+65 -65 :
01000001 (+65)
10111111 (-65)
(1)00000000

IBM PC 5
. .
, p ,
.
:
. , , 42 65. 42
00101010, e : - 11010110:
65 01000001
+(-42) 11010110
23 (i)00010111
23 .
.
,
: 00000001,
00000000? -1.
11111111:
00000001
11111111
: (1)00000000
(1), , 11111111
-1 :
0 00000000
-(+1) -00000001
-1 11111111
c
:
+3 00000011
+2 00000010
+i 00000001
0 00000000
-1 11111111
-2 11111110
-3 11111101
:
,
.

12 13.

IBM PC 6
, p (
). o
( ), .
32 , ""
.
. :
: 0101 1001 0011 0101 1011 1001 1100 1110
: 5 9 3 5 11 9 12 14
,
, 10=A, 11=B, 12=C, 13=D, 14=E, 15=F.
, :
59 35 B9 CE
"" 0 F, 16,
e. 1.1 ,
0 15.
.
- ,
.
DOS DEBUG
.
,
. - c .
, F 10,
16.
6 5 F F 10 FF
4 8 1 F 10 1
A D 10 1E 20 100
1.1. ,
.
, .20 32, .100 - 256
.100 - 4096.
, , .4B,
.01001011, , 75 ( -
). ,
. .

IBM PC 7
"H", , 25H ( 37). .
c 0-9, , B8H 0B8H.
2 p
. c PC,
x 2.

, - , ..
, 16 .
64 , , c
. :
1. . ,
.


.
(CS) .
2. .
, ,
. (DS)
.
3. .
,

. (SS)
.
, (ES),
. p.1.2 SS, DS CS.
.

.
c.
. (16-)
. 0000 . FFFF 0 65535.
, . ,
0, - 01 65535.

IBM PC 8
, , .
045F
0032. p , 045F,
045F0, .. . a
:
DS: 045F0
: 0032
: 04622
8086/8088 ?
16 . ,
p . . FFF0 65520 ( ) .
, , .
c . nnnn, ,
( . ), .. . nnnn0.
, . FFFF0 1048560 . e,
. F 1111,
.
80286 24 , FFFFF0
16 , 80386 .

8086/8088 14 , y
,
. (16 ) .
:
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
80286 80386 , 16. .
CS, DS, SS ES
64 ,
. , c
p .

IBM PC 9
1. CS.
.
(IP) ,
.
CS. 2. DS.

. ,
,
. 3. SS.
. 4. ES.

. ES
DI.
ES,
.
: AX, BX, CX DX
"
". ,
o .
(high), a - (low). , CX
: CH CL, .
CX, CH CL,
:
MOV CX,00
MOV CH,00
MOV CL,00
1. AX. AX
-,

. , ,
AX.
,
AX.
AX: | AH | AL |
2. BX. BX .
,
""
. - .
BX: | BH | BL |

IBM PC 10
3. CX. CX .

. CX
.
CX: | CH | CL |
4. DX. DX .
/
,
DX AX.
DX: | DH | DL |
c
8-, 16- .
: SP BP
SP BP .
.
1. SP.
,
. SS
.
2. BP. :
.
: SI DI

.
1. SI.
.
SI DS.
2. DI.
.
DI ES.
: IP
IP , .
,
DOS DEBUG .

IBM PC 11
16
.
. :

O ()
. D ()


(
). I ()
. T ( )
.
, DOS DEBUG
,


. S ()
(0 - ,
1 - ). Z ()

(0 - , 1 -
). A ( ) 3-
8- ,

. P ( )
8- (1 - 0 ). C () ,
,

.
O, S, Z, C
, D
.
p.
PC

: c ,
, , , ()

IBM PC 12
.
,
. :
- (Intel); - (ROM 40); - (RAM
512 ); - -.
,
(), ,
.
, o
, , ""
20 .
"" ,
. 8088 16- ,
o. 8088 8086,
: 8088 8- ( 16- ) ,
, .
.
80286 80386 8086.
. 1.3 : o ()
(). ,
. c
- (), y () .
,
o ( , ).
: ,
: -,
,
/. -,
1 .
.
, .
4 , , "
" ,
.
,
. c
/.

IBM PC 13
. ,
. , c
.

.
() ROM (read-only memory). ROM
, p ( ) .
ROM " " .
ROM :
ROM p
(RAM) (, DOS).
ROM BIOS (Basic Input/Output
System) /, . (Basic , ). ROM
.
, , RAM (Random Access
Memory) , .. , , . RAM

.
RAM ,
.
e ,
ROM DOS RAM. ( DOS,
DOS). o DOS
DOS .
RAM. DOS
, () .
RAM ,
. RAM.
()
RAM.
. 64
, RAM : 4 64 = 256.
. , c,
.

IBM PC 14
RAM , ROM - .
, . 1.4,
256 RAM . RAM
, 640
, DOS. ROM 768
o / c
. ROM, c 960 ,
,
.
RAM - .
. 00 -
. .
1025. . - 0401
. c - 04 - 01.
:
, - . ,
. 0401 5612 5613, :
|01|04|
||
5612, 5613

,
. ,
a,
.

- ,
.
. - ,
. - ASCII
. - ,
: 0 1,
. -
. , 1111 2**3 + 2**2 + 2**1 +
2**0, 15.

IBM PC 15
- :

+1. -
. . 0-9 A-F
0000 1111. - :

,

.
. - ,
,
. - ROM () RAM ()

. - ()
.

1.1. ASCII
. ( 1
): ) P, ) p, ) #, ) 5. 1.2.
: )
5, ) 13, ) 21, ) 27. 1.3. C :
) 00010101 ) 00111110 ) 00011111
00001101 00101001 00000001
1.4.
: ) 00010011, ) 00111100, ) 00111001. 1.5.

: ) 11001000, ) 10111101, )
10000000. 1.6. . ) ASCII Q,
) ASCII 7, ) 01011101, )
01110111. 1.7. . :
) 23A6 ) 51FD ) 7779 ) EABE
0022 3 887 26C4
1.8. .
.
2. ,
. . )
19, ) 33, ) 89, ) 255, ) 4095, ) 63398. 1.9. ,

,
.

IBM PC 16
1.10. :
) , ) , )
, ) , )
, )
? 1.11.
?

IBM PC . 2 30

2.

: , .

DOS - DEBUG,
,
.
.
.

.
, .
.
c
. - IBM PC
c DOS.

DOS A.
, ; e ,
Ctrl Alt Del.
DOS ,
, , A C
( ). ,
, Return. ,
.


DOS DEBUG . DEBUG Return,
DEBUG .

IBM PC . 2 31
, DEBUG .
, o , D -
.
1. .
.

, .
.413 414
DEBUG ,
:
400 - ,
40 ( )
13 - .
, :
D 40:13 ( Return)
, ,

,
.
. , .
.
.. . . . ()
8000 0080 128
0001 0100 256
8001 0180 384
0002 0200 512
8002 0280 640
2. . "" ROM
. FE000. ,
:
D FE00:0 ( Return)

.
3. ROM BIOS. ROM BIOS mm/dd/yy
. FFFF5.
D FFFF:05 ( Return)
()
.

IBM PC . 2 32
, , D (Display),
.
, D, - DEBUG ,
.
DOS Q (Quit).
DEBUG
.
:

- ,
.
:

B82301 . 0123 AX.
052500 . 0025 AX.
8BD8 AX BX.
03D8 AX BX.
8BCB BX CX.
2BC8 AX AX ( AX).
90 .
CB DOS.
, : ,
. .
.
, , .
, MOV - . B8, - . 8B.

. c
. -
o DEBUG Return. DEBUG
.
Ctrl PrtSc .

, :
E CS:100 B8 23 01 05 25 00 ( Return)
E Enter (). CS:100 ,
, - . 100 (256) . (

IBM PC . 2 33
DEBUG). E
p , CS:100 CS:105.
Enter:
E CS:106 8B D8 03 D8 8B CB (Return)
, CS:106 107, 108, 109, 10A 10B.
Enter:
E CS:10C 2B C8 2B C0 90 CB (Return)
, CS:10C 10D, 10E, 10F, 110 111.
. , ,
.
- . p. 2-1 ,
E.
o.
R .
. , ,
AX=0000, BX=0000, ...
DOS
. 2.1. IP ( )
IP=0100, 100
. ( E CS:100
.)
. 2.1 :
NV UP DI PL NZ NA PO NC
. 2.1. .
: , ,
, , , ,
. .
R 0100
. CS . 2.1 CS=13C6 (
), :
13C6:0100 B82301 MOV AX,0123

IBM PC . 2 34
CS=13C6 ,
13C6 13C60. 13C6:0100
100 (.) 13C6
CS. B82301 - , CS:100. MOV
AX,0123 - ,
.
,

.
.

AX.
MOV .
T ( ) Return. MOV
, ,
. , AX 0123.
AX B8 2301.
B8 23 AX, .
AL, 01 - AX, . AH:
AX: |01|23|
IP:0103
:
13C6:0103 052500 ADD AX,0025
T. 25 (AL)
AX 00 (AH) AX, . 0025 AX.
AX 0148, IP 0106 - c
.
T.
AX BX BX
0148. AX e 0148, MOV
p .
T
. c AX
BX, 0290. p BX CX,
AX CX, AX . ,
c NZ () ZR (),
( AX 0).

IBM PC . 2 35
T NOP RET,
. D :
D CS:100
16 .
(32 . ) ASCII (
. ). ASCII
.
.
00 CS:100
CS:10F. c CS:110 CS:11F. ,
CS:111, Dump a
CS:100 CS:170.
IP
. R IP, 100,
T. Return.
.2.2 D CS:100.
CS:100 111 ;
.

. 2.2. .
DEBUG Q (Quit - ).
DOS A> C>.
, c Ctrl/PrtSc.
:

,
(MOV ADD).
, 0123 0025 .

DS .
, c
:
DS ..
0000 2301 0 1

IBM PC . 2 36
0002 2500 2 3
0004 0000 4 5
0006 2A2A2A 6, 7 8
, . , o, , 23
0 ( ) , 01 - 1 (.. ).
, :

A10000 ( ), DS 0000, AX.
03060200 ( ), DS 0002,
AX.
A30400 AX , DS 0004.
CB DOS.
, MOV p
: A1 A3. ,
, ( ), (
) .
DEBUG
. , .
E (Enter) :
E DS:00 23 01 25 00 00 00 ( Return)
E DS:06 2A 2A 2A ( Return)
( ) , DS:00.
, , 0123
2301, a 0025 2500. MOV c,
2301 0123, 2500 - 0025.
(***) ,
D (Dump) - .
, CS:100:
E CS:100 A1 00 00 03 06 02 00
E CS:107 A3 04 00 CB

IBM PC . 2 37
CS:100 CS:10A.
. . 2.3 , E.
, CS DS
.
D (Dump) :
: D DS:000 (Return)
: D CS:100 (Return)
, .
2.3. DS:00 DS:08 CS:100 CS:10A
. 2.3.
R
. , .
- :
13C6:0100 A10000 MOV AX,[0000]
, CS 13C6, CS:100 A10000.
MOV
[0000] .
, .

. 2.3.
,
MOV AX,0000
o AX 0000.
T. MOV AX,[0000] c ,
, AX. 2301
0123 AX.
ADD , T.
DS 0002 AX. AX
0123 0025, . 0148.
MOV [0004],AX T.
AX 0004.
D DS:00. :
: 23 01 25 00 48 01 2A 2A 2A
: 00 01 02 03 04 05 06 07 08

IBM PC . 2 38
0148, AX 04
05, 4801. .
ASCII. , .23 e #,
.25 - %. . 2A
(***). ,
.
( ) .
D DS:100 , .
2.3. Q .


CS IP. , , CS
. 04AF ( 04AF0), IP . 0023:
CS: 04AF0
IP: 0023
: 04B13
, , 04B13 :
A11200 MOV AX,[0012]
|
04B13
04B13 .
(A1) o - 3 .
[0012] a,
DS ( ) c . DS
.04B1 ( 04B10),
c :
DS: 04B10
: 0012
: 04B22
, 04B22 04B23 :
: 24 01
||
: 04B22 04B23

IBM PC . 2 39
24 04B22 AL,
01 04B23 - AH. AX 0124.
IP
, IP
0026. p
, CS (04AF0)
IP (0026), . 04B16.

8086, 80286 80386 , e
, .
o 4B22
. ,
. , ,
, c 04B23 AX:
: ||24|01||
|
: 04B23
4B22 4B23
4B23 AL. 4B24 4B25
4B23 AH. AX
0124.
-
, .
, , -,
, , -,
,
, .
, ,

, , .
, ,
- .
EVEN,
.
:

IBM PC . 2 40
(RAM),
. BIOS ( /) ROM
, p . BIOS
INT, c 12H. BIOS AX
. DEBUG INT 12H RET
:
E CS:100 CD 12 CB
R ( Return) . IP
0100, INT 12H. T ( Return)
BIOS ( ,
):
STI
PUSH DS
MOV AX,0040
MOV DS,AX
MOV AX,[0013]
POP DS
IRET
AX p .
T BIOS .
RET CB, .

DOS 2.0 DEBUG


, .
.
A
A (Assemble) DEBUG
. :
A 100 [Return]
:0100.
, Return.
, Return .
:

IBM PC . 2 41

MOV AL,25 [Return]


MOV BL,32 [Return]
ADD AL,BL [Return]
RET [Return]
:
:0100 MOV AL,25
:0102 MOV BL,32
:0104 ADD AL,BL
:0106 RET
. Return
.
, .
, .
U
U (Unassemble) .
,
( c 100 106). :
U 100,106 [ Return]

:0100 B025 MOV AL,25
:0102 B332 MOV BL,32
:0104 00D8 ADD AL,BL
:0106 C3 RET
, R
. T
.
, .
, ,
- .
DEBUG
.

DEBUG :

IBM PC . 2 42
1.
.
:
:
DEBUG n:[Return]
D
E,
: W [Return]
2. DEBUG
. :
DEBUG,
A (assemble) E (enter)
,
: N .COM [Return].
COM (. 6
COM-).
,
,
.

:0106 C3 RET

106 () 100 (), .. 6.
CX : R CX [Return]
CX 0000 (
)
- 6,
: W [Return]
DEBUG "Writing nnnn bytes." ( nnnn ).
nnnn 0, ,
c.

DOS DEBUG ,
. ,
E ().
.
"" , DOS DEBUG
. ,
, ,
.

IBM PC . 2 43
, , ,
, E, . ,
p . E
. ,
(IP) 0100. R (register)
:
R IP [Return]
IP .
0100 R ( IP). 0
, . ,
T, .
- ,
. y
CS, DS, SP SS, .
DOS DEBUG.
: o: (D), (E),
(H), (N), (Q), (R), (T) (W).
o .

2.1.
) . 4629 AX;
) . 036A AX.
2.2. , :
E CS:100 B8 45 01 05 25 00
. 45 54.
E
, .. 45
54.
2.3. , :
E CS:100 B8 04 30 05 00 30 CB
) ? (
).
) AX
0460,
6004. ?

IBM PC . 2 44
)
.
?
2.4. :
B0 25 D0 E0 B3 15 F6 E3 CB
:
- . 25 AL;
- AL
( AL 4A);
- . 15 BL;
- AL
BL.
(E)
CS:100. ,
.
D CS:100 .
R T
RET.
AX
?
2.5. (E)
:
: 25 15 00 00
: A0 00 00 D0 E0 F6 26 01 00 A3 02 00 CB
:
- DS:00
(25) AL;
- AL
( 4A);
- AL
DS:01 (15);
- AX ,
DS:02.
D
.
R T
(RET). AX
0612. D
DS:00 , DS:02
1206.

2.6. (2.5)
TRIAL.COM.

IBM PC . 2 45
2.7. A ,
:
MOV BX,25
ADD BX,30
SHL BX,01
SUB BX,22
NOP
RET

NOP.

IBM PC . 3 60

3.

:
, .

2 .

. , -
, "" ()
.
,
.
,
, .
DOS EDLIN .

, . , DOS LINK
, .

, .

, o ,
. p
(;) ,
, ; .
, .
,
:
1. ;
2. ADD AX,BX ;

IBM PC . 3 61
-
,
, .
, -
( ).

:
[] [()]
( ), ( ) p
. - 132 ,
, 80 (
). :

COUNT DB 1 ;, ,
MOV AX,0 ;,

:
: A Z a z
: 0 9
: (?)
(.) ( )
" " (@)
(-)
($)
.
. - 31 .
: COUNT, PAGE25, $E10.
. , , AX, DI AL
. ,
ADD AX,BX
"", AX BX . ,
MOV REGSAVE,AX

IBM PC . 3 62
REGSAVE ,
. 3 c .


. ( ) , o
. , , (MOV)
(ADD).

, )
) , .
COUNTER
:

COUNTER DB 0 ; (DB)
;
, .
:

RET ;
INC CX ; CX
ADD AX,12 ; 12 AX
, -
. ,
y . , , DOS EDLIN
.

, p
.
.
. .
24
. 24 .
: PAGE TITLE

IBM PC . 3 63
, ( ).
PAGE TITLE .
PAGE. ,
, .
c PAGE. 60
132 :
PAGE 60,132
10 255, -
60 132. PAGE 66,80.
, 60. ,
60 ,
e.
, , .
PAGE .
p PAGE.
TITLE. ,
() , p TITLE :
TITLE
,
. , ASMSORT,
60 :
TITLE ASMSORT -
SUBTTL,
, .
SEGMENT
- .

. c SEGMENT
:

SEGMENT []
.
.

IBM PC . 3 64
.
ENDS
,
. ENDS .
SEGMENT ENDS . SEGMENT
, , .
1. .
. PARA,
.
16 , ..
. nnn0.
PARA. 2. .


( .
" ").
: STACK, COMMON, PUBLIC, AT
MEMORY.
:
SEGMENT PARA STACK

, :
PUBLIC, COMMON MEMORY. ,
' ,
. 3. . , ,

:
SEGMENT PARA STACK 'Stack'
. 3.1.
SEGMENT .
PROC
.
, PROC.
, :
- SEGMENT PARA
- PROC FAR
.
.

.
RET

IBM PC . 3 65
- ENDP
- ENDS
,
. FAR DOS,
.
ENDP ,
PROC. RET
DOS.
(. .7).
ASSUME
SS , DS
CS c .
. ASSUME,
:

ASSUME SS:_,DS:__,CS:__
, SS:_ ,
SS. .
ES .
ES, ES:NOTHING.
END
, ENDS , ENDP
. END :

END [_]
, ,
, ,
() .
o , PROC, o FAR.

,
. , WORDA :

IBM PC . 3 66

MOV AX,BX ; BX AX
MOV AX,WORDA ; WORDA AX
MOV AX,[BX] ;
; BX AX
MOV AX,25 ; 25 AX
MOV AX,[25] ; 25
,
.

: EXE COM.
EXE-, COM- 6. DOS
EXE-: 1) ,
c , 2) ,
DS, , 3)
4) DS .
DOS RET. .3.1
:
1. ASSUME - ,

; ,
CODESG - CS, DATASG - DS STACKSG - SS. DATASG
STACKSG ,
:
STACKSG SEGMENT PARA STACK Stack 'Stack'
DATASG SEGMENT PARA 'Data'
,

. ,
:
0, ,
2 ..
2.
256- (.100) ,
PSP.
DS
PSP.
, . , RET
DOS.

IBM PC . 3 67
3. ,
(, ).
SUB AX,
AX, PUSH
.
4. DOS
SS CS.
DS
, DS
MOV, .3.1.
" . II"
DS.

. 3.1. EXE-.
5. RET
DOS, ,
PUSH DS.
INT
20H.
, -
. ,
.

. 3.2. .
- STACKSG - CODESG.
STACKSG DB ( ), 12
'STACKSEG'. p ,
,
.
CODESG , ASSUME
. ASSUME SS STACKSG CS
CODESG. , ,
STACKSG SS CODESG -
CS.
SS CS.
, , , ASSUME
p DS.

IBM PC . 3 68
, ASSUME - PUSH, SUB PUSH
DS .
, , DOS,
DOS . ( ,
).
, p.2.1
, .

" "
.
ENDS,
- ENDP, -
END.
ASSUME
.
EXE- ( COM-, . .6)
32 ,
PUSH, SUB
PUSH DS .

3.1.
?
3.2. : ) PC_AT, ) $50,
) @$_Z, ) 34B7, ) AX?
3.3. ,
?
3.4. END,
) , ) , ) ?
3.5. .
3.6. RET END.
3.7. , CDSEG,
DATSEG STKSEG .
ASSUME.
3.8.
DS .

IBM PC . 4 79

4.

: , .

,
, , .
, .

.3.2. ,
. DOS EDLIN
.
EDLIN,
DOS. EDLIN DOS A
B.
, CHKDSK B:.
C: B:. EXASM1,

EDLIN :EXASM1.ASM [Return]
DOS EDLIN "New file"
"*-". I ,
, p . 3.2.
, , ,
, , y.
EDLIN .
. E ( Return)
EDLIN. ,
DIR B: ( )
DIR B:EXASM1.ASM ( )

IBM PC . 4 80
,
.
. PRINT ( DOS 2.0 ). DOS
:
PRINT B:EXASM1.ASM [Return]
EXASM.ASM -
. p
.

EXASM1.ASM
, .
p , .
,
.

OBJ-.
2 x .
OBJ- ,
. OBJ- EXE ()
, . LINK, DOS,
:
1. OBJ- ,
.

----R. 2. , ,
()
;
,
,
. 3. EXE-
.
OBJ- ( ) EXE-,
EXE- . , EXE, , OBJ OBJ-

IBM PC . 4 81
EXE-. , , , ,
, EXE-
. : EXE- o
COM-. , , c
. 6.

, ,
.
a. ASM.EXE -
MASM.EXE - .
, MASM ( .
).
, A,
B. p C
A B. MASM ( ASM),
. :
source filename [.ASM]:
object filename [filename.OBJ]:
source listing [NUL.LST]:
cross-reference [NUL.CRF]:
,
. ( )
: B:EXASM1. ASM,
.
- ( ).
, B:.
, .
B B: Return.
, c .
B, B: Return.
,
Return. ,
c OBJ, LST CRF-. , ,
, .
source filename [.ASM]:B:EXASM1 [Return]

IBM PC . 4 82
object filename [filename.OBJ]:B: [Return]
source listing [NUL.LST]:B: [Return]
cross-reference [NUL.CRF]:B: [Return]
, , OBJ- -
.
LST-, , . CRF , ,
. , LST-
, CRF-.
4 " "
() 1.0 2.0.

.
, (, MOVE MOV),
p . ASM
, , ASM
, . 100 .
,
, (EXASM1.ASM)
.
. 4.1. , c
EXASM1.LST.
PAGE
TITLE. , SEGMENT, PROC, ASSUME END
.
,
. .
.
0000.
p SS
p. SEGMENT 16-
, .
. DB, 0000, 12 'STACKSEG';
.0C ( 12) . ASCII
. (
). . 0060,
96 (128).

. 4.1.

IBM PC . 4 83
0000.
p CS .
ASSUME , ,
PUSH DS - (1E),
. SUB AX,AX
(2B C0), 0001.
. -, - .
END BEGIN, e
PROC 0000. ,
.
EXASM1.LST, PAGE p
132 .
.
MODE LPT1:132,6

.

, . -
( ) ,
( ). , ,
/N MASM, .. MASM/N.


, . ,
, ,
.
p
, , ..
a .
, .
,
.
, .
, , : OBJ, LST CRF.

IBM PC . 4 84

, c . EXASM1.OBJ
.
, .
, () .
LINK
( ) .
, DOS
A, B.
LINK C. LINK
Return. ,
( MASM), :

Object Modules [.OBJ]: B:EXASM1 EXASM1.OBJ
Run file [EXASM1.EXE]: B: EXASM1.EXE
List file [NUL.MAP]: CON EXASM1.MAP
Libraries [.LIB]: [Return]
- , OBJ
.
- (), (
A:EXASM1.EXE). B: , .
( )
.
, LINK y - NUL.MAP (..
MAP ). MAP- ,
LINK.
. CON , ,
.
. MAP-
:
Start Stop Length Name
00000H 00015H 0016H CODESG
00020H 0007FH 0060H STACKSG

IBM PC . 4 85
- Return, LINK
y.
DOS.
y
. LINK. 4
p LINK.

(-!) .
. 4.2 ,
EXASM1. EXE- B,
:
B:EXASM1.EXE B:EXASM1
DOS , EXE ( COM),
. ,
DEBUG.
DEBUG B:EXASM1.EXE
DOS DEBUG, , ,
EXE-. (-) .

D SS:0
12- STACKSEG.

D CS:0
:
1E2BC050B823010525008BD803 ...
, 0123 0025
2301 2500 .
. ()
.

IBM PC . 4 86
R p
T (). PUSH -
DS .

. RET, Q (Quit - )
.
dir, :
DIR B:EXASM1.*

. 4.2. ,
.
: EXASM1.BAK (
EXASM1.ASM EDLIN), EXASM1.ASM,
EXASM1.OBJ, EXASM1.LST, EXASM1.EXE EXASM1.CRF.
, .
, .
DOS
CHKDSK. OBJ-, CRF-, BAK- LST-
ERASE ( DEL):
ERASE B:EXASM1.OBJ, ...
() ASM- EXE-
.
.
c.

, . 4.1, ,
. ,
-.
2 (.2.3) ,
. . 4.3 ,
.
.

IBM PC . 4 87
DW (Define Word - c),
32 , (?).
32 ,
"" -
- .
'STACKSEG' p. 3.2
DEBUG.
: 32 .
, -
.
. 4.3 DATASG,
0000. DW.
FLDA ( ), 250,
. 00FA (. ).
FLDB 125, p .
007D. - FA00 7D00 ,
c DEBUG.

. 4.3.
.
FLDC ,
(?).
CODESG -
, . -, ASSUME
DATASG DS. ES,
. -,
PUSH, SUB PUSH, - , ,
:
0004 B8 ---- R MOV AX,DATASG
0007 8E D8 MOV DS,AX
MOV DATASG AX. ,
- DATASG.
:
B8 ---- R
, a DATASG;

.

IBM PC . 4 88
p , c
R;
.
MOV AX DS. ,
ASSUME, DS
, , DS DATASG.
. -,
DS, ,
MOV DS,DATASG ?
, c
DS. , DS .
-, DS, SS CS ?
, SS CS
, DS , ES,
.
, c
.
.
. ,

, , , .
, ,
. 4.3, .
DEBUG , ,
.

(CRF),
,
. ,
, o B:, , B:
cross-reference [NUL.CRF]:B: [Return]

IBM PC . 4 89
CRF- p
.
. CREF.
:
Cref filename [.CRF]:
List filename [cross-ref.REF]:
CRF-, .. B:EXASM1.
.
CRF EXASM1.REF B.
DOS PRINT.
4 CREF.

. 4.4.
. 4.4 , .
4.3. c
p , .
p.
n# LST-,
. ,
, c . , CODESG
17 19 32.

OBJ-,
- OBJ- EXE-.

(M)ASM, LINK CREF
Return.
. CREF .
.
CHKDSK
.
,

.

IBM PC . 4 90
4.1. MASM
TEMPY.ASM
LST, OBJ CRF, ,
B.
4.2. TEMPY ( 4.1) )
DEBUG, )
DOS.
4.3. : )
file.BAK, ) file.ASM, ) file.LST, ) file.CRF, )
file.OBJ, ) file.EXE, ) file.MAP.
4.4. DS,
, - DATSEG.
4.5. :
- . 30 ( )
AL;
- AL
( SHL);
- . 18 ( )
BL;
- AL BL ( MUL BL).
RET.
.
(
)
. .
DEBUG, ,
() .
4.6. 4.5 :
- ( DB)
FLDA, . 28, FLDB,
. 14;
- ( DW)
FLDC, ;
- FLDA AL
;
- AL
FLDB (MUL FLDB);
- AX FLDC.
.
,
DEBUG.

IBM PC . 5 104

5.

: .

,
-.
: , DB ,
DW o .
, .
, ..
, :
MOV AL,20H
20
. o , ,
, , c.

: -,
, -, c.
:
[] Dn
(
),
,
.
" " 3.

: DB (), DW (), DD ( ),
DQ ( ) DT ( ). ,
:
FLD1 DB 25
,

IBM PC . 5 105

FLDB DB ?
,
:
FLD3 DB 11, 12, 13, 14, 15, 16, ...
c .
FLD3 , 11, FLD3+1 - , 12. (FLD3
FLD3+0).
MOV AL,FLD3+3
AL 14 (. 0E).
:
[] Dn - DUP () ...
:
DW 10 DUP(?) ;
DB 5 DUP(14) ; , .14
DB 3 DUP(4 DUP(8));
8 (8888),
, p .
.

, , ,
. o ,
, 'PC' - "PC".
ASCII.
DB, p
. ,
DB .
. 5.1 .

. 5.1. .

IBM PC . 5 106
a .
.

- . .
. 0 9
D, , , 125 125D.
, ,
. . , 125 .
7D.
. . . 0 F
H. ,
, . 0 9.
, 2EH 0FFFH, 2E FF0F
( ).
. 0 1
B.
AND, OR, XOR TEST.
12, . C 1100B : . 0C 0000
1100 , .
. 0 7
Q O, , 253Q.
.
.
ASM.
, , ,
, DB '12', ASCII
. 3132, , o DB 12,
. 0C.
. 5.1
. ,
().
(DB)

IBM PC . 5 107
, ,
DB ( ). p DB
, (. FLD2DB FLD7DB . 5.1).
, FLD2DB 'Personal
Computer'. ASCII . . 20
.
DB
. . p. .
7F, "" 80 FF
. +127 -128.
. 5.1 FLD3DB, FLD4DB, FLD5DB
FLD8DB. FLD6DB ,
.
(DW)

DW , ( ).
DW ,
, , , 'PC' 'CP'.
DW .
DW .
. . .
7FFF; "" 8000 FFFF
. +32767 -32768.
. 5.1 FLD1DW FLD2DW .
FLD3DW - FLD7DB.
0021 (R ).
, , FLD7DB 0021.
FLD4DW . ,
o ( ).
DW, DD DQ .
, .
12345 .3039,
3930.
(DD)

IBM PC . 5 108
DD , c ( ).
,
( . ). .
7FFFFFFF; "" 80000000 FFFFFFFF
.
+2147483647 -2147483648.
. 5.1 FLD3DD . FLD4DD
,
FLD2DB. FLD5DD .
DD . ,
.
12345 . 00003039, o
39300000.
DD .
,
FLD2DD .
(DQ)

DQ , ( ).
,
16 .. . -
15 F. , ,
. 1 15 :
1152921504606846976
. 5.1 FLD2DQ FLD3DQ .
DQ . ,
, - DD DW.
DQ a DD
DW.
(DT)

DT , .
" " (. .13).
DT , ;
a.

IBM PC . 5 109
. 5.1 DT
.
.5.1 . X c
, LINK MAP : "Warning: No
STACK Segment", LINK "There were 1 errors detected" ( 1
). DEBUG
, . 5.2.
, , , "Personal
Computer".

. 2.1 2 .
MOV AX,0123H
. 0123 AX.
B82301, B8 "
AX", a .
: , -
.

. 5.2. .
, o
c
MOV, ,
: AMT1 DW 0123H
: MOV AX,AMT1

. ,
, AL
:
MOV AL,0123H ()
, , ,

ADD AX,25H ( )
, 0025
2500.

IBM PC . 5 110


, p, 0123H;
, , 291 ( .0123); ,
, 100100011 ( . 0123).
, :
: MOV, CMP.
: ADC, ADD, SBB, SUB.
: RCL, RCR, ROL, ROR, SHL, SAR, SHR.
: AND, OR, TEST, XOR.
. 5.3 .
,
. ,
.
, , (. .7)
(. .11).

. 5.3. .
EQU

EQU , ,
. ,
EQU:
TIMES EQU 10
, TIMES,
. , - TIMES
10. ,
FIELDA DB TIMES DUP (?)
FIELDA DB 10 DUP (?)
, EQU,
, :
COUNTR EQU 05

IBM PC . 5 111
...
MOV CX,COUNTR
COUNTR MOV 05, c
,
MOV CX,05 ; 05
EQU ,
, COUNTR.
, EQU. ,
EQU ,
. EQU :
1. TP EQU TOTALPAY
2. MPY EQU MUL
, p
TOTALPAY. , TP,
TOTALPAY. MPY
MUL.


. ,
EMPWAGE.

DB,

(-).
.
. , ,
AX 25 . 25:
ADD AX,25 ; 25
ADD AX,25H ; 37
, DW, DD DQ

.

IBM PC . 5 112
DB
(AL, AH, BL ..) DW
(AX, BX, CX ..). ,
DD DQ
.

: -
(AL, BH), -
(AX, BX).

5.1. ,
: ) DW, ) DD, ) DT, ) DB, ) DQ?
5.2. TITLE1,
RGB Electronics.
5.3.
FLDA FLDE:
a) , .
115;
b) , .
25;
c) ,
;
d) ,
25;
e) DW,
16, 19, 20, 27, 30.
5.4. .
) DB '26' ) DB 26.
5.5. .
) DB 26H, ) DW 2645H, ) DD 25733AH, ) DQ 25733AH.
5.6.
:
) 320 AX;
) FLDB ;
) . 40 BX;
) . 40 CX;
) FLDB ;
) CH .
5.7.
5.2, 5.3 5.6.
. .

DEBUG. LST- (),

IBM PC . 5 113
.
MODE LPT1:132,6
.

IBM PC . 6 123

6. COM-
COM-
: COM-
COM-.

, EXE-.
LINK EXE-,
() p 512 . (
22 ).
COM-.
COM- COMMAND.COM. EXE2BIN.COM
DOS EXE- COM-. BIN
() , " EXE in (EXE-to-BIN)".
in- COM-.
EXE COM-

, EXE2BIN EXE- COM-, c


, EXE- ,
COM-.
. EXE- , COM 64. COM- ,
EXE-; - COM- 512 EXE-.
. EXE- , COM .
, COM-, .
. EXE , DS
. COM-
. .

IBM PC . 6 124
. EXE-
DS. COM- , ,
. COM- ,
(PSP), - 256- (. 100) ,
DOS COM EXE
. . 100 PSP,
SEGMENT ORG 100H.
. EXE COM
OBJ-, EXE-.
EXE-, .
COM-, :
Warning: No STACK Segment
(: )
,
. EXE- COM-
EXE2BIN. , EXE2BIN A,
CALC.EXE - B.
EXE2BIN B:CALC,B:CALC.COM
EXE , EXE.
( CALC.COM). COM,
EXE2BIN BIN,
COM. OBJ- EXE-.
EXE-, , ,
COM .
COM-

EXCOM1, . 6.1, . 4.3,


COM- .
COM-: . ASSUME

. CS
,
(PSP). ORG
100 (.)
PSP.

IBM PC . 6 125
ORG 100H
.
. JMP
,
.
:
MASM [ ]
LINK [ ]
EXE2BIN B:EXCOM1,B:EXCOM1.COM
DEL B:EXCOM1.OBJ,B:EXCOM1.EXE ( OBJ EXE-)
EXE- COM- - 788 20 .
COM-, COM. ( ) RET
DEBUG B:EXCOM1.COM.
,
JMP .
,
.

. 6.1. COM-.
COM-

COM- DOS o
p.
64 , DOS SP
c - .FFFE. . 64
, DOS . DOS
.

. DIR p
.
COM-.

COM-
. EXE2BIN o,

IBM PC . 6 126
.
SEGMENT, ASSUME END. ORG 100H,

.
COM- DEBUG
D CS:100 .
RET; Q .
INT 20H RET.
EXE- , COM-,
.

COM- 64.
COM- , EXE-.
, COM-

DS.
, COM-
ORG 100H SEGMENT

.
EXE2BIN EXE- COM-,
COM .
DOS COM-
, ,
.

6.1. COM-?
6.2. ,
COM-?
6.3. COM-
?
6.4.
SAMPLE.EXE. DOS
COM-.

IBM PC . 6 127
6.5. 4.6 COM-,
DEBUG.

IBM PC . 7 132

7.

: ( )
.

. ,
.
, ,
, .
- .
,
.

.
,

. (
):
: JMP
: LOOP
: Jnnn (,,)
: CALL
, : SHORT, NEAR FAR. SHORT
, p .
NEAR FAR (CALL)
, , SHORT.
IP; FAR CS.
JMP

JMP.
, ..
.

IBM PC . 7 133
COM- . 7.1 JMP. p AX, BX, CX
1, :
1 AX,
AX BX,
CX.
AX: 1,2,3,4..., BX:
1,3,6,10..., CX: 1,2,4,8... , , A20: o, ( BEGIN)
.
JMP A20
, c A20.
, .
-
.

.7.1. JMP.
:
A20: ADD AX,01
:
A20:
ADD AX,01
A20 ADD. A20
- NEAR. :
. A20 -9 JMP,
- EBF7. EB
JMP, F7 - (-9). JMP
F7 (IP), p JMP
(0112):
. .
: 274 112
JMP: -9 F7 ( )
: 265 109

IBM PC . 7 134
- . 109.
, .109.
JMP .
JMP -128 +127 SHORT.
00 FF. JMP,
, FAR,
.
. , JMP
. JMP
p ( ):
A50:
...
JMP A50
.
( )
JMP A90
...
A90:
NEAR FAR, 3-
. ,
, SHORT:
JMP SHORT A90
...
A90:
, , ,
COM-. ,
.
DEBUG COM-
. AX 08, BX CX . 24 (. 36)
. 80 (. 128), . Q.
LOOP

JMP . 7.1 .
. LOOP,
, CX.
LOOP

IBM PC . 7 135
CX 1. CX , ,
, CX 0,
LOOP .
. 7.2, LOOP,
, . 7.1 ,
. MOV CX 10.
LOOP CX, 1
CX DX. JMP A20 LOOP
ADD AX,01 INC AX ( AX 1).
JMP, LOOP
LOOP A20,
. LOOP -128 +127 .
, "Relative jump out of
range" ( ).
LOOP
, .7.1, ,
COM-.
DEBUG. CX , p AX, BX
DX . 000B, 0042 0400.
Q.
LOOP - LOOPE ( LOOPZ)
LOOPNE ( LOOPNZ). CX 1.
LOOPE , CX
(ZF=1). LOOPNE
, CX (ZF=0).

. 7.2. LOOP.


. p 16 ,
.
, .
( ):
: 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0

IBM PC . 7 136
: * * * * O D I T S Z * A * P * C
.
CF (Carry Flag) - . "" (0 1)

(. .12).
PF (Parity Flag) - . p
. 0, - 1.
.
AF (Auxiliary Carry Flag) - . 1,
( 3)
.
ASCII .
ZF (Zero Flag) - . a
. ,
, - .
, , , 0 "" (..
), e "" (.. ).
JE JZ .
SF (SIgn Flag) - .
( ) p:
0, - 1. JG JL .
TF (Trap Flag) - .
, DEBUG.
c,
, .. .
IF (Interrupt Flag) - .
, - .
DF (DIrection Flag) - .
.

IBM PC . 7 137
SI DI, , -
, (. .11).
OF (Overflow Flag) - . , ..
/ ( ) .
: CMP AF,
CF, OF, PF, SF, ZF. , .
- BX :
CMP BX,00 ; BX
JZ B50 ; B50
. ( )
.
B50: ... ; BX=0
BX , CMP ZF
, ( ) . JZ ( )
ZF. ZF, ,
, , .. B50.

, LOOP
CX : , ,
. ,
. ,
.
,
.
LOOP .7.2 :
CX, :
LOOP
LOOP A20 DEC CX
JNZ A20 DEC JNZ LOOP:
CX 1 A20, CX .
DEC 0 1.
JNZ . LOOP
, , : DEC JNZ.

IBM PC . 7 138
JMP LOOP JNZ c
JNZ A20,
. -128 +127 .
"Relative jump out of range" (
).
.

. ,
:
. ;
: , .
, ,
, , .
.
, AX 11000110, BX - 00010110.

CMP AX,BX
AX BX. , AX
, - .
.

JE/JZ , / ZF JNE/JNZ , / ZF JA/JNBE
, / ZF,CF JAE/JNB , /
CF JB/JNAE , / CF JBE/JNA ,
/ CF,AF
. , JB
JNAE , JB
, JNAE.


JE/JZ , / ZF JNE/JNZ , / ZF JG/JNLE
, / ZF,SF,OF

IBM PC . 7 139
JGE/JNL , / SF,OF JL/JNGE ,
/ SF,OF JLE/JNG , /
ZF,SF,OF
(JE/JZ) (JNE/JNZ)
. /
.


JS , () SF
JNS , () SF
JC , ( JB) CF
JNC , CF
JO , OF
JNO , OF
JP/JPE , PF
JNP/JP , PF
CX
. p
. JCXZ ,
CX .
. ,
, , - ,
. ,
.
, . , JAE JGE
, .
CALL

o ,
:
BEGIN PROC FAR
.
.
BEGIN ENDP
FAR ,
, ENDP . , ,

IBM PC . 7 140
, PROC ENDP.
. 7.3.
:
PROC B10 C10 NEAR
,
.
,
NEAR.

ENDP .
BEGIN
: CALL B10 CALL C10.
CALL B10
. RET,

CALL B10. CALL C10,
RET.

. 7.3. .
RET
. BEGIN B10 C10,
BEGIN.
BEGIN
DOS RET
DOS. B10
RET,
B10 C10.
C10 RET,
, C10
.

. , CALL ,
-128 +127 .
NEAR
.
CALL
RET .

IBM PC . 7 141
,
, - PUSH ,
DOS, EXE- .
o . , CALL
, CALL,
. RET

.
, PUSH
. POP .
SP (.. )
. RET CALL
. ,
CALL , - .
, .
32 .
PUSH, PUSHF, CALL, INT, INTO
. POP, POPF, RET IRET a
.
EXE-
:
DS ES: - 256 (. 100) ,
.
CS: ( ).
IP: .
SS: .
SP: , . , 32
(64 ),
DW 32 DUP(?)
SP 64, . 40.
EXE-, .7.4.
.

. PUSH SP 2

IBM PC . 7 142
DS ( 049f) , .. 4B00+3E. PUSH
SP 2 AX (0000)
4B00+3C. CALL B10 SP
(0007) 4B00+3A. CALL C10
SP (000B)
4B00+38.
C10 RET 000B (4B00+38),
IP SP 2.
000B , ..
B10.

. 7.4. .
RET B10 0007 (4B00+3A),
IP SP 2.
0007 . RET 0007
, FAR.
.
DEBUG.
0034 003F SP:
SP
: 0040 PUSH DS ( 049F)
049F 003E PUSH AX ( 0000) 0000 049F 003C
CALL B10 ( 0007) 0700 0000 049F 003A CALL C10 ( 000B)
0B00 0700 0000 049F 0038 RET ( 000B) 0700 0000 049F 003A
RET ( 0007) 0000 049F 003C
| | | | | | : 0034 0036 0038 003A 003C 003E
. -,
, 0007 0700. -,
DEBUG ,
IP, .
:

c
, ,

IBM PC . 7 143
o .
p
.
, . 11

.
EXE-, . 7.5, c
, NAME1, NAME2, NAME3. -
NAME1 NAME2 NAME2 NAME3.
,
MOV .
.
BEGIN
B10MOVE C10MOVE. B10MOVE NAME1
NAME2. ,
NAME1 , ..:

. 7.5. .
NAME1: A B C D E F G H I
|||||||||
NAME2: J K L M N O P Q R
NAME1 NAME2 CX 9,
SI DI . LEA
a NAME1 NAME2 SI DI:
LEA SI,NAME1 ;
LEA DI,NAME2 ; NAME1 NAME2
NAME1 NAME2
SI DI. k MOV ,
, c.
,
MOV AL,[SI]
: SI (..NAME1)
AL.
MOV [DI],AL
: AL , DI (..
NAME2).

IBM PC . 7 144
SI DI
SH. CX ,
( B20). SI DI 1,
MOV NAME1+1 NAME2+1.
, NAME1+8 NAME2+8.
C10MOVE B10MOVE :
NAME2 NAME3 LOOP DEC
JNZ.
: , .7.5, ,
DEBUG.
, . NAME2
NAME3 D DS:0.
: AND, OR, XOR, TEST, NOT


. AND, OR, XOR TEST -
.
ASCII (..13).
, CF, OF, PF, SF, ZF.
AND: 1, 1;
- 0.
OR: 1, 1;
0, - 0.
XOR: 0, 1, 1;
( - 0 - 1) - 0.
TEST: AND- , .

,
. AND, OR XOR
:
AND OR XOR
0101 0101 0101
0011 0011 0011
: 0001 0111 0110

IBM PC . 7 145
, , AL 1100 0101, BH
0101 1100:
1. AND AL,BH ; AL 0100 0100
2. OR BH,AL ; BH 1101 1101
3. XOR AL,AL ; AL 0000 0000
4. AND AL,00 ; AL 0000 0000
5. AND AL,0FH ; AL 0000 0101
6. OR CL,CL ; SF ZF
3 4 . 5
AL. CMP ,
OR :
1. OR CX,CX ; CX
JZ ... ;,
2. OR CX,CX ; CX
JS ... ;,
TEST AND, ,
. :
1. TEST BL,11110000B ; BL
JNZ ... ; ?
2. TEST AL,00000001B ; AL
JNZ ... ; ?
3. TEST DX,OFFH ; DX
JZ ... ; ?
NOT p
, : , - . ,
, p AL 1100 0101, NOT AL
0011 1010. . NOT NEG,
,
(." " .1.).
:


. , , ,
.
, (, YES
yes) . A Z

IBM PC . 7 146
. 41 5A, a z . 61 7A.
p , 0 1 :
: 76543210 : 76543210
A: 01000001 a: 01100001
Z: 01011010 z: 01111010
COM-, . 7.6, TITLEX
, TITLEX+1.
BX TITLEX+1 AH,
TITLEX+1. .61 7A,
AND 5 0:
AND AH,11011111B
, ( a z), .
TITLEX, BX
.
BX
. SI DI.

. 7.6. .

,
, :
- ;
- ;
- ;
- 8 ( ) 16 ( );
- ( ) ( ).
1 c ,
1 CL.

CF
. c:

IBM PC . 7 147
SHR ; ()
SHL ; ()
SAR ;
SAL ;
SHR:
MOV CL,03 ; AX:
MOV AX,10110111B ; 10110111
SHR AX,1 ; 01011011 ; 1
SHR AX,CL ; 00001011 ; 3
SHR AX 1 .
CF, AX .
c AX . CF
1, 1, 0, AX
.
SAR:
MOV CL,03 ; AX:
MOV AX,10110111B ; 10110111
SAR AX,1 ; 11011011 ; 1
SAR AX,CL ; 11111011 ; 3
SAR SHR:
. ,
. .
. p,
SHL SAL .
, - 2.
, .
(, 5 7) (2 3,
) CF 1. ,
2 , ,
CL 2.
, CF JC (,
).

,
. :
ROR ;
ROL ;
RCR ;
RCL ;

IBM PC . 7 148


ROR:
MOV CL,03 ; BX:
MOV BX,10110111B ; 10110111
ROR BX,1 ; 11011011 ; 1
ROR BX,CL ; 01111011 ; 3
ROR
BX . ROR
.
RCR RCL CF.
CF, CF .
, .
, 32- DX:AX , 16
DX, - AX. 2
c :
SHL AX,1 ;
RCL DX,1 ; DX:AX 2
SHL AX ,
CF. RCL DX
CF.

:
1. ,

2.
. ,
p (
.7.5), c
.
, LOOP.
,
:

IBM PC . 7 149

:
1
1:
,
,
3. ,
. 25
( ) .
4. .

" "
.
5. ,
,

. (, XLAT,
).
6.
, .
LEA,
SI DI, .
, .

(, B20:)
NEAR.
.
LOOP
-128 +127 .
. .
01 7F +1
+127, . FF 80 -1
+128. 1
4 , .

( 50 ).
LOOP,
CX . LOOP
,
.

IBM PC . 7 150
,
,
. , ,
, MOV,
. ,
, c
,
.

.
CALL,
- RET.
, , ,
, RET

. ,
- COM.

. :
MOV AX,SI
MOV AX,[SI]
MOV AX
SI. MOV

SI.

,

.

7.1.
p JMP, LOOP ?
? 7.2. JMP .
0624.
, .
JMP: ) 27, ) 6B, ) C6. 7.3. 12
: 1,
1, 2, 3, 5, 8, 13,... (

).
LOOP. ,
DEBUG .

IBM PC . 7 151
7.4. , AX BX
, a CX DX - .
CMP ( )
:
) DX , CX?
) BX , AX?
) CX ?
) ?
) BX , AX?
) DX , CX? 7.5.

?
a) ;
) ;
) ;
) ;
) . 7.6.
,
.7.4, BEGIN
RET? 7.7. PROC
p FAR NEAR? 7.8.

? 7.9. EXE- A10 B10, B10


C10, C10 D10. ,
DOS,
? 7.10. , BL 11100011
BOONO 01111001.
BL : ) XOR
BL,BOONO; ) AND BL,BOONO; ) OR BL,BOONO; ) XOR
BL,11111111B; ) AND BL,00000000B. 7.11. .7.6 : )

TITLEX ; )
. 7.12. , DX 10111001
10111001, p CL - 03.
DX : )
SHR DX,1; ) SHR DX,CL; ) SHL DX,CL; ) SHL DL,1;
) ROR DX,CL; ) ROR DL,CL; ) SAL DH,1. 7.13. ,
,
AX 10. 7.14. ,
"
",
DX:AX 2. : )
4; ) 4; ) 48
DX:AX:BX 2.

IBM PC . 8 172

8. I:
I:
: ,
.

, o
( )
. .
c ,
, . ,
, ASCII .
INT ().
( )
.
.

INT 10H, BIOS.
INT 21H,
DOS. ,
,
Return. p DOS INT 21H
BIOS.
(-, BW),
. 9 10
.
: INT

INT , DOS BIOS



.
.
INT :

IBM PC . 8 173
2
; TF IF;
2
CS ; 2
; ;

,
INT.
.
.
: BIOS INT 10H DOS
INT 21H .
INT 10H INT 21H.


. , ,
25 ( 0 24) 80 ( 0 79).
:
-------------------------------------------------------. .
-------------- -------------
------------------------------------------------------- 00 00 00 00
00 79 00 4F
12 39/40 00 27/28
24 00 18 00
24 79 18 4F
------------------------------------------------------- INT 10H .
5- 12- :
MOV AH,02 ;
MOV BH,00 ; 0
MOV DH,05 ; 05
MOV DL,12 ; 12
INT 10H ; BIOS

IBM PC . 8 174
02 AH INT 10H
. DX, (
) BH ( 0). .
MOV c
. :
MOV DX,050CH ; 5, 12


("")
. c , .

.
DX, 07 - BH 0600H AX.
:
MOV AX,0600H ;AH 06 ()
;AL 00 ( )
MOV BH,07 ; (/)
MOV CX,0000 ;
MOV DX,184FH ;
INT 10H ; BIOS
06 AH INT 10H
. ; ()
.
, . 184F,
. -
, .
: DOS


,
. , DOS,
p , DOS 2.0.
DOS , DOS
. DOS
, ,
.

IBM PC . 8 175
: DOS

DOS
, AH 09 ( DOS)
DOS INT 21H.
o ($), :
NAMPRMP DB ' ?','$'
.
.
MOV AH,09 ;
LEA DX,NAMPRMP ; .
INT 21H ; DOS
"$" c (
), : ' ?$', DB '$'.
, "$". ,
,
, "$" .
LEA NAMPRMP DX DOS
. NAMPRMP, DX LEA,
o , DOS
DS DX (DS:DX).
: ASCII

256 ASCII ,
. . 00 FF
, ASCII . 20.
. 8.1 COM-,
ASCII. ; B10CLR, C10SET D10DISP.
B10CLR , C10SET 00,00.
D10DISP CTR,
00 y 1 ,
. FF.

. 8.1. ASCII
. 08 . 0D
c,

IBM PC . 8 176
. : (.8.1),
, COM-.
, , :ASCII.COM.
(.00),
" " (. 01 02) (.03, 04 05). 07
. 06 "",
.08 0D . 0D " "
(). .0E -
. . 7F .
.
, . 08 0D.
, o , , . 08 ( ) 0D (
):
CMP CTR,08H ; 08?
JB D30 ; -
CMP CTR,0DH ; / 0D?
JBE D40 ; -
D30:
MOV AH,40H ; < 08
... ; > 0D
INT 21H
D40:
INC CTR
: DOS

, . ,
DOS, c ,
, INT. -,
.
, ;
, . -,
,
.
, .
LABEL BYTE.
. ,
- . FF 255. DOS
. ,
.
NAMEPAR LABEL BYTE ; :

IBM PC . 8 177
MAXLEN DB 20 ;
ACTLEN DB ? ;
NAMEFLD DB 20 DUP (' ') ;
LABEL , NAMEPAR
MAXLEN a . MASM
STRUC. ,
, , , ,
c 24 " ".
AH - 10 (.
0AH), (NAMEPAR ) DX
INT 21H:
MOV AH,0AH ;
LEA DX,NAMEPAR ;
INT 21H ; DOS
INT ,
, c ,
(20 ).
Return. (. 0D) (NAMEFLD
). , , BROWN (Return), c
:
.: |20| 5| | R| O| W| N| #| | | | | ...
.: |14|05|42|52|4F|57|4E|0D|20|20|20|20| ...
(ACTLEN )
- 05. Return NAMEFLD +5. #
, . 0D .
20 .0D,
19 .
:

EXE-, . 8.2, ,
.
, Return
. , TED SMITH:

. 8.2.

IBM PC . 8 178

1. 09 2 4,
2. 40, 36
SHR E10CENT 09 o ,
2. 00001001 00000100. NEG
+4 -4. ADD 40, DL
- 36. 12 36
:
12: TED SMITH
||
: 36 40
E10CODE , c
(07) :
MOV NAMEFLD[BX],07
BX , MOV
, BX NAMEFLD, 07.
, 05 07 NAMEFLD+05 (
Return). E10CODE
"$" 07. , F10CENT
, p .
Return
, ,
, o Return.
, Return, y
:
(.): |14|00|0D|...
Return
. p .
Return
, :
, , . , ,
Return (.0D) NAMEFLD
(.20). NAMELEN

IBM PC . 8 179
c 0D. , , NAMELEN
05, 0D NAMEFLD+5.
BX NAMEFLD:
MOV BH,00 ; BX
MOV BL,NAMELEN ; 0005
MOV NAMEFLD[BX],20H ; 0D
MOV (.20) , o
: NAMEFLD BX, .. NAMEFLD+5.

,
. :
NAMEPAR (.)
1. BROWN |14|05|42|52|4F|57|4E|0D|20|20|20| ... |20|
2. HAMILTON |14|08|48|41|4D|49|4C|54|4F|4E|0D| ... |20|
3. ADAMS |14|05|41|44|41|4D|53|0D|4F|4E|0D| ... |20|
HAMILTON BROWN. , ADAMS
HAMILTON, HAMIL. Return T.
- ON o ADAMS. NAMEFLD
:
MOV CX,20 ; 20
MOV SI,0000 ;
B30:
MOV NAMEFLD[si],20H ;
INC SI ;
LOOP B30 ;20
SI DI BX.
, , .
, NAMEFLD DB (),
, WORD, a
PTR (), :
MOV CX,10 ; 10
LEA SI,NAMEFLD ;
B30:
MOV WORD PTR[SI],2020H ;
INC SI ;
INC SI ;
LOOP B30 ;10

IBM PC . 8 180
MOV B30 ,
SI. p LEA
SI MOV 30,
, , :
MOV WORD PTR[NAMEFLD],2020H ;
,
. c ,
.
: DOS

, DOS 2.0 (
UNIX). DOS,
.
(file handle), y BX,
/. :
0 ( ) CON
1 ( ) CON
2 ( ) CON
3 / AUX
4 LPT1 PRN
DOS / - INT 21H,
AH: .3F - , .40 - . CX
/, DX - /.
/
(CF) AX , .
o CF, ( 6)
AX. AX ,
, - CF,
- .
o , o /
.
-
, p.
: DOS

IBM PC . 8 181

DOS:
DISAREA DB 20 DUP(' ') ;
...
MOV AH,40H ;
MOV BX,01 ;
MOV CX,20 ;
LEA DX,DISAREA ;
INT 21H ; DOS
LEA DX DISAREA DOS
, .
( ), AX
. , y
. CF (
6) AX. AX ,
, - CF.
:
DEBUG .
DEBUG A 100
( ) p 100. , DEBUG
, .
100 MOV AH,40
102 MOV BX,01
105 MOV CX, ( )
108 MOV DX,10E
10B INT 21
10D RET
10E DB ' '
AH . 10F
DX - DB, .
, Return. U (U
100,10D) . R T
. INT 21H BIOS,
10B GO (G 10D)
RET. . Q DOS.
: DOS

IBM PC . 8 182

,
DOS:
INAREA DB 20 DUP (' ') ;
MOV AH,3FH ;
MOV BX,00 ;
MOV CX,20 ;
LEA DX,INAREA ;
INT 21H ; DOS
LEA INAREA DX. INT
, c ,
CX (20
). Return ( . 0D) . ,
"PC Users Group" INAREA :
PC Users Group, .0D, .0A
(. 0D),
, (. 0A), .

p . c
,
.
CF ( )
AX , .
14 2 , ..16.

. YES NO,
p , , , .
, .
CF AX (6
). AX , ,
- CF.
, , y
CX, . , CX
08, "PC Exchange". "PC
Excha" . AX
08. INT
, , .
,

IBM PC . 8 183
"ng",
, AX 05.
CF .
INT: PC Excha AX = 08
INT: ng,0D,0A AX = 05
, ) AX
, CX ) AX CX ,
- 0D 0A.
DOS 0AH
. .
:
c
DEBUG. 12 ,
. DEBUG
A 100 , c 100.
, DEBUG , .
100 MOV AH,3F
102 MOV BX,00
105 MOV CX,0C
108 MOV DX,10F
10B INT 21
10D JMP 100
10F DB ' '
AH BX c ,
CX DX 10F -
DB . .
, Return. U 100,108
. R T
MOV. 10B, G 10D
INT ( BIOS ).
, Return. AX,
CF D 10F, .
Q.
,

IBM PC . 9 200

9. II:

II:
: , ,
, , - .

8
. ,
-
, , . (
BIOS 10) , , .
c-
.

4,
. B0000 ( ). :
- 2 (25 80 );
- 2 -, , ,
.
/
16
( ), .B8000.
( ASCII-) ,
- (BW) . p ,
0 3 80 c 0 7 40 .
- 0.
.

, , (
) . 8 :

IBM PC . 9 201

: BL R G B I R G B
: 7 6 5 4 3 2 1 0
RGB , (red), (green)
(blue) . 7 (BL) , 3 (I) .
, - (BW).
o:

RGB RGB
( ) 000 000
( ) 000 001
( ) 000 111
( ) 111 000
;
.
, , ,
:
.

0000 0000 00 ( )
0000 0111 07 ()
1000 0111 87 ()
0000 1111 0F ()
0111 0000 70 ()
1111 0000 F0 (. )
, ,
. , .
INT 10H. BL
-, AH : 06 ( ), 07
( ), 08 ( ), 09 ( ).
p , ,
. .00,
.
BIOS INT 10H

IBM PC . 9 202
INT 10H . AH
, . c
BX, CX, DX, SI BP. .
AH=00: .
. p
c INT 10H. .
AL :
00 40 25 -
01 40 25 i6-
02 80 25 -
03 80 25 16-
04 320 200 4-
05 320 200 -
06 640 200 -
07 80 25 -
08 - 0A PCjr
0D 320 200 16- (EGA)
0E 640 200 16- (EGA)
0F 640 350 - (EGA)
10 640 350 64- (EGA)
EGA (Enhanced Graphics Adapter) -
. 16-

MOV AH,00 ;
MOV AL,03 ; 80 25
INT 10H ; BIOS
, , BIOS INT
11H. AX , 5 4
:
01 40 25 -
10 80 25 -
11 80 25 - -
, , p
AX INT 11H .
AH=01: . ASCII-.
.
INT . p
. INT 10H,
: 4-0 CH

IBM PC . 9 203
, 4-0 CL - . p
: 0 13 EGA p 0 7
.
:
MOV AH,01 ;
MOV CH,00 ;
MOV CL,13 ;
INT 10H ; BIOS

.
, , 04/08, 03/10 .. ,
. 12/13 ( ) 6/7 ( )
.
AH=02: . c
c .
0, 0 3 80 .
AH 02, BH
DX :
MOV AH,02 ;
MOV BH,00 ; 0
MOV DH, ;
MOV DL, ;
INT 10H ; BIOS
AH=03: .
( ), p , :
MOV AH,03 ;
MOV BH,00 ; 0
INT 10H ; BIOS
DH , DL - .
CH c, CL - .
AH=04: . e
p.
AH=05: .
0 3. 40 25 8 ( 0
7), 80 25 - 4 ( 0 3).

IBM PC . 9 204

MOV AH,05 ;
MOV AL, ;
INT 10H ; BIOS
AH=06: .
, .
p , ,
.
.
06 .
AL 00 ,
. AL
. , .
:
MOV AX,0601H ;
MOV BH,07 ;: , -
MOV CX,0000 ; 00,00
MOV DX,184FH ; 24,79 ( )
INT 10H ; BIOS

AL. BH
, , .. CX
DX .
:
1. ROW () 0
.
2. .
3. ,
(CMP ROW,22).
4. , ROW (INC ROW) .
5. , ,
ROW .
AH=07: .
. AH 07,
p 06 .
AH=08: / .
, ,
:

IBM PC . 9 205
MOV AH,08 ; ./.
MOV BH,00 ; 0 ( .)
INT 10H ; BIOS
AL , AH - .
. 00 ASCII-.
c, .
AH=09: / .
, ..
:
MOV AH,09 ;
MOV AL, ;
MOV BH, ; (..)
MOV BL, ;
MOV CX, ;
INT 10H ; BIOS
AL . CX
.
. .
"" :
MOV AH,09 ;
MOV AL,03H ; ( )
MOV BH,00 ; 0 (. )
MOV BL,0F0H ;,
MOV CX,05 ;
INT 10H ; BIOS
( )
.
, CX 01
AL . CX
, LOOP. ,

( 02).
BL .
7 0, , 7 1,
XOR.
AH=0A: .
0A 09 , 0A :

IBM PC . 9 206

MOV AH,0AH ;
MOV AL, ;
MOV BH, ; ( )
MOV CX, ;
INT 10H ; BIOS
DOS INT 21H .
AH=0E: . ,
. AH
. 0E, p AL , (
) BL - BH.
( 07H), (08H), (0AH)
(0DH) , .
, c,
.
AH=0F: . AL
(. AH=00), p AH - (20, 40
80), BH - .
AH=13: ( AT).
AT
:
MOV AH,13H ;
MOV AL, ;0, 1, 2 3
MOV BH, ;
LEA BP, ; ES:BP
MOV CX, ;
MOV DX, ;
INT 10H ; BIOS
:
0 - ;
1 - ;
2 - , ;
3 - , .
: ,

IBM PC . 9 207
, . 9.1,
. ,
, 40
:
Name? Francis Bacon Francis Bacon []
||
0 40
ROW
( ) COL ( ).
INT 10H . ,
20- .
.
D10INPT DOS INT 21H.
BIOS INT 10H :
1.
. 2. INT 10H ( 08) 08 AH 00
BH. AL. 3. AL
RETURN
,
. 4. AL . 5.
AL RETURN,
. 6. . 7.
. 8. 2.
RETURN, .
ASCII

ASCII- 128 255 (. 80-FF)


, , .
, c :
.
DA
BF
C0
D9
C4
B3

IBM PC . 9 208

INT 10H 25
:
MOV AH,09 ;
MOV AL,0C4H ;
MOV BH,00 ; 0
MOV BL,0FH ;
MOV CX,25 ;25
MOV 10H ; BIOS
, . ,
. B3.
:
.
B0 ( )
B1 ( )
B2 ( )

. 9.1. ,
,
,
.
/ DOS

DOS, .
AH , , INT 21H.
AH=01: .
AL. AL ,
ASCII- c, , . AL
,
, , , F1 PgUp. - ,
(. " "
). Ctrl/Break.
AH=02: .
p DL. ,
.

IBM PC . 9 209

AH=07: .
01 : ,
.. , o Ctrl/Break.
AH=08: .
01 : , .. .
AH=0B: . .FF
AL, , - 00.
01, 07 08, .
BIOS INT 16H

BIOS INT 16H ,


AH .
AH=00: . AL o ASCII
, , AH. (-
).
, , F1, AL 00.
.
AH=01: .
(ZF=0), ; -
AL AH .
AH=02: .
AL . 417:

7 (Ins)
6 (Caps Lock)

5 (Num Lock)

4 (Scroll Lock)

3 Alt/Shift
2 Ctrl/Shift
1 Shift
0 Shift

IBM PC . 9 210

:
1. (-) : a
z, 0 9, %, $, # ..
2. : , End, ,
, Return, Del, Ins, PgUp, PgDn .
3. : Alt, Ctrl Shift,
.
- ,
.
- .
, ,
, End
.
.
- 1 (Esc) 83 (Del) .01
.53. -
. , 00
AH BIOS INT 16H:
MOV AH,00 ;
INT 16H ; BIOS
,
. (, A)
:
1. ASCII- A (.41) AL; 2. - A (.1E)
AH.
(, Ins)
:
1. AL; 2. - Ins (.52) AH.

IBM PC . 9 211
, INT 16H
AL. AL , ,
, . :
MOV AH,00 ;
INT 16H ; BIOS
CMP AL,00 ; ?
JZ exit ; -
-
. 9.2 - .
*, + -. "",
, .2A AL -
AH , : .09
8 .29 PrtSc.
- :
CMP AL,2AH ;?
JNE EXIT1 ; -
CMP AH,09H ; -?
JE EXIT2
-
Alt/A - Alt/Z 1E - 2C
F1 - F10 3B - 44
Home 47
48
PgUp 49
4B
4D
End 4F
50
PgDn 51
Ins 52
Del 53
. 9.2. -
0 c 0
(- 47):
MOV AH,00 ;
INT 16H ;

CMP AL,00 ; ?
JNE EXIT1 ; --
CMP AH,47H ;- Home?

IBM PC . 9 212
JNE EXIT2 ; --
MOV AH,02 ;
MOV BH,00 ;
MOV DX,00 ; 0,0
INT 10H ; BIOS
F1 - F10 - .3B .44.
F10:
CMP AH,44H ; F10?
JE EXIT1 ;
EXIT1 .
- BASIC.
IBM PC -,
Alt, Ctrl Shift.

4 , 2
2 .
16
- (BW) .
,
ASCII-,
. -
.
, .
RGB
, . BIOS INT 10H

: ,
, ,
. ,
,
.
,
. INT 10H,
, . BIOS INT 16H

.

IBM PC . 9 213
-,
1 (Esc) 83 (Del), .01
.53.
AL - AH.

AL - AH.

9.1. )
, ) , )
.
9.2. ) BW
(-) 80 , )
, 5
12 , ) 10 , )

(. B1).
9.3. -
: ) , ) F3, ) Home, )
PgUp.
9.4. DEBUG,
AX .
A 100
(Return). :
MOV AH,00
INT 16H
JMP 100
U 100,104,
G 104 MOV INT.
INT
.
AH . G
104, , ,
. Q.
9.5. :
PgDn,
- 24 0.

IBM PC . 10 228

10. III:
III:
: ,
.

.
p,
( p ):
1.
( ),
.
2. ,
,
.
.
3. RGB-,
- ,
.
, RGB-
.
(CGA - Color/Graphics
Adapter) 16 , .B8000, 8 -
8 . 8025
(0-3) 4 . 4025
(0-7) 2 .
( ).

.
(EGA - Enhanced Graphics Adapter)
,
(CGA) .
320200, 640200 640350 .
: (-)
, .
. 9
"p BIOS INT 10H"

IBM PC . 10 229
(AH=0).
BIOS INT 10H, :
MOV AH,00 ; MOV AH,00 ;
MOV AL,03 ;+ MOV AL,04 ;
INT 10H INT 10H ;
(-)


. - (BW)
, .
ASCII (256 ),
- (BW), .
16 .
16 .

, .
, , , .
, 16 :
IRGBIRGB
0 0 0 0 1 0 0 0
0 0 0 1 - 1 0 0 1
0 0 1 0 - 1 0 1 0
0 0 1 1 - 1 0 1 1
0 1 0 0 - 1 1 0 0
0 1 0 1 - 1 1 0 1
0 1 1 0 1 1 1 0
0 1 1 0 - 1 1 1 1
o 16 .
.
, . ,
.
-
, p 9.
, BL (BLinking), RGB -
, , I - :

IBM PC . 10 230
: BL R G B I R G B
: 7 6 5 4 3 2 1 0
.
:
: 7 6 5 4 3 2 1 0
BL R G B I R G B .
0 0 0 0 0 0 0 0 00
0 0 0 0 0 0 0 1 01
0 0 0 1 0 1 0 0 14
0 0 1 0 0 0 1 1 23
- 0 1 1 1 1 1 0 1 7D
, 1 0 1 0 1 0 0 0 A8
- - (BW) .
INT 11H. BW
07 .
. ,
. INT 10H
AH=06, AH=07 AH=09. , :
MOV AH,09 ;
MOV AL,'*' ;
MOV BH,00 ; 0
MOV BL,0DAH ;
MOV CX,05 ;
INT 10H ; BIOS


- (pixel). (CGA)
:
1. ( ROM)
100 160 (..
). 16
,
"".
Motorola 6845 CRT.
: .3D4 3D5.
2.
200 320 .
(..
).

IBM PC . 10 231
3. 200 640 .
16 ,
-
(BW) . 8
(.. ).
, - .
, ROM
128 ASCII-. INT 1FH 1 ,
128 . (8 ).
, , p.

, 0
3:
: |C1 C0|C1 C0|C1 C0|C1 C0|
: 0 1 2 3
, 0 3. 4
, 4 : 00, 01, 10
11. p 00 16
01, 10, 11 . p :
C1 C0 0 1
0 0
0 1
1 0
1 1
INT 10H. p, , ,
0, : ,
, . , 10101010,
. - 1, : ,
, . , 00011011, ,
, .
BIOS INT 10H

IBM PC . 10 232
AH=00 INT 10H . AH=11
INT 10H .
AH :
AH=00: . AH 04 p AL
:
MOV AH,00 ;
MOV AL,04 ; 320200
INT 10H
.
9.
AH=0BH: . BH
BL:
BH=00 p BL.
1 16 . o 0 F;
BH=01 BL (0 1):
MOV AH,0BH ;
MOV BH,01 ;
MOV BL,00 ; 0 (, , .)
INT 10H ; BIOS
, , , .
.
AH=0BH , , 0 ,
.
AH=0CH: . 0C AH
( ). ,
320200 DX ( 0 199), CX ( 0 319). AL ( 0 3):
MOV AH,0CH ;
MOV AL, ;
MOV CX, ;
MOV DX, ;
INT 10H ; BIOS
AH=0DH: .
. DX ( 0
199),

IBM PC . 10 233
CX - ( 0 319). AH 0D.
AL.

. 10.1 .
:

, .10.1, INT 10H


, (40 320
). 1 .
,
.
.
DOS MODE (MODE CO80)
COM , INT 10H.

16
().
80
40 .
(
ROM), (
) ( -
).
(
)

(, ).

(CGA) ,
16 ,
.

10.1.
(CGA) ?

IBM PC . 10 234
10.2. )
-, ) ,
) .
10.3. ,
, .
10.4.
"" -
.
10.5.
) 320200 CGA ) 640200
EGA.
10.6.
.
10.7. 12 13
.
10.8. .10.1 : )
; ) ; )
10 30; ) 20 300.

IBM PC . 11 241

11.

: ,
.

, , ,
. , ,
, . ,
, .
,
. :
MOVS
;
LODS AL
AX;
STOS AL AX ;
CMPS ,
;
SCAS AL AX
.
REP .

p
. , ""
""
. , (
). , DI SI
:

MOVS DI,SI MOVSB MOVSW
LODS AL,SI AX,SI LODSB LODSW

IBM PC . 11 242
STOS DI,AL DI,AX STOSB STOSW
CMPS SI,DI CMPSB CMPSW
SCAS DI,AL DI,AX SCASB SCASW
, MOVS, MOVSB
MOVSW. , p DI SI
, (
LEA). SI - DS:SI. DI
- ES:DI. ,
MOVS, STOS, CMPS SCAS ES (
DS).
REP:

,
, REP .
, , REP MOVSB.
REP CX.
REP 1 CX
. , .
:
- CLD
DF 0;
- STD
DF 1.
20 STRING1 STRING2.
, DS ES :
STRING1 DB 20 DUP('*')
STRING2 DB 20 DUP(' ')
...
CLD ; DF
MOV CX,20 ; 20
LEA DI,STRING2 ; ""
LEA SI,STRING1 ; ""
REP MOVSB ;
CMPS SCAS ,
.
REP .
REP - , CX 0;

IBM PC . 11 243
REPZ REPE - , ZF
" ".
ZF,
CX 0; REPNE REPNZ - ,
ZF
" ".
ZF,
" "
CX 0.
8086, 80286 80386, o ,
, ,
.
MOVS:

.7.5 .
. MOVS
REP CX
.
, , , p ES,
DI , .
DS, SI . ,
MOVS
ES DS,
DI SI. DF MOVS
1 ( ) 2 ( ) DI
SI.
, REP MOVSB:
JCXZ LABEL2
LABEL1: MOV AL,[SI]
MOV [DI],AL
INC/DEC DI ;
UNC/DEC SI ;
LOOP LABEL1
LABEL2: ...
. 11.1 C10MVSB MOVSB
NAME1 NAME2. CLD
0 .
DF CLD
.

IBM PC . 11 244
LEA SI DI NAME1
NAME2 . DS ES
DATASG, NAME1 NAME2 ES:DI DS:SI. (COM
ES DS). MOV
CX 10 - NAME1 NAME2. REP MOVSB
:
NAME1 (
p ES:DI) NAME2
( DS:SI). 1 DI SI
. CX 1. (
10
), CX
.
DF , MOVSB
DI SI, , ..
NAME1+1 NAME2+1 .. DF 1, MOVSB
DI SI, .
SI DI , ..
NAME1+9 NAME2+9 .
D10MVSW (.11.1) MOVSW,
. MOVSW DS SI
2, . SI
NAME1+8, DI - NAME2+8.
LODS:

LODS AL AX
. DS:SI. DF
SI.
LODS ,
REP . MOV LODS,
MOV , LODS - ,
SI. LODS ,
( ),
.
, LODSB:
MOV AL,[SI]
INC SI

IBM PC . 11 245
.11.1 E10LODS LODSW.
: NAME1 (
As) AL, - AH. AX
sA.
STOS:

STOS () AL AX
. ES:DI.
DF STOS DI 1
2 .
STOS REP -
, , . (
c) AX. , REP
STOSB:
JCXZ LABEL2
LABEL1: MOV [DI],AL
INC/DEC DI ;
LOOP LABEL1
LABEL2: ...
.11.1 F10STOS STOSW.
. 2020 () NAME3,
AL , AH - .
DI NAME3+10.
CMPS:

CMPS (
DS:SI) ( ES:DI). DF
CMPS SI DI 1
2 . CMPS AF, CF, OF, PF, SF ZF.
REP CX .
CMPS .

. 11.1. .
, JEAN JOAN.
:

IBM PC . 11 246

J : J
E : O (E O)
A : A
N : N
N:N - p/.
" ", , "
". REP REPE,
, , CX p .
:
REPE CMPSB
.11.1 G10CMPS CMPSB.
NAME1 NAME2.
MOVSB NAME1 NAME2,
CMPSB p/: SF
0 () ZF - 1().
NAME2 NAME3. STOSW
NAME3 , CMPB
"/": SF 0
() ZF - 0 ().
"/" 01 BH.
"" 02 BL.
DEBUG ,
G10CMPS BX 0102.
! CMPSB
. CMPSW
, p CX 5.
, CMPSW . ,
SAMUEL ARNOLD CMPSW SA AR
, .. AS RA. "" "", ..
. CMPSW ,
, DW, DD DQ.
SCAS:

SCAS CMPS , ()
. SCAS

IBM PC . 11 247
( p ES:DI) AL AX.
DF SCAS DI 1
2 . SCAS AF, CF, OF, PF, SF ZF.
REP CX SCAS
.
SCAS , , ,
, : , .
.11.1 H10SCAS NAME1 "m".
SCASB , - " "
CX , REPNE:
REPNE SCASB
NAME1 "Assemblers", SCASB
"m" . DEBUG
H10SCAS AH 03 ,
"m" . REP SCASB CX
10 06.
SCASW AX.
LODSW MOV AX,
, AL, - AH.
SCAS , o .


, ,
.
c STRING (&)
. SCASB & (
STRING+8), DI a
STRING+9. & DI
.
STRLEN EQU 15 ; STRING
STRING DB 'The time&is now'
...
CLD
MOV AL,'&' ;
MOV CX,STRLEN ; STRING
LEA DI,STRING ; STRING
REPNE SCASB ;

IBM PC . 11 248
JNZ K20 ; ?
DEC DI ; -
MOV BYTE PTR[DI],20H ;
K20: RET

MOVSB MOVSW
.
MOVS . , FLDA
FLDB (DB),
REP MOVS FLDA,FLDB
FLDB FLDA.
:
REP MOVS ES:BYTE PTR[DI],DS:[SI]
DI SI FLDA FLDB o .

STOS o
. , ,
MOVS . ,
:
***---***---***---***---***--- . . .
, ,
.
:
PATTERN DB '***---'
DISAREA DB 42 DUP(?)
.
.
CLD
MOV CX,21
LEA DI,DISAREA
LEA SI,PATTERN
REP MOVSW
MOVSW (**)
PATTERN DISAREA, - (*-), (--):

IBM PC . 11 249

***---***--||
PATTERN DISAREA
DI DISAREA+6, p SI - PATTERN+6,
DISAREA. MOVSW
, DISAREA DISAREA+6, DISAREA+2,
DISAREA+8, DISAREA+4 DISAREA+10 ..
DISAREA:
***---***---***---***---***--- . . . ***--||||
PATTERN DISAREA+6 DISAREA+12 DISAREA+42

.
.
:

COM-, .1.2, ,
. :
B10INPT 30 ,
. D10SCAS SCASB
, "". E10RGHT
MOVSB
,
. ACTNLEN

, :
JEROME KERN
OSCAR HAMMERSTEIN
RICHARD ROGERS
F10CLNM STOSW
.

.11.2. .

IBM PC . 11 250
MOVS, STOS, CMPS SCAS ES.
(CLD) (STD)
.
DI SI
. , MOVS
DI,SI, CMPS - SI,DI.
CX
, .
REP
MOVS STOS (REPE
REPNE) CMPS SCAS.

c CMPSW SCASW.

. ,
, NAME1 10 ,

, LEA,
NAME1+9.
- NAME1+8.

11.1. )
MOVSB, ) LODSB )STOSB REP.
)
MOVSW, ) LODSW ) STOSW REP.
11.2. ,
, .11.1.
ES. MOVSB
MOVSW .
H10SCAS NAME1 "mb".
DEBUG ,

.
11.3. :
DATASG SEGMENT PARA
CONAME DB 'SPACE EXPLORERS INC.'
PRLINE DB 20 DUP(' ')
, :
) CONAME PRLINE ;

IBM PC . 11 251
) CONAME PRLINE ;
)
CONAME AX;
) AX
PRLINE+5;
) CONAME PRLINE (
);
) CONAME PRLINE,
. ,
BH.
11.4. H10SCAS (.11.1) ,
NAME1 "er".
, "er"
NAME1 : /As/se/mb/le/rs/.
:
) SCASW ,
NAME1, -
NAME1+1;
) SCASB ""
"r".
11.5. , . 03, 04, 05
B4. 20
.

IBM PC . 12 262

12. I:

I:
: , ,
.

, ( 10),
( 2). , ,
16- ,
.
, ,
.
.

ASCII .

ADD SUB ,
.
:
1, CX . , ,
.
. 12.1 ADD SUB,
. B10ADD ADD ,
C10SUB SUB . :
/ -;
/ -;
/ -;
/ -.;
/ -..

. 12.1 ADD SUB.


- , o
. WORDB

WORDA, DW:

IBM PC . 12 263

MOV AX,WORDA
ADD AX,WORDB
MOV WORDB,AX

.
, .. -128 +127.
. ,
AL, , AH.
, AL .60,
ADD AL,20H
AL - .80.
"". , .80
1000 0000 . .. , +128,
-128. AL
AX. CBW (Convert Byte to Word ) .60 AL .0060 AX,
(0) AH. ADD
AX : .0080, +128:
CBW ; AL AX
ADD AX,20H ; AX
: 15 ,
-32768 +32767.
, .

+32767
.
. - , , - ,
.

. 12.2. .

IBM PC . 12 264
.12.2 D10DWD
(WORD1A WORD1B) (WORD2A
WORD2B) (WORD3A WORD3B).
:
WORD1B BC62
WORD2B 553A
: 1119C
- .1119C AX.
1. , ,
ADD ADC (ADd with Carry).
, CF ,
1:
WORD1A 0123
WORD2A 0012
1
: 0136
DEBUG
0136 AX, p 3601 WORD3A 9C11
WORD3B.
.12.2 E10DWD
. .
c, - , .
SI, DI BX 2. DEC
.
SUB reg,02
, .. ,
.
, ADC.
CLC (CLear Carry - )
. : 1) , 2)
3) CX .
SBB (SuBtract with Borrow ) ADC. E10DWD (.12.2)
ADC SBB, .

IBM PC . 12 265
, , , a .
, , ,
, . ,
. ,
, , .

+32767 +65535.
. ADD SUB
, .
, .
249, -7:

11111001 249 -7
00000010 2 +2
11111011 251 -5
.
, +251 -5 . ,
.
"" , p .
"" ,
CX
. ,
:
CF OF
11111100 252 -4
00000101 5 +5
00000001 1 1 1 0
()
,
:
CF OF
01111001 121 +121
00001011 11 +11
10000100 132 -124 0 1
()
,
:

IBM PC . 12 266

CF OF
11110110 246 -10
10001001 137 -119
01111111 127 +127 1 1
() ()

MUL,
- IMUL (Integer MULtiplication - ).

. :
" ". AL,
. AX.
p , AH.
| AH | AL | | AX |
:| || :||
" ". AX, -
. ,
: () DX,
() AX. ,
DX.
| AX | | DX || AX |
:|| : |.||.|
| |
MUL IMUL .
:
MUL MULTR
MULTR (DB),
AL MULTR. MULTR
(DW), AX
MULTR. ,
, :
MUL CL ;-: AL, . AX
MUL BX ;-: AX, . DX:AX

IBM PC . 12 267

: MUL
MUL (MULtiplication - ) . . 12.3
C10MUL : ,
. MUL .80 (128) .47 (64). .2000 (8192) AX.

. 12.3. .
MUL . 10000000 p DX:AX.
MUL
BYTE1 . ,
AH . ( CBW
p AL 0 1). - . 00400000
DX:AX.
: IMUL
IMUL (Integer MULtiplication - )
. . 12.3 D10IMUL ,
C10MUL, MUL IMUL.
IMUL .80 ( ) .40
( ). - .E000 AX.
, MUL .2000,
MUL IMUL. MUL .80 +128,
IMUL - -128. -128 +64 -8192
.E000. ( .000 ).
IMUL .8000 ( )
.2000 ( ). - .F0000000
DX:AX o .
IMUL BYTE1
AX. ,
CBW AH: .80
p AL .FF80 AX.
WORD1 ,
. : .00400000

IBM PC . 12 268
DX:AX - , MUL,
.
, ,
MUL IMUL . ,
, MUL ,
IMUL - .
, DEBUG .
: 2 (2,4,8 ..)
. 1
CL. ,
AL AX:
2: SHL AL,1
8: MOV CL,3
SHL AX,CL

: " " " ".
, +32767.
.

. :
1365
12
2730
1365
16380
, .
13 65 12 , c :
13 65
12 12
26 130
13 65
156 780
, 13
, 15600:
15600

IBM PC . 12 269
+780
16380
,
( ) .
. E10XMUL .12.4
. , MULTCND, ,
. 3206 . 2521. (DW)
(DD) MOV,
AX. MULTPLR . 6400.
, PRODUCT, . MUL
MULTPLR c MULTCND; - . 0E80 E400
PRODUCT+2 PRODUCT+4. MUL MULTPLR
MULTCND, . 138A 5800.
:
1: 0000 0E80 E400
2: 138A 5800
: 138A 6680 E400
ADD , c
ADC (ADd with Carry).
p 8086/8088, PRODUCT
8A13 8066 00E4. ,
PRODUCT 0000.

.12.4. .
" ".
:

2 2
2 1
1 2
1 1
DX AX
. F10XMUL
. 12.4.

IBM PC . 12 270
MULTCND . 3206 2521, MULTPLR - . 6400 0A26.
PRODUCT, .
,
, ADD/ADC
ADC, 0 PRODUCT. ,
ADC ,
. ADC 0, , 1,
. ADD/ADC
ADC, PRODUCT
.
138A 687C 8E5C CCE6 PRODUCT
. DEBUG.
DX:AX

p
DX:AX . ,
(, , )
CX. ,
.
4
MOV CX,04 ; 4
C20: SHL DX,1 ; DX 1
SHL AX,1 ; AX 1
ADC DX,00 ;
LOOP C20 ;
4
MOV CX,04 ; 4
D20: SHR AX,1 ; AX 1
SHR DX,1 ; DX 1
JNC D30 ; ,
OR AH,10000000B ; 1 AH
D30: LOOP D20 ;
,
. CL.
4 , :
MOV CL,04 ;
SHL DX,CL ; DX 4
MOV BL,AH ; AH BL
SHL AX,CL ; AX 4
SHL BL,CL ; BL 4

IBM PC . 12 271
OR DL,BL ; 4 BL DL

DIV, a IDIV. .
:
" ". AX, -
. AH, -
AL. ( +255 (.FF)
+127 (.7F) ),
.
| AX | | AH | AL |
: | | : |||
" ". DX:AX,
- . DX,
AX. +32767
(.FFFF) +16383 (.7FFF) .
| DX || AX | | AH || AL |
:|.||.| :||||
| |
DIV IDIV .
:
DIV DIVISOR
DIVISOR (DB),
. DIVISOR (DW),
.
, , 13 3, 4 1/3. 4, - 1.
, ( BASIC)
4,333.... (4) (,333). 1/3
333... , 1 .
: DIV
DIV . .12.5 D10DIV
: , , .

IBM PC . 12 272
DIV .2000 (8092) .80 (128).
00 AH, .40 (64) - AL.
DIV BYTE1
. ,
AH . - . 12 AH,
.05 - AL.
DIV . 1000 DX
. 0080 AX.
DIV WORD1
DX. .0000 DX,
. 0002 - AX.

.15.5. .
: IDIV
IDIV (Integer DIVide) . .12.5
E10IDIV , D10DIV,
DIV IDIV. IDIV
.2000 ( ) .80 ( ). . 00 AH , - . C0 (-64) - AL. DIV,
, +64.
:
IDIV
2 EE (-18) FB (-5)
3 1000 (4096) 0080 (128)
4 0000 0002
4 , DIV.
, , DIV IDIV
p. ,
, DIV , IDIV -
. , DEBUG
.
. 2 (2, 4, ..)
.
, AX:
2: SHR AX,1

IBM PC . 12 273
8: MOV CL,3
SHR AX,CL

DIV IDIV, p.
( ,
) . ,
, . .
1 , ,
.
: - ,
, (AH) : - ,
, (DX) .
, 1:
:
: 0123 01 (1)23
: 0001 4026 0001 (1)4026
.
, DIV IDIV .
p , DIVBYTE - ,
AX. , DIVWORD , DX:AX.

CMP AH,DIVBYTE CMP DX,DIVWORD
JNB JNB
DIV DIVBYTE DIV DIVWORD
IDIV , ,
, ,
NEG
.

,
. ,
1. ,
. c , AX, - BX,
CX:

IBM PC . 12 274
SUB CX,CX ;
C20: CMP AX,BX ; < ,
JB C30 ;
SUB AX,BX ;
INC CX ;
JMP C20 ;
30: RET ; CX, AX
CX , AX - o.
.
DX:AX, :
1. C20 AX BX DX.
2. SUB SBB DX,00.
: .

NEG
. NEG
1. :
NEG AX
NEG BL
NEG BINAMT ( )
35- ( ) .
, DX:AX 32- .
NEG ,
.
NOT:
NOT DX ;
NOT AX ;
ADD AX,1 ; 1 AX
ADC DX,0 ; DX
: ,
, ,
. , ,
. , , ASCII-. ASCII ,
. .

IBM PC . 12 275
INTEL 8087 80287

,
Intel 8087 ( 80287). 8087 8088,
80287 80286.
,
. 80-
, 10 400
. 100
, .

, .
MASM, /E /R,
, MASM /R.


p.
-128 +127.
ADC
.
, CLC,
0.
MUL DIV
IMUL IDIV .
.
,
. ,
AH ( ) DX ( ).

c. SHR
SAR .
SHL SAL.
.
, FACTOR (DB),
MUL FACTOR AL,
DIV FACTOR AX.
FACTOR (DW), MUL
FACTOR AX, DIV
FACTOR DX:AX.

IBM PC . 12 276

:
DATAX DW 0148H
DW 2316H
DATAY DW 0237H
DW 4052H
12.1. ) DATAX
DATAY; ) ,
DATAX, DATAY.
12.2. :
STC
MOV BX,DATAX
ADC BX,DATAY
12.3. (MUL): )
DATAX DATAY; ) ,
DATAX, DATAY.
12.4. , ,
?
12.5. (DIV): ) DATAX
23; ) ,
DATAX, DATAY.
12.6. "
DX:AX"
.
.

IBM PC . 13 1

13. II:
II: ASCII BCD
: ASCII BCD
.

a
. 12,
, .
ASCII
c .
ASCII. , 23 00010111 .17;
ASCII c 25 ASCII- p
.3235.
- ASCII-

ASCII- . ,
, p 1
12.
, BASIC Pascal,
()
. , ()
.
( ) (),
.
ASCII-

, , ASCII-, , SAM
53414D, 1234 - . 31323334.
, , ,
.
, . 31323334, .

ASCII-:

IBM PC . 13 2
AAA (ASCII Adjust for Addition ASCII-)
AAD (ASCII Adjust for Division ASCII-)
AAM (ASCII Adjust for Multiplication ASCII-)
AAS (ASCII Adjust for Subtraction ASCII-)

AX. , ASCII
, ,
.
ASCII-
8 4 ASCII-:
. 38
34
. 6C
ASCII-, . ,
6 6 .C: .C + 6 = .12 -
. ,
, AAA .
, , AX . 0038, BX .0034. 38 34 ASCII ,
. :
ADD AL,BL ; 34 38
AAA ; ASCII
AAA . (4 ) AL.
A F AF 1, AL 6,
AH 1, AF CF 1. AAA
0 . AL. - AX:
ADD: 006C
AAA: 0102
, ASCII- ,
. :
OR AX,3030H ; 3132

IBM PC . 13 3
.
ASCII- ,
. , .13.1
ASCII- . :
ADC,
,
() . CLC
CF .

. 13.1. ASCII-.
MOV AH ,
AAA .
ADC p. ,
XOR SUB o AH
CF. ,
p AH (00 01)
. 01020702.
OR AAA
,
CF, p ADC.

PUSHF,
OR, , ,
POPF:
ADC AL,[DI] ;
AAA ; ASCII
PUSHF ;
OR AL,30H ;
POPF ;
MOV [BX],AL ;
PUSHF POPF LAHF (Load AH with Flags AH) SAHF (Store AH in Flag register -
AH ). LAHF AH SF, ZF, AF, PF CF;
SAHF AH .
, , AH .
ASCII- -
OR .
ASCII-

IBM PC . 13 4
AAS (ASCII Adjust for Subtraction - ASCII-)
a AAA. AAS . (
) AL. A F AF 1,
AL 6, AH 1, AF CF 1.
AAS 0 . p AL.
, ASC1 .38,
ASC2 - .34:
1: AX AF
MOV AL,ASC1 ;0038
SUB AL,ASC2 ;0034 0
AAS ;0004 0
2: AX AF
MOV AL,ASC2 ;0034
SUB AL,ASC1 ;00FC 1
AAS ;FF06 1
1 AAS . 2,
AL .C, AAS 6 AL 1
AH 1 AF CF. ( -4)
. FF06, .. -4.
ASCII-
AAM (ASCII Adjust for Multiplication - ASCII )
ASCII AX. , .

ASCII-. ( IBM
p ). , ASCII-
31323334 01020304. ,
, ,
o- ;
.
AAM AL 10 (. 0A)
AH, AL. , AL . 35,
CL - .39. AL
CL ASCII-:
AX:
AND CL,0FH ; CL 09
AND AL,0FH ; AL 05 0005
MUL CL ; AL CL 002D

IBM PC . 13 5
AAM ; .. 0405
OR AX,3030H ; ASCII-- 3435
MUL 45 (.002D) AX, AAM
10, 04 AH 05 AL. OR
p ASCII-.
.13.2 - . AAM
, , .
- 0108090105.
, ,
. ASCII (. " ASCII-
").

.13.2. ASCII-.
ASCII-
AAD (ASCII Adjust for Division - ASCII-)
ASCII . ,
ASCII-
. AAD AX.
, AX 3238 ASCII- CL
37 ASCII- .
:
AX:
AND CL,0FH ; CL ..
AND AX,0F0FH ; AX .. 0208
AAD ; 001C
DIV CL ; 7 0004
AAD AH 10 (.0A), p 20 (.14)
AL AH. 001C .
28. 01 09.
. 13.3.
. .
AH AAD AL.
p: 00090204 AH 02.

IBM PC . 13 6
,
, "
ASCII- ."
- (BCD)

ASCII- 00090204.
, , 0924.
- (BCD - Binary Coded Decimal) ( ).
0 9. -
ASCII-.

.13.3. ASCII-.
, , 0924 10 ,
16 (.. . ), .039C.
-
(BCD-). p :
DAA (Decimal Adjustment for Addition )
DAS (Decimal Adjustment for Subtraction )
.
, . 13.4, ASCII-
BCD- . B10CONV ASCII BCD.
, . ,
, , BCD-
ASCII-. ASCII.
C10ADD BCD-.
- 127263.
ASCII-

b ASCII BCD
.
.

IBM PC . 13 7
ASCII- ,
ASCII- BCD- , , :
, ASCII- 10,
2.
:
1. ASCII-
. 2. . ASCII. 3. ASCII- 1, 10, 100 (.1, A, 64)
.. .
1234 ASCII-
:

41=44
3 10 = 30 1E
2 100 = 200 C8
1 1000 = 1000 3E8
: 04D2

. 13.4. BCD- .
, .04D2 1234. . 13.5.
B10ASBI ASCII- 1234 .
, ASCII- 4 ASCLEN.
ASCII- ASCVAL-1 SI, - BX.
B20 ASCII- AL:
MOV AL,[SI+BX]
ASCVAL-1 BX (4), ..
ASCVAL+3 ( ASCVAL). BX
1, .
BX, CX, , ,
LOOP. MULT10 10,
1,10,100 .. , ,
SI DI.
ASCII-

IBM PC . 13 8

, p,
ASCII-.
. 10
(. 0A) 10. , 0 9,
ASCII-. .4D2
:

4D2 : A 7B 4
7B : A C 3
C:A12
1 , .A, .
ASCII-, 1234.
, .. 31323334.
. 13.5. C10BIAS . 4D2 (
B10ASBI) ASCII- 1234. (.13.5.)
p .

.13.5. ASCII .

.
12,345, 5
:
: 12,345
5: +5
: 12,350 = 12,35
12,3455, 50
. 12,34555 500
:
12,3455 12,34555
+50 +500
12,3505 = 12,35 12,35055 = 12,35
, , 5000
..

IBM PC . 13 9
, 12345 .3039. 5 3039, 303E,
12350 . .
.181F, 1675 - ..
. ,
. 10 (.A):
.303E : .A = 4D3 .1235
.4D3 ASCII- 1235. o
12,35,
.
.
5 10, :
50 p 100. : (5, 50,
500 ..) (10, 100, 1000 ..).
, p.
:

, .13.6,
p
. .
:
B10INPT
.
. D10HOUR ASCII
. E10RATE
ASCII . F10MULT , .



. ,

, , , ,
. G10WAGE ,
ASCII

ASCII-.

IBM PC . 13 10
K10DISP
. M10ASBI ASCII (
)
.

.13.6. .
. , .13.6, c ,
. -
, , 10, a
ASCII- 10.

655350, .

.
. , ,
, ,
.
0 9 .

. XLAT
(. 14).
: ,
, .

.
, , 12,34-, -12,34.
.
,
.
ASCII .
, ,
, , ASCII- ,
, 12 " ".

IBM PC . 13 11
IMUL IDIV .
, 5.

ASCII- .
0 9,

.
.
ASCII-
AAA; ASCII- -
AAS.
ASCII-,
"
" ,
.
AAM.
ASCII-, : 1)
"
" ,
2)
AAD.

ASCII-
.
ASCII-: .30
.39, ()
, , .

13.1. , AX 9 ASCII ,
BX -7 ASCII .
:
) ADD AX,33H ) ADD AX,BX
AAA AAA
) SUB AX,BX ) SUB AX,0DH
AAS AAS
13.2. UNPAK . 01040705
. ,
ASCII-, .. 31343735.

IBM PC . 13 12
13.3. ASCA 313733 ASCII-,
ASCB 35.
ASCII-
ASCPRO.
13.4. 13.3, ASCA
ASCB ASCQUO.
13.5. : )
ASCII 46328
.; )
. ASCII-.
13.6. ,
(INT 12H - ..2),
ASCII-
:
nnn .

IBM PC . 14 24

14.

: ,
.

,
, , , .
- XLAT. , -
, .
.
.
.

, ..
( ),
.
, - ,
64- :
STACK DW 64 DUP(?)
:
MONTAB DB 'JAN','FEB','MAR', ... ,'DEC'
COSTAB DB 205,208,209,212,215,224,...
MONTAB , COSTAB -
. (
).
( ) ( ),
() . , "Paper"
9 . ,
. .

IBM PC . 14 25
STOKTBL DB 12,'Computers',14,'Paper....',17,'Diskettes'
:
STOKTBL DB 12, 'Computers'
DB 14, 'Paper....'
DB 17, 'Diskettes'
.

, - 03
March.
,
. - September,
:
MONTBL DB 'January..'
DB 'February.'
DB 'March....'
9 . 'January' - MONTBL+0,
'February' - MONTBL+9, 'March' - MONTBL+18. 03,
:
1. ASCII 33
03. 2. : 03 - 1 = 02 3.
(9): 02 9 = 18 4. (18) MONTBL;
:
MONTBL+18.

. 14.1. .
.14.1 .
- .
MONIN. ,
ASCII- MONIN.
.
p
, .

IBM PC . 14 26
,
. ,
: 1, 2, 3,... 106, 107, 108,... 5, 10,
15. , .
, .

, .
- ,
, 134, 138, 141, 239 245.
, .
.

.
, , ,
, . ,
.
(, , ).
, :
STOKNOS DB '101','107','109',...
STOKDCR DB 'Excavators','Processors','Assemblers',...
, :
STOKTAB DB '101','Excavators'
DB '107','Processors'
DB '109','Assemblers'
...
.14.2 .
.
STOKNIN .
,
. , (A30)
DESCRN.

, ,
.

IBM PC . 14 27
, ,
STOKNIN AX. STOKNIN 3233,
MOV AX 3332.
, MOV
XCHG, AX,
, .. 3233. CMP, ,
, - . , p
, .
XCHG,
MOV, , BX AX
BX :
MOV AX,STOKNIN
LEA SI,STOKTAB
C20:
MOV BX,[SI]
CMP AX,BX
JA JB ...
.
,
( )
.
. 14.2
. o
. ,
REPE CMPSB, p CX.

.
, o ,
:
-
0-1000.00 10 0,00
1000,01-2500,00 15 050,00
2500,01-4250,00 18 125,00
4250,01-6000,00 20 260,00
6000,01 23 390,00

IBM PC . 14 28

.
:
TAXTBL DD 100000,250000,425000,600000,999999
, x
:
,
; ,
.
:
: 100 - -

,
REPE CMPS. ,
(.14.2) . STOKNIN
, STOKTAB - , c :
: |123|035Excavators|038Lifters |049Presses | ...
| | | | | | | : 00 03 06 16 19 29 32
.14.3 STOKTAB, '999'
.
STOKNIN:
STOKNIN
035 123 : .-
038 123 : .-
049 123 : .-
102 123 : .-
123 123 :
, CMPSB .14.3 ,
p SI DI.

.14.3. CMPSB

IBM PC . 14 29
CX 03,
SI DI 03 00 .
(035:123) , SI
04, DI: 01, CX: 02. SI 16, DI: 00.
DI STOKNIN.
, SI, ,
(, ) .
CX , , - 02.
SI CX ,
:
SI CMPSB 04
CX 02
10
. 16
CX , (
), : 1, 2 3 .
, CX 00,
p SI .

, .
, ,
.00; p .FF.
,
. ,
. SCAS.
XLAT

XLAT
. XLAT
.
(IBM) XLAT
ASCII EBCDIC.
0 9 ASCII
EBCDIC. ASCII .30-39, EBCDIC .F0-F9, OR. ,
ASCII (.40)

IBM PC . 14 30
EBCDIC. XLAT ,
256 , EBCDIC ASCII :
XLTBL DB 47 DUP(40H) ; EBCDIC
DB 0F0H,0F1H,0F2H,0F3H,...,0F9H ;0-9 (EBCDIC)
DB 199 DUP(40H) ; EBCDIC
XLAT BX,
(, ASCNO) AL.
:
LEA BX,XLTBL
MOV AL,ASCNO
XLAT
XLAT AL a
, .. BX AL. , , ASCNO 00,
XLTBL+00 XLAT 00 .40
. ASCNO c .32,
XLTBL+50. .F2 (2 EBCDIC), XLAT
AL.

.14.4. ASCII EBCDIC.


.14.4 (2E)
(2D) ASCII EBCDIC (4B 60 ).
. ASCNO
31.5 , .2D33312E3520.
EBCNO . 60F3F14BF540.
: . ASCII-

, .14.5, ASCII-,
.. , ASCII- .53 - S,
53 S.
1616:
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
................
................
................
F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF

IBM PC . 14 31

.14.5. . ASCII-
.8.1, ASCII- , o
. . ASCII,
. , ASCII . 00, 01 ..
.00 . 3030, .01 .3031 ..
HEXCTR 00.
1. C10HEX HEXCTR ..
, HEXCTR . 4F.
. 4 XLATAB.
AL .34.
. F .46. o .3446,
4F.
DOS (.40) .1A
, . ,
DOS (.09), '$' .
. ASCII-.
.
:


. ,
.
, ,
. ,
, ,
.
, ,
. , ,
. ,
,
. , .
. ,
. 1 2, 2 3 ..

IBM PC . 14 32
, .
, ..
1-2, 2-3 .. ,
.
, SWAP :
(YES) (NO):
G10:
G20: SWAP=NO

G30: > ?
:
SWAP=YES

?
: G30
: SWAP=YES?
: G20 ( .)
:
, .14.6, 30 ,

.

.14.6. .
,

,
. ,
( ) , .
TYPE (), LENGTH () SIZE ()
.
:
TABLEX DW 10 DUP(?) ; 10
TYPE (DW ),
LENGTH DUP- (10) SIZE
(10 2 = 20). :
MOV AX,TYPE TABLEX ;AX=0002
MOV BX,LENGTH TABLEX ;BX=000A (10)
MOV CX,SIZE TABLEX ;CX=0014 (20)

IBM PC . 14 33

LENGTH SIZE
. , SI
, :
CMP SI,SIZE TABLEX
23 " "
TYPE, LENGTH SIZE.

, ,

.
. ,

, .
: , ,
p,
.

3, - 2.
,
, 2 (SHL
),
. (
-1).
, DB ,
256, DW
. CMP CMPSW ,

.
,
,
.
.


.

. ,

.

IBM PC . 14 34
14.1. ,
, .
14.2 , 1,
,
14.1. .
14.3 ,
:
) : 06, 10, 14, 21, 24;
) : , ,
, , ;
) : 93.95, 82.25, 90.67, 85.80, 13.85.
14.4 ,
(ITEMIN) (QTYIN) .
14.3,
ITEMIN.
.
( )
.
14.5 14.3,
: )
() ; )
.

IBM PC . 15 45

15. I:
I:
: ()
, .


. ()
(), ,
.
. c
5 1/4 40 , 00
39. 512 .
, ,
. , ,
- ,
, .
.
. o
. , , ,
, .
:
+--+---+-----++--+---+-----++--+---+-----+ +--+---+-----+
|1||||2||||3|||...|n||| +--+---+-----++--+---+-----++--+--+-----+ +--+---+-----+

. ,
5 1/4" .

IBM PC . 15 46


DOS 2.0 40 8 512 327 680 DOS 2.0 40 9 512 368 640 80 15 512 1
228 800 3 1/2" 80 9 512 737 280
:

4-

10 306 17 512 10 653 696 20 614 17 512 21.377.024
(), .
0, - 1.
()

, , DOS
.
.
:

0 0 1
0 0 2-3 (FAT)
0 0 4-7
1 0 1-3
1 0 4 ...
1- 0-
. 0- 1-
p, 1- 1- , 0- 2- ..

. ,
.
FORMAT /S , DOS
IBMBIO.COM IBMDOS.COM .

IBM PC . 15 47
, 512 ( 512), .
DOS p .
, , .
:

0-7 , ,
.
: .00 ,
, .E5 - , . 2E . 8-10 11 , :
.00 - ;
.01 - ;
.02 - "" ;
.04 - DOS;
.08 - ;
.10 - ;
.20 - ( ). 12-21 DOS. 22-23
,
, :
||
24-25 ,
:
|||
1980
0 119, - 1 12, - 1 31. 26-27 .

.
( COM- DOS)
002. ,
. 28-31 . DOS
.
, ,
.

(FAT - File Allocation Table) -


.
, DOS

IBM PC . 15 48
.
1, 2 FAT. FAT ,
FAT .
, - .
FAT p
, .
FAT :
FE 8
FC 9
FF 8
FD 9
F9 (1,2 )
F8
FFFF.
(
). "" :
FAT
..
, 8 1 2-3 4-7 1
, 9 1 2-5 6-9 1
, 8 1 2-3 4-10 2
, 9 1 2-5 6-12 2
(1,2 ) 1 2-15 16-29 1
XT 1 2-17 18-49 8
AT 1 2-838 4-115 4
, FAT .
12 . ( DOS 3 FAT
16 ). FAT, 000
001, , ,
. 002.
FAT . (12 ),
:
000 ,
nnn ,
FF7 ( ),
FFF .
, ,
PAYROLL.ASM, 002, 003 004.

IBM PC . 15 49
PAYROLL, - ASM, .00 , , 002 -
. FAT
( ,
):
FAT: |FDF|FFF|003|004|FFF|000|000|...|000|
.: 0 1 2 3 4 5 6 ...
FAT
000 001. ,
:
1. DOS
PAYROLL ASM. 2. DOS
(002)

. 3. DOS FAT,
002.
, , ,
003. ,
003. DOS
. 4. DOS
FAT,
003.
004,
004. DOS
. 5. FAT
004
.FFF, ,
.
, FAT . ,
, . , , ,
, FAT .FFF ,
.
, ,
15.
FAT :
15 1,5, 22,5. 22 23
FAT.
, F*FF. : FFF*.

IBM PC . 15 50
15-, - FFF

.
, , 15.
FAT, 22 , p
p:
6* 01 17 80 01 FF*F
, FAT, 15 1,5, 22,5,
22 23, .
6*01, 016*. 15- ,
016. , ,
016.
, , 16 1,5 24.
24 25 FAT. 1780
8017. 16 , 017.
017.
, , 17 1,5, 25.5.
25 26 FAT. 8001
0180. 17 ,
018. 018.

FAT 27 28, FF*F,
*FFF. 18 , FFF,
.
, p. ,
,
.
,
FAT , , ,
DOS 1BH 1CH.


. ()
, , , , ,
p .

IBM PC . 15 51
(FAT)
p .

15.1. ?
15.2. ?
15.3. ?
15.4.
DOS FORMAT /S?
15.5. FAT,
?
15.6. 2890 () : )
c ? )
? )
, .

IBM PC . 16. 1

16. II:
DOS
II: DOS
: DOS
.

DOS,
(FCB),
.
DOS .
DOS
(FCB - file control block), .
FCB DOS -.
.
.
, "" DOS
. ,
"" , , DOS .
, "" , .
,
,
.
, ,
"" "" , DOS 21H.
, ,
DOS, 25H 26H.
BIOS 13H,
. DOS
BIOS. 17
DOS 2, 18
BIOS. :
.
(FCB)
- DOS
FCB. FCB ,

IBM PC . 16. 2
. FCB .
0-15 32-36, 16-31
DOS.
0 : 01 A, 02 B
.. 1-8 ,
, 8 .
, ,
LPT1 . 9-11 ,
, DTA ASM.
,
. DOS
. 12-13 . 128 .

(
32). 0, - 1
..
0. 14-15 .
128 (.80).


. 16-19 . DOS

(
) .

.
, . 20-21 .

DOS .

. 22-31 DOS. 32 .

(-127) (.
12-13).
.
- 0,

0 127. 33-36 .


.
, 25
(.19),
19000000.
,

IBM PC . 16. 3
.
(1.073.741.824 ),

.
64, 36
00.
,
.
FCB ,
.
.FF, - ,
..
FCB

. -
FCB DX. FCB
DS:DX.
.16 DOS INT 21H :
MOV AH,16H ;
LEA DX,FCBname ;
INT 21H ; DOS
DOS ,
FCB, . , ( ),
, DOS ,
, DOS .
0 "" .
, AL:
00
FF .
FCB - 0
( ) - 128 (.80) . , ,
.

(DTA - disk trausfer area). FCB
, DTA .
.1A

IBM PC . 16. 4
DOS DTA. DTA.
DTA:
MOV AH,1AH ;
LEA DX,DTAname ; DTA
INT 21H ; DOS
,
DTA .
DTA
.
. 15:
MOV AH,15 ;
LEA DX,FCBname ;
INT 21H ; DOS
FCB DTA.
, .
. ,
128 ,
(4*128=512) .
DOS FCB
1. 128,
0 FCB 1.
AL :
00 .
01 .
02 DTA .
, , ,
(.1A). .10:
MOV AH,10H ;
LEA DX,FCBname ;
INT 21H ; DOS
, DOS
, . AL
:
00 .
FF

IBM PC . 16. 5
(
).
: FCB
, .16.1, ,
. FCB (FCBREC)
:
FCBDRIV
4 ( D). FCBNAME - NAMEFILE. FCBEXT - DAT. FCBBLK
- 0. FCBRCSZ ,

128. FCBSQRC
- 0.
:
BEGIN ,
C10OPEN DTA
DOS, D10PROC .
, G10PROC
. C10OPEN ,
- 32 (.20)
DTA DOS. D10PROC ,

F10WRIT
. E10DISP . F10WRIT
. G10CLSE
. X10ERR

.
1 FCBSGRC ( )
.20 ( ) FCBFLSZ ( ). 32
, 16 .
DTA :
DTA: | |
: | 00| 01| 02|...| 15|
25 , 1 25 (.19).
:
25 * 32 = 800 . 320

IBM PC . 16. 6

. 16.1. .

.
: 20030000. :
: | 16| 17|...| 24|.1A|...|...|
,
. , ,
DTA. ,
(EOF),
. 1A.
, ,
, .
, ,
FCB.

DOS , ,
, , .
. OF:
MOV AH,OFH ;
LEA DX,FCBname ;
INT 21H ; DOS
,
FCB. , AL
. FF. , AL 00
FCB ,
0, .80.
.
DTA ,
. DTA
.1A ( EOF .1A)
:
MOV AH,1AH ;
LEA DX,DTAname ; DTA
INT 21H ; DOS

IBM PC . 16. 7
.14:
MOV AH,14H ;
LEA DX,FCBname ;
INT 21H ; DOS
DTA
FCB. AL :
00 .
01 , .
02 DTA .
03 , , .
DOS.
FCB DTA.
( )
.
.
FCB
1.
(EOF), .
,
. ,
. ,
DOS .
: FCB
.16.2 , ,
, .
FCB, , FCB .
.
:
BEGIN ,
E10OPEN DTA
F10READ .
, ,
, G10DISP. E10OPEN ,

, 32 (.20),
DTA.

IBM PC . 16. 8
F10READ .

FCB. G10DISP .
X10ERR
.

. 16.2.
.
, FCB
, . 00
(16 ) .
DTA, FCB 00 01:
: | 00| 01| 02|... | 15|
DTA : | 00|
.
, 01 DTA
.
16 .
16-
DTA.
DTA.
AL . 01.

,
,
.
, ,
(
DTA, FCB).
A B.
,
.

, , .
, , 300- ,

IBM PC . 16. 9
299 , 300-
. : ).
, ,
(). ,
DOS,
FCB .
( 33-36)
FCB.
.
( 12-13)
( 32).

DTA ,
. ,
. 05 FCB
.
DTA.

FCB .21:
MOV AH,21H ;
LEA DX,FCBname ;
INT 21H ; DOS

. ,
DTA AL :
00
01
02 - DTA
03 , .
, .
- 00.

DTA FCB.
, AL .

IBM PC . 16. 10
, ,
, ,
DTA. , ,
128 , .. .
23 , :
| 20 | 21 | 22 | 23 |
, , 23,
. ,
DTA. 35,
, ,
DTA. ,
, .

DTA ,
. ,
, , , ,
(, ) .
FCB .22
:
MOV AH,22H ;
LEA DX,FCBname ;
INT 21H ; DOS
AL :
00
01
02 DTA.

.
00.
FCB
( ), .

,
.

IBM PC . 16. 11
:
.16.3 , ,
(..16.1). ,
, .
25 , 00 24.
ASCII - .
:
C10OPEN , 32
DTA. D10RECN ,

FCB.

00 24. F10READ DTA
FCB. G10DISP .
D10RECN
. :
00
01 ( AL)
02 ( AX)

.16.3. .
ASCII .
AX, AAD
. AX
FCB. , ,
12 ASCII , AX 3132. AND
0102, AAD - 000C.
FCB 000 0000.

,
DTA , DTA.
,
.

IBM PC . 16. 12
.
, .
DTA.
X
, FCB
.28:
MOV AH,28H ;
MOV CX,records ;
LEA DX,FCBname ;
INT 21H ; DOS

. .
AL :
00
01 .
FCB
, .
, 00 24, 25
(.19).
CX
.27:
MOV AH,27H ;
MOV CX,records ;
LEA DX,FCBname ;
INT 21H ; DOS
AL :
00
01
02 DTA
03 .
CX , FCB

, .
, ,
. ,
.320 (800) .20 (32) .19 (25).

IBM PC . 16. 13
:
.16.4 , ,
.16.1.
00, CX - 25 DTA
( , , ).
25
.
:
E10OPEN , FCB
32 DTA. F10READ
25
. G10DISP .
00 FCB
00 00. FCB
.19, - . 19000000.

. 16.4. .
-

DOS INT 25H 26H.
,
DOS INT 21H.
, ,
.
" " ( ).

0, 1, :

010
021
119
1 9 17
2 9 26
:
= ( 9) + ( - 1)

IBM PC . 16. 14

, 2 9
(2 9) + (9 - 1) = 18 + 8 = 26
-:
MOV AL,drive# ; 0 A, 1 B ..
MOV BX,addr ; -
MOV CX,sectors ;
MOV DX,record# ;
INT 25H 26H ;
,
, CF (0) (1)
. AL
:
AL
1000 0000
0100 0000
0010 0000
0001 0000 ?
0000 1000 DMA
0000 0100
0000 0011
0000 0010
INT .
INT , CF.

DOS
.
: . D

. (
) . DOS . D
. ,
.
MOV AH,ODH ;
INT 21H ; DOS
: . E

IBM PC . 16. 15
DOS .E - ( )
. DL, 0 A,
1 - B ..
MOV AH,OEH ;
MOV DL,02 ; C
INT 21H ; DOS
AL ( ).
DOS 2 A B, DOS
02 . (
INT 11H).
: . 11 12

, , .
DX
FCB 11H. FCB
(. DOS).
MOV AH,11H ;
LEA DX,FCBname ; FCB
INT 21H ; DOS
FCB 5CH ,
(DTA ). . . 22.
AL .FF, , .00,
. DTA (1=A, 2=B ..)
.
(, *.ASM),
12H:
MOV AH,12H ;
LEA DX,FCBname ; FCB
INT 21H ; DOS
AL 11H.
: .13
DOS 13H.
.
MOV AH,13H ;
LEA DX,FCBname ; FCB
INT 21H ; DOS
, AL
00, .FF.

IBM PC . 16. 16

: . 17
DOS .17.
FCB, - 16.
MOV AH,17H ;
LEA DX,FCBname ; FCB
INT 21H ; DOS
? *
. AL
00, ( ) FF.
: .19
DOS .19 :
MOV AH,19H ;
INT 21H ; DOS
. AL (0=A, 1=B ..).
FCB
.
FAT
(1B 10), (24), (25),
(26) (29).
DOS.
:
.16.5 COM- SDEL, DOS
11H, 12H 13H .
,, :
SDEL *.* ( )
SDEL *.BAK ( BAK-)
SDEL TEST.* ( TEST)
DOS ,
. DOS PSP (
) .81 (DTA ).
. Y () , N ()
, Return .

IBM PC . 16. 17
, COM, EXE-
.5 81 PSP.
.

.16.5. .

- , INT 21H DOS
- ,
(FCB) . - 128
.
FCB ,
. - FCB

: , ,
. - ,
,
FCB. - - (DTA)
,

. ,
,
DTA. - FCB
: , ,
(.80), .
. - ,
DOS INT
21H, ,

( )
. - DOS INT
21H
FCB. - DOS INT 21H

. -

FCB. - ( )

. -

, DTA.

, . -


.
.

IBM PC . 16. 18
- DOS INT 25H 26H
,
,
.

16.1. DOS
: ) , ) DTA, )
, ) , )
. 16.2. ,
. )
? )

? ) () ,

? 16.3. ,
,
:
( ), (12 )
( ).

. ASCII
. 16.4. ,
,
16.3. 16.5.
: )45, )73,
)150, )260. 16.6. 2652 ()
FCB? 16.7.

: ) , ) , )
, ) . 16.8.
,
, .
FCB FLSZ
FCB FCSZ. 16.9. 16.4
, ,
.
,

.

023 00315
024 00430
027 00525
049 00920
114 11250
117 00630

IBM PC . 16. 19
122 10520
124 21335
127 00960
232 05635 ?
999 00000
16.10. 16.9 ,
. 16.11. 16.9
, )
, )
)
(
).

IBM PC . 17. 1

17. III:
DOS
III: DOS
: DOS, 2.0
.

DOS , 16,
DOS.
, DOS 2.0 3.0
. , ,
DOS.
DOS.
DOS ,
UNIX.
ASCIIZ , ;
; .
ASCIIZ

DOS ASCIIZ,
- , ( )
, :
PATHNM1 DB 'B:\TEST.ASM',0
PATHNM2 DB 'C:\UTILITY\NU.EXE',0
( ) .
(zero) ( ASCIIZ ). ,
ASCIIZ , DX,
, LEA DX,PATHNM1.

AX
, . 8 ,

: 0 - , 1 - , 2 - , 3 -
, 4 - .

IBM PC . 17. 2
ASCIIZ
DOS . 3C 3D. CF 0
AX. DW
.
CF 1, AX - ,
(..17.1).
01
02
03
04
05 ( )
06
07
08
09
10
11
12
13
15
16
17 ?
18

,
DOS.
: .3C

.3C. DX ASCIIZ-, CX . 15;
- 0.
:
MOV AH,3CH ;
MOV CX,00 ;
LEA DX,PATHNM1 ; ASCIIZ
INT 21H ; DOS
JC error ;
MOV HANDLE1,AX ; DW
,
CF AX.
.

(.. ), 0
.

IBM PC . 17. 3
CF 1
AX : 03, 04 05 (..17.1). 05
, " ".
CF,
AX 0005,
05 ( ).
: .40
DOS .40. BX
, CX - ,
DX - . 256
OUTREC:
HANDLE1 DW ?
OUTREC DB 256 DUP (' ')
MOV AH,40H ;
MOV BX,HANDLE1 ;
MOV CX,256 ;
LEA DX,OUTREC ;
INT 21H ; DOS
JC error2 ;
CMP AX,256 ; ?
JNE error3
(256 ),
CF AX .
, .
CF 1, AX 05 (
) 06 ( ).
: .3E
BX ,
DOS .3E, .
FAT.
MOV AH,3EH ;
MOV BX,HANDLE1 ;
INT 21H ; DOS
AX 06 ( ).
: .
, .17.2, ,
. :

IBM PC . 17. 4
C10CREA .3C

HANDLE. D10PROC

. F10WRIT , .40. G10CLSE
, .3E,
,
.
30 :
(.0DH) (. 0AH). - 32
. 32-x ,
. " " " ", ,
. DOS SORT
. SORT
:
SORT B:<NAMEFILE.DAT >NAMEFILE.SRT
NAMEFILE.DAT
NAMEFILE.SRT. ,
.17.3 NAMEFILE.SRT
. : 1) -

. 2) (
); ,
.17.4.
.17.2. .


DOS.
: .3D
,
, .3D.
. DX ASCIIZ, AL - :
0
1

IBM PC . 17. 5
2
AL DOS 3.0
(. DOS). ,
(.3C), .
:
MOV AH,3DH ;
MOV AL,00 ;
LEA DX,PATHNM1 ; ASCIIZ
INT 21H ; DOS
JC error4 ;
MOV HANDLE2,AX ; DW
,
1, , CF
AX.
.
, CF AX
: 02, 04, 05 12 (. .17.1). CF.
AX 0005,
05 ( ).
: .3F
DOS . 3F.
BX , CX - DX . 512- :
HANDLE2 DW ?
INPREC DB 512 DUP (' ')
MOV AH,3FH ;
MOV BX,HANDLE2 ;
MOV CX,512 ;
LEA DX,INPREC ;
INT 21H ; DOS
JC error5 ;
CMP AX,00 ; 0 ?
JE endfile
, CF
AX .
AX .
CF AX 05 ( ) 06
( ).

IBM PC . 17. 6
DOS , ,
, .
:
.17.3 , ,
(..17.2) DOS SORT.
.3D.
HANDLE .3F .
,
" " " ".
ASCII- ( ASCII)
.
ASCII- ( ),
DOS . FAT,
, . DOS
, , ASM- ,
(.09), (.OD) (.OA).
DOS ,
, ,
" ". ,
:
<tab>MOV<tab>AH,09<return>
.17.3. .
ASCII- :
094D4F560941482C30390D0A
TYPE
"", " " " " .
, .17.4,
HANREAD.ASM ( . 17.3) . HANREAD
, .

IBM PC . 17. 7
.17.3. ASCII-.
, DOS TYPE, ..
" " " " (CR/LE).
() .
,

.
. ASCII-
, , .
SECTOR.
G10XFER SECTOR DISAREA,
. " ",
DISAREA, " ". (
(.09)
8).
( )
. ASCII-, ASM-,
CR/LF.
, EXE OBJ,
DISAREA .
ASCII-,
.
G10XFER : 1. SECTOR.
2. DISAREA. 3. SECTOR

. ,
, SECTOR. 4.
DISAREA
CR/LF,
DISAREA. 5. SECTOR DISAREA. 6.
" " (.1A)
. 7. " " (.OA)
.2,
.3.
DEBUG.
, DOS
.
.

IBM PC . 17. 8
DOS
:
.36
.
DL (0 - , 1 - A, 2 - B
..):
MOV AH,36H ;
MOV DL,0 ;
INT 21H ; DOS
AX
.FFFF, :
AX
BX
CX
DX
DOS 2.0
.1B ( FAT).
: .41
( "
") .41. DX
ASCIIZ , :
MOV AH,41H ;
LEA DX,PATHNAM ; ASCIIZ-
INT 21H ; DOS
AX 02 ( ) 05 (
).
: .42
DOS ,
0 1 .

.42, .
BX
CX:DX . 65.535
CX 0, DX - . AL
, :
0 - .

IBM PC . 17. 9
1 - ,
, . 2 - .
(
) ,
CX:DX 0 2
AL.
1024
:
MOV AH,42H ;
MOV AL,00 ;
LEA BX,HANDLE1 ;
MOV CX,00 ;
MOV DX,1024 ; 1024
INT 21H ; DOS
JC error
CF
DX:AX. CF 1
AX 01 ( ) 06 ( ).
: .43

.43H. DX ASCIIZ .
AL 00.
AL 01, CX - .
:
MOV AH,43H ;
MOV AL,01 ;
MOV CX,00 ;
LEA DX,PATHNM2 ; ASCIIZ-
INT 21H ; DOS
CX.

CX. AX 02, 03 05.
: .47

.47. ,

DX. DL : 0 - , 1 - A, 2 - B ..

IBM PC . 17. 10
(
), , :
ASSEMBLE\EXAMPLES
(.00) .
- .00.

. .17.5 .
: .4E .4F
. 11 12 DOS. 4E
, 4F - .
DX ASCIIZ-,
. ? *.
CX (, ,
).
MOV AH,4EH ;
MOV CX,00H ;
LEA DX,PATHNM1 ; ASCIIZ-
INT 21H ; DOS
, ,
DTA FCB :
00 - DOS
21 -
22 -
24 -
26 - : ,
30 - 13- ASCIIZ ,
.00.
AX 02 ( ) 18 (
). ( .4E)
4F. DTA.
MOV AH,4FH ;
INT 21H ; DOS
AX - 18 ( ).
CF.
: . 56

IBM PC . 17. 11
.56. DX
ASCIIZ- , ,
, , DI ( ES:DI) - ASCIIZ, , , .
, .
, ,
.
MOV AH,56H ;
LEA DX,oldstring ; DS:DX
LEA DI,newstring ; ES:DI
INT 21H ; DOS
AX 03 ( ), 05 (
?) 17 ( ).
DOS, ,
(.39), (.3A),
(. 3B), - (.44),
(.45), (.46),
? (.54).

- DOS ASCIIZ,
, .00. -

,
. - CF
AX. - ,

, - . - , ,
,
.

17.1. "
" " " ? 17.2. ASCIIZ-
PATH1
CUST.LST C. 17.3. (.17.2) )
CUSTHAN
, ) , )
CUSTOUT (128 ) ) .
.

IBM PC . 17. 12
17.4. (.17.3) )
) CUSTIN.
. 17.5. ,
? 17.6. .17.4 ,

,
.

, ..
Return.

IBM PC . 18. 1

18. IV: BIOS


IV: BIOS
: BIOS
.

BIOS,
BIOS /
. BIOS INT 13H "",
,
.
,
:
AH : , ,
. AL . CH . CL
. DH () : 0 1 .
DL : 0=A, 1=B .. ES:BX /
(
).
BIOS
INT 13H
AH .
AH = 00:

INT 13H AH .00.
, .
AH = 01:
AL
/ (. ).
01 AH.
AH = 02:

. 1, 8 9.
BX, ,

IBM PC . 18. 2
EX,
ES:BX. INSECT,
, :
MOV AH,02 ;
MOV AL,01 ;
LEA BX,INSERT ; ES:BX
MOV CH,05 ; 05
MOV CL,03 ; 03
MOV DH,00 ; () 00
MOV DL,01 ; 01 (B)
INT 13H ; BIOS
AL. DS,
BX, CX DX .

.
CH CL. ,
, 01, 1
0 1 ( ).
AH = 03:
( 512
512) .
( 02).
AL , .
DX, BX, CX DX .
AH = 04:
, ,
. ( 03)
, /.
- ( 03),
- ES:BX - .
AL . - DX, BX, CX DX .
AH = 05:

( PC - 512).
.

IBM PC . 18. 3
ES:BX , .
T/H/S|B,
T ,
H ,
S ,
B ,
(00-128, 01-256, 02-512, 03-1024).
, 03 , 00 512 ,
.03000102
. AT
BIOS.

(02, 03, 04 05)
CF AH 0. CF 1,
AH , .
AL 01.
AH
0000 0001
0000 0010
0000 0011
0000 0100
0000 1000 DMA (
)
0000 1001 64K
0001 0000
0010 0000
0100 0000 ()
1000 0000
, (AH=00)
. ,
.
: BIOS
, .18.1, BIOS
INT 13H . ,
.16.3, :
1. FCB .

IBM PC . 18. 4
2. .
.
10 C10ADDR
01. = 1,
;
: 0 1 1 0. 3. CURADR

( ),
ENDADR - .
-

.
DEBUG.
, ,
FAT (
FAT ). G ()
FAT
.

.18.1. BIOS .
, DEBUG ASCII-
. ,
DEBUG (. .14.5).
( ""),
.
, DOS
, . ,
BIOS INT 13H .

- BIOS INT 13
. - BIOS INT 13
, ,
. -
,
. -
BIOS.

IBM PC . 18. 5
18.1. . 18.2.
. 18.3. BIOS INT 13H,

INDISK,
A, 0, 6 3. 18.4. BIOS INT 13H,

OUTDISK,
B, 0, 8 1. 18.5. 18.4,

? 18.6. 18.4

( ).

IBM PC . 19 1

19.

:
().

.
, DOS INT 21H BIOS INT 17H. ,
, " ", " " "
".
.
,
. ,
, , , ,
- .
"" ,
.
10,12 15 ,
, ,
. ,
.
. IBM
PC ,
. , ,
.
, .
().
"" , , ,
. , ""
, "".

-
.

:
. .

IBM PC . 19 2
08 08
09 09
10 0A
11 0B
12 0C
13 0D
. (. 09)
, ,
.
.
. (.OA)
.
.
.
. 11 .
, .
,
.

(, 55 ) (.OC) , ,
0 1.
" " " "
,
. " "
.
DOS
DOS 2.0 ,
.
DOS .40 04.
25 HEADG:
HEADG DB 'Industrial Bicycle Mfrs', 0DH, 0AH
...
MOV AH,40H ;
MOV BX,04 ;
MOV CX,25 ; 25
LEA DX,HEADG ;
INT 21H ; DOS

IBM PC . 19 3
CF
AX.
:
, .19.1, .9.1,
, ,
.
:
List of Employee Names Page 01
Clancy Alderson
Ianet Brown
David Christie
...

. :
D10INPT
. E10PRNT (
);
M10PAGE. M10PAGE
,
,
. P100UT

.
,
. M10PAGE , PAGECTR
01 ( ). PAGECTR
PAGECTR DB '01'
,
. M10PAGE , PAGECTR
01 ( ). PAGECTR
PAGECTR DB '01'
ASCII - . 3031. M10PAGE
PAGECTR 1 , 3032,
3033 .. 3039, 303A, ,
(:). , PAGECTR .3A,

IBM PC . 19 4
.30, . .303A
. 3130, .. 10 .

.19.1. .
( ) ,
.
ASCII-

, , , ,
( 09) ,
8. , 8, 16, 24
.. , , . , ,
DOS PRINT, ASCII (
) , . ,
,
8.
, .19.2, ,
, .
.17.3 ( )
. 0 7
8, 8 15 - 16 .. ,
, G10XFER G60.
:
: 1 9 21
: 00000001 00001001 00010101
: 00000000 00001000 00010000
8: 00001000 00010000 00011000
: 8 16 24
:
10PRMP .
Return
. E10OPEN . G10XFER
, ,
, " "
. .

IBM PC . 19 5
P10PRNT
. R10READ .
" ", " " " "
.
(.OC) , , 62.

.19.2. ASCII .
" " ASCII
, ,
. , 05
DOS. .
.
DOS

DOS AH 05,
DL , , INT 21H
:
MOV AH,05 ;
MOV DL,char ;
INT 21H ; DOS
. ,
, ,
, .
. SI
HEADG, CX - . ,
P20, HEADG .
HEADG - " ", - " ",
.
HEADG DB 0CH,'Industrial Bicycle Mfrs',0DH,0AH,0AH
LEA SI,HEADG ;
MOV CX,27 ;
P20:
MOV AH,05 ;

IBM PC . 19 6
MOV DL,[SI] ;
INT 21H ; DOS
INC SI ;
LOOP P20
, DOS "Out of pap er".
.
Ctrl/Break.

,
. :
. .
15 0F
14 0E
18 12
20 14
, Esc (.IB).
:
1B 30 8
1B 32 6
1B 45
1B 46
:
1. .
, 8 ,
"
" " ":
HEADG DB 0FH, 1BH, 30H, 'Title...', 0DH, 0AH
2. :
MOV AH,05 ;
MOV DL,0FH ;
INT 21H

,
, .

IBM PC . 19 7
.

.
BIOS INT 17H

BIOS INT 17H ,


AH:
AH=0: 0,1
2 ( - 0).
MOV AH,00 ;
MOV AL,char ;,
MOV DX,00 ; 0
INT 17H ; BIOS
, AH 01.
AH=1: :
MOV AH,01 ;
MOV DX,00 ; 0
INT 17H ; BIOS
" ",
" ".
.
AH=2: :
MOV AH,02 ;
MOV DX,00 ; 0
INT 17H ; BIOS
TEST AH,00101001B; ?
JNZ errormsg ; -
AH=1 AH=2 .
AH 1:

7
6
5
4
3 /
0

IBM PC . 19 8
, .90 10010000 " " "" - .
5 ( 3 ( ).
, .B0 10110000, "
".
, BIOS
, ,
. ,
.
, . ,
BIOS , ,
, . ( DOS
, "Out of paper"
). ,
.
.

.

,
.
"
" " "
.
DOS
. BIOS
. BIOS
INT 17H .

19.1. DOS )
; ) ; )
; )
/ (); )
. 19.2.
DOS.

IBM PC . 19 9
19.3. ,
: , ,
, ( )
. 19.4. 19.1
BIOS INT 17H.
. 19.5. 19.1 ,
), ), ) 5 . 19.6. .19.1
DOS. 19.7. .19.2 ,
.

IBM PC . 20 18

20.

: .


. Pascal C
( ) .
, .
MASM ,
. , MACRO,
,
- MEND. ,
, .
.
:
- ;
- ;
- .
-,
ASCII
, ,
, .
, ,
.
.

.
INIT1,
EXE-:
INIT1 MACRO ;
ASSUME CS:CSEG,DS:DSEG,SS:STACK;ES:DSEG ; \
PUSH DS ; \

IBM PC . 20 19
SUB AX,AX ; \
PUSH AX ; \
MOV AX,DSEG ;/
MOV DS,AX ; /
MOV ES,AX ; /
ENDM ;
MACRO , ENDM
. - INIT1,
. ENDM
. MACRO ENDM
.
, , CSEG, DSEG STACK
- . INIT1
, .
INIT1, ,
, .
INIT1 ,
- .
, ,

.
.20.1 .
, (+), .
, ASSUME,
.
"

.

.20.1. .

: CSEG,
DSEG STACK. ,
, , :
INIT2 MACRO CSNAME,DSNAME,SSNAME ;
ASSUME CS:CSNAME,DS:DSNAME,SC:SSNAME,ES:DSNAME
PUSH DS
SUB AX,AX
PUSH AX

IBM PC . 20 20
MOV AX,DSNAME
MOV DS,AX
MOV ES,AX
ENDM ;

.
CSNAME, DSNAME SSNAME ASSUME, DSNAME
MOV.
,
.
INIT2
.
, ,
:
:
INIT2 MACRO CSNAME,DSNAME,SSNAME ( ) : | |
|
INIT2 CSEG,DSEG,STACK ()

,
:
- 1: CSEG CSNAME
. CSEG
CSNAME ASSUME.
- 2: DSEG DSNAME
. DSEG
DSNAME: ASSUME MOV.
- 3: STACK SSNAME
. STACK
SSNAME ASSUME.

.20.2.

.20.2. .
(
, , CX),
. , ,

IBM PC . 20 21
, .
, , 120 .

.
COMMENT ,
PROMPT:
PROMPT MACRO MESSGE
;
MOV AH,09H
LEA DX,MESSGE
INT 21H
ENDM

, ,
. , ,
.LALL ("list all" - ),
:
.LALL
PROMPT MESSAG1
,
, - .
.LALL. -
(;;) - .
.XALL, ,
. , ,
,
. .SALL ("suppress all" - ),
,
.
.LALL, .XALL, .SALL
, .
,
, - , .
.20.3 .
INIT2 PROMPT, .
.SALL

IBM PC . 20 22
INIT2 PROMPT. PROMPT .LALL
. , ,
, (;;)
PROMPT,
.

.20.3.
.

.
DOS21, AH DOS
INT 21H:
DOS21 MACRO DOSFUNC
MOV AH,DOSFUNC
INT 21H
ENDM
:
LEA DX,NAMEPAR
DOS21 0AH
, , 02
AH :
DISP MACRO CHAR
MOV AH,02
MOV DL,CHAR
INT 21H
ENDM
, , DISP '*'.
DISP, DOC21:
DISP MACRO CHAR
MOV DL,CHAR
DOS21 02
ENDM
, DISP DISP '*',
:
MOV DL,'*'

IBM PC . 20 23
MOV AH,02
INT 21H
LOCAL

.

.
- .
LOCAL,
MACRO, .
:
LOCAL dummy-1,dummy-2,... ;
.20.4. LOCAL.
;
1 , .
: COMP - , OUT -
. COMP OUT LOCAL
.
COMP ??0000, OUT - ??0001.
DIVIDE ,
??0002 ??0003 .
, LOCAL
.

.20.4. LOCAL.

, INIT1 INIT2
.
,
, , MACRO.LIB:
INIT MACRO CSNAME,DSNAME,SSNAME
.
.
ENDM
PROMPT MACRO MESSGE
.
.

IBM PC . 20 24
ENDM
MACRO
INCLUDE:
INCLUDE C:MACRO.LIB
.
.
INIT CSEG,DATA,STACK
MACRO.LIB ( ) C
INIT PROMPT.
INIT. ,
C 30 LST-.
(+) 31 .
,
INCLUDE ( )
:
IF1
INCLUDE C:MACRO.LIB
ENDIF
IF1 ENDIF . IF1
. ENDIF
IF-. , .
.20.5 IF1, INCLUDE
ENDIF, LST- ENDIF.
INIT PROMPT MACRO.LIB, ..
MACRO.LIB
.
INCLUDE ,
.

.20.5. .

INCLUDE
. , INIT, PROMPT
DIVIDE,

IBM PC . 20 25
INIT. PURGE ""
PROMPT DIVIDE :
IF1
INCLUDE MACRO.LIB ;
ENDIF
PURGE PROMRT,DIYIDE ;
...
INIT CSEG,DATA,STACK ;
;
PURGE
, .
(&)

(&) ()
. MOVE MOVSB MOVSW:
MOVE MACRO TAG
REP MOVS&TAG
ENDM
MOVE B MOVE W.
MOVS REP MOVSB
REP MOVSW. .
: REPT, IRP, IRPC

,
ENDM. ,
, ENDM
, ENDM - .
REPT:
REPT ENDM
, :
REPT
N=0
DB N :
N=0

IBM PC . 20 26
REPT 5
N=N+1
DB N
ENDM
DB DB 1 DB 5. REPT
.
MOVSB, REP MOVSB
CX 05:
REPT 5
MOVSB
ENDM
IRP:
IRP ENDM.
:
IRP dummy,<arguments>
, ,
, , .
. DB 3, DB 9, DB 17, DB
25 DB 28:
IRP N,<3, 9, 17, 25, 28>
DB N
ENDM
IRPC:
IRPC ENDM.
:
IRPC dummy,string
"string".
DW 3, DW 4 ... DW 8:
IRPC N,345678
DW N
ENDM

.
IF1
.

IBM PC . 20 27
,
. IF ENDIF
IF- ELSE :
IFxx ()
.}
. }
ELSE ( ) }
. }
.}
ENDIF ( IF-)
ENDIF : "Undeterminated
conditional" ( ). ,
ELSE ELSE -
ENDIF. ,
ELSE, ELSE .
:
IF ,

. IFE ,

. IF1 ( )
,
. IF2 ( )
,
. IFDEF
EXTRN,

. IFNDEF
EXTRN,

. IFB <> ,

.
. IFNB <> ,

.
.

IBM PC . 20 28
IFIDN <-1>,<-2>
,

.
. IFDIF<-1>,<-2>

,
.
.
IFNB ( ). DOS INT 21H
AH,
DX.
:
DOS21 MACRO DOSFUNC,DXADDRES
MOV AN,DOSFUNC
IFNB <DXADDRES>
MOV DX,OFFSET DXADDRES
ENDIF
INT 21H
ENDM
DOS21 01
AH:
DOS21 01
MOV AH,01 INT 21H.
AH 0AH, DX - :
DOS21 0AH,IPFIELD
MOV INT 21H.
EXITM.

,
. ,
. EXITM:
IFxx []
.
. ( )
.
EXITM
.
.

IBM PC . 20 29
ENDIF

EXITM,
ENDM. EXITM REPT, IRP
IRPC .
, IF IFNDEF

.20.6 DIVIDE,
.
: , , .
IFNDEF .
CNTR.

. , CNTR:
IF CNTR
;
EXITM
CNTR ,
EXITM . ,
CNTR , , IFNDEF
CNTR , 1.
, .
DIVIDE ,
.
-
; , .

.20.6. IF IFNDEF.
, IFIDN-

IBM PC . 20 30
.20.7 MOVIF,
MOVSB MOVSW .
B ( ) W ( )
MOVSB MOVSW MOVS.
:
MOVIF MACRO TAG
IFIDN <&TAG>,<B>
IFIDN ( B W)
B. , REP MOVSB.
(&) - , <TAG>
. B W,
MOVSB ( ).
MOVIF: B,
W .
, , CX DX
.
,
- .
, ,
.

.20.7. IFIDN


(MASM).

. MACRO,
,
ENDM
. , ,
. .SALL,.LALL .XALL


. LOCAL
. LOCAL
MACRO.

IBM PC . 20 31

,
.
.

.

20.1. : )
, )
, . 20.2.
: )
MULTBY
; ) MULTWD
.

.
,
. 20.3.
20.2 "
".
INCLUDE
. 20.4. BIPRINT,
BIOS
INT 17H .

. 20.5. .20.6
( ).

IBM PC . 21 1

21.

: ,
.

.
, , ,
. ,
.
:
,
, ,
; ,
,
;

,
; ,

.

(OBJ) . (LINK)
(EXE) .
, . ,
, .
.21.1
. . 21.1 () 1, 2 3.
. 21.1 () 1 2, 1
3.

.21.1. .
,
"" , , .
, , , 1

IBM PC . 21 2
2, 3 ,
1. , , ,
.

CALL , ..
. CALL (
+127 -128 ) ( ).
"" IP , ""
.
, CALL : E82000.
.E8 , 2000
0020 IP. CS
IP .
RET
IP CALL .
() .
CS
, IP
.

.
, CALL :
9A 0002 AF04
.9A
0002 0200 IP, AF04 04AF CS.

:
04AF0
IP 0200
04CF0
REP
CS IP
CALL .
EXTRN PUBLIC

IBM PC . 21 3

(MAINPROG),
(SUBPROG) CALL, .21.2.
CALL MAINPROG "", SUBPROG
( , SUBPROG
). EXTRN ,
SUBPROG FAR, .. .
, ""
:
9A 0000 ---- E
SUBPROG PUBLIC,
, "" SUBPROG. ,
MAINPROG SUBPROG ,
:
LINK: :
Object Modules [.OBJ]: B:MAINPROG+B:SUBPROG
Run File [filespec.EXE]: B:COMBPROG ( )
List File [NUL.MAP]: CON
Libraries [.LIB]: [return]

.21.2. .
EXTRN
PUBLIC .
.
.
.
EXTRN
EXTRN :
EXTRN : [, ... ]
( )
EXTRN.
PUBLIC.

IBM PC . 21 4
ABS, BYTE, DWORD, FAR, NEAR, WORD. EQU
.
PUBLIC
PUBLIC ,
:
PUBLIC [, ... ]
( )
PUBLIC. ( PROC), .
EQU-, .
.
: EXTRN PUBLIC

.21.3 CALLMUL1
SUBMUL1. , .
QTY PRICE. AX
PRICE, BX - QTY,
. EXTRN SUBMUL
.
PUBLIC ( ASSUME),
, SUBMUL.
AX () BX
(). DX:AX .
002E 4000.
- ,
. ,
.
,
, . ,
.

.
,
. , SUBMUL
FAR External (), - F

IBM PC . 21 5
( FAR) Global (). ,
, .. .
( ) .
, ( )
.
(
). ,
- .00000, - . 00020.

. 21.3. EXTRN PUBLIC.


, CALL
SUBMUL
9A 0000 D413
CALL - .9A.
IP 0000, .13D2 CS
.D413.
CS:IP .. 13D40 0000. ,
CS, .13D2, .. 13D20.
, .0020.
,
:
CS 13D20
IP 0020
13D40
,
CALL.
: PUBLIC

.21.4 .21.3.
- .
SEGMENT PUBLIC:
CODESG SEGMENT PARA PUBLIC 'CODE'

.21.4. , PUBLIC.

IBM PC . 21 6

CALL.
( ) :
CODESG - PUBLIC ( .21.3 NONE).
,
! , (CODESG),
('CODE') PUBLIC,
. ,
,
:
9A 2000 D213
.2000 IP . D213 CS.
,
CS - .D213.
.0020:
CS: 13D20
IP: 0020
: 13D40
, , ,
.13D40. ? ,
,
.0016. SEGMENT,
, .. .10
0.
-
.00020.
13D20 0020 13D40.
+----------------------------------------+--------------+
| ... ( | |
| ) | |
+----------------------------------------+--------------+
|||
13D20 13D30 13D40
, ,
.
:

IBM PC . 21 7


, .
, QTY PRICE - ,
BX AX .
.21.5. :
QTY PRICE
PUBLIC.
PUBLIC. Global (
) QTY PRICE .
QTY PRICE EXTRN
WORD.
2 .
MOV,
. , QTY
PRICE External
().

.21.5. .
MOV :
A1 0000 E MOV AX,PRICE
8B 1E 0000 E MOV BX,QTY
.A1 AX, .8B BX ( AX
, ).
, :
A1 0200
8B 1E 0000
,
MOV . ,
DS
.
,
PUBLIC EXTRN.
, ,
,

IBM PC . 21 8
. -
, 64
.
23 ,

GROUP .


.
. PUSH
.
, .21.6, SUBMUL
PRICE QTY. CALL
:
... | 1600 | D213 | 4001 | 0025 | 0000 | C213 |
654321
1. PUSH DS
.
DOS. 2. PUSH AX . 3. PUSH PRICE
(2500). 4. PUSH QTY (0140). 5.
CALL CS
(D213) 6. CALL
, IP
(1600).
BP ,
BP, . ,
, BP ,
().
BP SP,
BP, SP.
BP 0072. SP , ..
.80. SP 2:
| 0000 | 1600 | D213 | 4001 | 0025 | 0000 |C213 |
|||||||
SP: 72 74 76 78 7A 7C 7E

IBM PC . 21 9
BP 0072, (PRICE) BP+8,
(QTY) - BP+6.
AX BX .

.21.6. .
BP
, SP 2, 72 74.
RET ""
. :
IP
(1600). SP 2, 74 76.

CS (D213). SP 2 76 78.
.
. RET
RET 4
4
( ). RET
SP, 7C. ,
.
SP - .
BASIC-

BASIC IBM PC BASIC . :


BIOS-
. - ;
BASIC
.
BASIC ,
. ,
64 , BASIC.
.

IBM PC . 21 10
:
BASIC - POKE BASIC-.
BASIC- POKE.
, .
,
LST- DEBUG.
BASIC- DATA.
BASIC- READ POKE
.
.
,
(EXE) .
BASIC- .
BASIC- BSAVE (BASIC save)
BLOAD - .
BASIC- , ,
. BASIC : USR
CALL. DS, ES SS
BASIC. CS ,
DEF SEG ( ). SP
, ,
.
, .
SP BASIC
RET.
,
. HIGH
, , B:/HIGH. DEBUG
EXE- R CS IP:
. (
N) BASIC L.
BASIC- EXE- -
USR CALL. , EXE , , USRn CALL.
BASIC IBM PC USRn
CALL .

IBM PC . 21 11

: BASIC .
BASIC-
. BASIC-
- . FOR-NEXT
. BASIC , .
. 21.7 BASIC- .
BASIC-: 10
32 ; 20, 30, 40 50 .
BASIC- . BASIC . BASIC
, .
F2.
SAVE "B:BASTEST.BAS"
:
- , BASIC;
;
- BP
SP BP;
- ,
,
.

.21.7. BASIC
.
- . ,
(DOS) A, -
B:
1. ,
B:LINKBAS.ASM . 2. LINK,

,
:
LINK B:LINKBAS,B:LINKBAS/HIGH,CON;
3. DEBUG BASIC - :
DEBUG BASIC.COM.

IBM PC . 21 12
4. R
. SS, CS IP. 5.

:
N B:LINKBAS.EXE
L
6. R
CX, CS IP. 7. SS, CS IP

4. ( R SS, R CS R IP). 8. G
(go)
BASIC.
BASIC-. 9. , ,
( ):
DEF SEG = &Hxxxx ( CS 6)
BSAVE "B:CLRSCRN.MOD",0,&Hxx ( CX 6)

.
, .
B. 10.
BASIC-
. ,
, SYSTEM
BASIC , , Q
DEBUG.
DOS. 11. BASIC, BASIC-
:
BASIC
LOAD "B:BASTEST.BAS"
LIST
12. 20, 30, 40 50 :
20 BLOAD "B:CLRSCRN.MOD"
30 DEF SEG = &Hxxxx ( CS 6)
40 CLRSCRN = 0 ( )
50 CALL CLRSCRN ( )
13. , BASIC.
BASIC- ,
,
.

IBM PC . 21 13
.21.8 -
.
.
, BASIC
CALL (-1,-2,...)

.21.8. BASIC .
,
BP [BP], .21.3.
RET, .
, CALL
RET 6.
PASCAL

,
PASCAL IBM MicroSoft . .21.9
PASCAL- . PASCAL-
OBJ-,
OBJ-. LINK OBJ EXE-.
PASCAL- : temp_row temp_col,
.
temp_row temp_col
. PASCAL-
procedure move_cursor
, extern (). PASCAL-,
, :
move_cursor (temp_row, temp_col);
: ,
, .
:
00
02

IBM PC . 21 14
04
06
08
BP,
PASCAL. ,
.21.6.

.21.9. PASCAL-.
SP .
, BP
SP BP.
BP .
- .
( ) 08,
BP+08. ( )
06 BP+06.
BX, DI SI.
[BP+08] SI,
[SI] ( ) DH.
DL.
DX BIOS
. BP. RET
, , 22,
4.
.

PUSH POP .
.
- , PASCAL
, AX
DX:AX.
,
PASCALL PASCALL-, CODESEG
( ) .
PASCALL-.

IBM PC . 21 15
.5720 - 20.
.
C

C ,
C
C.
, :
C
(
) . ,
, , ,
:
MOV ES,BP
MOV BP,SP
MOV DH,[BP+4]
MOV DL,[BP+6]
...
POP BP
RET
C
,
,
C-.
C ,
, DI SI,

.
,
, AX ( )
DX:AX ( ).
C,
DF,
CLD .

, ,
EXTRN,
- PUBLIC.

IBM PC . 21 16
,
1 2,
1.

,
, PUBLIC.

.

( ).
PUBLIC, (
) - EXTRN.

21.1. , MAINPRO
SUBPRO. )
MAINPRO , SUBPRO
? )
SUBPRO ,

MAINPRO?
21.2. , MAINPRO
QTY DB, VALUE DW PRICE DW.
SUBPRO VALUE QTY
PRICE. )
MAINPRO ,
? )
SUBPRO
,
?
21.3. 21.2 21.3
.
21.4. ,
MAINPRO ,
. SUBPRO
.
21.5. ,
.
21.4 , MAINPRO
(QTY) (VALVE)
, SUBCONV
ASCII- ;
SUBCALC (PRICE); SUBDISP
ASCII-
.

IBM PC . 22 33

22.

: .

DOS ,
DOS . DOS
, :
1.
DOS, ,
FORMAT /S.
(, DOS
A C)
.
,
, .
2. IBMBIO.COM
BIOS ROM;
, .00600.
IBMBIO.COM
,
COMMAND.COM. IBMBIO.COM
- ,
.
3. IBMDOS.COM
,
.00B00.
,
, INT 21H,
.
4. COMMAND.COM DOS,
DIR CHKDSK, COM, EXE
BAT-. :
,
. COMMAND.COM,
,
.
.22.1 .
.

IBM PC . 22 34

00000 (..23)
00400 ROM ()
00500 DOS
00600 IBMBIO.COM
XXXX0 IBMDOS.COM



(FAT,
)
XXXX0 COMMAND.COM
XXXX0 (COM EXE-)
XXXX0 COM- (256 )
XXXX0 COMMAND.COM,
.
.22.1. DOS .
COMMAND.COM

COMMAND.COM
.
COMMAND.COM:
1.
IBMDOS.COM ( ),
.
-
:
INT 22H .
INT 23H Ctrl/Break.
INT 24H
/
(FAT).
INT 27H ,
.
2.
AUTOEXEC.
.

,
.

.

.

IBM PC . 22 35
3.
. "" , DOS
, .
COMMAND.COM
DOS A> C>, .

COM- EXE-
.
- ,
(PSP)
COMMAND.COM.

.100 ,

.
:
IBMBIO.COM
IBMDOS.COM
COMMAND.COM ()


...
COMMAND.COM ( , ).
RET INT 20H
COMMAND.COM. ,
.

(PSP) 256 (. 100)


COM- EXE-, .
PSP :
00 INT 20H (.CD20). 02 0.

, 512K .8000 .80000. 04 . 05


DOS. OA . OE
Ctrl/Break. 12
. 16 . 2C ASCIIZ . 50
DOS (INT 21H RETF). 5C 1,

(FCB1).

IBM PC . 22 36
6C 2,
(FCB2);
, FCB1 . 80-FF (DTA).
DTA
PSP .80
- . ,

. , (
). "",
. DTA:
1. . ,
CALCIT.EXE CALCIT [return]. , DOS
PSP , .80
.000D. ,
CALCIT, " ". Return
, . ,
.0D. , .80 81 000D.
2. . ,
( ), , COLOR BY, COLOR
"BY" .
, .80, DOS :
80: 03 20 42 59 0D
3, , "BY" .
3. . DEL ( )
.
, , DEL B:CALCIT.OBJ [return], PSP, .5C
.80, :
5C: 02 43 41 4C 43 49 54 20 20 4F 42 4A
CALCITOBJ
80: 0D 20 42 3A 43 41 4C 43 49 54 2E 4F 42 4A 0D
B:CALCIT.0BJ

IBM PC . 22 37
.5C, FCB, ,
, CALCIT.OBJ, .
(02=B ). CALCIT
, , , OBJ.
, :
progname A:FILEA,B:FILEB
DOS FCB FILEA .5C FCB FILEB
.6C.
.80 (
) - 16, (.20) A:FILEA,B:FILEB (OD).
PSP ,
PSP .
DTA COM- .80 SI
:
MOV SI,80H ; DTA
CMP BYTE PTR [SI],0 ; ?
JE EXIT
EXE- ,
PSP. , DS
ES PSP, ES
DS:
MOV AX,DSEG
MOV DS,AX
MOV SAVEPSP,ES
PSP:
MOV SI,SAVEPSP
CMP BYTE PTR [SI+ 80H],0 ; ?
JE EXIT
DOS 3.0 INT 62H, BX
PSP, PSP.
COM-

EXE-, COM- .
COM- , DOS "" ,
- COM.

IBM PC . 22 38
, COM- EXE-
. INT 20H
( DOS). COM- DOS
PSP. 64
(.FFFE) , .
. .100
( PSP). CS:IP, ..
PSP. COM .
RET IP ,
. CS:IP
PSP, INT 20H.
COMMAND.COM. (
INT 20H RET,
COMMAND.COM).
EXE-

EXE-, , : 1)
- , 2)
.
,
, ,
. :
00 .4D5A.
EXE-. 02 EXE-. 04
512 EXE-,
. 06 . 08 16- ()
,
( ,
). OA ,

. OC
.
,

.
. .0000
, .FFFF - .
,
.

IBM PC . 22 39
OE
. 10 , SP
. 12 -
(
) . 14 ,

IP
. 16
. CS. 18
. 1A : ,
EXE-. 1C ,

,
06.
512 ,
. 06
, .
, 1C ,
.

COMMAND.COM, . COMMAND.COM
:
.
(
04 08)
.


( OE). SS SP
. DS ES

. CS PSP

( 16) CS.
PSP,
256 (.100).
CS:IP ,
.. .
CS SS , DS ( ES)
:
1. PUSH DS ; PSP
2. SUB AX,AX ;

IBM PC . 22 40
3. PUSH AX ;
4. MOV AX,datasegname ; DX
5. MOV DS,AX ;
RET IP ,
. CS:IP
, PSP,
INT 20H. , DOS.
EXE-

(MAP) :
Start Stop Length Name Class
00000H 0003AH 003BH CSEG CODE
00040H 0005AH 001BH DSEG DATA
00060H 0007FH 0020H STACK STACK
Program entry point at 0000:0000
MAP ( )
. H .
,
, .
MAP CSEG 00000 -
.
.003B . DSEG
.00040 .001B. .00040 CSEG
, (.. .10).
, STACK, .00060 - DSEG,
.
DEBUG ,
DOS
. ,
( ),
.
(
).
00 .4D5A. 02 : 5B00. 04 512
, :
0200 (.0002512=1024).

IBM PC . 22 41
06 ,
: 0100, .. 0001. 08 16
: 2000
(.0020=32 3216=512). 0C : .FFFF. 0E
: 6000 .
60. 10 SP: 2000 .20. 14 IP: 0000. 16 C
CS: 0000. 18 C : 1E00
.1E.
DEBUG
:
SP = 0020 DS = 138F ES = 138F
SS = 13A5 CS = 139F IP = 0000
EXE- DS ES
, , IP, SS SP
- .
SP
.20
. , 16 DUP (?), .. 16
32 (.20) . SP .
CS
DS , PSP
.138F(0). PSP .100 , ,
PSP, .138F0+100= 139F0.
CS. , CS
(CSEG). D CS:0000
DEBUG .
LST
, R.
SS
SS
:
PSP (.DS) 138F0
PSP 100

IBM PC . 22 42
60
13A50
DS
DS PSP.
, DS
:
0004 B8 ---- R MOV AX,DSEG
0007 8E D8 MOV DS,AX
DSEG,
. DEBUG
:
B8 A313
A313 DS 13A3.

CS 139F0 00
DS 13A30 40
SS 13A50 60

DEBUG
:

PUSH DS IP SP
SUB AX,AX IP AX ( )
PUSH AX IP SP
MOV AX,DSEG IP AX
MOV DS,AX IP DS
DS .
D DS:00 DSEG D SS:00
.

, .
.4B
. ASCIIZ DX,

IBM PC . 22 43
BX ( ES:BX).
AL 0 3:
AL=0. .
, Cntrl/Break
.
, SP, , .
, ES:BX, :

0
.
2
PSP+80H.
6 FCB
PSP+5CH.
10 FCB
PSP+6CH.
AL=3. . ,
PSP .
. ES:BX
:

0
.
2
.
, AX: 01, 02, 05, 08, 10 11.
.22.2 DOS DIR D.
, EXE-. ( PC Magazine
).

.22.2. DIR .

IBM PC . 23 55

23. BIOS DOS


BIOS DOS
: , BIOS DOS.

,
.
: , (,
).
BIOS (Basic Input/Output System) ROM
.
- .
BIOS- DOS-, IN OUT.

IBM PC ROM FFFF0H.


, ,
CS FFFFH, IP - .
FFFF:0 FFFF0, BIOS. BIOS
.
BIOS ( 0) ,
, INT 11H (
) INT 12H ( ).
BIOS
DOS. , BIOS INT 19H
, .
, IBMBIO.COM,
IBMDOS.COM COMMAND.COM .
:

BIOS
IBMBIO.COM IBMDOS.COM
COMMAND.COM

IBM PC . 23 56

COMMAND.COM
RAM ()
ROM BASIC
ROM BIOS
INTR .
, IF 1 (
), ( ) , IF 0
( ).
, , INT 12H, ,
.
, 0000. 256
, 1024 .0 .3FF.

,
CS IP .
. 23.1.
, CS IP.
, 12H ( AX )
.0048 (.12 4 = .48).
. 0048 IP
SS. , CS:IP,
BIOS, .
IRET (Interrupt Return),
CS IP ,
.
BIOS

BIOS.
INT 05H ( ).
. INT 05H , .. , Ctrl/PrtSc
.
.


() ()
0-3 0
4-7 1 ( DEBUG)

IBM PC . 23 57
8-B 2 (NMI)
C-F 3 ( DEBUG)
10-13 4
14-17 5
18-1F 6,7
20-23 8
24-27 9
28-37 A,B,C,D AT
38-3B E
3C-3F F
40-43 10 (.. 8, 9, 10)
44-47 11 (..9)
48-4B 12 (..2)
4C-4F 13 - (..18)
50-53 14
54-57 15 . AT
58-5B 16 (..9)
5C-5F 17 (..19)
60-63 18 BASIC, ROM
64-67 19
68-6B 1A
6C-6F 1B
70-73 1C
74-77 1D
78-7B 1E
7C-7F 1F
80-83 20 (DOS)
84-87 21 DOS
88-8B 22 (DOS)
8C-8F 23 Ctrl/Break (DOS)
90-93 24 (DOS)
94-97 25 (DOS)
98-9B 26 (DOS)
97-9F 27 (DOS)
AO-FF 28-3F DOS
100-1FF 40-7F
200-217 80-85 BASIC
218-3C3 86-F0 BASIC-
3C4-3FF F1-FF
: 00-1F BIOS,
20-FF DOS BASIC.
.23.1. .
BIOS
BIOS.

IBM PC . 23 58
INT 05H .
. INT 05H ,
Ctrl/PrtSc - .
.
INT 10H . ,
9.
INT 11H .
, AX.
AX
.410. AX:

15,14
13
12
11-9 RS232
7,6 , 0=1:
00=1, 01=2, 10=3 11=4
5,4 :
00 =
01 = 4025
10 = 8025
11 = 8025 -
1 1
0 1


INT 12H . AX
, , .200 512 .
.
INT 13H -. -
, 16.
INT 14H .
- RS232. DX (0
1) RS232. , AH,
AX
.
INT 15H - AT.
- ,
AT.

IBM PC . 23 59

INT 16H . ,
9.
INT 17H . .
19.
INT 18H BASIC, ROM. BASIC-,
ROM.
INT 19H . 1
0 ( 0, 7C00)
. ,
INT 18H ROM BASIC.
ROM BASIC, .
INT 1AH .
AH.

0, . 18,2 .
AH :
AH=00 . CX ,
DX - . 24 , AL
.
AH=01 . CX (
) DX ( ).
02 06 AT.
INT 1FH .
128-255 1 , .
128 ASCII-
( 0 127).
DOS

BIOS DOS: IBMBIO.COM


IBMDOS.COM. DOS
, DOS
, BIOS .
IBMBIO.COM BIOS .
-
.

IBM PC . 23 60
IBMDOS.COM
, .
INT 21H, IBMDOS
. IBMDOS
IBMBIO, BIOS.
:
ROM

+-----------+ +----------+ +----------+
|| | DOS | | DOS | +----+ +----------+
| / | |IBMDOS.COM| |IBMBIO.COM| |BIOS| ||
+-----------+ +----------+ +----------+ +----+ +----------+
, .20 .62
DOS. :
INT 20H .
DOS. .
INT 21H DOS. DOS,
AH. DOS
.
INT 22H . (.INT 24H).
INT 23H Ctrl/Break. (.INT 24H).
INT 24H .
,
, .
DOS.
INT 25H . ..17.
INT 26H . ..17.
INT 27H , .
COM- .
" ".
DOS INT 21H

IBM PC . 23 61
DOS INT 21H.
AH:
00 ( INT 20H).
01 .
02 .
03 . .
04 . .

IBM PC . 1
1
ASCII-
128 ASCII-. BASIC
128 . , .20
.
2
-

. . A7B8
42936, - 42936 . A7B8.

-------------------------------------------------------- . A7B8 ,
. (A), 16 .
, . A F
10 15.
: A (10) 10
16 *16
160
, 7 7
167
16 *16
2672
, B (11) 11
2683
16 *16
42928
, 8 8
42936
. . A7B8
(8) 1, (B) 2,
(7) 3 (A) 4. B-1
. :
1 (8), 1 8
1 (8), 1 176

1 (8), 1 1792
1 (8), 1 40960

IBM PC . 2
42936

-------------------------------------------------------- 42936
42936 16; , , (6)
.
16 (11 B)
. , 0,
.
.
42936 / 16 2683 8 8 ( )
2683 / 16 167 11 B
167 / 16 10 7 7
10 / 16 0 10 A ( )

B-1. 42936
,
.
42936 :
. .
42936
40960 A000
1976
1792 700
184
176 B0
8 8
. 7 A7B8
3


(
- ):

AH BH CH DH CS SS BP
AL BL CL DL DS SI SP

IBM PC . 3
AX BX CX DX ES DI

AAA DIV JLE JS OR SBB


AAD ESC JMP JZ OUT SCAS
AAM HLT JNA LAHF POP SHL
AAS IDIV JNAE LDS POPF SHR
ADC IMUL JNB LEA PUSH STC
ADD IN JNBE LES PUSHF STD
AND INC JNE LOCK RCL STI
CALL INT JNG LODS RCR STOS
CBW INTO JNGE LOOP REP SUB
CLC IRET JNL LOOPE REPE TEST
CLD JA JNLE LOOPNE REPNE WAIT
CLI JAE JNO LOOPNZ REPNZ XCHG
CMC JB JNP LOOPZ REPZ XLAT
CMP JBE JNS MOV RET XOR
CMPS JCXZ JNZ MOVS ROL
CWD JE JO MUL ROR
DAA JG JP NEG SAHF
DAS JGE JPE NOP SAL
DEC JL JPO NOT SAR

ASSUME END EXTRN IFNB LOCAL PURGE COMMENT ENDIF GROUP IFNDEF MACRO
RECORD DB ENDM IF IF1 NAME REPT DD ENDP IFB IF2 ORG SEGMENT DQ ENDS
IFDEF INCLUDE OUT STRUC DT EQU IFDIF IRP PAGE SUBTTL DW EVEN IFE IRPC
PROC TITLE ELSE EXITM IFIDN LABEL PUBLIC

BYTE FAR LENGTH MOD PRT THIS COMMENT GE LINE NE SEG TYPE CON GT LT
NEAR SHORT WIDTH DUP HIGH LOW NOTHING SIZE WORD EQ LE MASK OFFSET
STACK

IBM PC . . 9
. . . . . .
0000 0 0 1000 8 8 0001 1 1 1001 9 9 0010 2 2 1010 10 A 0011 3 3 1011 11 B 0100 4 4 1100 12 C
0101 5 5 1101 13 D 0110 6 6 1110 14 E 0111 7 7 1111 15 F

+======================+
IDOSI
II
+---------+ - - - - - - - - - - - +
SS | +------->I I |
+----+II|
DS | +----+ - - - - - - - - - - - | + - - - - + +-->I I |
CS | +---+ I I |
+---------+ | - - - - - - - - - - - |
+--->I I |
I I |
- - - - - - - - - - - +
II
II
II
II
+======================+

IBM PC . . 10

|
: | :
|
|
+--------+--------+ |
| AH | AL | |
+--------+--------+ |
| BH | BL | |
+--------+--------+ |
| CH | CL | |
+--------+--------+ |
| DH | DL | |
+--------+--------+ | +-----------------+
| SP | | | CS |
+-----------------+ | +-----------------+
| BP | | | DS |
+-----------------+ | +-----------------+
| SI | | | SS |
+-----------------+ | +-----------------+
| DI | | | ES |
+-----------------+ | +-------+---------+
||
| | | +-------+
V | V | -|
====================================>| |<==> 8088
| | |
| | | +-------+
V||
+-----------------+ | +---+---+
| : -| | +---+ 1 |
| | | | +-------+
| | | | | 2 | ( ) +->+ - - - - - - - - + | | +-------+ | | : | | | | 3 | |
| | | | +-------+ | + - - - - - - - - + | | | 4 | | | | | | +-------+ | +----------------+ | | | | | | +-----------------+ | | +--+ |<--+--+
| | |
+-----------------+ |
|

IBM PC . . 11


. . +-----------------------------+
0K 00000 | RAM 256K - |
| |
+-----------------------------+
256K 40000 | RAM 384K - |
| I/O |
+-----------------------------+
640K A0000 | RAM 128K /- |
| |
+-----------------------------+
768K C0000 | ROM 192K |
| |
+-----------------------------+
960K F0000 | ROM 64K |
| |
+-----------------------------+

IBM PC . . 12
D>DEBUG -E CS:100 B8 23 01 05 25 00 -E CS:106 8B D8 03 D8 8B CB -E CS:10C 2B C8 2B C0
90 CB -R AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0100 NV UP EI PL NZ NA PO NC 13C6:0100 B8230
MOV AX,0123 -T
AX=0123 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0103 NV UP EI PL NZ NA PO NC 13C6:0103 052500 ADD
AX,0025 -T
AX=0148 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0106 NV UP EI PL NZ NA PE NC 13C6:0106 8BD8 MOV
BX,AX -T
AX=0148 BX=0148 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0108 NV UP EI PL NZ NA PO NC 13C6:0108 03D8 ADD
BX,AX -T
AX=0148 BX=0290 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=010A NV UP EI PL NZ AC PO NC 13C6:010A 8BCB MOV
CX,BX -T
AX=0148 BX=0290 CX=0290 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=010C NV UP EI PL NZ AC PO NC 13C6:010C 2BC8 SUB
CX,AX -T
AX=0148 BX=0290 CX=0148 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0100 NV UP EI PL NZ AC PO NC 13C6:010E 2BC0 SUB
AX,AX -T
AX=0000 BX=0290 CX=0148 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0110 NV UP EI PL ZR NA PO NC 13C6:0110 90 NOP -T
AX=0000 BX=0290 CX=0148 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0111 NV UP EI PL ZR NA PO NC 13C6:0111 CB RETF -

IBM PC . . 13
-D CS:100 13C6:0100 B8 23 01 05 25 00 8B D8-03 D8 8B CB 2B C8 2B C0 .#..%.......+.+.
13C6:0110 90 CB 8D 46 14 50 51 52-FF 76 28 E8 74 00 8B E5 ...F.PQR.v(.t... 13C6:0120 B8 01 00
50 FF 76 32 FF-76 30 FF 76 2E FF 76 28 ...P.v2.v0.v..v( 13C6:0130 E8 88 15 8B E5 BF 36 18-12
FF 36 16 12 8B 76 28 ......6...6...v( 13C6:0140 FF 74 3A 89 46 06 E8 22-CE 8B E5 30 E4 3D 0A 00
.t:.F.."...0.=.. 13C6:0150 75 32 A1 16 12 2D 01 00-8B 1E 18 12 83 DB 00 53 u2...-.........S
13C6:0160 50 8B 76 28 FF 74 3A A3-16 12 89 1E 18 12 E8 FA P.v(.t:......... 13C6:0170 CD 8B E5
30 E4 3D 0D 00-74 0A 83 06 16 12 01 83 ...0.=..t....... -Q

IBM PC . . 14
D>DEBUG -E DS:23 01 25 00 00 -E DS:2A 2A 2A -E CS:100 A1 00 00 03 06 02 00 -E CS:107 A3
04 00 CB -D DS:0 13C6:0000 23 01 25 00 00 9A 2A 2A-2A F0 F5 02 2C 10 2E 03 #.%...***...,...
13C6:0010 2C 10 BD 02 2C 10 B1 0D-01 03 01 00 02 FF FF FF ,...,........... 13C6:0020 FF FF FF
FF FF FF FF FF-FF FF FF FF EF 0F 64 00 ..............d. 13C6:0030 61 13 14 00 18 00 C7 13-FF FF
FF FF 00 00 00 00 a............... 13C6:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00
................ 13C6:0050 CD 21 CB 00 00 00 00 00-00 00 00 00 00 20 20 20 .!........... 13C6:0060 20 20
20 20 20 20 20 20 00 00 00 00 00 20 20 20 ..... 13C6:0070 20 20 20 20 20 20 20 20-00 00 00 00 00
00 00 00 ........ -R AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=13C6 ES=13C6 SS=13C6 CS=13C6 IP=0100 NV UP EI PL NZ NA PO NC 13C6:0100
A10000 MOV AX,[0000] DS:0000=0123 -T
AX=0123 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0103 NV UP EI PL NZ NA PO NC 13C6:0103 03060200 ADD
AX,[0002] DS:0002=0025 -T
AX=0148 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0107 NV UP EI PL NZ NA PE NC 13C6:0107 A30400 MOV
[0004],AX DS:0004=9A00 -T
AX=0148 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000 DS=13C6
ES=13C6 SS=13C6 CS=13C6 IP=0108 NV UP EI PL NZ NA PO NC 13C6:010A CB RETF -D
DS:0 13C6:0000 23 01 25 00 00 9A 2A 2A-2A F0 F5 02 2C 10 2E 03 #.%...***...,... 13C6:0010 2C
10 BD 02 2C 10 B1 0D-01 03 01 00 02 FF FF FF ,...,........... 13C6:0020 FF FF FF FF FF FF FF FFFF FF FF FF EF 0F 64 00 ..............d. 13C6:0030 61 13 14 00 18 00 C7 13-FF FF FF FF 00 00 00 00
a............... 13C6:0040 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................ 13C6:0050 CD
21 CB 00 00 00 00 00-00 00 00 00 00 20 20 20 .!........... 13C6:0060 20 20 20 20 20 20 20 20 00 00
00 00 00 20 20 20 ..... 13C6:0070 20 20 20 20 20 20 20 20-00 00 00 00 00 00 00 00 ........ -Q

CODESG SEGMENT PARA 'CODE'


BEGIN PROC FAR
1. ASSUME CS:CODESG,DS:DATASG,SS:STACKG
2. PUSH DS ; DS
3. SUB AX,AX ; AX
PUSH AX ;

IBM PC . . 15
4. MOV AX,DATASG ;
MOV DS,AX ; DATASG DS
.
.
.
5. RET ; DOS
BEGIN ENDP
CODESG ENDS
END BEGIN

page 60,132 TITLE EXASM1 (EXE) ;----------------------------------------------- STACKSG SEGMENT PARA SACK 'Stack'
DB 12 DUP('STACKSEG') STACKSG ENDS ;-----------------------------------------------CODESG SEGMENT PARA 'Code' BEGIN PROC FAR
ASSUME SS:STACKSG,CS:CODESG,DS:NOTHING
PUSH DS ; DS
SUB AX,AX ;
PUSH AX ;
MOV AX,0123H ; .0123 AX
ADD AX,0025H ; .25 AX
MOV BX,AX ; AX BX
ADD BX,AX ; BX AX
MOV CX,BX ; BX CX
SUB CX,AX ; AX CX
SUB AX,AX ; AX
NOP
RET ; DOS BEGIN ENDP ;
CODESG ENDS ;
END BEGIN ;

IBM PC . . 16
1 page 60,132 2 TITLE EXASM1 (EXE) 3 ;----------------------------------------------- 4 0000 STACKSG SEGMENT PARA SACK 'Stack' 5 0000 0C [ DB 12
DUP('STACKSEG') 6 53 54 41 43 7 4B 53 45 47 8 ] 9 10 0060 STACKSG ENDS 11 ;------------------------------------------------ 12 0000 CODESG SEGMENT PARA 'Code' 13 0000 BEGIN PROC
FAR 14 ASSUME SS:STACKSG,CS:CODESG,DS:NOTHING 15 0000 1E PUSH DS ;
DS 16 0001 2B C0 SUB AX,AX ; 17 0003 50 PUSH AX ; 18 19 0004
B8 0123 MOV AX,0123H ; .0123 AX 20 0007 05 0025 ADD AX,0025H
; .25 AX 21 000A 8B D8 MOV BX,AX ; AX BX 22 000C 03 D8
ADD BX,AX ; BX AX 23 000E 8B CB MOV CX,BX ; BX CX 24 0010
2B C8 SUB CX,AX ; AX CX 25 0012 2B C0 SUB AX,AX ; AX 26 0014 90
NOP 27 0015 CB RET ; DOS 28 0016 BEGIN ENDP ; 29 30 0016
CODESG ENDS ; 31 END BEGIN ;
Segments and Groups:
N a m e Size Align Combine Class
CODESG . . . . . . . . . . . . 0016 PARA NONE 'CODE'
STACKSG. . . . . . . . . . . . 0060 PARA STACK 'STACK'
Symbols:
N a m e Type Value Attr
BEGIN. . . . . . . . . . . . . F PROC 0000 CODESG Length=0016

IBM PC . . 17
1 page 60,132 2 TITLE EXASM2 (EXE) 3 ;-------------------------------------------------- 4 0000 STACKSG SEGMENT PARA SACK 'Stack' 5 0000 20 [ DB 32
DUP(?) 6 ???? 7 ] 8 9 0040 STACKSG ENDS 10 ;--------------------------------------------------- 11
0000 DATASG SEGMENT PARA 'Data' 12 0000 00FA FLDA DW 250 13 0002 007D FLDB DW
125 14 0004 ???? FLDC DW ? 15 0006 DATASG ENDS 16 ;-------------------------------------------------- 17 0000 CODESG SEGMENT PARA 'Code' 18 0000 BEGIN PROC FAR 19 ASSUME
CS:CODESG,DS:DATASG,SS:STACKSG,ES:NOTHING 20 0000 1E PUSH DS ; DS
21 0001 2B C0 SUB AX,AX ; 22 0003 50 PUSH AX ;
23 0004 B8 ---- R MOV AX,DATASG ; DATASG 24 0007 8E D8 MOV
DS,AX ; DS 25 26 0009 A1 0000 R MOV AX,FLDA ; 0250 AX 27 000C 03
06 0002 R ADD AX,FLDB ; 0125 AX 28 0010 A3 0004 R MOV FLDC,AX
; FLDC
29 0013 CB RET ; DOS 30 0014 BEGIN ENDP 31 0014 CODESG ENDS
END BEGIN
Segments and Groups:
N a m e Size Align Combine Class
CODESG . . . . . . . . . . . . 0014 PARA NONE 'CODE'
DATASG . . . . . . . . . . . . 0006 PARA NONE 'DATA'
STACKSG. . . . . . . . . . . . 0040 PARA STACK 'STACK'
Symbols:
N a m e Type Value Attr
BEGIN. . . . . . . . . . . . . F PROC 0000 CODESG Length=0014
FLDA . . . . . . . . . . . . . L WORD 0000 DATASG
FLDB . . . . . . . . . . . . . L WORD 0002 DATASG
FLDC . . . . . . . . . . . . . L WORD 0004 DATASG

IBM PC . . 18

EXASM2 (EXE)
Symbol Cross Reference (# is definition) Cref-1
BEGIN. . . . . . . . . . . . 18# 30 32
CODE . . . . . . . . . . . . 17
CODESG . . . . . . . . . . . 17# 19 31
DATA . . . . . . . . . . . . 11
DATASG . . . . . . . . . . . 11# 15 19 23
FLDA . . . . . . . . . . . . 12# 26
FLDB . . . . . . . . . . . . 13# 27
FLDC . . . . . . . . . . . . 14# 28
STACK. . . . . . . . . . . . 4
STACKSG. . . . . . . . . . . 4# 9 19
10 Symbols

IBM PC . . 19

page 60,132
TITLE EXDEF (EXE)
0000 DATASG SEGMENT PARA 'Data'
; - DB:
; ---------------------0000 ?? FLD1DB DB ? ;
0001 50 65 72 73 6F 6E FLD2DB DB 'Personal Computer' ;.
61 6C 20 43 6F 6D
70 75 74 65 72
0012 20 FLD3DB DB 32 ;
0013 20 FLD4DB DB 20H ;.
0014 59 FLD5DB DB 01011001B ;
0015 01 4A 41 4E 02 46 FLD6DB DB 01,'JAN',02,'FEB',03,'MAR' ;
45 42 03 4D 41 52
0021 33 32 36 35 34 FLD7DB DB '32654' ;
0026 0A [ 00 ] FLD8DB DB 10 DUP(0) ;
; - DW:
; ---------------------0030 FFF0 FLD1DW DW 0FFF0H ;.
0032 0059 FLD2DW DW 01011001B ;
0034 0021 R FLD3DW DW FLD7DB ;
0036 0003 0004 0007 FLD4DW DW 3,4,7,8,9 ;
0008 0009
0040 05 [ 0000 ] FLD5DW DW 5 DUP(0) ;
; - DD:
; ------------------------------004A ???????? FLD1DD DD ? ;
004E 43 50 00 00 FLD2DD DD 'PC' ;
0052 3C 7F 00 00 FLD3DD DD 32572 ;
0056 11 00 00 00 FLD4DD DD FLD3DB - FLD2DB ;
005A 0E 00 00 00 31 00 FLD5DD DD 14,49 ;
00 00
; - DQ:
; -----------------------------------0062 ???????????????? FLD1DQ DQ ? ;
006A 47 4D 00 00 00 00 FLD2DQ DQ 04D47H ;.
00 00
0072 3C 7F 00 00 00 00 FLD3DQ DQ 32572 ;.
00 00
; - DT:
; ---------------------------007A ?????????????????? FLD1DT DT ? ;

??
0084 43 50 00 00 00 00 FLD2DT DT 'PC' ;
00 00 00 00
008E DATASG ENDS
END

IBM PC . . 20
Segments and Groups:
N a m e Size Align Combine Class
DATASG . . . . . . . . . . . . 008E PARA NONE 'DATA'
Symbols:
N a m e Type Value Attr
FLD1DB . . . . . . . . . . . . L BYTE 0000 DATASG
FLD1DD . . . . . . . . . . . . L DWORD 004A DATASG
FLD1DQ . . . . . . . . . . . . L QWORD 0062 DATASG
FLD1DT . . . . . . . . . . . . L TBYTE 007A DATASG
FLD1DW . . . . . . . . . . . . L WORD 0030 DATASG
FLD2DB . . . . . . . . . . . . L BYTE 0001 DATASG
FLD2DD . . . . . . . . . . . . L DWORD 004E DATASG
FLD2DQ . . . . . . . . . . . . L QWORD 006A DATASG
FLD2DT . . . . . . . . . . . . L TBYTE 0084 DATASG
FLD2DW . . . . . . . . . . . . L WORD 0032 DATASG
FLD3DB . . . . . . . . . . . . L BYTE 0012 DATASG
FLD3DD . . . . . . . . . . . . L DWORD 0052 DATASG
FLD3DQ . . . . . . . . . . . . L QWORD 0072 DATASG
FLD3DW . . . . . . . . . . . . L WORD 0034 DATASG
FLD4DB . . . . . . . . . . . . L BYTE 0013 DATASG
FLD4DD . . . . . . . . . . . . L DWORD 0056 DATASG
FLD4DW . . . . . . . . . . . . L WORD 0036 DATASG
FLD5DB . . . . . . . . . . . . L BYTE 0014 DATASG
FLD5DD . . . . . . . . . . . . L DWORD 005A DATASG
FLD5DW . . . . . . . . . . . . L WORD 0040 DATASG Length =0005
FLD6DB . . . . . . . . . . . . L BYTE 0015 DATASG
FLD7DB . . . . . . . . . . . . L BYTE 0021 DATASG
FLD8DB . . . . . . . . . . . . L BYTE 0026 DATASG Length =000A

IBM PC . . 21
D:\ D>DEBUG D:EXDEF.EXE -D 1421:0000 00 50 65 72 73 6F 6E 61-6C 20 43 6F 6D 70 75 74
.Personal Comput 1421:0010 65 72 20 20 59 01 4A 41-4E 02 46 45 42 03 4D 41 er Y.JAN.FEB.MA
1421:0020 52 33 32 36 35 34 00 00-00 00 00 00 00 00 00 00 R32654.......... 1421:0030 F0 FF 59 00
21 00 03 00-04 00 07 00 08 00 09 00 ..Y.!........... 1421:0040 00 00 00 00 00 00 00 00-00 00 00 00
00 00 43 50 ..............CP 1421:0050 00 00 3C 7F 00 00 11 00-00 00 0E 00 00 00 31 00 ..<...........1.
1421:0060 00 00 00 00 00 00 00 00-00 00 47 4D 00 00 00 00 ..........GM.... 1421:0070 00 00 3C 7F
00 00 00 00-00 00 00 00 00 00 00 00 ..<............. -D 1421:0080 00 00 00 00 43 50 00 00-00 00 00 00
00 00 33 33 ....CP........33 1421:0090 3E 36 33 33 73 00 00 00-0A 0E 00 00 3E 63 63 30
>633s.......>cc0 1421:00A0 1C 06 63 63 3E 00 00 00-0A 0E 00 00 FF DB 99 18 ..cc>...........
1421:00B0 18 18 18 18 3C 00 00 00-0A 0E 00 00 63 63 63 63 ....<.......cccc 1421:00C0 63 63 63 63
3E 00 00 00-0A 0E 00 00 C3 C3 C3 C3 cccc>........... 1421:00D0 C3 C3 66 3C 18 00 00 00-0A 0E
00 00 C3 C3 C3 C3 ..f<............ 1421:00E0 DB DB FF 66 66 00 00 00-0A 0E 00 00 C3 C3 66 3C
...ff.........f< 1421:00F0 18 3C 66 C3 C3 00 00 00-0A 0E 00 00 C3 C3 C3 66 .<f............f -Q

IBM PC . . 22

page 60,132
TITLE EXIMM (EXE)
; ( ,
; ) 0000 DATASG SEGMENT PARA 'Data' 0000 ?? FLD1 DB ? 0001
???? FLD2 DW ? 0003 DATASG ENDS
0000 CODESG SEGMENT PARA 'Code' 0000 BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG
; :
; ------------------------------ 0000 BB 0113 MOV BX,275 ; 0003 3C 19 CMP AL,H
;
; :
; ----------------------- 0005 14 05 ADC AL,5 ; 0007 80 C7 0C ADD
BH,12 ; 000A 1C 05 SBB AL,5 ; 000C 80 2E 000 R 05 SUB
FLD1,5 ;
; ( 1 ):
; --------------------------------- 0011 D0 D3 RCL BL,1 ; 0013 D0 DC
RCR AH,1 ; 0015 D1 06 0001 R ROL FID2,1 ; 0019
D0 C8 ROR AL,1 ; 001B D1 E1 SAL CX,1 ; 001D D1 FB SAR BX,1
;. 001F D0 2E 0000 R SHR FLD1,1 ;
; :
; ------------------- 0023 24 2C AND AL,00101100B ;AND () 0025 80 CF 2A OR
BH,2AH ;OR () 0028 F6 C3 7A TEST BL,7AH ;TEST () 002B 80 36 0000 R 23
OR FLD1,23H ;XOR () 0030 BEGIN ENDP 0030 CODESG ENDS
END

IBM PC . . 23

page 60,132 TITLE XCOM1 COM- CODESG


SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG
ORG 100H ; PSP BEGIN: JMP MAIN ; ; -------------------------------------------------- FLDA DW 250 ; FLDB DW 125 FLDC DW ? ; -------------------------------------------------- MAIN PROC NEAR
MOV AX,FLDA ; 0250 AX
ADD AX,FLDB ; 0125 AX
MOV FLDC,AX ; FLDC
RET ; DOS MAIN ENDP CODESG ENDS
END BEGIN

page 60,132
TITLE EXJUMP (COM) JMP 0000 CODESG SEGMENT
PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG 0100 ORG 100H
0100 MAIN PROC NEAR 0100 B8 0001 MOV AX,01 ; AX, 0103 BB 0001 MOV
BX,01 ; BX, 0106 B9 0001 MOV CX,01 ; CX 0109 A20: 0109 05 0001 ADD AX,01 ;
01 AX 010C 03 D8 ADD BX,AX ; 01 BX 010E D1 E1 SHL CX,1 ; CX
0110 EB F7 JMP A20 ; A20 0112 MAIN ENDP 0112 CODESG ENDS
END MAIN

IBM PC . . 24

page 60,132
TITLE EXLOOP (COM) LOOP 0000 CODESG SEGMENT
PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG 0100 ORG 100H
0100 BEGIN PROC NEAR 0100 B8 0001 MOV AX,01 ; AX, 0103 BB 0001
MOV BX,01 ; BX, 0106 BA 0001 MOV DX,01 ; DX 0109 B9 000A MOV CX,10 ;
010C A20: 010C 40 INC AX ; 01 AX 010D 03 D8 ADD BX,AX ; AX
BX 010F D1 E2 SHL DX,1 ; DX 0111 E2 F9 LOOP A20 ; CX
; , 0113 C3 RET ; 0114 BEGIN ENDP 0114 CODESG
ENDS
END BEGIN

+-------------------------+
| CODESG SEGMENT PARA |
+-------------------------+
| BEGIN PROC FAR |
|.|
|.|
| CALL B10 |
| CALL C10 |
| RET |
| BEGIN ENDP |
+-------------------------+
| B10 PROC NEAR |
|.|
|.|
| RET |
| B10 ENDP |
+-------------------------+
| C10 PROC NEAR |
|.|
|.|
| RET |
| C10 ENDP |
+-------------------------+
| CODESG ENDS |
| END BEGIN |
+-------------------------+

IBM PC . . 25

TITLE CALLPROC (EXE) 0000 STACKSG SEGMENT PARA STACK


'Stack' 0000 20 [ ???? ] DW 32 DUP(?) 0040 STACKG ENDS
0000 CODESG SEGMENT PARA 'Code' 0000 BEGIN PROC FAR
ASSUME CS:CODESG,SS:STACKSG 0000 1E PUSH DS 0001 2B C0 SUB AX,AX 0003 50
PUSH AX 0004 E8 0008 R CALL B10 ; B10
; ... 0007 CB RET ; 0008 BEGIN ENDP
;-------------------------------------- 0008 B10 PROC 0008 E8 000C R CALL C10 ; C10
; ... 000B C3 RET ; 000C B10 ENDP ;
;---------------------------------------------- 000C C10 PROC
; ... 000C C3 RET ; 000D C10 ENDP ;
;---------------------------------------------- 000D CODESG ENDS
END BEGIN

IBM PC . . 26

page 65,132 TITLE EXMOVE (EXE) ;----------------------------------------------------- STACKSG SEGMENT PARA STACK 'Stack'
DW 32 DUP(?) STACKSG ENDS ;------------------------------------------------------ DATASG
SEGMENT PARA 'Data' NAME1 DB 'ABCDEFGHI' NAME2 DB 'JKLMNOPQR' NAME3 DB
'STUVWXYZ*' DATASG ENDS ;------------------------------------------------------- CODESG
SEGMENT PARA 'Code' BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DATASG
MOV DS,AX
MOV ES,AX
CALL B10MOVE ; JUMP
CALL C10MOVE ; CALL
RET ; BEGIN ENDP
; (JUMP-), ; : ; ---------------------------------------- B10MOVE PROC
LEA SI,NAME1 ;
LEA DI,NAME2 ; NAME1 NAME2
MOV CX,09 ; 9 B20:
MOV AL,[SI] ; NAME1
MOV [DI],AL ; NAME2
INC SI ; NAME1
INC DI ; NAME2
DEC CX ;
JNZ B20 ; > 0? -
RET ; = 0, B10MOVE ENDP ;
; (LOOP-), ; LOOP: ; ----------------------------------------; C10MOVE PROC
LEA SI,NAME2 ;
LEA DI,NAME3 ; NAME2 NAME3
MOV CX,09 ; 9 C20

IBM PC . . 27
MOV AL,[SI] ; NAME2
MOV [DI],AL ; NAME3
INC DI ; NAME2
INC SI ; NAME3
LOOP C20 ; ,
; ,
RET ; = 0, C10MOVE ENDP ; CODESG ENDS
END BEGIN

TITLE CASE (COM) 0000 CODESG SEGMENT PARA


'CODE'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG 0001 ORG 100H 0001 EB 1C 90 BEGIN:
JMP MAIN
; ------------------------------------------- 0003 43 68 61 6E 67 65 TITLEX DB 'Change to uppercase
letters'
20 74 6F 20 75 70
70 65 72 63 61 73
65 20 6C 65 74 74
65 72 73
; ------------------------------------------- 011E MAIN PROC NEAR 011E 8D 1E 0104 R LEA
BX,TITLEX+1 ; 0122 B9 001F MOV CX,31 ; 0125 B20:
0125 8A 27 MOV AH,[BX] ; TITLEX 0127 80 FC 61 CMP AH,61H ; 012A 72 0A
JB B30 ; 012C 80 FC 7A CMP AH,7AH ; 012F 77 05 JA B30 ; ? 0131 80 E4 DF
AND AH,11011111B ; - 0134 88 27 MOV [BX],AH ; TITLEX 0136
B30: 0136 43 INC BX ; 0137 E2 EC LOOP B20 ; 31
0139 C3 RET 013A MAIN ENDP 013A CODESG ENDS
END BEGIN

IBM PC . . 28

page 60,132 TITLE ALLASC (COM) ASCII- 00-FF CODESC


SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:NOTHING
ORG 100H BEGIN: JMP SHORT MAIN CTR DB 00,'S'
; : ; ------------------ MAIN PROC NEAR
CALL B10CDR ;
CALL C10SET ;
CALL D10DISP ;
RET MAIN ENDP ; : ; -------------- B10CLR PROC
MOV AX,0600H
MOV BH,07
MOV CX,0000 ;
MOV DX,184FH ;
INT 10H
RET B10CLR ENDP ; 00,00: ; ------------------------- C10SET PROC
MOV AN,02
MOV BN,00
MOV DX,0000
INT 10H
RET C10SET ENDP ; ASCII : ; ----------------------------- D10DISP
PROC
MOV CX,256 ;256
LEA DX,CTR ; D20
MOV AH,09 ;
INT 21H
INC CTR ;
LOOP D20 ; CX,
; ,
RET ; D10DISP ENDP
CODESG ENDS
END BEGIN

IBM PC . . 29

page 60,132 TITLE CTRNAME (EXE) ;------------------------------------------------------- STSCKSG SEGMENT PARA STACK 'Stack'
DW 32 DUP(?) STACKSG ENDS ;-------------------------------------------------------- DATASG
SEGMENT PARA 'Data' NAMEPAR LABEL BYTE ; : MAXNLEN DB
20 ; . NAMELEN DB ? ; NAMEFLD DB 20 DUP('
'),'$' ;
; PRIMPT DB 'Name? ', '$' DATASG ENDS ;------------------------------------------------------- CODESG SEGMENT PARA 'Code" BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASC
PUSH DS
SUB AX,AX
PUCH AX
MOV AX,DATASC
MOV DS,AX
MOV ES,AX
CALL Q10CLR ; A20LOOP:
MOV DX,0000 ; 00,00
CALL Q20CURS
CALL B10PRMP ;
CALL D10INPT ;
CALL Q10CLR ;
CMP NAMELEN,00 ; ?
JE A30 ; -
CALL E10CODE ;
; '$'
CALL F10CENT ;
JMP A20LOOP
A30:
RET ; DOS BEGIN ENDP ; : ; -------------------- B10PRMP
PROC NEAR
MUV AN,09 ;
LEA DX,PROMPT
INT 21H
RET B10PRMP ENDP ; : ; ----------------------- D10INPT PROC
NEAR

IBM PC . . 30
MOV AN,0AN ;
LEA DX,NAMEPAR
INT 21H
RET D10INPT ENDP ; '$': ; -----------------------------------E10CODE PROC NEAR
MOV BN,00 ; Return (0D)
MOV BL,NAMELEN ; . (07)
MOV NAMEFLD[BX],07
MOV NAMEFLD[BX+1],'$' ;
RET E10CODE ENDP ; : ; ----------------------------------- F10CENT PROC NEAR
MOV DL,NAMELEN ; :
SHR DL,1 ; 2,
NEG DL ; ,
ADD DL,40 ; 40
MOV DH,12 ;
CALL Q20CURS ;
MOV AN,09
LEA DX,NAMEFLD ;
INT 21H
RET F10CENT ENDP ; : ; -------------- Q10CLR PROC NEAR
MOV AX,0600H ;
MOV BH,30 ; (07 /)
MOV CX,0000 ; 00,00
MOV DX,184FH ; 24,79
INT 10H ; BIOS
RET Q10CLR ; (/): ; ---------------------------------Q20CURS PROC NEAR ;DX
MOV AH,02 ;
MOV BH,00 ; #0
INT 10H ; BIOS
RET Q20CURS ENDP
CODESG ENDS
END BEGIN

IBM PC . . 31

page 60,132 TITLE NMSCROLL (EXE) , , ; ------------------------------------------------------ STACKSG SEGMENT PARA STACK 'Stack'
DW 32 DUP(?) STACKSG SEGMENT PARA STACK 'Stack'
DW 32 DUP(?) STACKG ENDS ; ------------------------------------------------------- DATASG
SEGMENT PARA 'Data' NAMEPAR LABEL BYTE ; : MAXNLEN DB
20 ; . ACTNLEN DB ? ; NAMEFLD DB 20 DUP('
') ;
COL DB 00 COUNT DB ? PROMPT DB 'Name? ' ROW DB 00 DATASG ENDS ; ------------------------------------------------------ CODESG SEGMENT PARA 'Code' BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG
PUSH DS
SUB AX,AX
PUSH DS
MOV AX,DATASG
MOV ES,AX
MOV AX,0600H
CALL Q10CLR ; A20LOOP:
MOV COL,00 ; 0
CALL Q20CURS
CALL B10PRMP ;
CALL D10INPT ;
CMP ACTNLEN,00 ; ? (.. )
JNE A30
MOV AX,0600H
CALL Q10CLR ; , ,
RET ; A30:
CALL E10NAME ;
JMP A20LOOP BEGIN ENDP ; : ; -------------------- B10PRMP PROC
NEAR
LEA SI,PROMPT ;
MOV COUNT,05 B20:
MOV BL,70H ;

IBM PC . . 32
CALL F10DISP ;
INC SI ;
INC COL ;
CALL Q20CURS
DEC COUNT ;
JNZ B20 ; n
RET B10PRMP ENDP ; : ; ---------------------- D10INPT PROC NEAR
MOV AN,0AH
LEA DX,NAMEPAR
INT 21H
RET D10INPT ENDP ; : ; ---------------------------------E10NAME PROC NEAR
LEA SI,NAMEFLD ;
MOV COL,40 ; E20:
CALL Q20CURS ;
MOV BL,0FOH ;
CALL F10DISP ;
INS SI ;
INS COL ;
DES ACTNLEN ;
JNZ E20 ; n
CMP ROW,20 ; ?
JAE E30 ;
INC ROW
RET E30: MOV AX,0601H ; -CALL Q10CLR ;
RET E10NAME ENDP ; : ; ---------------------- F10DISP PROC
NEAR ;BL ()
MOV AN,09 ;
MOV AL,[SI] ;
MOV BH,00 ;
MOV CX,01 ;
INT 10H ; BIOS
RET F10DISP ENDP ; : ; -------------- Q10CLR PROC NEAR ;AX

MOV BH,07 ; /
MOV CX 0000
MOV DX,184FH

IBM PC . . 33
INT 10H ; BIOS
RET Q10CLR ENDP ; (/): ; ---------------------------------Q20CURS PROC NEAR
MOV AN,02
MOV BH,00
MOV DH,ROW
MOV DL,COL
INT 10H
RET Q20CURS ENDP CODESG ENDS
END BEGIN

-
Alt/A Alt/Z 1E - 2C
F1 F10 3B - 44
Home 47
48
PgUp 49
4B
4D
End 4F
50
PgDn 51
Ins 52
Del 53

IBM PC . . 34
TITLE GRAPHIX (COM) CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG
ORG 100H
MAIN PROC NEAR
MOV AN,00 ;
MOV AL,0DH ; EGA (CGA=04)
MOV AH,0BH ;
MOV BH,00 ;
MOV BL,02 ;
INT 10H
MOV BX,00 ; ,
MOV CX,00 ;
MOV DX,00 ; A50:
MOV AH,0CH ;
MOV AL,BL ;
INT 10H ;BX, CX, DX
INC CX ;
CMP CX,320 ; 320?
JNE A50 ; - ,
MOV CX,00 ; -
INS BL ;
INS DX ;
CMP DX,40 ; 40?
JNE A50 ; - ,
RET ; - MAIN ENDP CODESG ENDS
END MAIN

IBM PC . . 35

page 60,132 TITLE STRING (EXE) ; -------------------------------------------------- STACKSG SEGMENT PARA STACK 'Stack'
DW 32 DUP(?) STACKG ENDS ; --------------------------------------------------- DATASG
SEGMENT PARA 'Data' NAME1 DB 'Assemblers' ; NAME2 DB 10 DUP(' ')
NAME3 DB 10 DUP(' ') DATASG ENDS ; --------------------------------------------------- CODESG
SEGMENT PARA 'Code' BEGIN PROC FAR ;
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DATASG
MOV DS,AX
MOV ES,AX
CALL C10MVSB ; MVSB
CALL D10MVSW ; LODS
CALL E10LODS ; LODS
CALL F10STOS ; CMPS
CALL H10SCAS ; SCAS
RET BEGIN ENDP ; MOVSB: ; ------------------- C10MVSB PROC NEAR
CLD
LEA SI,NAME1
LEA D1,NAME2
MOV CX,10 ; 10
REP MOVSB ; NAME1 NAME2
RET C10MVSB ENDP ; MOVSW: ; ------------------- D10MVSW PROC
NEAR
CLD
LEA SI,NAME2
LEA DI,NAME3
MOV CX,05 ; 5
REP MOVSW ; NAME2 NAME3
RET D10MVSW ENDP ; LODSW: ; ------------------- E10LODS PROC NEAR

IBM PC . . 36
CLD
LEA SI,NAME1 ;
LODSW ; NAME1 AX
RET E10LODS ENDP ; STOSW: ; ------------------- F10STOS PROC NEAR
CLD
LEA D1,NAME3
MOV CX,05
MOV AX,2020H ;
REP STOSW ; NAME3
RET F10STOS ENDP ; CMPSB: ; ------------------- G10CMPS PROC NEAR
CLD
MOV CX,10
LEA SI,NAME1
LEA DI,NAME2
REPE CMPSB ; NAME1 NAME2
JNE G20 ; ?
MOV BH,01
G20: MOV CX,10
LEA SI,NAME2
LEA DI,NAME3
REPE CMPSB ; NAME2 NAME3
JE G30 ; ,
MOV BL,02 G30: RET G10CMPS ENDP
; SCASB: ; ------------------- H10SCAS PROC NEAR
CLD
MOV CX,10
LEA DI,NAME1
MOV AL,'m' ; 'm'
REPNE SCASB ; NAME1
JNE H20 ; -
MOV AH,03 H20: RET H10SCAS ENDP
CODES ENDS
END BEGIN

IBM PC . . 37

page 60,132 TITLE EXRING (COM) , CODESG


SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ;-------------------------------------------------------NAMEPAR LABEL BYTE ; MAXNLEN DB 31 ;.
ACTNLEN DB ? ; NAMEFLD DB 31 DUP(' ') ;
PROMPT DB 'Name?', '$' NAMEDSP DB 31 DUP(' '), 13, 10, '$' ROW DB 00 ;------------------------------------------------------- MAIN PROC NEAR ;
MOV AX,0600H
CALL Q10SCR ;
SUB DX,DX ; 00,00
CALL Q20CURS A10LOOP:
CALL B10INPT ;
TEST ACTNLEN,0FFH ; ? (.. )
JZ A90 ; -
CALL D10SCAS ;
CMP AL,'*' ;?
JE A10LOOP ; -
CALL E10RGHT ;
CALL A10LOOP A90: RET MAIN ENDP ; : ; ---------------------------- B10INPT PROC
MOV AH,09
LEA DX,PROMPT ;
INT 21H
RET B10INPT ENDP ; : ; ----------------------- D10SCAS PROC
CLD
MOV AL,'*'
MOV CX,30 ; - 30
LEA DI,NAMEFLD
REPNE SCASB ; ?
JE D20 ; - ,
MOV AL,20H ; * AL D20: RET D10SCAS ENDP

IBM PC . . 38
; : ; ------------------------------------ E10RGHT PROC
STD
SUB CH,CH
MOV CL,ACTNLEN ; CX REP
LEA SI,NAMEFLD ;
ADD SI,CX ;
DEC SI ;
LEA DI,NAMEDSP+30 ; .
REP MOVSB ;
MOV DH,ROW
MOV DL,48
CALL Q20CURS ;
MOV AH,09
LEA DX,NAMEDSP ;
INT 21H
CMP ROW,20 ; ?
JAE E20 ; INC ROW ; ,
JMP E90 E20:
MOV AX,0601H ; CALL Q10SCR ;
MOV DH,ROW ;
MOV DL,00
CALL Q20CURS E90: RET E10RGHT ENDP ; : ; ---------------------F10CLNM PROC
CLD
MOV AX,2020H
MOV CX,15 ; 15
LEA DI,NAMEDSP
REP STOSW
RET F10CLNM ENDP ; : ; ---------------- Q10SCR PROC ;AX

MOV BH,30 ; ( 07 /)
MOV CX,00
MOV DX,184FH
INT 10H
RET Q10SCR ENDP ; (/): ; ---------------------------------Q20CURS PROC ;DX
MOV AH,02
SUB BH,BH

IBM PC . . 39
INT 10H
RET Q20CURS ENDP CODESG ENDS
END BEGIN

IBM PC . . 84
TITLE EXDWMUL - CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ; --------------------------------------------- MULTCND
DW 3206H ;
DW 2521H MULTPLR DW 6400H
DW 0A26H PRODUCT DW 0
DW 0
DW 0
DW 0 ; --------------------------------------------- MAIN PROC NEAR ;
CALL E10XMUL ; 1-
CALL Z10ZERO ;
CALL F10XMUL ; 2-
RET MAIN ENDP ; : ; ---------------------------------------------- E10XMUL PROC
MOV AX,MULTCND+2 ;
MUL MULTPLR ;
MOV PRODUCT+4,AX ;
MOV PRODUCT+2,DX
MOV AX,MULTCND ;
MUL MULTPLR ;
ADD PRODUCT+2,AX ;
ADC PRODUCT,DX
RET E10XMUL ENDP ; : ; ------------------------------------------- F10XMUL PROC
MOV AX,MULTCND+2 ;-2
MUL MULTPLR+2 ; * -2
MOV PRODUCT+6,AX ;
MOV PRODUCT+4,DX
MOV AX,MULTCND+2 ;-2
MUL MULTPLR ; * -1
ADD PRODUCT+4,AX ;
ADC PRODUCT+6,DX
ADC PRODUCT,00 ;
MOV AX,MULTCND ;-1
MUL MULTPLR+2 ; * -2
ADD PRODUCT+4,AX ;

IBM PC . . 85
ADC PRODUCT+6,DX
ADC PRODUCT,00 ;
MOV AX,MULTCND ;-1
MUL MULTPLR ; * -1
ADD PRODUCT+2,AX ;
ADC PRODUCT,DX
RET F10XMUL ENDP ; : ; ---------------------------------------Z10XMUL PROC
MOV PRODUCT,0000
MOV PRODUCT+2,0000
MOV PRODUCT+4,0000
MOV PRODUCT+6,0000
RET Z10XMUL ENDP
CODESG ENDS
END BEGIN

IBM PC . . 86

page 60,132 TITLE EXDIV (COM) DIV IDIV CODESG SEGMENT


PARA 'Code'
ORG 100H BEGIN: JMP SHORT MAIN ; --------------------------------------------- BYTE1 DB
80H ;Data items BYTE2 DB 16H WORD1 DW 2000H WORD2 DW 0010H WORD3 DW 1000H ;
--------------------------------------------- MAIN PROC NEAR ;
CALL D10DIV ; DIV
CALL E10IDIV ; IDIV MAIN ENDP ; DIV: ; -------------------------------------------- D10DIV PROC
MOV AX,WORD1 ; /
DIV BYTE1 ; : AH:AL
MOV AL,BYTE1 ; /
SUB AH,AH ; AH
DIV BYTE3 ; : AH:AL
MOV DX,WORD2 ; /
MOV AX,WORD3 ; DX:AX
DIV WORD1 ; : DX:AX
MOV AX,WORD1 ; /
SUB DX,DX ; DX
DIV WORD3 ; : DX:AX
RET D10DIV ENDP ; IDIV: ; --------------------------------------------E10IDIV PROC
MOV AX,WORD1 ; /
IDIV BYTE1 ; : AH:AL
MOV AL,BYTE1 ; /
CBW ; AH
IDIV BYTE3 ; : AH:AL
MOV DX,WORD2 ; /
MOV AX,WORD3 ; DX:AX
IDIV WORD1 ; : DX:AX
MOV AX,WORD1 ; /
CWD ; DX
IDIV WORD3 ; : DX:AX
RET E10DIV ENDP
CODESG ENDS

IBM PC . . 87
END BEGIN
TITLE ASCADD (COM) ASCII- CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ; ----------------------------------------------- ASC1 DB
'578' ; ASC2 DB '694' ASC3 DB '0000' ; ----------------------------------------------MAIN PROC NEAR
CLC
LEA SI,AASC1+2 ; ASCII-
LEA DI,AASC2+2
LEA BX,AASC1+3
MOV CX,03 ; 3 A20:
MOV AH,00 ; AH
MOV AL,[SI] ; ASCII-
ADC AL,[DI] ; ( )
AAA ; ASCII
MOV [BX],AL ;
DEC SI
DEC DI
DEC BX
LOOP A20 ; 3
MOV [BX],AH ;
RET MAIN ENDP CODESG ENDS
END BEGIN

IBM PC . . 88
TITLE ASCMUL (COM) ASCII- CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG
ORG 100H BEGIN: JMP MAIN ; --------------------------------------------- MULTCND DB '3783'
; MULTPLR DB '5' PRODUCT DB 5 DUP(0) ; -------------------------------------------- MAIN PROC NEAR
MOV CX,04 ;4
LEA SI,MULTCND+3
LEA DI,PRODUCT+4
AND MULTPLR,0FH ; ASCII- A20:
MOV AL,[SI] ; ASCII-
; ( LODSB)
AND AL,OFH ; ASCII-
MUL MULTPLR ;
AAM ; ASCII
ADD AL,[DI] ;
AAA ;
MOV [DI],AL ;
DEC DI
MOV [DI],AH ;
DEC SI
LOOP A20 ; 4
RET MAIN ENDP CODESG ENDS
END BEGIN
TITLE ASCDIV (COM) ASCII- CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ; --------------------------------------------- DIVDND DB
'3698' ; DIVSOR DB '4' QUOTNT DB 4 DUP(0) ; -------------------------------------------- MAIN PROC NEAR
MOV CX,04 ;4
SUB AH,AH ;
AND DIVSOR,0FH ; ASCII 3
LEA SI,DIVDND
LEA DI,QUOTNT A20:

IBM PC . . 89
MOV AL,[SI] ; ASCII
; ( LODSB)
AND AL,0FH ; ASCII
AAD ;
DIV DIVSOR ;
MOV [DI],AL ;
INC SI
INC DI
LOOP A20 ; 4
RET MAIN ENDP CODEGS ENDS
END BEGIN

IBM PC . . 90
TITLE SCREMP (EXE) ,
; ; ---------------------------------------------------- STACKSG SEGMENT
PARA STACK 'Stack'
DW 32 DUP(?) STACKSG ENDS ; ---------------------------------------------------- DATASG
SEGMENT PARA 'Data' HRSPAR LABLE BYTE ;
; : MAXHLEN DB 6 ;--------------------- ACTHLEN DB ? HRSFLD DB 6
DUP(?)
RATEPAR LABLE BYTE ;
; : MAXRLEN DB 6 ;--------------------- ACTRLEN DB ? RATEFLN DB 6
DUP(?)
MESSG1 DB 'Hours worked? ','$' MESSG2 DB 'Rate of pay? ','$' MESSG3 DB 'Wage = '
ASCWAGE DB 10 DUP(30H), 13, 10, '$' ADJUST DW ? ASCHRS DB 0 ASCRATE DB 0
BINVAL DW 00 BINHRS DW 00 BINRATE DW 00 COL DB 00 DECIND DB 00 MULT10 DW
01 NODEC DW 00 ROW DB 00 SHIFT DW ? TENWD DW 10 DATASG ENDS ; --------------------------------------------------- CODESG SEGMENT PARA 'Code' BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DATASG
MOV DS,AX
MOV ES,AX
MOV AX,0600H
CALL Q10SCR ;
CALL Q20CURS ; A20LOOP:

IBM PC . . 91
CALL B10INPT ;
CMP ACTHLEN,00 ; ?
JE A30
CALL D10HOUR ;
CALL E10RATE ;
CALL F10MULT ;
CALL G10WAGE ; ASCII
CALL K10DISP ;
JMP A20LOOP A30:
MOV AX,0600H
CALL Q10SCR ;
RET ; BEGIN ENDP ; ; --------------------------------------------------- B10INPT PROC
LEA DX,MESSG1 ;
MOV AH,09
INT 21H
LEA DX,HRSPAR ;
MOV AH,0AH
INT 21H
CMP ACTHLEN,00 ; ?
JNE B20
RET ; - A20LOOP B20:
MOV COL,25 ;
CALL Q20CURS
LEA DX,MESSG2 ;
MOV AH,09
INT 21H
LEA DX,RATEPAR ;
MOV AH,0AH
INT 21H
RET B10INPT ENDP ; : ; ----------------- D10HOUR PROC
MOV NODEC,00
MOV CL,ACTHLEN
SUB CH,CH
LEA SI,HRSFLD-1 ;
ADD SI,CX ;
CALL M10ASBI ;
MOV AX,BINVAL
MOV BINHRS,AX
RET D10HOUR ENDP ; : ; ------------------ E10RATE PROC

IBM PC . . 92
MOV CL,ACTRLEN
SUB CH,CH
LEA SI,RATEFLD-1 ;
ADD SI.CX ;
CALL M10ASBI ;
MOV AX,BINVAL
MOV BINRATE,AX
RET E10RATE ENDP ; , : ; ----------------------------F10MULT PROC
MOV CX,05
LEA DI,ASCWAGE ;
MOV AX,3030H ; ASCII (30)
CLD
REP STOSW
MOV SHIFT,10
MOV ADJUST,00
MOV CX,NODEC
CMP CL,06 ; 6
JA F40 ; ,
DEC CX
DEC CX
JLE F30 ;, 3
MOV NODEC,02
MOV AX,01 F20:
MUL TENWD ;
LOOP F20
MOV SHIFT,AX
SHR AX,1 ;
MOV ADJUST,AX F30:
MOV AX,BINHRS
MUL BINRATE ;
ADD AX,ADJUST ;
ADC DX,00
CMP DX,SHIFT ;
JB F50 ; DIV? F40:
SUB AX,AX
JMP F70 F50:
CMP ADJUST,00 ; ?
JZ F80
DIV SHIFT ; F70: SUB DX,DX ; F80: RET F10MULT
ENDP ; ASCII : ; ----------------------------- G10WAGE PROC

IBM PC . . 93
LEA SI,ASCWAGE+7 ; .
MOV BYTE PTR[SI],'.'
ADD SI,NODEC ; G30:
CMP BYTE PTR[SI],'.'
JNE G35 ;, ..
DEC SI G35:
CMP DX,00 ; dx:ax < 10,
JNZ G40
CMP AX,0010 ;
JB G50 G40:
DIV TENWD ; - ASCII-
OR DL,30H
MOV [SI],DL ; ASCII
DEC SI
SUB DX,DX ;
JMP G30 G50:
OR AL,30H ; ASCII
MOV [SI],AL ;
RET G10WAGE ENDP ; : ; --------------------- K10DISP PROC
MOV COL,50 ;
CALL Q20CURS
MOV CX,09
LEA SI,ASCWAGE K20: ;
CMP BYTE PTR[SI],30H
JNE K30 ;
MOV BYTE PTR[SI],20H
INC SI
LOOP K20 K30:
LEA DX,MESSG3 ;
MOV AH,09
INT 21H
CMP ROW,20 ; ?
JAE K80
INC ROW ; -
JMP K90 K80:
MOV AX,0601H ; -CALL Q10SCR ;
MOV COL,00 ;
CALL Q20CURS K90: RET K10DISP ENDP ; ASCII-

IBM PC . . 94
; : ; -------------------------- M10ASBI PROC
MOV MULT10,0001
MOV BINVAL,00
MOV DECIND,00
SUB BX,BX M20:
MOV AL,[SI] ;ASCII-
CMP AL,'.' ;, .
JNE M40
MOV DECIND,01
JMP M90 M40:
AND AX,000FH
MUL MULT10 ;
ADD BINVAL,AX ; .
MOV AX,MULT10 ;
MUL TENVD ; x 10
MOV MULT10,AX
CMP DECIND,00 ; ?
JNZ M90
INC BX ; - M90:
DEC SI
LOOP M20
;
CMP DECIND,00 ; .?
JZ M100 ; -ADD NODEC,BX ; M100: RET M10ASBI ENDP ; : ; --------------- Q10SCR PROC NEAR ;AX
MOV BH,30 ; (07 /)
SUB CX,CX
MOV DX,184FH
INT 10H
RET Q10SCR ENDP ; : ; ----------------- Q20CURS PROC NEAR
MOV AH,02
SUB BH,BH
MOV DH,ROW
MOV DL,COL
INT 10H
RET Q20CURS ENDP
CODESG ENDS

IBM PC . . 95
END BEGIN

IBM PC . . 96

page 60,132 TITLE DIRECT (COM) CODESG SEGMENT PARA


'Code'
ASSUME CS:CODESG,DS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ; ------------------------------------------------ THREE DB
3 MONIN DB '11' ALFMON DB '???','$' MONTAB DB 'JAN','FEB','MAR','APR','MAY','JUN'
DB 'JUL','AUG','SEP','OKT','NOV','DEC' ; ------------------------------------------------ MAIN
PROC NEAR ;
CALL C10CONV ;
CALL D10LOC ;
CALL F10DISP ;
RET MAIN ENDP ; ASCII : ; ------------------------------------- C10CONV PROC
MOV AH,MONIN ;
MOV AL,MONIN+1
XOR AX,3030H ; ASCII
CMP AH,00 ; 01-09?
JZ C20 ; -
SUB AH,AH ; - AH,
ADD AL,10 ; C20 RET C10CONV ENDP ;
: ; --------------------------- D10LOC PROC
LEA SI,MONTAB
DEC AL ;
MUL THREE ; AL 3
ADD SI,AX
MOV CX,03 ;
CLD
LEA DI,ALFMON
REP MOVSB ; 3
RET D10LOC ENDP ; .: ; -------------------------- F10DISP PROC
LEA DX,ALFMON
MOV AH,09
INT 21H
RET F10DISP ENDP

IBM PC . . 97
CODESG ENDS
END BEGIN

IBM PC . . 98

page 60,132 TITLE TABSRCH (COM) CODESG SEGMENT PARA 'Code'


ASSUME CS:CODESG,DS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ; ----------------------------------------------- STOKNIN
DW '23' STOKTAB DB '05','Excavators'
DB '08','Lifters '
DB '09','Presses '
DB '12','Valves '
DB '23','Processors'
DB '27','Pumps ' DESCRN 10 DUP(?) ; ----------------------------------------------- MAIN PROC
NEAR
MOV AX,STOKNIN ;
XCHG AL,AH
MOV CX,06 ;
LEA SI,STOKTAB ; A20:
CMP AX,[SI] ;
JE A30 ; - ,
ADD SI,12 ; -
LOOP A20
CALL R10ERR ;
RET A30:
MOV CX,05 ;
LEA DI,DESCRN ;
INC SI
INC SI ;
REP MOVSW ;
RET MAIN ENDP ; R10ERR PROC ; < >
RET R10ERR ENDP
CODESG ENDS
END BEGIN

IBM PC . . 99

page 60,132 TITLE TABSRCH (COM) , CMPSB CODESG


SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ; ---------------------------------------------------STOKNIN DW '123' STOKTAB DB '035','Excavators' ;
DB '038','Lifters '
DB '049','Presses '
DB '102','Valves '
DB '123','Processors'
DB '127','Pumps '
DB '999', 10 DUP(' ') ; DESCRN 10 DUP(?) ; --------------------------------------------------- MAIN PROC NEAR
CLD
LEA SI,STOKTAB ; A20:
MOV CX,03 ; 3
LEA DI,STOKNIN ;
REPE CMPSB ;
JE A30 ; - ,
JA A40 ; -
ADD SI,CX ; CX
JMP A20 ; A30:
MOV CX,05 ; 5
LEA DI,DESCRN ;
REP MOVSV ;
RET A40:
CALL R10ERR ;
RET MAIN ENDP
R10ERR PROC ; < >
RET R10ERR ENDP
CODESG ENDS
END BEGIN

IBM PC . . 100

page 60,132 TITLE XLATE (COM) ASCII EBCDIC CODESG


SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP MAIN ; ---------------------------------------------------- ASCNO DB '31.5' EBCNO DB 6 DUP(' ') XLTAB DB 45 DUP(40H)
DB 60H, 2DH
DB 5CH
DB 0F0H,0F1H,0F2H,0F3H,0F4H
DB 0F5H,0F6H,0F7H,0F8H,0F9H
DB 199 DUP(40H) ; ---------------------------------------------------- MAIN PROC NEAR
;
LEA SI,ASCNO ; ASCNO
LEA DI,EBCNO ; EBCNO
MOV CX,06 ;
LEA BX,XLTAB ; A20:
MOV AL,[SI] ; ASCII
XLAT ;
MOV [DI],AL ; EBCNO
INC DI
INC SI
LOOP A20 ; 6
RET MAIN ENDP CODESG ENDS
END BEGIN

IBM PC . . 101

page 60,132 TITLE ASCHEX (COM) ASCII . CODESG SEGMENT


PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP MAIN ; ----------------------------------------------- DISPROW DB 16
DUP(' '), 13 HEXSTR DB 00 XLATAB DB 30H,31H,32H,33H,34H,35H,36H,37H,38H,39H
DB 41H,42H,43H,44H,45H,46H ; ----------------------------------------------- MAIN PROC NEAR
;
CALL Q10CLR ;
LEA SI,DISPROW A20LOOP:
CALL C10HEX ;
CALL D10DISP ;
CMP HEXCTR,0FFH ; (FF)?
JE A50 ; -
INC HEXCTR ; -
JMP A20LOOP A50: RET MAIN ENDP
C10HEX PROC NEAR ; .
MOV AH,00
MOV AL,HEXCTR ; .
SHR AX,CL ; .
LEA BX,XLATAB ;
MOV CL,04 ;
XLAT ; .
MOV [SI],AL ;
MOV AL,HEXCTR
SHL AX,CL ;
XLAT
MOV [SI]+1,AL ; .
RET ; C10HEX ENDP
D10DISP PROC NEAR ;
MOV AL,HEXCTR
MOV [SI]+3,AL
CMP AL,1AH ; EOF?
JE D20 ; -
CMP AL,07H ;/ 08?
JB D30 ; - OK
CMP AL,10H ;/ 0F?
JAE D30 ; - OK D20:
MOV BYTE PTR [SI]+3,20H

IBM PC . . 102
D30:
ADD SI,05 ;
LEA DI,DISPROW+80
CMP DI,SI
JNE D40
MOV AH,40H ;
MOV BX,01 ;
MOV CX,81 ;
LEA DX,DISPROW
INT 21H
LEA SI,DISPROW ; D40: RET D10DISP ENDP
Q10CLR PROC NEAR ;
MOV AX,0600H
MOV BH,03 ; (07 /)
MOV CX,0000
MOV DX,184FH
INT 10H
RET Q10CLR ENDP
CODESG ENDS
END BEGIN

IBM PC . . 103

page 60,132 TITLE NMSORT (EXE) ; ---------------------------------------------- STACK SGMENT PARA STACK 'Stack'
DW 32 DUP(?) STACK ENDS ; ----------------------------------------------- DATASG SEGMENT
PARA 'Data' NAMEPAR LABEL BYTE ; : MAXNLEN DB 21 ; .
NAMELEN DB ? ; NAMEFLD DB 21 DUP(' ') ;
CRLF DB 13, 10, '$' ENDADDR DW ? MESSG1 DB 'Name?', '$' NAMECTR DB 00 NAMETAB
DB 30 DUP(20 DUP(' ')) ; NAMESAV DB 20 DUP(?), 13, 10, '$' SWAPPED DB 00
DATA ENDS ; ----------------------------------------------- CODESG SEGMENT PARA 'Code' BEGIN
PROC FAR
ASSUME CS:CODESG,DS:DATDSG,SS:STACK,ES:DATASG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DATASG
MOV DS,AX
MOV ES,AX
CLD
LEA DI,NAMETAB
CALL Q10CLR ;
CALL Q20CURS ; A20LOOP:
CALL B10READ ;
CMP NAMELEN,00 ; ?
JZ A30 ; -
CMP NAMECTR,30 ; 30 ?
JE A30 ; -
CALL D10STOR ;
JMP A20LOOP A30: ;
CALL Q10CLR ;
CALL Q20CURS ;
CMP NAMECTR,01 ; 2 ?
JBE A40 ; -
CALL G10SORT ;
CALL K10DISP ; A40: RET ; BEGIN
ENDP

IBM PC . . 104
; ? ; ---------------------- B10READ PROC
MOV AH,09
LEA DX,MESSG1 ;
INT 21H
MOV AH,0AH
LEA DX,NAMEPAR ;
INT 21H
MOV AH,09
LEA DX,CRLF ; CRLF
INT 21H
MOV BH,00 ;
MOV BL,NAMELEN ;
MOV CX,21
SUB CX,BX ; B20:
MOV NAMEFLD[BX],20H ;
INC BX
LOOP B20
RET B10READ ENDP ; : ; ---------------------- D10STOR PROC
INC NAMECTR ;
CLD
LES SI,NAMEFLD
MOV CX,10
REP MOVSV ;
RET D10STOR ENDP ; : ; ------------------------- G10SORT PROC
SUB DI,40 ;
MOV ENDADDR,DI G20:
MOV SWAPPED,00 ;
LEA SI,NAMETAB ; G30:
MOV CX,20 ;
MOV DI,SI
ADD DI,20 ;
MOV AX,DI
MOV BX,SI
REPE CMPSB ;
JBE G40 ;
CALL H10XCHG ; G40:
MOV SI,AX
CMP SI,ENDADDR ; ?

IBM PC . . 105
JBE G30 ; -
CMP SWAPPED,00 ; ?
JNZ G20 ; - ,
RET ; - G10SORT ENDP ; : ; ----------------------------- H10XCHG PROC
MOV CX,10
LEA DI,NAMESAV
MOV SI,BX
REP MOVSW ;
MOV CX,10
MOV DI,BX
REP MOVSW ;
;
MOV CX,10
LEA SI,NAMESAV
REP MOVSW ;
;
MOV SWAPPED,01 ;
RET H10XCHG ENDP ; : ; ----------------------------------- K10DISP PROC
LEA SI,NAMETAB K20:
LEA DI,NAMESAV ;
MOV CX,10
REP MOVSV
MOV AH,09
LEA DX,NAMESAV
INT 21H ;
DEC NAMECTR ; ?
JNZ K20 ; - ,
RET ; - K10DISP ENDP ; : ; -------------- Q10CLR PROC
MOV AX,0600H
MOV BH,61H ; (07 /)
SUB CX,CX
MOV DX,184FH
INT 10H
RET Q10CLR ENDP ; : ; ----------------- Q20CURS PROC
MOV AH,02

IBM PC . . 106
SUB BH,BH
SUB DX,DX ; 00,00
INT 10H
RET Q20CURS ENDP
CODESG ENDS
END BEGIN

IBM PC . . 107

page 60,132 TITLE FCBCREAT (EXE) FCB ;--------------------------------------------------------- STACKSG SEGMENT PARA STACK 'Stack'
DW 80 DUP(?) STACKSG ENDS ;---------------------------------------------------------- DATASG
SEGMENT PARA 'Data' RECLEN EQU 32 NAMEPAR LABEL BYTE ; :
MAXLEN DB RECLEN ; . NAMELEN DB ? ;
NAMEDTA DB RECLEN DUP(' ') ; (DTA)
FCBREC LABEL BYTE ;FCB FCBDRIV DB 04 ; D FCBNAME
DB 'NAMEFILE' ; FCBEXT DB 'DAT' ; FCBBLK DW 0000 ;
FCBRCSZ DW ? ; FCBFLSZ DD ? ;
(DOS)
DW ? ; (DOS)
DT ? ; (DOS) FCBSQRC DB 00 ;
DD ? ;
CRLF DB 13,10,'$' ERRCDE DB 00 PROMPT DB 'Name? ','$' ROW DB 01 OPNMSG DB '***
Open error ***', '$' WRTMSG DB '*** Write error ***', '$' DATASG ENDS ; -------------------------------------------------------- CODESG SEGMENT PARA 'Code' BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DATASG
MOV DS,AX
MOV ES,AX
MOV AX,0600H
CALL Q10SCR ;
CALL Q20CURS ;
CALL C10OPEN ;, DTA
CMP ERRCDE,00 ; ?
JZ A20LOOP ; - ,
RET ; - DOS A20LOOP:
CALL D10PROC

IBM PC . . 108
CMP NAMELEN,00 ; ?
JNE A20LOOP ; - ,
CALL G10CLSE ; -
RET ; DOS BEGIN ENDP ; : ; -----------------------C10OPEN PROC NEAR
MOV AH,16H ;
LEA DX,FCBREC
INT 21H
CMP AL,00 ; ?
JNZ C20 ; -
MOV FCBRCSZ,RECLEN ; (EQU)
LEA DX,NAMEDTA ; DTA
MOV AH,1AH
INT 21AH
RET C20:
LEA DX,OPNMSG ;
CALL X10ERR
RET C10OPEN ENDP ; : ; ----------------- D10PROC PROC NEAR
MOV AH,09 ;
LEA DX,PROMPT ;
INT 21H
MOV AH,0AH ;
LEA DX,NAMEPAR ;
INT 21H
CALL E10DISP ;
CMP NAMELEN,00 ; ?
JNE D20 ; - ,
RET ; - D20:
MOV BH,00 ; Return
MOV BL,NAMELEN
MOV NAMEDTA[BX],' ' ;
CALL F10WRIT ;
;
CLD
LEA DI,NAMEDTA ;
MOV CX,RECLEN / 2 ;
MOV AX,2020H ;
REP STOSW
RET ; D10PROC ENDP ; :

IBM PC . . 109
; ----------------------------- E10DISP PROC NEAR
MOV AH,09 ;
LEA DX,CRLF ;CR/LF
INT 21H ; DOS
CMP ROW,18 ; ?
JAE E20 ; - ,
INC ROW ; -
RET E20:
MOV AX,0601H ; 1
CALL Q10SCR
CALL Q20CURS ;
RET E10DISP ENDP ; : ; -------------- F10WRIT PROC NEAR
MOV AH,15H ;
LEA DX,FCBREC
INT 21H
CMP AL,00 ; ?
JZ F20 ;
LEA DX,WRTMSG ; CALL X10ERR ;
MOV NAMELEN,00 F20: RET F10WRIT ENDP ; : ; ----------------------- G10CLSE PROC NEAR
MOV NAMEDTA,1AH ; EOF
CALL F10WRIT
MOV AH,10H ;
LEA DX,FCBREC
INT 21H
RET G10CLSE ENDP ; : ; ---------------- Q10SCR PROC NEAR ;AX

MOV BH,1EH ;
MOV CX,0000
MOV DX,184FH
INT 10H ;
RET Q10SCR ENDP ; : ; ----------------- Q20CURS PROC NEAR
MOV AH,02
MOV BH,00
MOV DL,00

IBM PC . . 110
MOV DH,ROW ;
INT 10H
RET Q20CURS ENDP ; : ; --------------------------------- X10ERR PROC NEAR
MOV AH,09 ;DX
INT 21H ;
MOV ERRCDE,01 ;
RET X10ERR ENDP
CODESG ENDS
END BEGIN

IBM PC . . 111
TITLE FCBREAD (EXE) CREATDSK ; ------------------------------------------------------ STACKSG SEGMENT PARA STACK 'Stack'
DW 80 DUP(?) STACKSG ENDS ;-------------------------------------------------------- DATASG
SEGMENT PARA 'Data' FCBREC LABEL BYTE ;FCB FCBDRIV DB 04 ;
D FCBNAME DB 'NAMEFILE' ; FCBEXT DB 'DAT' ; FCBBLK DW 0000
; FCBRCSZ DW 0000 ;
DD ? ; (DOS)
DW ? ; (DOS)
DT ? ; (DOS) FCBSQRC DB 00 ;
DD ? ;
RECLEN EQU 32 ; NAMEFLD DB RECLEN DUP(' '), 13, 10, '$'
ENDCDE DB 00 OPENMSG DB '*** Open error ***', '$' READMSG DB '*** Read error ***', '$'
ROW DB 00 DATASG ENDS ;-------------------------------------------------------- CODESG
SEGMENT PARA 'Code' BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DATASG
MOV DS,AX
MOV ES,AX
MOV AX,0600H
CALL Q10SCR ;
CALL Q20CURS ;
CALL E10OPEN ; ,
; DTA
CMP ENDCDE,00 ; ?
JNZ A90 ; - A20LOOP:
CALL F10READ ;
CMP ENDCDE,00 ; ?
JNZ A90 ; -
CALL G10DISP ;
JMP A20LOOP ; A90: RET ; BEGIN ENDP

IBM PC . . 112
; : ; ----------------------- E10OPEN PROC NEAR
LEA X,FCBREC
MOV AH,0FH ;
INT 21H
CMP AL,00 ; ?
JNZ E20 ; -
MOV FCBRCSZ,RECLEN ; (EQU)
MOV AH,1AH
LEA DX,NAMEFLD ; DTA
INT 21H
RET E20:
MOV ENDCDE,01 ;
LEA DX,OPENMSG
CALL X10ERROR
RET E10OPEN ENDP ; : ; ---------------------- F10READ PROC
NEAR
MOV AH,14H ;
LEA DX,FCBREC
INT 21H
CMP NAMEFLD,1AH ; EOF?
JNE F20 ;
MOV ENDCDE,01 ;
JMP F90 F20:
CMP AL,00 ; ?
JZ F90 ; -
MOV ENDCDE,01 ;:
CMP AL,01 ; ?
JZ F90 ; - ,
LEA DX,READMSG ; -
CALL X10ERR ; F90:
RET F10READ ENDP ; : ; --------------------- G10DISP PROC NEAR
MOV AH,09 ;
LEA DX,NAMEFLD
INT 21H
CMP ROW,20 ; ?
JAE G30 ; INC ROW ; -
JMP G90 G30:
MOV AX,0601H

IBM PC . . 113
CALL Q10SCR ;
CALL Q20CURS ; G90: RET G10DISP ENDP ; ()
: ; ---------------------------- Q10SCR PROC NEAR ;AX
MOV BH,1EH ;
MOV CX,0000
MOV DX,184FH ;
INT 10H
RET Q1OSCR ENDP ; : ; ----------------- Q20CURS PROC NEAR
MOV AH,02
MOV BH,00
MOV DH,ROW
MOV DL,00
INT 10H
RET Q20CURS ENDP ; : ; --------------------------------- X10ERR PROC NEAR
MOV AH,09 ;DX
INT 21H ;
RET X10ERR ENDP
CODESG ENDS
END BEGIN

page 60,132 TITLE RANREAD (COM) , ; FCBCREAT


CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP MAIN ;----------------------------------------------------- FCBREC
LABEL BYTE ;FCB FCBDRIV DB 04 ; D FCBNAME DB
'MAMEFILE' ; FCBEXT DB 'DAT' ; FCBBLK DW 0000 ;
FCBRCSZ DW 0000 ;
DD ? ; (DOS)
DW ? ; (DOS)
DT ? ; (DOS)

IBM PC . . 114
DB 00 ; FCBRNRC DD 000000000 ;
RECLEN EQU 32 ; RECDPAR LABEL BYTE ; : MAXLEN DB
3 ; ACTLEN DB ? ; RECDNO DB 3 DUP(' ') ;
NAMEFLD DB RECLEN DUP(' '),13,10,'$' ;DTA
OPENMSG DB '*** Open error ***',13,10,'$' READMSG DB '*** Read error ***',13,10,'$' COL
DB 00 PROMPT DB 'Record number? $' ROW DB 00 ENDCDE DB 00 ;---------------------------------------------------- MAIN PROC NEAR
CALL Q10CLR ;
CALL Q20CURS ;
CALL C10OPEN ; ,
; DTA
CMP ENDCDE,00 ; ?
JZ A20LOOP ; - ,
RET ; - A20LOOP:
CALL D10RECN ;
CMP ACTLEN,00 ; ?
JE A40 ; -
CALL F10READ ; ( )
CMP ENDCDE,00 ; ?
JNZ A30 ; -
CALL G10DISP ; A30:
JMP A20LOOP A40: RET ; MAIN ENDP ;
: ; ------------------------------------ C10OPEN PROC NEAR
MOV AH,0FH ;
LEA DX,FCBREC
INT 21H
CMP AL,00 ; ?
JNZ C20 ; -
MOV FCBRCSZ,RECLEN ; (EQU)
MOV AH,1AH
LEA DX,NAMEFLD ; DTA
INT 21H
RET C20:
LEA DX,OPENMSG

IBM PC . . 115
CALL X10ERR
RET C10OPEN ENDP ; : ; ------------------------------D10RECN PROC NEAR
MOV AH,09H ;
LEA DX,PROMPT
INT 21H
MOV AH,0AH ;
LEA DX,RECDPAR
INT 21H
CMP ACTLEN,01 ; (0,1,2)
JB D40 ; 0,
JA D20
SUB AH,AH ; 1
MOV AL,RECDNO
JMP D30 D20:
MOV AH,RECDNO ; 2
MOV AL,RECDNO+1 D30:
AND AX,0F0FH ; ASCII
AAD
MOV WORD PTR FCBRNRC,AX D40:
MOV COL,20
CALL Q20CURS ;
RET D10RECN ENDP ; : ; ---------------------- F10READ PROC
NEAR
MOV ENDCDE,00 ;
MOV AH,21H ;
LEA DX,FCBREC
INT 21H
CMP AL,00 ; ?
JZ F20 ; -
LEA DX,READMSG ; -
CALL X10ERR ; F20: RET F10READ ENDP ;
: ; -------------------- G10DISP PROC NEAR
MOV AH,09 ;
LEA DX,NAMEFLD
INC 21H
INC ROW
MOV COL,00
RET G10DISP ENDP

IBM PC . . 116
; : ; -------------- Q10CLR PROC NEAR
MOV AX,0600H ;
MOV BH,41H ; (07 /)
MOV CX,0000
MOV DX,184FH
INT 10H
RET Q10CLR ENDP ; : ; ----------------- Q20CURS PROC NEAR
MOV AH,02 ;
MOV BH,00 ;
MOV DH,ROW
MOV DL,COL
INT 10H
RET Q20CURS ENDP ; : ; --------------------------------- X10ERR PROC NEAR
MOV AH,09 ;DX
INT 21H ;
INC ROW
MOV ENDCDE,01
RET X10ERR ENDP
CODESG ENDS
END BEGIN

IBM PC . . 117
TITLE RANBLOK (COM) CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP MAIN ;---------------------------------------------------- FCBREC LABEL
BYTE ;FCB FCBDRIV DB 04 ; D FCBNAME DB 'NAMEFILE' ;
FCBEXT DB 'DAT' ; FCBBLK DW 0000 ;
FCBRCSZ DW 0000 ; FCBFLZ DD ? ; DOS
DW ? ; DOS
DT ? ; DOS
DB 00 ; FCBRNRC DD 00000000 ;
DSKRECS DB 1024 DUP(?),'$' ;DTA
ENDCODE DB 00 NORECS DW 25 ; OPENMSG DB '*** Open error
***',13,10,'$' READMSG DB '*** Open error ***',13,10,'$' ROWCTR DB 00 ; -------------------------------------------------- MAIN PROC NEAR
CALL Q10CLR ;
CALL Q20CURS ;
CALL E10OPEN ; ,
; DTA
CMP ENDCODE,00 ; ?
JNZ A30 ; -
CALL F10READ ;
CALL G10DISP ; A30: RET ; MAIN ENDP ;
: ; --------------------- E10OPEN PROC NEAR
MOV AH,0FH ;
LEA DX,FCBREC
INT 21H
CMP AL,00 ; ?
JNZ A30 ; -
MOV FCBRCSZ,0020H ;
MOV AH,1AH
LEA DX,DSKRECS ; DTA
INT 21H
RET E20:

IBM PC . . 118
LEA DX,OPENMSG ;
CALL X10ERR
RET E10OPEN ENDP ; : ; ------------ F10READ PROC NEAR
MOV AH,27H ;
MOV CX,NORECS ;
LEA DX,FCBREC
INT 21H
MOV ENDCODE,AL ;
RET F10READ ENDP ; : ; -------------------- G10DISP PROC NEAR
MOV AH,09 ;
LEA DX,DSKRECS
INT 21H
RET G10DISP ENDP ; : Q10CLR PROC NEAR
MOV AX,0600H ;
MOV BH,41H ; (07 /)
MOV CX,0000
MOV DX,184FH
INT 10H
RET Q10CLR ENDP ; : ; -----------------------------Q20CURS PROC NEAR
MOV AH,02 ;
MOV BH,00
MOV DH,ROWCTR
MOV DL,00
INT 10H
INC ROWCTR
RET Q20CURS ENDP ; : ; ------------------------------------- X10ERR PROC NEAR
MOV AH,09 ;DX
INT 21H ;
MOV ENDCODE,01
RET X10ERR ENDP
CODESG ENDS
END BEGIN

IBM PC . . 119
TITLE SELDEL (COM) ; ; ;
: *.*, *.BAK, .. CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG
ORG 100H BEGIN JMP MAIN ; ---------------------------------------------------------- TAB EQU 09
LF EQU 10 CR EQU 13 CRLF DB CR,LF,'$' DELMSG DB TAB,'Erase','$' ENDMSG DB
CR,LF,'No more directory entries',CR,LF,'$' ERRMSG DB 'Write protected disk','$' PROMPT DB
'y = Erase, N = Keep, Ret = Exit',CR,LF,'$' ; ---------------------------------------------------------- MAIN
PROC NEAR ;
MOV AH,11H ;
CALL D10DISK
CMP AL,0FFH ; ,
JE A90 ;
LEA DX,PROMPT ;
CALL B10DISP A20:
LEA DX,DELMSG ;
CALL B10DISP ;
MOV CX,11 ;11
MOV SI,81H ; A30:
MOV DL,[SI] ;
CALL C10CHAR ;
INC SI ;
LOOP A30
MOV DL,'?'
CALL C10CHAR
MOV AH,01 ;
INT 21H ;
CMP AL,ODH ; Return?
JE A90 ; -
OR AL,00100000B ;
;
CMP AL,'y' ; ?
JNE A50 ; - ,
MOV AH,13H ; -
MOV DX,80H
INT 21H
CMP AL,0 ; ?
JZ A50 ; -
LEA DX,ERRMSG ; -
CALL B10DISP ;
JMP A90

IBM PC . . 120
A50:
LEA DX,CRLF ;
CALL B10DISP
MOV AH,12H
CALL B10DISK ;
CMP AL,0FFH ; ?
JNE A20 ; - A90:
RET ; DOS MAIN ENDP ; ; ; --------------------- B10DISP
PROC NEAR ; DX
MOV AH,09 ;
INT 21H
RET B10DISP ENDP ; ; ; ---------------------- C10CHAR PROC
NEAR ; DL
MOV AH,02
INT 21H
RET C10CHAR ENDP ; : ; ------------------------ D10DISK PROC
NEAR
MOV DX,5CH ; FCB
INT 21H
CMP AL,0FFH ; ?
JNE D90
PUSH AX ; AL
LEA DX,ENDMSG
CALL B10DISP
POP AX ; AL D90: RET D10DISK ENDP
CODESG ENDS
END BEGIN

IBM PC . . 121

page 60,132 TTILE HANCREAT (EXE) ; ---------------------------------------------------- STACKSG SEGMENT PARA STACK 'Stack'
DW 80 DUP(?) STACKSG ENDS ; ----------------------------------------------------- DATASG
SEGMENT PARA 'Data' NAMEPAR LABEL BYTE ; : MAXLEN DB 30 ;
NAMELEN DB ? ; NAMEREC DB 30 DUP(' '), 0DH, 0AH ; ,
; CR/LF ERRCDE DB 00 HANDLE DW ? PATHNAM DB
'D:\NAMEFILE.DAT',0 PROMPT DB 'Name? ' ROW DB 01 OPNMSG DB '*** Open error ***',
0DH, 0AH WRTMSG DB '*** Write error ***', 0DH, 0AH DATASG ENDS ; ------------------------------------------------------ CODESG SEGMENT PARA 'Code' BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DATASG
MOV DS,AX
MOV ES,AX
MOV AX,0600H
CALL Q10SCR ;
CALL Q20CURS ;
CALL C10CREA ; ,
; DTA
CMP ERRCDE,00 ; ?
JZ A20LOOP ; - ,
RET ; - DOS A20LOOP:
CALL D10PROC
CMP NAMELEN,00 ; ?
JNE A20LOOP ; - ,
CALL G10CLSE ; -
RET ; DOS BEGIN ENDP ; : ; ----------------------C10CREA PROC NEAR
MOV AH,3CH ;
MOV CX,00 ;
LEA CX,PATHNAM

IBM PC . . 122
INT 21H
JC C20 ; ?
MOV HANDLE,AX ; - ,
RET C20: ; LEA DX,OPNMSG ;
CALL X10ERR ;
RET C10CREA ENDP ; : ; ----------------- D10PROC PROC NEAR
MOV AH,40H ;
MOV BX,01 ; (Handle)
MOV CX,06 ;
LEA DX,PROMPT ;
INT 21H
MOV AH,0AH ;
LEA DX,NAMEPAR ;
INT 21H
CMP NAMELEN,00 ; ?
JNE D20 ; -
RET ; - D20:
MOV AL,20H ;
SUB CH,CH
MOV CL,NAMELEN ;
LEA DI,NAMEREC ;
ADD DI,CX ; +
NEG CX ;
ADD CX,30 ;
REP STOSB ; D90:
CALL F10WRIT ;
CALL E10SCRL ;
RET D10PROC ENDP ; : ; -------------------- E10SCRL PROC NEAR
CMP ROW,18 ;
JAE E10 ; - ,
INC ROW ; -
JMP E10 E10:
MOV AX,0601H ;
CALL Q10SCR E90: CALL Q20CURS ;
RET E10SCRL ENDP ; : ; --------------

IBM PC . . 123
F10WRIT PROC NEAR
MOV AH,40H ;
MOV BX,HANDLE
MOV CX,32 ;30 + 2 CR/LF
LEA DX,NAMEREC
INT 21H
JNC F20 ; ?
LEA DX,WRTMSG ; CALL X10ERR ;
MOV NAMELEN,00 F20:
RET F10WRIT ENDP ; : ; ----------------------- G10CLSE PROC
NEAR
MOV NAMEREC,1AH ; (EOF)
CALL F10WRIT
MOV AH,3EH ;
MOV BX,HANDLE
INT 21H
RET G10CLSE ENDP ; () : ; ---------------------------- Q10SCR
PROC NEAR ; AX -
MOV BH,1EH ; -
MOV CX,0000
MOV DX,184FH
INT 10H ;
RET Q10SCR ENDP ; : ; ----------------- Q20CURS PROC NEAR
MOV AH,02
MOV BH,00
MOV DH,ROW ;
MOV DL,00
INT 10H
RET Q20CURS ENDP ; : ; ------------------------- X10ERR PROC
NEAR ;DX
MOV AH,40H ;
MOV BX,01
MOV CX,21 ;
INT 21H
MOV ERRCDE,01 ;
RET X10ERR ENDP

IBM PC . . 124
CODESG ENDS
END BEGIN

IBM PC . . 125

page 60,132 TITLE HANREAD (EXE) , HANCREAT ; ---------------------------------------------------- STACKSG SEGMENT PARA STACK 'Stack'
DW 80 DUP(?) STACKSG ENDS ; ----------------------------------------------------- DATASG
SEGMENT PARA 'Data' ENDCDE DB 00 HANDLE DW ? IOAREA DB 32 DUP(' ') PATHNAM
DB 'D:\NAMEFILE.SRT',0 OPENMSG DB '*** Open error ***', 0DH, 0AH READMSG DB '***
Read error ***', 0DH, 0AH ROW DB 00 DATASG ENDS ; ----------------------------------------------------- CODESG SEGMENT PARA 'Code' BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG,ES:DATASG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DATASG
MOV DS,AX
MOV ES,AX
MOV AX,0600H
CALL Q10SCR ;
CALL Q20CURS ;
CALL E100PEN ; , ; ; DTA
CMP ENDCDE,00 ; ?
JNZ A90 ; - A20LOOP:
CALL F10READ ;
CMP ENDCDE,00 ; ?
JNZ A90 ; - ,
CALL G10DISP ; - ,
JMP A20LOOP ; A90: RET BEGIN ENDP ; : ; -------------E100PEN PROC NEAR
MOV AH,3DH ;
MOV CX,00 ;
LEA DX,PATHNAM
INT 21H
JC E20 ; ?
MOV HANDLE,AX ; -
RET ; E20:

IBM PC . . 126
MOV ENDCDE,01 ; -
LEA DX,OPENMSG ;
CALL X10ERR
RET E100PEN ENDP ; : ; ---------------------- F10READ PROC
NEAR
MOV AX,3FH ;
MOV BX,HANDLE
MOV CX,32 ;30 , 2 CR/LF
LEA DX,IOAREA
INT 21H
JC F20 ; ?
CMP AX,00 ; ?
JE F30
CMP IOAREA,1AH ; (EOF)?
JE F30 ; -
RET F20:
LEA DX,READMSG ; -
CALL X10ERR ; F30:
MOV ENDCDE,01 ; F90: RET F10READ ENDP ; : ; ------------------- G10DISP PROC NEAR
MOV AH,40H ;
MOV BX,01 ;
MOV CX,32 ;
LEA DX,IOAREA
INT 21H
CMP ROW,20 ; ?
JEA G90 ; -
INC ROW
RET G90:
MOV AX,0601H
CALL Q10SCR ; ()
CALL Q20CURS ;
RET G10DISP ENDP ; () : ; ---------------------------- Q10SCR
PROC NEAR ; AX -
MOV BH,1EH ;
MOV CX,0000
MOV DXX,184FH ;
INT 10H
RET Q10SCR ENDP

IBM PC . . 127
; : ; ----------------- Q20CURS PROC NEAR
MOV AH,02 ;
MOV BH,00 ;
MOV DH,ROW ;
MOV DL,00 ;
INT 10H
RET Q20CURS ENDP ; : ; ------------------------- X10ERR PROC
NEAR
MOV AH,40H ; DX -
MOV BX,01 ;
MOV CX,20 ;
INT 21H
RET X10ERR ENDP
CODESG ENDS
END BEGIN

IBM PC . . 128

page 60,132 TITLE ASCREAD (COM) ASCII CODESG SEGMENT PARA


'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP MAIN ; ------------------------------------------------- SECTOR DB 512
DUP(' ') ; DISAREA DB 120 DUP(' ') ; ENDCDE DW 00
HANDLE DW 0 OPENMSG DB '*** Open error ***' PATHNAM DB 'D:\HANREAD.ASM', 0
ROW DB 00 ; ------------------------------------------------- MAIN PROC NEAR ;

MOV AX,0600H
CALL Q10SCR ;
CALL Q20CURS ;
CALL E10OPEN ; ,
; DTA
CMP ENDCDE,00 ; ?
JNE A90 ; - , A20LOOP: ; -
CALL R10READ ;
CMP ENDCDE,00 ; , ?
JE A90 ; -
CALL G10XPER ; A90: RET ; MAIN ENDP ;
: ; --------------------- E10OPEN PROC NEAR
MOV AH,3DH ;
MOV AL,00 ;
LEA DX,PATHNAM
INT 21H
JNC E20 ; CF
CALL X10ERR ; ,
RET E20:
MOV HANDLE,AX ;
RET E10OPEN ENDP ; : ; -------------------------------G10XPER PROC NEAR
CLD ; -
LEA SI,SECTOR G20:
LEA DI,DISAREA G30:

IBM PC . . 129
LEA DX,SECTOR+512
CMP SI,DX ; ?
JNE G40 ; - ,
CALL R10READ ; -
CMP ENDCDE,00 ; ?
JE G80 ; -
LEA SI,SECTOR G40:
LEA DX,DISAREA+80
CMP DI,DX ; DISAREA?
JB G50 ; - ,
MOV [DI],0D0AH ; - CR/LF
CALL H10DISP ;
LEA DI,DISAREA G50:
LODSB ; [SI] AL
; SI
STOSB ; AL [DI]
; DI
CMP AL,1AH ; ?
JE G80 ; -
CMP AL,0AH ; ?
JNE G30 ; - ,
CALL H10DISP ; -
JMP G20 G80:
CALL H10DISP ; G90: RET G10XPER ENDP ;
: ; --------------------- H10DISP PROC NEAR
MOV AH,40H ;
MOV BX,01 ; (Handle)
LEA CX,DISAREA ;
NEG CX ;
ADD CX,DI ;
LEA DX,DISAREA
INT 21H
CMP ROW,22 ; ?
JAE H20 ; -
INC ROW
JMP H90 H20:
MOV AX,0601H ; ()
CALL Q10SCR
CALL Q20CURS H90: RET H10DISP ENDP ; : ; ----------------------R10READ PROC NEAR
MOV AH,3FH ;

IBM PC . . 130
MOV BX,HANDLE ;
MOV CX,512 ;
LEA DX,SECTOR ;
INT 21H
MOV ENDCDE,AX
RET R10READ ENDP ; () : ; ---------------------------- Q10SCR
PROC NEAR ; AX
MOV BH,1EH ;
MOV CX,0000 ;
MOV DX,184FH
INT 10H
RET Q10SCR ENDP ; : ; ----------------- Q20CURS PROC NEAR
MOV AH,02 ;
MOV BH,00 ;
MOV DH,ROW
MOV DL,00
INT 10H
RET Q20CURS ENDP ; : ; --------------------------------- X10ERR PROC NEAR
MOV AH,40H ;
MOV BX,01 ;
MOV CX,18 ;
LEA DX,OPENMSG
INT 21H
MOV ENDCDE,O1 ;
RET X10ERR ENDP
CODESG ENDS
END BEGIN

IBM PC . . 131
TITLE GETPATH (COM) CODESG SEGMENT PARA 'Code'
ASSUME CS:CODESG,DS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ; ----------------------------------------------- PATHNAM
DB 65 DUP(' ') ; ; ----------------------------------------------- MAIN
PROC NEAR
MOV AH,19H ;
INT 21H
ADD AL,41H ; .
MOV DL,AL ; : 0=A, 1=B ...
CAL B10DISP ; ,
MOV DL,':'
CAL B10DISP ; ,
MOV DL,'\'
CAL B10DISP ;
MOV AH,47H ;
MOV DL,00
LEA SI,PATHNAM
INT 21H A10LOOP:
CMP BYTE PTR [SI],0 ;
JE A20 ; -
MOV AL,[SI] ;
MOV DL,AL ;
CALL B10DISP ;
INC SI
JMP A10LOOP A20: RET ; DOS MAIN ENDP
B10DISP PROC NEAR
MOV AH,02 ; DL -
INT 21H ;
RET B10DISP ENDP
CODESG ENDS
END BEGIN

IBM PC . . 132
TITLE BIOREAD (COM) BIOS CODESG SEGMENT PARA
'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG
ORG 100H BEGIN JMP MAIN ; --------------------------------------------------------- RECDIN DB
512 DUP(' ') ; ENDCDE DB 00 CURADR DW 0304H ; (/)
ENDADR DW 0501H ; (/) READMSG DB '*** Read error ***$' SIDE DB
00 ; --------------------------------------------------------- MAIN PROC NEAR
MOV AX,0600H ; A20LOOP:
CALL Q10SCR ;
CALL Q20CURS ;
CALL C10ADDR ;
MOV CX,CURADR
MOV DX,ENDADR
CMP CX,DX ; ?
JE A90 ; -
CALL F10READ ;
CMP ENDCDE,00 ; ?
JNZ A90 ; -
CALL G10DISP ;
JMP A20LOOP ; A90 RET ; MAIN ENDP ;
: ; ---------------------------------- C10ADDR PROC NEAR
MOV CX,CURADR ; /
CMP CL,10 ; ?
JNE C90 ; -
CMP SIDE,00 ;, = 0
JE C20
INC CH ; C20:
XOR SIDE,01 ;
MOV CL,01 ; = 1
MOV CURADR,CX C90: RET C10ADDR ENDP ; : ; ----------------------- F10READ PROC NEAR
MOV AL,01 ;
MOV AH,02 ;
LEA BX,RECDIN ;
MOV CX,CURADR ;/

IBM PC . . 133
MOV DH,SIDE ;
MOV DL,01 ; B
INT 13H ;
CMP AH,00 ; ?
JZ F90 ; -
MOV ENDCDE,01 ; :
CALL X10ERR ; F90:
INC CURADR ;
RET F10READ ENDP ; : ; ---------------------- G10DISP PROC NEAR
MOV AH,40H ;
MOV BX,01 ;
MOV CX,512 ;
LEA DX,RECDIN
INT 21H
RET G10DISP ENDP ; : ; -------------- Q10SCR PROC NEAR
MOV AX,0600H ;
MOV BH,1EH ;
MOV CX,0000 ;
MOV DX,184FH
INT 10H
RET Q10SCR ENDP ; : ; ----------------- Q20CURS PROC NEAR
MOV AH,02 ;
MOV BH,00 ;
MOV DX,0000
INT 10H
RET Q20CURS ENDP ; : ; --------------------------------- X10ERR PROC NEAR
MOV AH,40H ;
MOV BH,01 ;
MOV CX,18 ;
LEA DX,READMSG
INT 21H
RET X10ERR ENDP CODESG ENDS
END BEGIN

IBM PC . . 134
TITLE PRTNAME (COM) CODESG SEGMENT PARA PUBLIC 'CODE'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG
ORG 100H BEGIN: JMP SHORT MAIN ; ----------------------------------------------------NAMEPAR LABEL BYTE ; MAXNLEN DB 20 ;
NAMELEN DB ? ; NAMEFLD DB 20 DUP(' ') ;
; : HEADG DB 'List of Employee Names Page ' PAGECTR DB '01',0AH,0AH
FFEED DB 0CH ; LFEED DB 0AH ; LINECTR DB 01
PROMPT DB 'Name? ' ; ----------------------------------------------------- MAIN PROC NEAR
CALL Q10CLR ;
CALL M10PAGE ; A2LOOP:
MOV DX,0000 ; 00,00
CALL Q20CURS
CALL D10INPT ;
CALL Q10CLR
CMP NAMELEN,00 ; ?
JE A30 ; - ,
CALL E10PRNT ; -
;
JMP A20LOOP A30:
MOV CX,01 ; :
LEA DX,FFEED ;
CALL P10OUT ; ,
RET ; DOS MAIN ENDP ; : ; ----------------------D10INPT PROC NEAR
MOV AH,40H ;
MOV BX,01 ;
MOV CX,05 ; 5
LEA DX,PROMPT
INT 21H ; DOS
MOV AH,0AH ;
LEA DX,NAMEPAR
INT 21H ; DOS
RET D10INPT ENDP ; : ; ----------------------

IBM PC . . 135
E10PRNT PROC NEAR
CMP LINECTR,60 ; ?
JB E20 ; -
CALL M10PAGE ; - E20: MOV CH,00
MOV CL,NAMELEN ;
LEA DX,NAMEFLD ;
CALL P10OUT ;
MOV CX,01 ;
LEA DX,LFEED ;
CALL P10OUT
INC LINECTR ; E10PRNT ENDP ;
: ; ----------------------------- M10PAGE PROC NEAR
CMP WORD PTR PAGECTR,3130H ; ?
JE M30 ; -
MOV CX,01 ;
LEA DX,FFEED ; -CALL P10OUT ; ,
MOV LINECTR,03 ; M30:
MOV CX,36 ;
LEA DX,HEADG ; M40:
CALL P10OUT
INC PAGECTR+1 ;
CMP PAGECTR+1,3AH ; = .xx3A?
JNE M50 ; - ,
MOV PAGECTR+1,30H ; - ASCII
INC PAGECTR M50: RET M10PAGE ENDP ; : ; ------------------P10OUT PROC NEAR ;CX DX
MOV AH,40H ;
MOV BX,04 ;
INT 21H ; DOS
RET P10OUT ENDP ; : ; -------------- Q10CLR PROC NEAR
MOV AX,0600H ;
MOV BH,60H ; (07 /)
MOV CX,0000 ; 00,00
MOV DX,184FH ; 24,79
INT 10H ; BIOS
RET Q10CLR ENDP ; (/):

IBM PC . . 136
; ---------------------------------- Q20CURS PROC NEAR ;DX
MOV AH,02 ;
MOV BH,00 ; 0
INT 10H ; BIOS
RET Q20CURS ENDP CODESG ENDS
END BEGIN

IBM PC . . 137
TITLE PRINASK (COM) CODESG SEGMENT PARA
'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG,ES:CODESG
ORG 100H BEGIN JMP MAIN ; --------------------------------------------------------- PATHPAR
LABEL BYTE ; MAXLEN DB 32 ; NAMELEN DB ? ;
FILENAM DB 32 DUP(' ') SECTOR DB 512 DUP(' ') ;
DISAREA DB 120 DUP(' ') ; COUNT DW 00 ENDCDE DW 00 FFEED DB 0CH
HANDLE DW 0 OPENMSG DB '*** Open error ***' PROMPT DB 'Name of file? ' ; --------------------------------------------------------- MAIN PROC NEAR ;
CALL Q10SCR ;
CALL Q20CURS ; A10LOOP:
MOV ENDCDE,00 ;
CALL C10PRMP ;
CMP NAMELEN,00 ; ?
JE A90 ; -
CALL E10OPEN ; ,
; DTA
CMP ENDCDE,00 ; ?
JNE A80 ; -
CALL R10READ ;
CMP ENDCDE,00 ; , ?
JE A80 ; -
CALL G10XPER ; A80:
JMP A10LOOP A90: RET MAIN ENDP ; : ; ------------------------------- C10PRMP PROC NEAR
MOV AH,40H ;
MOV BX,01
MOV CX,13
LEA DX,PROMPT
INT 21H
MOV AH,0AH ;
LEA DX,PATHPAR
INT 21H
MOV BL,NAMELEN ;
MOV BH,00 ; 00

IBM PC . . 138
MOV FILENAM[BX],0 ; C90 RET C10PRMP ENDP ;
: ; ------------------------ E10OPEN PROC NEAR
MOV AH,3DH ;
MOV AL,00 ;
LEA DX,FILENAM
INT 21H
JNC E20 ; CF
CALL X10ERR ; ,
RET E20:
MOV HANDLE,AX ;
MOV AX,2020H
MOV CX,256 ;
REP STOSW ;
RET E100PEN ENDP ; : ; -------------------------- G10XFER
PROC NEAR
CLD ; -
LEA SI,SECTOR ; G20:
LEA DI,DISAREA
MOV COUNT,00 G30:
LEA DX,SECTOR+512
CMP SI,DX ; ?
JNE G40
CALL R10READ ; -
CMP ENDCDE,00 ; ?
JE G80 ; -
LEA SI,SECTOR G40:
MOV BX,COUNT
CMP BX,80 ; ?
JB G50 ; -
MOV [DI+BX],0D0AH ; - CR/LF
CALL P10PRNT
LEA DI,DISAREA ; G50:
LODSB ; [SI] AL,
; SI
MOV BX,COUNT
MOV [DI+BX],AL ;
INC BX
CMP AL,1AH ; ?
JE G80 ; -
CMP AL,0AH ; ?
JNE G60 ; - ,

IBM PC . . 139
CALL P10PRNT ; -
JMP G20 G60:
CMP AL,09H ; ?
JNE G70
DEC BX ; - BX:
MOV BYTE PTR [DI+BX],20H ; TAB
AND BX,0FFF8H ; 8
ADD BX,08 ; 8 G70:
MOV COUNT,BX
JMP G30 G80: MOV BX,COUNT ;
MOV BYTE PTR [DI+BX],0CH ;
CALL P10PRNT ; G90: RET G10XFER ENDP ;
: ; ------------------- P10PRNT PROC NEAR
MOV AH,40H ;
MOV BX,04
MOV CX,COUNT ;
INC CX
LEA DX,DISAREA
INT 21H
MOV AX,2020H ;
MOV CX,60
LEA DI,DISAREA
REP STOSW
RET P10PRNT ENDP ; : ; --------------------------- R10READ
PROC NEAR
MOV AH,3FH ;
MOV BX,HANDLE ;
MOV CX,512 ;
MOV DX,SECTOR ;
INT 21H
MOV ENDCDE,AX
RET R10READ ENDP ; : ; ---------------- Q10SCR PROC NEAR
MOV AX,0600H
MOV BH,1EH ;
MOV CX,0000 ; ()
MOV DX,184FH
INT 10H
RET Q10SCR ENDP

IBM PC . . 140
; : ; ------------------------------ Q20CURS PROC NEAR
MOV AH,02 ;
MOV BH,00 ;
MOV DX,00
INT 10H
RET Q20CURS ENDP ; : ; ------------------------- X10ERR PROC
NEAR
MOV AH,40H ;
MOV BX,01 ;
MOV CX,18 ;
LEA DX,OPENMSG ;
INT 1H
MOV NDCDE,01 ;
RET X10ERR ENDP CODESG ENDS
END BEGIN

IBM PC . . 141

TITLE MACRO1 (EXE)


; -------------------------------------------INIT1 MACRO
ASSUME CS:CSEG,DS:DSEG,SS:STACK,ES:DSEG
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DSEG
MOV DS,AX
MOV ES,AX
ENDM ;
; -------------------------------------------- 0000 STACK SEGMENT PARA STACK 'Stack' 0000 20
[ ???? ] DW 32 DUP(?) 0040 STACK ENDS
; -------------------------------------------- 0000 DSEG SEGMENT PARA 'Data' 0000 54 65 73 74
20 6F MESSGE DB 'Test of macro-instruction', 13
66 20 6D 61 63 72
6F 2D 69 6E 73 74
72 65 73 74 69 6F
6E 0D 001A DSEG ENDS
; -------------------------------------------- 0000 CSEG SEGMENT PARA 'Code' 0000 BEGIN
PROC FAR
INIT1 ; 0000 1E + PUSH DS 0001 2B C0 + SUB AX,AX 0003 50 + PUSH AX
0004 B8 ---- R + MOV AX,DSEG 0007 8E D8 + MOV DS,AX 0009 8E C0 + MOV ES,AX 000B
B4 40 MOV AH,40H ; 000D BB 0001 MOV BX,01 ; 0010 B9 001A MOV
CX,26 ; 0013 8D 16 0000 R LEA DX,MESSGE ; 0017 CD 21 INT 21H 0019
CB RET 001A BEGIN ENDP 001A CSEG ENDS
END BEGIN
Macros:
N a m e Length INIT1. . . . . . . . . . . . . . . . 0004
Segments and Groups:
N a m e Size Align Combine Class CSEG . . . . . . . . . . . . . . . . 001A PARA NONE 'CODE'
DSEG . . . . . . . . . . . . . . . . 001A PARA NONE 'DATA' STACK. . . . . . . . . . . . . . . . 0040 PARA
STACK 'STACK'

IBM PC . . 142
Symbols:
N a m e Type Value Attr BEGIN. . . . . . . . . . . . . . . . F PROC 0000 CSEG Length=001A
MESSAGE. . . . . . . . . . . . . . . L BYTE 0000 DSEG

IBM PC . . 143

TITLE MACRO2 (EXE)


; -----------------------------------------------INIT2 MACRO CSNAME,DSNAME,SSNAME
ASSUME CS:CSNAME,DS:DSNAME,SS:SSNAME,ES:DSNAME
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DSNAME
MOV DS,AX
MOV ES,AX
ENDM ;
; ------------------------------------------------ 0000 STACK SEGMENT PARA STACK 'Stack' 0000
20 [ ???? ] DW 32 DUP(?) 0040 STACK ENDS
; ------------------------------------------------ 0000 DSEG SEGMENT PARA 'Data' 0000 54 65 73
74 20 6F MESSAGE DB 'Test of macro', '$'
66 20 6D 61 63 72
6F 24 000E DSEG ENDS
; ------------------------------------------------ 0000 CSEG SEGMENT PARA 'Code' 0000 BEGIN
PROC FAR
INIT2 CSEG,DSEG,STACK 0000 1E + PUSH DS 0001 2B C0 + SUB AX,AX 0003 50 +
PUSH AX 0004 B8 ---- R + MOV AX,DSEG 0007 8E D8 + MOV DS,AX 0009 8E C0 + MOV
ES,AX 000B B4 09 MOV AH,09 ; 000D 8D 16 0000 R LEA DX,MESSGE
; 0011 CD 21 INT 21H 0013 CB RET 0014 BEGIN ENDP 0014 CSEG ENDS
END BEGIN

IBM PC . . 144

TITLE MACRO3 (EXE) .LALL .SALL


; -----------------------------------------------INIT2 MACRO CSNAME,DSNAME,SSNAME
ASSUME CS:CSNAME,DS:DSNAME,SS:SSNAME,ES:DSNAME
PUSH DS
SUB AX,AX
PUSH AX
MOV AX,DSNAME
MOV DS,AX
MOV ES,AX
ENDM
; -----------------------------------------------PROMPT MACRO MESSAGE
;
;; DOS
MOV AH,09 ;
LEA DX,MESSAGE
INT 21H
ENDM
; ------------------------------------------------ 0000 STACK SEGMENT PARA STACK 'Stack' 0000
20 [ ???? ] DW 32 DUP (?) 0040 STACK ENDS
; ------------------------------------------------ 0000 DATA SEGMENT PARA 'Data' 0000 43 75 73
74 6F 6D MESSG1 DB 'Customer name?', '$'
65 72 20 6E 61 6D
65 3F 24 000F 43 75 73 74 6F 6D MESSG2 DB 'Customer address?', '$'
65 72 20 61 64 64
72 65 73 73 3F 24 0021 DATA ENDS
; ------------------------------------------------ 0000 CSEG SEGMENT PARA 'Code' 0000 BEGIN
PROC FAR
.SALL
INIT2 CSEG,DATA,STACK
PROMPT MESSG1
.LALL
PROMPT MESSG2
+ ; 0013 B4 09 + MOV AH,09 ;
0015 8D 16 000F R + LEA DX,MESSG2 0019 CD 21 + INT 21H 001B CB RET 001C
BEGIN ENDP 001C CSEG ENDS
END BEGIN

IBM PC . . 145

TITLE MACRO4 (COM) LOCAL


; ------------------------------------------------DIVIDE MACRO DIVIDEND,DIVISOR,QUOTIENT
LOCAL COMP
LOCAL OUT
; AX=, BX=, CX=
MOV AX,DIVIDEND ;
MOV BX,DIVISOR ;
SUB CX,CX ;
COMP:
CMP AX,BX ; < ?
JB OUT ; -
SUB AX,BX ; -
INC CX ; + 1
JMP COMP
OUT:
MOV QUOTIENT,CX ;
ENDM
; ------------------------------------------------ 0000 CSEG SEGMENT PARA 'Code'
ASSUME CS:CSEG,DS:CSEG,SS:CSEG,ES:CSEG 0100 ORG 100H 0100 EB 06 BEGIN:
JMP SHORT MAIN
; ------------------------------------------------ 0102 0096 DIVDND DW 150 ; 0104 001B
DIVSOR DW 27 ; 0106 ???? QUOTNT DW ? ;
; ------------------------------------------------ 0108 MAIN PROC NEAR
.LALL
DIVIDE DIVDND,DIVSOR,QUOTNT
+ ; AX=, BX=, CX= 0108 A1 0102 R + MOV AX,DIVDND
; 010B 8B 1E 0104 R + MOV BX,DIVSOR ; 010F 2B C9
+ SUB CX,CX ; 0111 + ??0000: 0111 3B C3 + CMP AX,BX ; <
? 0113 72 05 + JB ??0001 ; - 0115 2B C3 + SUB AX,BX ; -
0117 41 + INC CX ; + 1 0118 EB F7 + JMP ??0000 011A + ??0001: 011A 89 0E 0106 R +
MOV QUOTNT,CX ; 011E C3 RET 011F MAIN ENDP 011F CSEG ENDS
END BEGIN

IBM PC . . 146

TITLE MACRO5 (EXE) INCLUDE


EDIF
; ------------------------------------------------ 0000 STACK SEGMENT PARA STACK 'Stack' 0000
20 [????] DW 32 DUP(?) 0040 STACK ENDS
; ------------------------------------------------ 0000 DATA SEGMENT PARA 'Data' 0000 54 65 73
74 20 6F MESSGE DB 'Test of macro','$'
66 20 6D 61 63 72
6F 24 000E DATA ENDS
; ------------------------------------------------ 0000 CSEG SEGMENT PARA 'Code' 0000 BEGIN
PROC FAR
INIT CSEG,DATA,STACK 0000 1E + PUSH DS 0001 3B C0 + SUB AX,AX 0003 50 + PUSH
AX 0004 B8 ---- R + MOV AX,DATA 0007 8E D8 + MOV DS,AX 0009 8E C0 + MOV ES,AX
PROMPT MESSGE 000B B4 09 + MOV AH,09 ; 000D 8D 16 0000 R + LEA
DX,MESSGE 0011 CD 21 + INT 21H 0013 CB RET 0014 BEGIN ENDP 0014 CSEG ENDS
END BEGIN

IBM PC . . 147

TITLE MACRO6 (COM) IF IFNDEF


; -----------------------------------------------DIVIDE MACRO DIVIDEND,DIVISOR,QUOTIENT
LOCAL COMP
LOCAL OUT
CNTR = 0
; AX-, BX-, CX-
IFNDEF DIVIDEND
;
CNTR = CNTR +1
ENDIF
IFNDEF DIVISOR
;
CNTR = CNTR +1
ENDIF
IFNDEF QUOTIENT
;
CNTR = CNTR +1
ENDIF
IF CNTR
;
EXITM
ENDIF
MOV AX,DIVIDEND ;
MOV BX,DIVISOR ;
SUB CX,CX ;
COMP:
CMP AX,BX ; < ?
JB OUT ; -
SUB AX,BX ; -
INC CX ; + 1
JMP COMP
OUT:
MOV QUOTIENT,CX ;
ENDM
; ------------------------------------------------ 0000 CSEG SEGMENT PARA 'Code'
ASSUME CS:CSEG,DS:CSEG,SS:CSEG,ES:CSEG 0100 ORG 100H 0100 EB 06 BEGIN:
JMP SHORT MAIN
; ------------------------------------------------ 0102 0096 DIVDND DW 150 0104 001B DIVSOR
DW 27 0106 ???? QUOTNT DW ?
; ------------------------------------------------ 0108 MAIN PROC NEAR
.LALL
DIVIDE DIVDND,DIVSOR,QUOTNT = 0000 + CNTR = 0
+ ; AX-, BX-, CX-
+ ENDIF

+ ENDIF

IBM PC . . 148
+ ENDIF
+ ENDIF 0108 A1 0102 R + MOV AX,DIVDND ; 0108 8B 1E 0104 R +
MOV BX,DIVSOR ; 010F 2B C9 + SUB CX,CX ; 0111 +
??0000: 0111 3B C3 + CMP AX,BX ; < ? 0113 72 05 + JB ??0001 ; -
0115 2B C3 + SUB AX,BX ; - 0117 41 + INC CX 0118 EB F7 + JMP ??0000
011A + ??0001: 011A 89 0E 0106 R + MOV QUOTNT,CX ;
DIVIDE DIDND,DIVSOR,QUOT = 0000 + CNTR = 0
+ ; AX-, BX-, CX-
+ IFNDEF DIDND
+ ; = 0001 + CNTR = CNTR +1
+ ENDIF
+ ENDIF
+ IFNDEF QUOT
+ ; = 0002 + CNTR = CNTR +1
+ ENDIF
+ IF CNTR
+ ;
+ EXITM 011E C3 RET 011F MAIN ENDP 011F CSEG ENDS
END BEGIN

IBM PC . . 149

TITLE MACRO7 (COM) IFIDN


; -------------------------------------------MOVIF MACRO TAG
IFIDN <&TAG>,<B>
REP MOVSB
EXITM
ENDIF
IFIDN <&TAG>,<W>
REP MOVSW
ELSE
; B W,
; B
REP MOVSB
ENDIF
ENDM
; -------------------------------------------- 0000 CSIG SEGMENT PARA 'Code'
ASSUME CS:CSEG,DS:CSEG,SS:CSEG,ES:CSEG 0100 ORG 100H 0100 EB 00 BEGIN:
JMP SHORT MAIN
; ... 0102 MAIN PROC NEAR
.LALL
MOVIF B
+ IFIDN <B>,<B> 0102 F3/A4 + REP MOVSB
+ EXITM
MOVIF W
+ ENDIF
+ IFIDN <W>, <W> 0104 F3/A5 + REP MOVSW
+ ENDIF
MOVIF
+ ENDIF
+ ELSE
+ ; B W,
+ ; B 0106 F3/A4 + REP MOVSB
+ ENDIF 0108 C3 RET 0109 MAIN ENDP 0109 CSEG ENDS
END BEGIN

IBM PC . . 150

+-----------+ +-----------+
| | | |
| | | |
+-----+-----+ +-----+-----+
||
||
+------------+------------+ +------+------+
|||||
| | | | | +--------+ +--------+ +--------+ +--------+ +--------+ | / 1 | | / 2 | | / 3 | | / 1 | |
/ 2 | +---------+ +---------+ +---------+ +----+----+ +---------+
|
|
+--------+
| / 3 |
+---------+

IBM PC . . 151

+---------------------------------------+
| EXTRN SUBPROG:FAR |
| MAINPROG: . |
|.|
| CALL SUBPROG |
|.|
|.|
+---------------------------------------+
| PUBLIC SUBPROG |
| SUBPROG: . |
|.|
|.|
| RET |
+---------------------------------------+

IBM PC . . 152

page 60,132
TITLE CALLMULL1 (EXE)
EXTRN SUBMUL:FAR
;----------------------------------------------- 0000 STACKSG SEGMENT PARA STACK 'Stack'
0000 40 [ ???? ] DW 64 DUP(?) 0080 STACKSG ENDS
;----------------------------------------------- 0000 DATASG SEGMENT PARA 'Data' 0000 0140
QTY DW 0140H 0002 2500 PRICE DW 2500H 0004 DATASG ENDS
;----------------------------------------------- 0000 CODESG SEGMENT PARA 'Code' 0000 BEGIN
PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG 0000 1E PUSH DS 0001 2B C0 SUB
AX,AX 0003 50 PUSH AX 0004 B8 ---- R MOV AX,DATASG 0007 8E D8 MOV DS,AX 0009
A1 0002 R MOV AX,PRICE ; 000C 8B 1E 0000 R MOV BX,QTY ;
0010 9A 0000 ---- E CALL SUBMUL ; 0015 CB RET 0016
BEGIN ENDP 0016 CODESG ENDS
END BEGIN
Segments and Groups:
N a m e Size Align Combine Class CODESG . . . . . . . . . . . . 0016 PARA NONE 'CODE'
DATASG . . . . . . . . . . . . 0004 PARA NONE 'DATA' STACKSG. . . . . . . . . . . . 0080 PARA
STACK 'STACK'
Symbols:
N a m e Type Value Attr BEGIN. . . . . . . . . . . . . F PROC 0000 CODESG Length=0016 PRICE.
. . . . . . . . . . . . L WORD 0002 DATASG QTY. . . . . . . . . . . . . . L WORD 0000 DATASG
SUBMUL . . . . . . . . . . . . L FAR 0000 External
page 60,132
TITLE SUBMUL
;----------------------------------------------- 0000 CODESG SEGMENT PARA 'Code' 0000
SUBMUL PROC FAR
ASSUME CS:CODESG
PUBLIC SUBMUL 0000 F7 E3 MUL BX ;AX-, BX- 0002 CB RET
; DX:AX

IBM PC . . 153
0003 SUBMUL ENDP 0003 CODESG ENDS
END SUBMUL
Segments and groups:
N a m e Size Align Combine Class CODESG . . . . . . . . . . . . 0003 PARA NONE 'CODE'
Symbols:
N a m e Type Value Attr SUBMUL . . . . . . . . . . . . F PROC 0000 CODESG Clobal
Length=0003
LINK IBM Personal Computer Linker Version 2.30 (C) Copyright IBM Corp 1981, 1985 Object
Modules: B:CALLMUL1+B:SUBMUL1 Run File: [B:CALLMUL1.EXE]: <return> List
File:[NUL.MAP]: CON Libraries [.LIB]: <return>
Start Stop Length Name Class
00000H 00015H 0016H CODESG CODE <--: 2
00020H 00022H 0003H CODESG CODE <--
00030H 00033H 0004H DATASG DATA
00040H 000BFH 0080H STACKSG STACK
Program entry point at 0000:0000

IBM PC . . 154

page 60,132
TITLE CALLMUL2 (EXE)
EXTERN SUBMUL:FAR
;---------------------------------------------- 0000 STACKSG SEGMENT PARA STACK 'Stack'
0000 40 [????] DW 64 DUP(?) 0080 STACKSG ENDS
;---------------------------------------------- 0000 DATASG SEGMENT PARA 'Data' 0000 0140
QTY DW 0140H 0002 2500 PRICE DW 2500H 0004 DATASG ENDS
;---------------------------------------------- 0000 CODESG SEGMENT PARA PUBLIC 'Code' 0000
BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG 0000 1E PUSH DS 0001 2B C0 SUB
AX,AX 0003 50 PUSH AX 0004 B8 ---- R MOV AX,DATASG 0007 8E D8 MOV DS,AX 0009
A1 0002 R MOV AX,PRICE ; 000C 8B 1E 0000 R MOV BX,QTY ;
0010 9A 0000 ---- E CALL SUBMUL ; 0015 CB RET 0016
BEGIN ENDP
0016 CODESG ENDS
END BEGIN
Segments and Group:
N a m e Size Align Combine Class CODESG . . . . . . . . . . . . .0016 PARA PUBLIC 'CODE'
DATASG . . . . . . . . . . . . .0004 PARA NONE 'DATA' STACKSG. . . . . . . . . . . . .0080 PARA
STACK 'STACK'
Symbols:
N a m e Type Value Attr BEGIN. . . . . . . . . . . . . F PROC 0000 CODESG Lenght=0016 PRICE.
. . . . . . . . . . . . L WORD 0002 DATASG QTY. . . . . . . . . . . . . . L WORD 0000 DATASG
SUBMUL . . . . . . . . . . . . L FAR 0000 External
page 60,132
TITLE SUBMUL2
;---------------------------------------------- 0000 CODESG SEGMENT PARA PUBLIC 'CODE'
0000 SUBMUL PROC FAR
ASSUME CS:CODESG
PUBLIC SUBMUL 0000 F7 E3 MUL BX ;AX-, BX-

IBM PC . . 155
0002 CB RET ; DX:AX 0003 SUBMUL ENDP 0003 CODESG ENDS
END SUBMUL
Segments and Groups:
N a m e Size Align Combine Class CODESG. . . . . . . . . . . . . 0003 PARA PUBLIC 'CODE'
Symbols:
N a m e Type Value Attr SUBMUL. . . . . . . . . . . . .F PROC 0000 CODESG Global
Length=0003
LINK IBM Personal Computer Linker Version 2.30 (C) Copyright IBM Corp 1981, 1985 Object
Modules: B:CALLMUL2+B:SUBMUL2 Run File: [B:CALLMUL2.EXE]: <return> List File:
[NUL.MAP]: CON Libraries [.LIB]: <return>
Start Stop Length Name Class
00000H 00022H 0023H CODESG CODE <-- : 1
00030H 00033H 0004H DATASG DATA
00040H 000BFH 0080H STACKSG STACK
Program entry point at 0000:0000

IBM PC . . 156

page 60,132
TITLE CALLMUL3 (EXE)
;
EXTRN SUBMUL:FAR
PUBLIC QTY,PRICE
;------------------------------------------------- 0000 STACKSG SEGMENT PARA STACK 'Stack'
0000 40 [????] DW 64 DUP(?) 0080 STACKSD ENDS
;------------------------------------------------- 0000 DATASG SEGMENT PARA PUBLIC 'Data'
0000 0140 QTY DW 0140H 0002 2500 PRICE DW 2500H 0004 DATASG ENDS
;------------------------------------------------- 0000 CODESG SEGMENT PARA PUBLIC 'Code'
0000 BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG 0000 1E PUSH DS 0001 2B C0 SUB
AX,AX 0003 50 PUSH AX 0004 B8 ---- R MOV AX,DATASG 0007 8E D8 MOV DS,AX 0009
9A 0000 ---- E CALL SUBMUL ; 000E CB RET 000F BEGIN ENDP
000F CODESG ENDS
END BEGIN
Segments and Groups:
N a m e Size Align Combine Class CODESG . . . . . . . . . . . . 000F PARA PUBLIC 'CODE'
DATASG . . . . . . . . . . . . 0004 PARA PUBLIC 'DATA' STACKSG. . . . . . . . . . . . 0080 PARA
STACK 'STACK'
Symbols:
N a m e Type Value Attr BEGIN. . . . . . . . . . . . . F PROC 0000 CODESG Length=000F PRICE.
. . . . . . . . . . . . L WORD 0002 DATASG Global QTY. . . . . . . . . . . . . . L WORD 0000 DATASG
Global SUBMUL . . . . . . . . . . . . L FAR 0000 External
page 60,132
TITLE SUBMUL
EXTRN QTY:WORD,PRICE:WORD
;------------------------------------------------- 0000 CODESG SEGMENT PARA PUBLIC 'CODE'
0000 SUBMUL PROC FAR
ASSUME CS:CODESG
PUBLIC SUBMUL

IBM PC . . 157
0000 A1 0000 E MOV AX,PRICE 0003 8B 1E 0000 E MOV BX,QTY 0007 F7 E3 MUL BX
; DX:AX 0009 CB RET 000A SUBMUL ENDP 000A CODESG ENDS
END SUBMUL
Segments and Groups:
N a m e Size Align Combine Class CODESG . . . . . . . . . . . . 000A PARA PUBLIC 'CODE'
Symbols:
N a m e Type Value Attr PRICE. . . . . . . . . . . . . V WORD 0000 External QTY. . . . . . . . . . . . . .
V WORD 0000 External SUBMUL . . . . . . . . . . . . F PROC 0000 CODESG Global Length=000A
LINK IBM Personal Computer Linker Version 2.30 (C) Copyright IBM Corp 1981, 1985 Object
Modules: B:CALLMUL3+B:SUBMUL3 Run File: [B:CALLMUL3.EXE]: <return> List File:
[NUL.MAP]: CON Libraries [.LIB]: <return>
Start Stop Length Name Class
00000H 00019H 001AH CODESG CODE
00030H 00033H 0004H DATASG DATA
00040H 000BFH 0080H STACKSG STACK
PROGRAM entry point at 0000:0000

IBM PC . . 158

page 60,132
TITLE CALLMULL4 (EXE)
;
EXTRN SUBMUL:FAR
;------------------------------------------------- 0000 STACKSG SEGMENT PARA STACK 'Stack'
0000 40 [ ???? ] DW 64 DUP(?) 0080 STACKSG ENDS
;------------------------------------------------- 0000 DATASG SEGMENT PARA 'Data' 0000 0140
QTY DW 0140H 0002 2500 PRICE DW 2500H 0004 DATASG ENDS
;------------------------------------------------- 0000 CODESG SEGMENT PARA PUBLIC 'Code'
0000 BEGIN PROC FAR
ASSUME CS:CODESG,DS:DATASG,SS:STACKSG 0000 1E PUSH DS 0001 2B C0 SUB
AX,AX 0003 50 PUSH AX 0004 B8 ---- R MOV A,DATASG 0007 8E D8 MOV DS,AX 0009 FF
36 0002 R PUSH PRICE 000D FF 36 0000 R PUSH QTY 0011 9A 0000 ---- E CALL SUBMUL
; 0016 CB RET 0017 BEGIN ENDP 0017 CODESG ENDS
END BEGIN
Segments and Groups:
N a m e Sise Align Combine Class CODESG . . . . . . . . . . . . 0017 PARA NONE 'CODE'
DATASG . . . . . . . . . . . . 0004 PARA NONE 'DATA' STACKSG. . . . . . . . . . . . 0080 PARA
STACK 'STACK'
Symbols:
N a m e Type Value Attr BEGIN. . . . . . . . . . . . . F PROC 0000 CODESG Length=0017 PRICE.
. . . . . . . . . . . . L WORD 0002 DATASG QTY. . . . . . . . . . . . . . L WORD 0000 DATASG
SUBMUL . . . . . . . . . . . . L FAR 0000 External
page 60,132
TITLE SUBMUL 0000 CODESG SEGMENT PARA
PUBLIC 'Code' 0000 SUBMUL PROC FAR
ASSUME CS:CODESG
PUBLIC SUMBUL 0000 55 PUSH BP 0001 8P EC MOV BP,SP

IBM PC . . 159
0003 8B 46 08 MOV AX,[BP+8] ; 0006 8B 5E 06 MOV BX,[BP+6] ; 0009
F7 E3 MUL BX ; DX:AX 000B 5D POP BP 000F SUMBUL ENDP 000F
CODESG ENDS
END
Segments and Groups:
N a m e Size Align Combine Class CODESG . . . . . . . . . . . . 000F PARA PUBLIC 'CODE'
Symbols:
N a m e Type Value Attr SUBMUL . . . . . . . . . . . . F PROC 0000 CODESG Global
Length=000F
LINK IBM Personal Computer Linker Version 2.30 (C) Copyright IBM Corp 1981, 1985 Object
Modules: B:CALLMUL4+B:SUBMUL4 Run File: [B:CALLMUL4.EXE]: <return> List File:
[NUL.MAP]: CON Libraries [.LIB]: <return>
Start Stop Length Name Class
00000H 00019H 001AH CODESG CODE
00030H 00033H 0004H DATASG DATA
00040H 000BFH 0080H STACKSG STACK
PROGRAM entry point at 0000:0000

IBM PC . . 160
LOAD"D:BASTEST.BAS
LIST 010 CLEAR ,32768! 020 ' BLOAD 030 ' DEFSEG 040 ' CALL
050 ' ASM- 060 FOR N = 1 TO 5 070 INPUT "Hours "; H 080 INPUT "Rate ";
R 090 W = H * R 100 PRINT "Wage = " W 110 NEXT N 120 END
TITLE LINKBAS , BASIC CODESG SEGMENT
PARA 'CODE'
ASSUME CS:CODESG CLRSCRN PROC FAR
PUSH BP ; BP
MOV BP,SP ;
MOV AX,0600H ;
MOV BH,07 ;
MOV CX,0000 ;
MOV DX,184FH
INT 10H
POP BP
RET ; CLRSCRN ENDP CODESG ENDS
END

IBM PC . . 161
D>LINK
IBM Personal Computer Linker Version 2.30 (C) Copyright IBM Corp. 1981, 1985
Object Modules [.OBJ]: LINKBAS Run File [LINKBAS.EXE]: LINKBAS/HIGH List File
[NUL.MAP]: CON Libraries [.LIB]: Warning: no stack segment
Start Stop Length Name Class
00000H 00011H 00012H CODESG CODE D>DEBUG BASIC.COM -R AX=0000 BX=0000
CX=0012 DX=0000 SP=FFFF BP=0000 SI=0000 DI=0000 DS=1410 ES=1410 SS=1410 CS=1410
IP=0100 NV UP EI PL NZ NA PO NC 1410:0100 E9E03E JMP 3FE3 -N D:LINKBAS.EXE -L -R
AX=FFA3 BX=0000 CX=0012 DX=0000 SP=0000 BP=0000 SI=0000 DI=0000 DS=1410
ES=1410 SS=9FE0 CS=9FE0 IP=0000 NV UP EI PL NZ NA PO NC 9FE0:0000 55 -R SS SS 9FE0
:1410 -R CS CS 9FE0 :1410 -R IP IP 0000 :0100 -G Ok DEF SEG = &H9EF0 Ok BSAVE
"D:CLRSCREEN.MOD",0,&H12 Ok SYSTEM Program terminated normally -Q D>BASIC IBM
Personal Computer Basic Ver4sion D3.10 Copyright IBM Corp. 1981, 1985 61310 Bytes free Ok
LOAD"D:BASTEST.BAS Ok 20 BLOAD "D:CLRSCREEN.MOD" 30 DEF SEG = &H9FE0 40
CLRSCRN = 0

IBM PC . . 162
50 CALL CLRSCRN LIST
10 CLEAR ,32768! 20 BLOAD "D:CLRSCRN.MOD" 30 DEF SEG = &H9FE0 40 CLRSCRN = 0
50 CALL CLRSCRN 60 FOR N = 1 TO 5 70 INPUT "HOURS"; H 80 INPUT "rATE"; R 90 W = H
* R 100 PRINT "WAGE = " W 110 NEXT N 120 END Ok
program pascall ( input, output );
procedure move_cursor( const row: integer;
const col: integer ); extern;
var
temp_row: integer;
temp_col: integer;
begin
write( 'Enter cursor row: ' );
readln( temp_row );
write( 'Enter cursor column:' );
readln( temp_col );
move_cursor( temprow, temp_col );
write( 'New cursor location' );
end.
TITLE MOVCUR , ;
PUBLIC MOVE_CURSOR ;---------------------------------------------------------- ;
MOVE_CURSOR: ; ; : const row
; const col ; : ;--------------------------------------------------------- CODESEG SEGMENT PARA PUBLIC 'CODE'
MOVE_CURSOR PROC FAR
ASSUME CS:CODESEG

IBM PC . . 163
ROWWPAR EQU 8 ; "" COLPAR EQU 6 ; ""
PUSH BP ; BP
MOV BP,SP ; BP
MOV SI,[BP+ROWPAR] ;SI
MOV DH,[SI] ; DL
MOV AH,02 ;
SUB BH,BH ; #0
INT 10H
POP BP ;
RET 4 ; MOVE_CURSOR ENDP CODESEG ENDS
END

00000 (. . 23)
00400 (ROM)
00500 (DOS)
00600 IBMBIO.COM


/
(FAT, )
XXXX0 COMMAND.COM
XXXX0 ( COM EXE)
XXXX0 COM- (256 )
XXXX0 COMMAND.COM
( ).
TITLE EXDOS (EXE) DOS 4BH DIR CSEG GMENT PARA 'Code'
ASSUME CS:CSEG,DS:CSEG,ES:CSEG BEGIN: JMP SHORT MAIN ;--------------------------------------------------------- PARAREA DW ? ;

IBM PC . . 164
DW OFFSET DIRCOM ;
;
DW CSEG
DW OFFSET FCB1 ; FCB2
DW CSEG
DIRCOM DB 17,'/C DIR D:',13,0 FCB1 DB 16 DUP(0) FCB2 DB 16 DUP(0) PROGNAM DB
'D:COMMAND.COM',0 ; --------------------------------------------------------- MAIN PROC FAR
MOV AH,4AH ; 64K
MOV BH,100H ;
INT 21H
JC E10ERR ; ?
MOV DI,2CH ;
MOV AX,[DI] ;
LEA SI,PARAREA ;
MOV [SI],AX ; 1
MOV AX,CS ; DS ES
MOV DS,AX ; CSEG
MOV ES,AX
MOV AH,4BH ;
MOV AL,00 ;
LEA BX,PARAREA ; COMMAND.COM
LEA DX,PROGNAM
INT 21H ; DOS
JC E20ERR ; ?
MOV AL,00 ;
JMP X10XIT 0ERR:
MOV AL,01 ; 1
JMP X10XIT 0ERR:
MOV AL,02 ; 2
JMP X10XIT 0XIT:
MOV AH,4CH ;
INT 21H ; DOS IN ENDP EG ENDS
END

(.) (.)
0-3 0
4-7 1 ( DEBUG)

IBM PC . . 165
8-B 2 (NMI)
C-F 3 ( DEBUG)
10-13 4
14-17 5
18-1F
20-23 8
24-27 9
28-37 A,B,C,D AT
38-3B E
3C-3F F
40-43 10 (. . 8,9,10)
44-47 11 (. . 9)
48-4B 12 (. . 2)
4C-4F 13 - (. 18)
50-53 14 -
54-57 15 . AT
58-5B 16 (. 9)
5C-5F 17 (. 19)
60-63 18 BASIC (ROM)
64-67 19
68-6B 1A
6C-6F 1B
70-73 1C
74-77 1D
78-7B 1E
7C-7F 1F
80-83 20 DOS
84-87 21 DOS DOS
88-8B 22 DOS
8C-8F 23 DOS Ctrl+Break
90-93 24 DOS
94-97 25 DOS
98-9B 26 DOS
9C-9F 27 DOS ,
A0-FF 28-3F DOS DOS 100-1FF 40-7F 200-217 80-85
BASIC 218-3C3 86-F0 BASIC- 3C4-3FF
F1-FF
: 00-1F BIOS, 20-FF DOS BASIC
TITLE RESIDENT (COM) ;
; Alt+Left Shift ;---------------------------------------------------------INTTAB SEGMENT AT 0H ; :
ORG 9H*4 ; Int 9H, KBADDR LABEL DWORD ; INTTAB ENDS

IBM PC . . 166
;---------------------------------------------------------ROMAREA SEGMENT AT 400H ; BIOS:
ORG 17H ; , KBFLAG DB ? ; Alt + Shift ROMAREA
ENDS ;---------------------------------------------------------CSEG SEGMENT PARA ;
ASSUME CS:CS
ORG 100H BEGIN: JMP INITZ ;
KBSAVE DD ? ; INT 9 BIOS ; : ; -------------------------------- COLORS PROC NEAR ;
PUSH AX ; Alt+Left Shift
PUSH BX
PUSH CX ;
PUSH DX
PUSH SI
PUSH DI
PUSH DS
PUSH ES
PUSHF
CALL KBSAV ;
ASSUME DS:ROMAREA
MOV AX,ROMAREA ; DS
MOV DS,AX ;
MOV AL,KB AG ; Alt+Left Shift
CMP AL,00001010B ;Alt+Left Shift ?
JNE EXIT ; -
MOV AX,0600H ;
MOV BH,61H ;
MOV CX,00
MOV DX,18 FH
INT 10H EXIT:
POP ES ;
POP DS
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
IRET ; COLORS ENDP
; : ; -------------------------- INITZE PROC NEAR ;

IBM PC . . 167
ASSUME DS:INTTAB
PUSH DS ; DOS
MOV AX,INTTAB ;
MOV DS,AX
CLI ;
; :
MOV AX,WORD PTR KBADDR ;
MOV WORD PTR KBSAVE,AX ; BIOS
MOV AX,WORD PTR BADDR+2
MOV WORD PTR KBSAVE+2,AX
MOV WORD PTR KBADDR,OFFSET COLORS ;
MOV WORD PTR KBADDR+2,CS ; BIOS
STI ;
MOV DX,OFFSET INITZE ;
INT 27H ; INITZE ENDP ;
CSEG ENDS
END BEGIN
TITLE SOUND (COM) SOUNSG SEGMENT PARA 'Code'
ASSUME CS:SOUNG,DS:SOUNG,SS:SOUNG
ORG 100H BEGIN: JMP SHORT MAIN ; ------------------------------------------------------DURTION DW 1000 ; TONE DW 256H ; () ; ------------------------------------------------------ MAIN PROC NEAR
IN AL,61H ;
PUSH AX ;
CLI ;
CALL B10SPKR ;
POP AX ;
OUT 61H,AL ;
STI ;
RET MAIN ENDP
B10SPKR PROC NEAR B20: MOV DX,DURTION ; B30:
AND AL,11111100B ; 0 1
OUT 61H,AL ;
MOV CX,TONE ; B40:
LOOP B40 ;
OR AL,00000010B ; 1
OUT 61H,AL ;
MOV CX,TONE ;

IBM PC . . 168
B50:
LOOP B50 ;
DEC DX ;
JNZ B30 ;?
SHL DURTION,1 ; - ,
SHR TONE,1 ;
JNZ B20 ; ?
RET ; - B10SPKR ENDP
SOUNSG ENDS
END BEGIN

IBM PC 98

TITLE RECORD (COM) RECORD 0000 CODESG SEGMENT PARA


'Code'
ASSUME CS:CODESG,DS:CODESG,SS:CODESG 0100 ORG 100H 0100 EB 02 BEGIN:
JMP SHORT MAIN
; ----------------------------------------------------BITREC RECORD BIT1:3,BIT2:7,BIT3:6 ; 0102 9A AD DEFBITS
BITREC <101B,0110110B,011010B> ;
; ----------------------------------------------------- 0104 MAIN PROC NEAR 0104 A10: ;:
0104 B7 10 MOV BH,WIDTH BITREC ; (16) 0106 B0 07 MOV AL,WIDTH BIT2 ;
(07) 0108 B10: ; : 0108 B1 0D MOV CL,BIT1 ; .0D 010A B1 06 MOV
CL,BIT2 ; 06 010C B1 00 MOV CL,BIT3 ; 00 010E C10: ;: 010E B8 E000 MOV
AX,MASK BIT1 ; .E000 0111 BB 1FC0 MOV BX,MASK BIT2 ; 1FC0 0114 B9 003F MOV
CX,MASK BIT3 ; 003F 0117 D10: ; BIT2: 0117 A1 0102 R MOV AX,DEFBITS ;
, 011A 25 1FC0 AND AX,MASK BIT2 ; BIT1 BIT3, 011D B1 06
MOV CL,BIT2 ; 06, 011F D3 E8 SHR AX,CL ; 0121 E10:
; BIT1: 0121 A1 0102 R MOV AX,DEFBITS ; , 0124 B1 0D MOV
CL,BIT1 ; 13, 0126 D3 E8 SHR AX,CL ; 0128 C3 RET 0129
MAIN ENDP 0129 CODESG ENDS
END BEGIN
Structures and records:
N a m e Widht # fields
Shift Widht Mask Initial
BITREC . . . . . . . . . . . 0010 0003
BIT1 . . . . . . . . . . . . 000D 0003 E000 0000
BIT2 . . . . . . . . . . . . . 0006 0007 1FC0 0000
BIT3 . . . . . . . . . . . . 0000 0006 003F 0000
Segments and Groups:
N a m e Size Align Combine Class CODESG . . . . . . . . . . . . 0129 PARA NONE 'CODE'
Symbols:
N a m e Type Value Attr A10. . . . . . . . . . . . . . L NEAR 0104 CODESG B10. . . . . . . . . . . . . . L
NEAR 0108 CODESG

IBM PC 99
BEGIN. . . . . . . . . . . . . L NEAR 0100 CODESG C10. . . . . . . . . . . . . . L NEAR 010E CODESG
D10. . . . . . . . . . . . . . L NEAR 0117 CODESG DEFBITS. . . . . . . . . . . . L WORD 0102 CODESG
E10. . . . . . . . . . . . . . L NEAR 0121 CODESG MAIN . . . . . . . . . . . . . N PROC 0104 CODESG
Length =0025

IBM PC 100

TITLE DSTRUC (COM) 0000 CODESG SEGMENT PARA 'Code'


ASSUME CS:CODESG,DS:CODESG,SS:CODESG 0100 ORG 100H 0100 EB 29 BEGIN:
JMP SHORT MAIN
; --------------------------------------------PARLIST STRUC ; 0000 19 MAXLEN DB 25 ; 0001 ?? ACTLEN DB ? ;
0002 19 [ 20 ] NAMEIN DB 25 DUP(' ') ; 001B PARLIST ENDS
; 0102 19 PARAMS PARLIST <> ; 0103 ?? 0104 19 [ 20 ] 011D 57 68 61
74 20 69 PROMPT DB 'What is name?', 'S'
73 20 6E 61 6D 65
3F 24
; --------------------------------------------- 012B MAIN PROC NEAR 012B B4 09 MOV AH,09
; 012D 8D 16 011D R LEA DX,PROMPT 0131 CD 21 INT 21H 0133 B4 0A MOV
AH,0AH ; 0135 8D 16 0102 R LEA DX,PARAMS 0139 CD 21 INT 21H 013B A0
0103 R MOV AL,PARAMS.ACTLEN ;
; ... 013E C3 RET 013F MAIN ENDP 013F CODESG ENDS
END BEGIN
Structures and records:
N a m e Width # fields
Shift Width Masc Initial PARLIST. . . . . . . . . . . . . 001B 0003
MAXLEN . . . . . . . . . . . . 0000
ACTLEN . . . . . . . . . . . . 0001
NAMEIN . . . . . . . . . . . . 0002
Segments and Groups:
N a m e Size Align Combine Class CODESG . . . . . . . . . . . . . 013F PARA NONE 'CODE'
Symbols:
N a m e Type Value Attr BEGIN. . . . . . . . . . . . . L NEAR 0100 CODESG MAIN . . . . . . . . . . . .
. N PROC 012B CODESG Length =0014 PARAMS . . . . . . . . . . . . L 001B 0102 CODESG
PROMPT . . . . . . . . . . . . L BYTE 011D CODESG

IBM PC 101
, :
: w = 0 w = 1
000 AL AX
001 CL CX
010 DL DX
011 BL BX
100 AH SP
101 CH BP
110 DH SI
111 BH DI
: :
00 ES
01 CS
10 SS
11 DS
r/m mod=00 mod=01 mod=10 mod=1.1 mod=11
w=0 w=1 000 BX+SI BX+SI+disp BX+SI+disp AL AX 001 BX+DI BX+DI+disp BX+DI+disp
CL CX 010 BP+SI BP+SI+disp BP+SI+disp DL DX 011 BP+DI BP+DI+disp BP+DI+disp BL BX
100 SI SI+disp SI+disp AH SP 101 DI DI+disp DI+disp CH BP 110 Direct BP+disp BP+disp DH
SI 111 BX BX+disp BX+disp BH DI

IBM PC 102

A-1 ASCII

000 00h 032 20h sp 064 40h @ 096 60h ` 001 01h 033 21h ! 065 41h A
097 61h a 002 02h 034 22h " 066 42h B 098 62h b 003 03h 035 23h #
067 43h C 099 63h c 004 04h 036 24h $ 068 44h D 100 64h d 005 05h 037
25h % 069 45h E 101 65h e 006 06h 038 26h & 070 46h F 102 66h f 007 07h 039 27h '
071 47h G 103 67h g 008 08h 040 28h ( 072 48h H 104 68h h 009 09h
. 041 29h ) 073 49h I 105 69h i 010 0Ah 042 2Ah * 074 4Ah J
106 6Ah j 011 0Bh . 043 2Bh + 075 4Bh K 107 6Bh k 012 0Ch
044 2Ch , 076 4Ch L 108 6Ch l 013 0Dh 045 2Dh - 077 4Dh M 109 6Dh m 014
0Eh Shift out 046 2Eh . 078 4Eh N 110 6Eh n 015 0Fh Shift in 047 2Fh / 079 4Fh O 111 6Fh o 016
10h Data line esc 048 30h 0 080 50h P 112 70h p 017 11h 1 049 31h 1 081 51h Q 113
71h q 018 12h 2 050 32h 2 082 52h R 114 72h r 019 13h 3 051 33h 3 083
53h S 115 73h s 020 14h 4 052 34h 4 084 54h T 116 74h t 021 15h 053 35h 5 085
55h U 117 75h u 022 16h 054 36h 6 086 56h V 118 76h v 023 17h
055 37h 7 087 57h W 119 77h w 024 18h 056 38h 8 088 58h X 120 78h x 025 19h
End of medium 057 39h 9 089 59h Y 121 79h y 026 1Ah 058 3Ah : 090 5Ah Z 122 7Ah z
027 1Bh Escape 059 3Bh ; 091 5Bh [ 123 7Bh { 028 1Ch . 060 3Ch < 092 5Ch \ 124
7Ch | 029 1Dh . 061 3Dh = 093 5Dh 125 7Dh } 030 1Eh . 062 3Eh >
094 5Eh ^ 126 7Eh ~ 031 1Fh . 063 3Fh ? 095 5Fh _ 127 7Fh

IBM PC 103

B-1 -
+------------+-----------+----------+--------+-------+------+------+-----+
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
+------------+-----------+----------+--------+-------+------+------+-----+
|0 0|0 0|0 0|0 0|0 0|0 0|0 0|0 0|
|1 268435456|1 16777216|1 1048576|1 65536|1 4096|1 256|1 16|1 1|
|2 536870912|2 33554432|2 2097152|2 131072|2 8192|2 512|2 32|2 2|
|3 805306368|3 50331648|3 3145728|3 196608|3 12288|3 768|3 48|3 3|
|4 1073741824|4 67108864|4 4194304|4 262144|4 16384|4 1024|4 64|4 4|
|5 1342177280|5 83886080|5 5242880|5 327680|5 20480|5 1280|5 80|5 5|
|6 1610612736|6 100663296|6 6291456|6 393216|6 24576|6 1536|6 96|6 6|
|7 1879048192|7 117440512|7 7340032|7 458752|7 28672|7 1792|7 112|7 7|
|8 2147483648|8 134217728|8 8388608|8 524288|8 32768|8 2048|8 128|8 8|
|9 2415919104|9 150994944|9 9437184|9 589824|9 36864|9 2304|9 144|9 9|
|A 2684354560|A 167772160|A 10485760|A 655360|A 40960|A 2560|A 160|A 10|
|B 2952790016|B 184549376|B 11534336|B 720896|B 45056|B 2816|B 176|B 11|
|C 3221225472|C 201326592|C 12582912|C 786432|C 49152|C 3072|C 192|C 12|
|D 3489660928|D 218103808|D 13631488|D 851968|D 53248|D 3328|D 208|D 13|
|E 3758096384|E 234881024|E 14680064|E 917504|E 57344|E 3584|E 224|E 14|
|F 4026531840|F 251658240|F 15728640|F 983040|F 61440|F 3840|F 240|F 15| +-----------+-----------+----------+--------+-------+------+------+-----+ .| 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 |
+------------+-----------+----------+--------+-------+------+------+-----+