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

PDP-11

ASSEMBLER LANGUAGE
PROGRAMMING
AND MACHINE ORGANIZATION
Michael Singer
Stanford University

JOHN WILEY & SONS


NEW YORK CHICHESTER BRISBANE
TORONTO SINGAPORE
1980

- PDP-11:




..
..

..

1984

22.19
38
681.3

.
38
- PDP-11:
: . . M.: , 1984.272 ., .

PDP-11,
- -3, -4 . , -,
, . .
, -.

2405000000-424
164-84, . 1
041 (01)-84

22.19
518

1980 by John Wiley & Sons, Inc.


All Rights Reserved. Authorized translation
from English language edition published by
John Wiley & Sons, Inc.
, , 1984


, 25 , 50-
, ,
,
,
. ,

.
: -, - ,
, .
- 50-
, .
- . ,
, . , , . -, , :
,
.. -, -
, ,
. ,
.
. ,

. , PDP-11,
,
.
PDP-11
. , ,
.

. ,
, ,
( )
.
.. (, . 1 2) .. (. 3, 4
).
.



. , ,
, .
.
PDP-11,
Digital Equipment Corporation (DEC). ,
, ,
.

. ,
,
. ,
, ,
, ,
.
,
, , .
PDP-11. ; ,
.
, PDP-11 ,
.
.
, , ,
. ;

, , , , ,
. , ,
. -
,
. , PDP-11,
. PDP-11, , ,
, ,
, . ,

PDP-11; , ,
.
, ,
: ,
.
, .
, .
,
,
. , , ,
. , . ,
, ,

. ,

, ,
, , .
,
, . ,
, ,
, ,
. .
, . ,
,
;
, ,
.
(
),
. ,

.
. 3, , PDP-11,
, .
,
, .
1 .
,
. ,
, ,
, ,
.
, , . PDP-11,
, , , 4.1 . 1;
, ,
.
. 2
. , ,
.
PDP-11.

. ,
. ,
(, , ),
,
. PDP-11 ,
, , . . 4,
.
- , .
. ODT ,
PDP-11.
; . 2.

PDP-11.
- ;
.

, ,
. ,
, .
* .
, ,
; Ross Systems Inc., DEC
Artificial Intelligence Laboratory, .
John Wiley & Sons.

1.
1.1.
, PDP-11,
, . ,
. ( , ),
.
PDP-11; ,
( ).
, .
( ), ,
. , PDP-11,
,
, .
( ,
), PDP-11
.
PDP-11
( ), , , ,
. , . ,
. ;
, ,
.
,
.
, SHIFT 1. , ,
() .
,
.
SHIFT, . ,
@ SHIFT-P, ] SHIFT-M, [ SHIFT-K.
.
, : I ( i), l (
L) 1 (); O ( O) 0 (), (..), <..>
[..] .
CONTROL 2. SHIFT,
, , ,
. . ,
CONTROL-A, ^A. , ,
CONTROL-I, , , ,
, .
. PDP-11, CONTROL-C
, ^C (
, CONTROL-C). CONTROL-3,
. (
1

P ( HP), . .
. . .
3
.
2

).
CONTROL ^.
: ,
( , SHIFT-N).
^, C, ^C,
CONTROL-C.
^A , , ,
CONTROL .
on-line4
, ^I. ,
. on-line,
. ,
, , , ^I (
). , ,
, ^I;
, ^I , .
.
( ). ,
on-line ( ), .
, ,
; , ^I
.
,
. (..
) , .
.
. ,
,
.
. , .
( ,
) .
,
, . ,
; , ,
, . ,
,
.
PDP-11, . ,
, ,
.
,
; ,
. , ;
, .
(?),
.
,
. ,
.
4

, off-line .

, PDP-11.
,
, , .
, ,
( ).
;
.
, ;
. ,
.
- ,
PDP-11 - .
, ,
; ,
. ,
,
.
,
.
,
;
, .
, , ;
, , .
PDP-11, , .
- ;
, ,
. ,
, ,
.
, -
. ,
PDP-11 ,
. ,
DEC.

.
, , ,

,
. , 1.2 ,

, ( ).
, .
DEC , , . EDIT,
1.2, L. , , , TECO,
,
, .
. 1 ,
. 4,
-. ,

DEC, .
PDP-11 DEC
, ; UNIX
Bell Laboratories.
, , , UNIX

PDP-11. ,

PDP-11.
, ,
PDP-11 . ,
LSI-11 ( PDP-11) PDP-11
, . , ,
, 1.4 4.1,
,
.

1.2.
1.1, ,
.
, .. . ,
.
, ,
, .
. .
, , , .
,

LOGIN
HELLO.
, CARRIAGE
RETURN. , .
, RUBOUT ( DELETE)
.
BACKSPACE. , , , ,
, . ^U.
LOGIN ( ),
. , ,
. : READY (),
, . () @.
, . ,
, ^C.
,
, -
. ,
. BYE.
CONFIRM (), YES, CARRIAGE RETURN.
.
, .

. ,
.
-. ,
RUN; R.
, . , EDIT,

RUN EDIT
CARRIAGE RETURN ( ).
RUN
$.
RUN $EDIT
, ,
; ,
#. , .
. ,
, .
TEST. , ,
.
. ,
() ,
TEST.MAC. , ,
.
, ,
- . ,
, TEST
TEST.BAS. ,
TEST.TXT.
, TEST.TXT,
.. TEST.TXT . (
#)
TEST.TXT
EDIT, , ,
, *.

. , TECO *
. ;
TECO EW,
EWTEST.TXT
, TECO ESCAPE (
ALTMODE), CARRIAGE RETURN.
ESCAPE, $. TECO
PDP-11; ,
.
. ,
, .
, ..
. ( )
, . ,
, ;
.

. , ,
. ,
, .
, I.
, ( ). ,
TECO I : I, ,
, ESCAPE .
, , :
*ITHE QUICK
BROWN FOX
$$
* TECO; .
, $ ESCAPE. ,
CARRIAGE RETURN .
:
THE QUICKBROWN FOX
, , .
EDIT I .
, I :
I
EDIT , (
, ), ,
LINE FEED, . ,
EDIT :
*I
THE QUICK
BROWN FOX
*,
ITHE QUICKBROWN FOX
, , , .
*, , .
, ,
. EX.
,
. TECO EX
. EDIT EX #
. ,
^Z (, CONTROL-Z);
DEC.
, DIR,
. , TEST.TXT !
,
TYPE TEST.TXT
.
. , .
RUBOUT, BACKSPACE ^U .
, ^Z EX?
^Z? , , ,
?

. , ,
TEST.TXT. ,
.
, ; ..
TEST.TXT .
TEST.TXT , TEST.TXT
. EDIT #
TEST.TXT<TEST.TXT
. TEST.TXT ,
<, , .
, , ,
TEST1.TXT, # :
TEST1.TXT<TEST.TXT
, ,
.
,
. , :
, , . ,
EDIT :
EDIT TEST.TXT
TEST.TXT ,
. ,
EX .
,
, .
,
. . EDIT,
, R.
, , , ,
. EDIT L.
L
THE QUICK
.. . , ,
, .
, 2L ..
, 100L , 2L.
L , ,
.
, .
.
; EDIT A.
L 2L
BROWN FOX
L ,
. , ;
A.
.
. 1. ,
, ?

TEST.TXT , 5
THE QUICK BROWN FOX JUMPS
OVER THE LAZY DOG
3. I ( )
, TEST.TXT
THE QUICK BROWN FOX JUMPS
AGAIN AND AGAIN
OVER THE LAZY DOG
EX?
4. , -, TEST.BAK,
?
5. , ^C ,
EX? .
6. EDIT K . K
.
:
THE QUICK BROWN FOX JUMPS
OVER THE LAZY DOG
AGAIN AND AGAIN
TEST.TXT TEST.BAK.
7. ,
THE QUICK BROWN FOX JUMPS
AGAIN AND AGAIN OVER THE LAZY DOG
2.

. , .
,
, . , ,
. , , DOG
TEST.TXT . 2. ,
. ,
, , . ,
. G
DOG , .
.
, ,
. EDIT G. G
, I. G ,
, .
. ,
,
GG
G, G ,
(LINE FEED) .
,
, L. L ,
. (
L? 0L?) , K ,
L, (, ,
). , ( A),
5

, .
: . . .

.
, G,
.
2G .. ( , G
, ?
? , DOG
?) ,
; EDIT B.
JUMPS JUMPED.
, , ,
. TECO :
JUMPS,
FSJUMPS$JUMPED$$
TECO FS , $ (ESCAPE),
, .
, , .
JUMP, S ED. EDIT
D; ,
.
, .
. EDIT
J,
.
. 1. , 6
ALL THAT GLISTERS IS NOT GOLD
SHAKESPEARE
1596
.
2. ,
ALL IS NOT GOLD THAT GLISTERS
CERVANTES
1615
.
3. , :
ALL IS NOT GOLD THAT GLISTENETH
MIDDLETON
1617
TEST.TXT ,
. QUICK, ,
, .
, ,
CARRIAGE RETURN
.
,
; ( ) , ^M.
; LINE FEED,
, , ^J.
6

, . , 1596.
. . .

. 1. , ^J ^M ,
.
2. , TEST.TXT QUICK
BROWN . , ,
.
. , R EDIT
, .
, . TEST.TXT
, .
: -,
, ;
-, -
, . , ,
,
, .
DEC
FORM FEED ^L.
TECO, , I,
^L. EDIT ,
F (.. F) FORM FEED,
I.
, ,
, . EDIT
N; ,
, .
, , .
, , ,
. ,
, .
EDIT H ,
, .
P, , , ,
. ,
, .
.
,
.
, ,
. I.
.
, ,
. : ,
. EDIT ,
. S
, L, , S
. ,
, . ,
,
; EDIT U.

, - .
. 1. , ,
,
.
2. , ,
.

1.3.
1.2
. , ,
.
.
.
( ).
,
. (),
,
.
: , ,
(
).
( )
( ).
, , 0
1. , ( )
1, . , , , ,
0, 1,
. , ,
. , ,
, 0+0 0, 1+1 1. ,
, 1, , , 0, .

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

. ,
. , 1000 , 100, 1000
, 100. (
) ,
() , . , -
9, .
, 1
.
, ,
.
, , , .. , , ,
, ..
binary digit ( ).
, ,
10 011. ,
. :
D 19 = B 10011
D , B (binary) .
,
. ,
PDP-11 :
0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1
15
12
9
6
3
0
, ,
1 ; ..
: 24+21+20= 16+2+1 = 19.
,

. ,
10 010 110 101 10 010 101 101, , .
: 1205 1197.
.
.

; , . ,
,
. ,
, .
; ,
.
, .
0, 1, 2, 3, 4, 5, 6, 7;
. ,
10
O 10 = D 8
8=2 3,
.
,
.

,
(.. ).
B 000 = O 0 B 100 = O 4
B 001 = O 1 B 101 = O 5
B 010 = O 2 B 110 = O 6
B 011 = O 3 B 111 = O 7
, B 10 011=O 23. , D 19, ,
: .
D 1205=B 10 010 110 101.
: O 5, O 6, O 2, O 2. O 2265;
2 ( ) +2 ( ) + 6 () + 5.
,
. , O 734; O 4 = B 100; O 3=B 011; O 7=B 111.
, O 734=B 111 011 100. 7(88) + 3(8) + 4=D
476.

D 10 = O 12
D 8 = O 10
D 64 = O 100
. 1.
?
2. :
) ;
) ;
) ;
) ?
, , .
3. , 59
?
4. : ) O 37; ) O 40; ) B 1 111; ) B 11
110.
5. : ) D 37; ) D 40; ) B 1 111; ) B 11
110.
6. : ) D 37; ) O 37; ) D 32; ) O -32.
7. O 100-1: ) ; )
?
8. O 15 - O 60? ?

,
.
.

; ,
. .
, 17 762 1001, 762
17 743 (!). ,
. , O 1000=D
888=D 512, , O 762 - ;
.

ASCII. ,
; , . ,
. ,
, American Standard Code for Information Interchange (
). ASCII
( -). 127
( 127). ,
, ,
ASCII . , ^A ASCII 1.
, - , 1.
, 1, .
,
^A, 1. ,
, , .
ASCII 0 O
177. , D 128 2 ( ), .. O 200.
, D 127=O 177 ASCII.
, O 2001=O 177. ,
1 O 7. ,
, : O 7+1=O 10. O 17+ 1=O 20.
1 O 77 8,
, ( ): O 77+1 = O 100.
O 177+1 = O 200 ..
, ASCII ,
.
, . ,
7; 1 , 7, 0, 1
.
A G ASCII:
A
101
E
105
B
102
F
106
C
103
G
107
D
104
, -, ASCII H? , , , G
1;
H
110
..
W
127
X
130
Y
131
Z
132
:
0
60
1
61
..
7
67
8
70
9
71
, ASCII
; , ,

O 60.
. 1.
ASCII?
2. PDP-11 ASCII,
, (
).
.
3.
PDP-11?
. ,
. , -
; .
.
:
, ,
. ,
. , ,
. , , B ASCII
2. PDP-11:
MOV
#102,2

MOV
102,2
2
O 102. ;
, .

. ,
. ,
.
@. ,
MOV
@102,2
2 ,
O 102.
( ).
PDP-11 , . PDP11 , .
.
, , ,
.
. ,
0 7 ( ), ;
( 8 15) . ,
;

0
3
"
"
2
5
"
"
4
7
"
"
6
11
"
"
10

...
...
...
...
, .
. PDP-11
.
,
. ,
, , .
.
: 0 000 000 001 000 010. ,
.
;
. ,
O 102,
O 102, B ASCII. .

,
( ),
B.
, ,
(). (, ), ,
.
,
. 000110, ;
001110, . ,
.
.
, ,
. , , .
, .
.
, ,
, .
, ,
(O 102 , B?). ,
, : ,
, ?
, !
. ,
,
.
, 7 (PC), ,
. , ,
, ,
.
:
1. , PC
( ).
2. , , ,
, :
7

Program counter, . .

1)
2)

3.
4.
5.

PC , ;
(
,
PC);
3) , . );
.
PC .
.
1.

, ,
, PC, PC .
(, ,
); 2.
, ,
, , .
. ,

INC
102
O 102.
, ,

102

2. PC
102 . 4
102.
. 1. INC 102 , 100.
, ? ,
?
2. INC PC .

INC
PC
INC
PC
PC ?
3. ADD #2,PC PC.
PC
2

ADD
#2,PC
ADD
#2.PC
PC ?
4.
ADD
#2,PC
INC
PC
5. SUB ADD.
SUB #4,PC ?

1.4.
1.1 ,
PDP-11 .
. ,
, , ,
PDP-11.
,
. ,
, .
, , ,
, , ,
.
B
. PDP-11
O 102; ,
ASCII O 102 (.. B), .

, .
,
, .
, .

, ,
.
PDP-11

, .
, , .
,
- 4.1.
, . -,
, RT-11.
,
. , ,
, , . ASCII ,

.TTYOUT
, . TTY
,
.TTYOUT .
,
. ASCII B.

.TTYOUT
102
O 102
ASCII.
.TTYOUT
#102
# , (
), .
, . , , ,
( TEST.MAC), .

, , , .
. 1.3 ,
. , 1 PC
:
0 000 101 010 000 111
005 207 (!)
. , ,

INC
PC
, , (?).
, ,
. ,
INC.
. , ,
()8, PC. ,
;
. , ,
, ,
.
.
,
. , ,
, .
DEC PDP-11 ,
- ,
. , ,
, .
, MACRO-11
PDP-11 . ,
, MACRO-11 ;
PAL-11 (Program Assembly Language).
.
. ,
, ,
. , ,
, ,
. ,
, , ,
.
, .
, , ,
.

. , ,
. , -
.
. - , .
8

, . . .

;
. . .TTYOUT
, START.
, , , :
START: .TTYOUT
#102
START .TTYOUT ; ,
, ,
, .
START
START .
START .
, .
PDP-11 , ,
. , ,
. ,
.END,
. .END ,
, .
,
START: .TTYOUT
#102
.END START
, ,
.
. , .END .
, . ,
.END, ( ).
.END, , ,
.
, .TTYOUT .
, ,
, . .TTYOUT
. .TTYOUT
; , .
,
. ,
; .MCALL.
.TTYOUT . .
; ,
.

.MCALL .TTYOUT
START: .TTYOUT
#102
.END START
, , . , ,
, .
, .TTYOUT #102.
B, , . ,
,
. (?),
.EXIT.

.EXIT .
:
.MCALL
.EXIT
, , . ,

.
B
.MCALL .TTYOUT,.EXIT
START: .TTYOUT #102
.EXIT
.END START
TEST.MAC, .
.
, .
, .
MACRO. ,
1.2.
:
RUN $MACRO
, ,
, $MACRO $MACROL;
.TTYOUT .EXIT. ,
, .
*, .
, TEST.MAC , ,
( ).
, . MACRO
, , =
TEST=TEST
, .OBJ
. TEST.OBJ
, ^Z, .


COMPILE TEST
,
, , .
COMPILE ,
. ,
; TEST
, TEST.MAC .
. ,
-
. , , .TTYOUT
.EXIT. , ,
, ( ).
. ,
.
; SYSMAC.SML,

RT-11.
. -
, , .
;
(?).

. , ,
, :
TEST,TEST = TEST
TEST ;
TEST.LST .
. 1.1 TEST.MAC.
. ,
- .
, . ,
.
.MAIN.

RT-11 MACRO VM02-11

1
2 000000
START:
3 000010
4
000000'

26-JAN-79 09:28:07 PAGE 1

.MCALL .TTYOUT,.EXIT
.TTYOUT #102
.EXIT
.END
START

.MAIN. RT-11 MACRO VM02-11


SYMBOL TABLE

26-JAN-79 09:28:07 PAGE 1+

START
. ABS.

000000R
000000
000
000012
001
ERRORS DETECTED: 0
FREE CORE: 18899. WORDS

. 1.1. .
, 0 .
, , ,
, , ).
.
.
, .TTYOUT
.EXIT, ,

.LIST
ME
.
, . ,
.TITLE. .TITLE ,
; , (
):
.TITLE TEST
.TITLE, .MAIN, .
. 1. TEST.MAC
.

2. ,
, .
3. , .MCALL;
.LIST; .TITLE?
. RSX-11 IAS,
.
RT-11 RSTS.
,
. ,
, , ,
. '
. . 1.1 , START
.END . , ,
.
TEST.OBJ
, .
LINK, :
RUN $LINK
LINK *,
, MACRO.
TEST,TEST = TEST
LINK .OBJ,
TEST.OBJ . ,
, TEST.SAV. ,
, .
( ) .
, , 400 ( )
, 1000 ( 400? 1002?).
, LINK,
. .MAP.
TEST.MAP .

.
RUN TEST
. RT-11
RUN :
GET TEST
,
START
PC, .
. 1. TEST.MAC
.
2. , ,
.
3. , .EXIT?

2.
2.1.
,
.
PDP-11, , , .
.
.
, ,
, ,
.
, 1.4.
ASCII, , ( 0)
0 .
%. , 0
%0;
.TTYOUT %0
, 0 5, R0R5. ( 6 7
.)
, PDP11. , .
, R0 %0 ..
R0=%0 (
). = :
R0=%0
...
...
.TTYOUT
R0
, R0,
. ( )
MOV. ,
, , .
O 102 R0:
MOV
#102,R0
R0 .
. 2.1.
REGTST
RT-11 MACRO VM02-11
26-JAN-79 09:34:07 PAGE 1
1
.TITLE REGTST
2
.LIST
ME
3
.MCALL .TTYOUT,.EXIT
4
5
000000
R0=%0
6
7 000000 012700 START: MOV
#102,R0
000102
8 000004
.TTYOUT R0
000004 110000 .IIF NB <R0>,
MOVB
R0,%0
000006 104341
EMT
^O341
000010 103776
BCS
.-2

9 000012
000012 104350
10
000000'

.EXIT
EMT
.END

REGTST RT-11 MACRO VM02-11


SYMBOL TABLE
R0
=%000000
START
. ABS. 000000
000
000014
001
ERRORS DETECTED: 0
FREE CORE: 18895. WORDS

^O350

START
26-JAN-79 09:34:07 PAGE 1+
000000R

. 2.1. .
. 1. R0 - ,
, , .
2. ?
3. MOV #102,%1 MOV #102,1?
? ?
4. , ,
, B C. (
, .)
5. , ,
, .

START: INC
LABEL
LABEL: MOV
#102,R0
, B?
. 1.4 , ,
, .
( ?)
.
RT-11 .TTYIN.
, ASCII. ,
.TTYIN R0
R0 .

.TTYIN
, R0.
.TTYIN R0.
, R0 .
, .TTYIN R1 R0 R1
, MOV .
.TTYOUT R0. ,
.TTYOUT R1 R0 R1 .
.TTYIN, ,
. ,
, ,
. ,
, .
RUBOUT,
.

, ^U.
. 1. , ,
R0 ( ).
2. ,
?.
3. ,
( ) . ?
, , ? (:
R0.)
4. , ?
, , , .
1 , .

.TTYIN
INC
R0
.TTYOUT
, .TTYIN .TTYOUT R0.
,
5 ( ) 6.
, , 5.
.TTYIN O 65,
5 ASCII.
INC R0 O 66. .TTYOUT
6.
, ,
, ASCII.
0 8. 9 ,
ASCII O 72. ,
. 10, 1;
2. 0 , ,
; .
- 10,
10 .
, , 10
. 10
1 0.
ASCII,
. A, B. B C ..
Z ( ASCII 132) [ (
ASCII 133).
, .
0 9 ,
ASCII:
.TTYIN
SUB
#60,R0
O 60 R0. 7,
.TTYIN
ASCII, 67. 7.
, 8; O 70.

O 10, D 8.
SUB
ASCII .
, , , R0, ASCII
.TTYOUT O 60.
:
ADD
#60,R0
. 1. ,
( ) ,
. ( R0!)
2. , m+n=, , m
n , .
3. , ,
. (: ?) 2
2?
. ADD SUB . ,
,
, . ,

.TTYIN R1
SUB
#60,R1
ADD
R1,R1
,
R1. 9, R1 18.
ADD #60,R1 .TTYOUT R1 : D 18= O 22, O
22+60=O 102, 102 ASCII B (!).
18,
. 1 18; 8
. 18 10, 1 8 .
PDP-11 .
. PDP-11, ,
.
, ;
, . 2.2
, ,
.
, R1 ,
. DIV:
DIV
#12,R0
; !
, ( ),
. , ,
. , , DIV
;
(, CLR):
CLR
R0
DIV
#12,R0
DIV (
R0), , (R1). ,

R0 1 8 R19.
. 1. ,
. ( , ,
08. ?)
2. , .

.
MUL10. , R1
MUL
#2,R1
,
.
:
.TTYIN R1
.TTYIN R0
SUB
#60,R0
SUB
#60,R1
MUL
R0,R1
, MUL
, , , .
DIV.
. 1. .
2. ?
, ,
. , ,
;
, .
, D 2174, 10 :

2174

217 4

21 7 4

2 174
R1. DIV R0 R1.
3 : R2 ,
( 1), R3 , R4
. :
CLR
R0
DIV
#12,R0
MOV
R1,R4
, DIV R1,
. :
MOV
R0,R1
CLR
R0
R3 :
9

DIV. .
MUL, .

10

DIV
#12,R0
MOV
R1,R3
, R2 :
MOV
R0,R1
CLR
R0
DIV
#12,R0
MOV
R1,R2
ADD
#60,R0
.TTYOUT
R0
ADD
#60,R2
.TTYOUT
R2
ADD
#60,R3
.TTYOUT
R3
ADD
#60,R4
.TTYOUT
R4
. 1. D 2174,
R1 (, ).
2.
, .
3. ,
MOV, R0 R1.
- ?
4. , ,
. ,
? , , ? ,
?
5. , R0R5?
. , ,
, .
10.
, 2174
. 2

.TTYIN R1
SUB
#60,R1
, . , ,
1, 2
1:
.TTYIN R0
;
SUB
#60,R0
MUL
#12,R1
ADD
R0,R1
R1 D 21. ( R0?) 7,
, R1 D 217 (?).
, : R1
D 2174.
2
(2 10) + 1 =
21
(21 10) + 7 = 217

(217 10) + 4 = 2174


, , ,
: 10 .
, ,
.
. 1. ,
.
2. ?
3. ,
.
4. , ,
:
) ;
) .
.
. , ,
, .
, . ,
:
;
PRINT: DIV
#12,R0
;O 12 = D 10
.
. , PRINT
.
O 12;
. ,
PRINT: DIV
#10,R0
;
;
- ,
. -
. ,
.
.
,
.
, ,
. ,
. , ,
, , ,
. , , .
, .
, , , . ,
. ,
.
.

2.2.
2.1, , , ,
PDP-11 .

;

, - .
MUL DIV, -
, .
,
.
, ( ),
, , , . ,
;
, . ,
, . ,
, , ,
.
, , , R1.
R1.
, ; R0, ,
, 1 ,
R1. ,
INC
R0
SUB
#12,R1
,
.

. , ,
,
( , )
, .
R1,
R0 ,
( ) .

DIVTEN: INC
R0
SUB
#12,R1
BPL
DIVTEN
BPL (Branch if PLus )
, , ..
. BPL , ,
.
, R0, R1 ;
.
,
, , BPL DIVTEN.
, ;
, ,
. DEC (DECrement )
1, :
DIVTEN: INC
R0
SUB
#12,R1
BPL
DIVTEN
DEC
R0
;

ADD
#12,R1
;
R0 , R1, DIV #12,R0. ,
, DIV, R0 (?).
, BPL , ,
. ,
DIVTEN .
.
.
. 1. ,
D 2174, R1.
2. ?
.
MUL .
, .
R1;
R1 R2
ADD
R1,R1
;2
MOV
R1,R2
;2,2
ADD
R1,R1
;4,2
ADD
R1,R1
;8,2
ADD
R2,R1
;10,2
. 1. , ,
.
2*. , ,
:
) ;
) () ;
) , , .
3. DIVTEN MOV #12,R2,
. ,
,
.
. , ,
. 2.1, ,
.
, ,
,
, .
:
READ:
.TTYIN
; , DONE
SUB
#60,R0
MUL
#12,R1
ADD
R0,R1
BR
READ
DONE:
...
BR (BRanch )
, - .

MUL, .
, .
BPL, , ASCII
, O 60 O 71. :
, . :

. , ,
, ; . ,
,
CARRIAGE RETURN ASCII O 15
LINE FEED ASCII O 12
, ASCII O 40, , O 60.
READ ,

READ:
.TTYIN
SUB
#60,R0
; , DONE
, BMI (Branch if Minus
), , BPL
; BMI BPL.
, , ,
.
. 1. , ? ,
, ,
. ( ,
.) ?
2. , , ,

) ;
) .
) .
( NEG (NEGate)
; ,
, , , ,
.)
2 :
,
.TTYOUT #55
;
:
, . (
?) , ,
. , ; ,
, R5 ( R5
). , .TTYIN R0
O 55. CMP (CoMPare)
CMP
R0,#55
CMP ,
. CMP ,
. BEQ (Branch if EQual

), , :
READ:
.TTYIN
CMP
R0,#55
BEQ
MINUS
;
-
MINUS: INC
R5
BR
READ
READ .
:
READ:
.TTYIN
CMP
R0,#55
BNE
PLUS
INC
R5
BR
READ
PLUS:
;
BNE (Branch if Not Equal). , , ? , , BNE, ,
, READ .
.TTYIN.
?
, , R1.
R5 , ( R5
), ( R5 1).
R1 :
TST
R5
BEQ
POS
; R1
NEG
R1
POS:
...
TST
. CMP,
.
. 1. mn, m
n , + - .
2. , .
3.
. ! , 8 9.
4. ,
CMP
R1,R2
BPL
ELSWHR

SUB
R1,R2
BPL
ELSWHR
5. , ,
, .
. ,
, , .
PS (Processor Status word);
,
PS.
PS ( 0 3) .

, , .
PS 3 N, , -
, ,
.
BPL N. N ,
, BPL. N
, BPL ( BPL
), .
BMI , ,
. , ,
N. ADD, SUB, MUL DIV ( N
); , INC, DEC NEG. CLR N.
MOV N .
TST N , .

CMP
X,Y
X Y # , N
, Y, , X.
,
CMP
#60,R1
N, R1 , O 60, .
, R1 . ,
SUB
#60,R1
O 60 R1 N R1;
, N , R1 ,
O 60, . CMP
SUB, , .
2 PS Z. ,
, , .
BEQ BNE Z .
,
, . BPL,
BNE, ,
.

, , .
, ,
.
. 1. ,
N Z .
2. , R1
3, 5 7 (). ,
VALA, VALB VALC,
R1.
.
. ,
, ,
. MUL DIV
. 2.2.

START:

READ:

RE1:

SEP:
S1:

MEAN:
DIVID:

PRINT:

.TITLE MEAN
.MCALL .TTYIN,.TTYOUT,.EXIT
R0=%0
;
R1=%1
;
R2=%2
;
R3=%3
;
R4=%4
;
CLR
R1
CLR
R2
CLR
R3
.TTYOUT #77
.TTYIN
CMP
R0,#60
BMI
SEP
; (R0)<60
CMP
#71,R0
BMI
SEP
; (R0)>71
SUB
#60,R0
ADD
R1,R1
; (R1) D10
MOV
R1,R4
ADD
R1,R1
ADD
R1,R1
ADD
R4,R1
ADD
R0,R1
;
BR
READ
INC
R3
ADD
R1,R2
CLR
R1
CMP
R0,#15
BEQ
MEAN
.TTYIN
; ?
CMP
R0,#60
BMI
S1
CMP
#71,R0
BMI
S1
BR
RE1
CLR
R1
CLR
R4
; (R2)/(R3)
INC
R4
;
SUB
R3,R2
BPL
DIVID
DEC
R4
;
ADD
R3,R2
;
ADD
R2,R2
;
SUB
R3,R2
BMI
PRINT
INC
R4
;

. 2.2. .
,
. :
1 , .
,
, .
, .
. ,
, , ,

, .
R3 0. READ ,
R0 R1. SEP:
R3 1; R1 , R2;
R1
; , , ,
READ ( READ?).
, MEAN .
- . 2.3.

. 2.3. - . 2.2.
;
, .
SEP .
. 1. PRINT . 2.2
,
? .
2. . 2.2,
? .
3. ,
.

2.3.
2.2 ;
,
. ,
, ,

; .
,
.
( ).
.
,
, , ,
.
, ,
. , R1
. ( ,
) , ;
MEM.
MOV
R1,MEM
R1 MEM; R1 .
MEM,
MEM .
. ,
MEM WRD
MOV
MEM,WRD

MEM WRD. ,
, . ,
, MEM.
:
MEM:
.WORD 0
.WORD ,
, , ,
.WORD. ,
CLR
R0
MEM:
.WORD 0
INC
R1
: CLR R0, , INC R1.
, ,
MEM. ,
,
, .WORD.
, , , MEM
.
1.3, ,
.WORD . ,
, MEM, ,
. CLR R0
, .WORD 0, .
HALT; HALT ,
, .
, 1.3,
, , ,
.
,
.

.END,
.
.WORD
.EXIT .END. .EXIT
; , ,
.WORD .
.EXIT. ,
.EXIT, HALT
, . , ,
;
. .EXIT,
. .WORD ,
.END.
,
. , SEP (. 2.2)
,
MEAN. (
?)
. 2.2
, .
. .
, ,
.
. , ,
, ,
.
.
Rn . Rn
, ,
. , R1 ,
MEM. Rn
MEM.
MEM , , MEM.
Rn
MOV
#MEM,Rn

()
MOV
MEM,Rn
()
MOV
#MEM,Rn
() MEM Rn,
() MEM Rn.
MOV #MEM,Rn
MOV
R1,(Rn)
R1 MEM. (Rn) , R1
Rn, , Rn.

()
MOV
R1,Rn
()
MOV
R1,(Rn)
() R1 Rn,
() R1 , Rn.
R1 .

, MOV R1,MEM.

Rn, .
, , , R1.
R0; ,
DIV. R2 -, ,
MEM, .
R2 MEM.
R2 , , MEM.

R2, .
, , 1.3, PDP-11,
, , .
,
- , 2 .
R2 2 ,
( ?).
, R2 2 , ,
R2, . ,
, R2 ;
.
MOV
#MEM,R2
L1:
CLR
R0
; R0
DIV
#12,R0
; R1
ADD
#60,R1
; ASCII
MOV
R1,(R2)
;
ADD
#2,R2
;
MOV
R0,R1
;
BNE
L1
;, (R1)
L2:
SUB
#2,R2
;
MOV
(R2),R0
;
.TTYOUT
;.TTYOUT(R2)
CMP
#MEM,R2
BNE
L2
;
;
, L1 CMP .
( L2?) R1
(R1). ?
, ,
MEM:
.WORD 0
.
.WORD ,
. (?),

MEM:
.WORD 0,0,0,0,0
, MEM.
MEM,
.WORD .BLKW (BLocK of
Words).

MEM:
.BLKW 5
, .

. 1. ,
, R0, , ,
R1.
2. , . 1, R0 MEM, R1 WRD.
3. , -, MOV R1,(R1)? ?
4. , ,
, ,
.
5. , ,
; ,
, .
ABCDEFGHIJKLMNOPQRSTUVWXYZ
THEQUICKBROWNFXJMPSVLAZYDG
,
.
.
. ,
; ,
.
, . , ,
, ,
, , .
,
. ,
. ,
.
. ,
,
. R0 , R2 .

CMP
R2,R0
BPL
REPEAT
;
R0 (R0).
, .
.
, , ,
(?).
.
, , ,
.
, ,
; ,
, .
,
- ,
.
,
, , .
PDP-11 ODT-11 (On-line Debugging

Technique ), .
ODT ,
2.4.
DDT ,
DECsystem-10.
, . DDT
Michael Singes, Introduction to DECsystem-10 Assembler Language (Wiley, 1978).

, , .
. , ,
, .
, , ,
.EXIT. , ,
. .EXIT , ,
E (Examine ).
, , , MEM O 1376,
RT-11
E1376
() MEM.
.
, , E1370-1376
MEM, MEM
.
, , MEM 000376';
, 000 000'; ,
376.
, ;
. , O 1000, ,
, ,
.
, ,
.
D (Deposit ). ,
=. , , O 2000 O 10:
D 2000 = 10
,
=, , , . ,

D 2002 = 1,2,3,4
O 2002 1, 2004 2, 2006 3 2010 4. ,
D, E (.. ).
, ,
. ,
;
; , ,
; . R0
;, R1,
; R2. R1,
;R2 .

.
.

MOV
R1,(R2)
ADD
#2,R2
, .
,
. PDP-11
,
, -. Rn
-; , Rn
: (Rn). , (Rn) (Rn)+, ,
, , Rn , .
,

MOV
R1,(R2)+
: ,
R2. (
), R2 , ; ,
- 1, 2.
, R2,
.

. : -(Rn),
: Rn, .
, Rn. ,

SUB
#2,R2
MOV
(R2),R0

MOV
-(R2),R0
, .
2.4
, .
MOV (R2)+, (R2).
. 1. , ,
.
2. ,
MEM, , WRD.
?
3. , MEM,
. :
) ;
) MEM,
.
4. ,
MEM. ,
, WRD.
MEM , WRD.

. ,
,
.
.
.
; ,
. , ,
.
,
. , .
. ,
.
, , (
, ).
,
2
1
7
5
3
:
1 #
2
7
5
3
1
2 *
7
5
3
1
2
5 #
7
3
1
2 *
5
7
3
1
2
5 *
7
3
1
2
5
3 #
7
1
2
3 #
5
7
1
2 *
3
5
7
1
2
3 *
5
7
1
2
3
5 *
7
, , #,
, *, . , ,
, , .
,
COMPAR, , , .
, MEM.
MOV
COMPAR: CMP
BEQ
MOV
CMP
BPL
SWAP:
MOV
MOV
MOV
SUB
CMP
BPL
ADD
BR

R0,R2
R1,R2
DONE
(R2)+,R3
(R2),R3
COMPAR
(R2),R4
R3,(R2)
R4,-(R2)
#2,R2
R2,R0
COMPAR
#4,R2
COMPAR

. 2.4. .
R2 , .. -.
, (R2) ,

(R2); , (R2) R2
.
, , . 2.4.
, MEM R0,
R1.
, -
, , . ,

. 2.5. - . 2.4.
.
, .
- . 2.5.
. 1. ,
, .
2. , MEM.
R. ,
) ,
. , ,
, ,
;
) , .
3. ,
. (:
.)
4. ,
(, 3/7=0.428571, 6 ).

2.4.
,
INC
Rn
Rn , Rn . ,
INC R4 : 005204. ,
, , .
0052 INC.
,
16- PDP-11.
0 2.
3 5, 6 8, 9 11 12 14. ,
, PDP-11 ,
0, 1. , 0052 ( INC)
10 .
,
, , ,
2.3:
005201
INC
R1
005211
INC
(R1)
005221
INC
(R1)+
005241
INC
-(R1)
INC, DEC, NEG, CLR
TST,
( )


.
3 5,
, () .
, PDP-11
.
. :

0
000

Rn
1
001

(Rn)
2
010

(Rn)+
4
100

-(Rn)
6 ;
INC
MEM(R1)
1 , R1
MEM. , MEM 1376 R1 100 (
), MEM(R1) 1476. ,
( ),
R1 MEM.

R1 6,
:

INC ?(R1),
, , ? MEM.
MEM . , PDP-11
.
, . ,
,
, , .
INC MEM(R1) MEM.
, , 376, :
005261
INC
MEM(R1)
000376
,
, .
, , . 0052
INC,
, 61 .
1 R1; 6 .
R1 . PC
(Program Counter) , ,
.
INC,
, . PC,
.
P. ,
MEM?
4 5,
.


54

00

Rn
01
1
(Rn)+
10
1
-(Rn)
11

MEM(Rn)
, , ,
0 2. ,
() 1 , ..
MEM(R1)+ .
, 4 5,
0 2 . 3
. 3 ,

, . 0

(), 2 (), 4 () 6 ().


3 ,
.
. ,
, ;
.
, , INC
3 1376. ,
1376 2000. 3 ,
1376, 1376 2000 2001.
3 , 1376 .
1376 , .. 2000. ,
2000, 1376 .
P. ?
@ . ,
1, 3, 5 7 : @Rn, @(Rn)+, @(Rn)
@MEM(Rn). 1, , (Rn)
@Rn.
, , ,
. 0,
.

; ,
.
,
.
. ,
INC MEM(R1), , -,
ADD #MEM,R1, INC (R1). ,
ADD #MEM,R1 , .. .
,
.
P. 1. INC (R1) INC 0(R1)? ?
2. , TABLE, ,
, . TABLE ,
MEM. , .
3. :
MOV
#MEM,R1
CLR
R0
LOOP:
CLR
@0(R1)
ADD
#2,(R1)
INC
R0
CMP
R0,1000
BNE
LOOP
) ?
) CLR @0(R1) CLR @(R1)?
) , , LOOP,
CLR @(R1)+?

) ?
. ,
:
. ADD, SUB, CMP MOV,
( ),
. ,
. , ,
, ; CMP,
. :

6 ( ) 7 ( ), , ,
ADD
MEM(R1),@WRD(R2)
066172, MEM WRD. (
ADD?) , ,
. , ,
, .
P. 1. SUB #2,R1 (
)?
2. :
; ,
. MEM ;
.
) ,
, WRD.
*) ,
, WRD, .
,
MEM:
6
4
7
5
0
WRD 2, 4, 1, 3,
..
.
,
.
-

, .
,
,
.
:
1. .
2. PC.
3. ( PC 6 7). ,
4.
.
5. ( PC 6 7).
6.
.
7. , , 3 5. (:
.)
, , ,
,
, . , ,
MOV
(R1)+,(R1)
, R1 2000, 2000
10, 2002 . 3 ;
2000. 4 R1 2002; , 5
2002.
2000, 2002 10, R1 2002.
,
.
ADD
(R1)+,R1
, : 2000 R1 10 2000.
2000. 4 R1 2002;
ADD 2000,
R1 2012.
P. 1.
,
?
2. 2.3.
3. ADD #4,R1 ?
,
.

, .
, ,
ADD
R1,(R1)+
5 2000; 6
R1 2002. 7
2000 2002, .. 10+2002=2012. ,
, PDP-11
. 7.
, 6 R1 2002, 2000
2000, 2010.

, ,
PDP-11. ,
,
, , - .
, ,
, .
Z , .
, . ,
( );
, , (
). , ,
:
A
E .END;
M
U
P. 1. ADD R1,(R1)
7.
2. , .
.
CMP #100,R1 CLR MEM,
.
.
, , ,
CMP #100,R1, .
,
.
022701
CMP
(PC)+,R1
000100
.WORD 100
O 100. PC
. PDP-11 ,
. 7,
, ,

PC=%7
, , ,
PC .
, ,
,
.
, .
, CMP #100,MEM 1100
1102 (, ).
PC 1100. ,
PC, .. CMP (PC)+,R1. ,
, PC , ; PC
1102. , PC (, 2),
,
.

, 1102;
CMP 1102 (.. 100)
R1. , .
(, ,
).
PC 2. PC 1104
. , PC,
.
, , :
R0,
026001
CMP
100(R0),R1
000100
, PC 4
. PC
. , ,
CMP PC, PC ,
.
, PC CMP. , CMP #100,R1
CMP, ,
. ,

. , , PC 2,
PC , ,
. ,
, .
, MOV #MEM,R1,
. ,
, ,
.
P. 1. CLR #MEM?
2. 101 INC #100?
3.
(a) INC
(PC)
() INC
(PC)+
DEC
(PC)
DEC
-(PC)
. PDP-11
,
, , , CLR MEM MOV MEM,WRD.
PC
. CLR MEM CLR X(PC),
X , . ,
X, .
CLR MEM 100,
MEM 376.
PC CLR PC ,
; .. PC,
104. X , 104 376;
X 272, CLR MEM , CLR 272(PC).
000100
005067
CLR
MEM
000102
000272

...
...
000376
000000
MEM:
.WORD 0
X
( MEM) ( , , X),
, , PC ,
, X. X
, ;
.
, , ,
, . ,
,
, .
, , , ,
CLR MEM,
; .
,
. ,
, .
P. , ,
START 1000, ,
:
START: INC
MEM
INC
MEM
ADD
#1,MEM
BR
START
MEM:
.WORD 0
.END
START
, ,
- PIC (Position-Independent Code).
, ,
. ,
; ,
.
- .
;
,
, -
. ,
;
.
.
PDP-11 .

. ,
MOV
#-1,-2(R1)

MEM:
.WORD -1
, 2(R1) 2, R1 (

).
, R1, R1.
, , .
PDP-11 ,
. 15
1 . , ( ?),
, , 1 1,
15. PDP-11
(
). X , X :
1. X; X ,
, 0 14 X.
2. 1.
3. , .
,
PDP-11, 0 15 1 .
077777, 2151 = 32 767.
, 1 : 177777, 2 177776
.. :

077777
077776
...
000001
000000
177777
177776
...
100001
100000

, 2 ,
1, ..

. ,
.
P. 1. O 100000
PDP-11?
2.

, X.
3.
CMP
#-77777,#77777
BMI
MINUS
, -, ?
4. R0 7777, INC R0?
5. MEM 100.
CLR MEM, ,
376?

3. PP PP
3.1.
. 2 .
.
, ,
.
. : , , .
, ..
, .
, .
,
,
. , ,
. ,
, , .
,
.
,
, .
. ,
, ,
.
, , , ,
, . ,
, PRINT.
PRINT,
,
, .
.

.
, , , . -
MEM,
, ,
PRINT
MEM
PRINT .
, ,
.
, -
. , ,
. , ,
.
. , ,
, . ,
,
.

ASCII ,
.
.
, , R2
:
CMP
#40,(R2)+
; ?
BNE
ONWARD
; -
SPACE: CMP
#40,(R2)
; -
BNE
ONWARD
CLR
(R2)+
BR
SPACE
ONWARD: ...
,
. , ,
. ,
, .
, ,
, . ,
, ,
.
, ,
- .
,
. ,
,
.
, ,
, .
, , ,
. ,
.
,
, , ,

. ,
:
; , (R2)
SPACE: CMP
#40,(R2)
BNE
RETURN
CLR
(R2)+
BR
SPACE
RETURN: ;
,
, .
.
. ,
,
,
.
, , PC
SPACE ( , PC

). SPACE (
) PC.
. , PC
R5, (R5). , ,
BR (R5). ,
,
.
; .
, , , R5,
. , PC .
:
MOV
R5,PC
, .
. -
MOV
PC,R5
BR
SPACE
(?). , , ,
PC
. JSR (Jump to SubRoutine),
:
JSR
R5,SPACE
JSR , ( )
004, ,
PC, .
, . (
JSR PC
?) , , PC
. PC,
JSR , .
, , ,
:
LOOP:
CMP
#40,(R2)+
BNE
LOOP
JSR
R5,SPACE
BR
LOOP
BR.
,
LOOP, . ,
, . ,
- . ,
LOOP -
. ,
SPACE, . ,
LOOP
(?).
,
, .
, (R2), ,
. ,
, -
(?) . ,

R2 SPACE,
.
P.

. .
.
, . ,
, . ,
, LOOP ,
. :
LOOP:
CMP
#40,(R2)
BNE
L1
TST
(R2)+
JSR
R5,SPACE
L1:
CMP
#56,(R2)
LOOP,

L1, .
, , R2.

SPACE ( ?).
:
BNE
L2
JSR
R4,PERIOD
L2:
TST
(R2)+
BR
LOOP
PERIOD .
, R2 , R2
, ,
LOOP. R4. ,
.
PERIOD -,
.
.
PERIOD
. ,
. .
, PERIOD
R2 SPACE; R2
. R2
SPACE. R2
,

PERIOD: CMP
#40,-(R2)
BNE
P1
JSR
R5,SPACE
TST
-(R2)
P1:
ADD
#10,R2
JSR
R5,SPACE

TST
-(R2)
MOV
R4,PC
, SPACE
CLR (R2). , ,
,
,

. 3.1. - .
.
SPACE ,
.
- . 3.1. + , R2
.
P. 1. -
?
2. , .
SPACE , .
PERIOD?
3. . ,
.
, .

.
.. , ,
, . ( )
.
,
. R4 PRINT, , ,
PRINT SPACE, .
PRINT . ,
, ,
,
PDP-11.
, JSR
, .
. PDP-11
.

, , .
, JSR,
. , ,
.
PDP-11,
JSR .
,
JSR
R5,SUB
1) R5;
2) PC R5;
3) SUB PC.
, JSR ,
3.2.
, , ,
( SPACE, PERIOD)
. PERIOD
JSR
R5,PERIOD
PC, R5
. PERIOD
JSR
R5,SPACE
SPACE. R5
SPACE PERIOD. R5,
.. PERIOD .
,
, . SPACE
PERIOD MOV R5,PC; ,
JSR R5,SPACE
PERIOD ,
.
, SPACE
, .
MOV R5,PC RTS
(ReTurn from Subroutine).
RTS
R5

1) R5 PC;
2) R5 , JSR (
RTS).
, RTS
, ,
, JSR
. JSRRTS
, , ,
.
,
, .
.
R5. JSR RTS
:
-
.
, , SUB1 SUB2,
SUB3. , . 3.2.
JSR :
SUB2 SUB1
SUB1
R5
, ,. .
SUB3 SUB2 , SUB3
JSR, .

...
SUB1:
...
...
JSR
R5,SUB1
...
...
...

SUB1
...
...
JSR
...
...
RTS

R5,SUB2
R5

SUB2
SUB2: ...
...
...
...
JSR
...
RTS

R5,SUB3

SUB3
SUB3: ...
...
...
...
RTS

R5

R5

. 3.2. .
, JSR
11.
, ,
.
RTS
R5.
, . 3.2 , RTS R5
SUB3. R5, JSR
SUB3, SUB2. RTS
R5 SUB2 SUB1.
SUB2 ,
RTS R5. R5 ( RTS SUB3)
SUB1. RTS
( SUB1 )
R5.
11

stack . . .

, SUB1 , RTS R5
R5,
.
-, ,
.
,
RTS R5. , , ,
.
P. 1. .

?
2.
. ,
, ..
.
.
3. , .
4*. PDP-11
, .
,
.
ASCII. ,
ASCII. ,
, ,
. ,
, ,
, .
.WORD, .
WAITING FOR GODOT12 MEM,

MEM:
.WORD 127,101,111,...
.. . ,
( ) .WORD,
.
, , .
ASCII,
' ,
ASCII.
MEM:
.WORD 'W,'A,'I,...
..
, , , ,
ASCII ' . , , '0
, 60,
CMP
#60,(R1)

CMP
#'0,(R1)
.
,
12

. . . .

( ).
, ASCII,
.ASCII .ASCIZ. :
MEM:
.ASCII
/WAITING FOR GODOT/
.ASCIZ. /.../,
, .
.
/, " '. ,
, ASCII ,
.
, .ASCII .ASCIZ ,
. , .WORD,
.
, ,
. .ASCII .ASCIZ
, ASCII ( ),

WAITING
FOR GODOT
, MEM, :
MEM:
.ASCII
/WAITING/<15><12>/FOR GODOT/
: ASCII
.
:
A

MEM

MEM+2

MEM+4

..
,
. MOV #MEM,R1,
.TTYOUT (R1)
W. A, MEM,
, .TTYOUT
, ,
. .TTYOUT,
, MOVB (MOVe a Byte):
MOVB
(R1),R0
, R1 (..
MEM). ( , .)
R0. ,
,
. ,
R0+1 R1.
, A, R1
, .. MEM ,

LOOP:
.TTYOUT (R1)
INC
R1
BR
LOOP
R1 , , ,

. , , :
LOOP:
.TTYOUT (R1)+
BR
LOOP
R1
MOVB
(R1)+,R0
, R1
1, MOVB .
3.3.

.BYTE, .WORD:
MEM:
.BYTE
'W,'A,'I,...
.. " .WORD,
ASCII
:
MEM:
.WORD
"WA,"IT,"IN,...
..
, ,
- .
:
LOOP:
MOVB
(R1)+,R0
BEQ
FINIS
.TTYOUT
BR
LOOP
FINIS: RTS
R5
:
LOOP:
.TTYOUT (R1)+
BNE
LOOP
RTS
R5
. 4.
.ASCII .ASCIZ ,

. .
, ,
. RT-11 .PRINT.
.PRINT #MEM ; !
, MEM.

. .ASCIZ. ,
.PRINT .MCALL.
, .PRINT ,
, 200;
.PRINT ,
. , .ASCII
, :
MEM:
.ASCII /WAITING FOR GODOT/
.BYTE
200
,
, , ,
.EVEN.
, .
, .WORD .END:
MEM:
.ASCIZ /WAITING FOR GODOT/

.EVEN
.END START
.ASCIZ , .EVEN
( ?). -
, .
P.
.PRINT #MEM
MEM:
.ASCIZ 'I'm all right'
.END START
?
. , ,
.
PDP-11 .
,
CMPB (CoMPare a Byte):
READ:
MOV
#MEM,R1
1$:
.TTYIN (R1)
CMPB
#12,(R1)+
BNE
1$
DONE:
...
( ?) 1$ ( $
, ESCAPE)
. 1$, 2$, 3$ ..
, , ,
, , , ,
. 1$
READ DONE. .
, DONE READ ( ,
), 1$ .
,
, .
, ,
. .

3.2.
3.1, ,
, .
.
, ( )

LIFO: (Last
In, First Out). .
,
13. . ,
.
,
13

.
, . .

, ,
.
,
. ,
; . , ,
, .
. PDP-11 ,
,
LIFO. , , ,
, , , . ,
, .

.
, R1
1000 1400 ( ). ,
R1.
.
, , , .

PDP11 .
, .
, .

, . ,
MOV #1400,R1, MEM

MOV
MEM,-(R1)
WRD
MOV
(R1)+,WRD
R1 .
,
MOV, WRD, ,
. ,
, ,
. ,

.
,
, . , ,
,
:
.BLKW 400
START: MOV
#1400,R1
, , .
MOV , R1 .
PDP-11 . ()
, . MOV
START: MOV
#.,R1
, ,
. . ,
TST
(R0)+
BEQ
.-2
, .
.
, -
PDP-11.
n$, .
.

MEM+2 ( , MEM), MEM2 . . ,
, MEM+WRD MEMWRD?
( *)
( /), . , ,

. , 1+2*2 5, 6.
<. .>.
. ,
. :
,
.
, .
. ,
,
. , 3*(74)+1(63) . ,
. , ,
, ,
.
, R1.
ASCII , R2
. ,
. NUM ,
(R2). NUM R2
, , NUM
. OP (R2)
( ASCII) R2 ,
. , , ,

NUM R2 , OP
.
CALC, ,
:

R1

,
, . , +
CALC :
TST
(R1)+,(R1)+
ADD
-4(R1),(R1)
! , , ,
CALC.
2(R1) ,
.
P. .
EVAL
.
R2, EVAL,
. ,
.
, EVAL,
. .
, ,
. .
CALC, ,
. ,
. ,
.
EVAL:
JSR
R5,NUM
CMP
#15,(R2)
BNE
1$
RTS
R5
1$
JSR
R5,OP
JSR
R5,NUM
JSR
R5,CALC
CMP
#15,(R2)
BNE
1$
RTS
R5
P. 1. ?
2. - .
3. ( ) .
, . ,
1+2*2. EVAL NUM, ..
1 . , 1$
+, 2 . :

2
+
1

R1

CALC, :
3
R1
,
2
R1
*
3

CALC
6
R1
. RTS R5 .
(.. 6) .

P: , ,
(
,
).
.
, , . ,
, , : 3*(75). ,
EVAL, 3,
. ,
3* . 75.
, EVAL,
7. EVAL ,
. CALC,
2.
, , 3*2. EVAL
CALC .
,
.
; , EVAL. EVAL,
, , ,
.
, 3.1 ,
JSRRTS
. , 3.2,
, , SUB1, SUB2 SUB3
SUB, . ,

.
,
: ,
, .
, , ,
EVAL , . ,
,
(
,

).
EVAL
. ,

, EVAL
, NUM: .
, ,
EVAL. - . 3.3.

. 3.3. - .
, , .
P.
EVAL, ,
CALC .
, ? , ,
. 3.3, :
) (1+2)*3?
) 1+((2+3)+4)?
) 1+(2*(3+4))?
, ?
EVAL ,

-. . 3.4.
EVAL:

1$:

2$:
3$:

4$:

JSR
CMP
BNE
RTS
JSR
CMP
BNE
TST
JSR
BR
JSR
JSR
CMP
BEQ
CMP
BNE
RTS

R5,NUM
#15,(R2)
1$
R5
R5,OP
#'(,(R2)
2$
(R2)+
R5,EVAL
3$
R5,NUM
R5,CALC
#'),(R2)+
4$
#15,-(R2)
1$
R5

; (

; )
; ),

. 3.4. .
3*(74)(1(63)). . 3.5
.
, .

. 3.5. 3(7-4)-(1-(6-3)).
EVAL 3 *,
. (, ,
R2, .
7, 4 ( b),
CALC, 74 c.
CALC ,
. EVAL ) .
, CMP, 3$,
, , R2
.
, JSR R5,EVAL EVAL,
EVAL . , -
, EVAL CALC, 3*3
d ( ). EVAL
1$ ,
e. , , .
EVAL 1 ( f),
. EVAL 6, 3,
g; CALC, h,
EVAL, JSR R5,EVAL.

,
() EVAL.
EVAL CALC, i;
, , EVAL.
CALC, j,
, .
P. 1. .
2. , ,
.
3. , .
4*. , ( ) ,
, * /
+ .
5. ,
.
. JSR RTS , , ,
PDP-11 ,
6. , ,
, SP.
SP=%6
,
JSR
R5,SUB

MOV
R5,-(SP)
MOV
"return PC",R5
MOV
#SUB,PC
RTS R5
MOV
R5,PC
MOV
(SP)+,R5
, ,
. ,
, .
SP.
776,
400. ,
1000.
,
,
MOV
#.,SP
,
. .
SP , ,
, PC SP ,
. ,
.
: SP PC ,
,
.
. ,

- .
P. EVAL , R1
SP.
,
. 3.5. , ?
,
,
?
, ? ,
PC
JSR
PC,SUB

RTS
PC
3.4 .
. , ,
PDP-11 , .
, JSR ,
PC, .
, ,
, . ,
(SP) (.. ), , (SP).

JSR
PC,@(SP)
,
. , , ,
. , PC, .
:
JSR
PC,@(SP) +
PC . (
JSR ?) , ,
, ,
.
JSR PC,@(SP)+ .
,
. ,
, , , .
,
, ,
. ,
, . ,
, JSR PC,@(SP)+
,
. . 3.6
, ,
.

. 3.6. .
. . ,

.
,
. ,

MOV
#.,SP
, , ,
.
, . ,
, ,
.BLKW , ..
. .BLKW
( ).
.BLKW .BLKB, .

.BLKW 40
.BLKB 100
.
:
.=.+100
,

. ,
, 1400. , ,

.=1400
, ,
.
.
;
1000,
.

.ASECT. .
: .=1400.
,
, .
. , , 340,
.
( ?),
:
.ASECT
.=12
.WORD 340
.CSECT ,
, .
.ASECT .CSECT,
.
,
.
P. 1. 12 ?
2. MOV .,SP?
3. . PC?
4. MOV #.,SP , 1400.
? ? ,
: ?

3.3.
, ,
,
,
. ,
, , .
,
,
, . ,
,
MEM. , , .
MEM ,
- . , BEQ BNE ,
, Z. - ,

MEM , , ( ),
. , , MEM .
. ,
. , ,
: ,
. ,
, , .
,
, , .
( MEM ).
MEM ,
: , ?
, 0,
1. (, .) ,
.
, ,
( ), (
) . , 1
, 0 ,
.
. , , p q ,
p q ( pq) , p, q .
BIT (Bit Test), PDP-11,
. ,
BIT
MEM,WRD
(MEM)(WRD), .. , 1 ,
(MEM) (WRD) 1. , R0
1, BIT R0,MEM 0, (MEM) ,
1 .
BIT ,
.
. , BIT
CMP. ,
:
BIT
#1,MEM
SEQ
EVEN
ODD:
...
,
BIT .

, .
.
,
, (, IF) .
, ,
.
: 0;
1; 1, 0; 0, 1.
. BIT

BIT

0
0
0

0
1
0

1
0
0

1
1
1

P. 1. Z N BIT
MEM,WRD, MEM WRD :
) 100, 200?
) 100, 300?
) 177777, 77777?
2. , MEM ?
, , .
, ,
, :
pq , , q, ;
( ). -:
pq , p q, .
:

PDP-11 BIS
(Bit Set). BIT . ,

BIS
#20,MEM
MEM .
XOR14 :
XOR
R,X
R , X . R X
, X. ,
MOV
#20,R0
XOR
R0,MEM
MEM 0, 1, 1,
0.
, ( ~),
: 1 0 .
COM (COMplement).
BIC (BIt Clear):
BIC
MEM,WRD
WRD : {MEM)}(WRD).
WRD , MEM 1.
,
BIC
#20,MEM
MEM 0.
1 0 N Z
.
14

P. 1. ,
.
2. ASCII + , ?
3.
ASCII ?
4. COM NEG?
5*. , :
BIT, BIS, XOR COM; ; .
,
N Z.
. PDP-11, ,
: ,
, , ,
, .
PDP-11 . ADD SUB
15- .
,
, , .
, 2 14+1.
15- ( ), 14 0
. :
010 ... 001
+ 010 ... 001
100 ... 010
,
, .
215+2 -215+2. ,
. ,
, .
,
, . ,
, SUB MEM,WRD,
MEM -(214+1), WRD 214+1.
. ,
ADD MEM,MEM, MEM -1. ,
MEM 1,
111 ... 111
+ 111 ... 111
1111 ... 110
, PDP-11.

.
; , .
, ,
. ,
. -2,
, . ,
,
. .
, , ADD MEM,MEM, MEM

-215+1. 15 0 1, .
100 ... 001
+ 100 ... 001
1000 ... 010
, 2,
216+2. ,
, ,
. , ,
. , ,
.
P. 1. (,
) ?
2. m n ( )
, -m -n?

PS ( V).
, , ADD, SUB, CMP, NEG, DEC INC,
, V, . MOV, CLR
V.
P. , R0 177776,
V TST (R0)+?
, V; ,
V 1, BVS (Branch if V is Set), , V 0, BVC (Branch
if V is Clear).
,
MEM WRD.
, ,
ONWARD, (MEM)(WRD). ,

CMP
MEM,WRD
BPL
ONWARD
, , CMP,
. , MEM 214, WRD -214, , ,
(MEM)(WRD). CMP MEM,WRD -
1 . BPL
, 214-(-214)=214+214=215, BPL
N. N 1,
, 1 (
). , CMP N, , , BPL
.
, CMP N 1,
, , 1
, . ,
N V 1, :
CMP
MEM,WRD
BPL
ONWARD
BVS
ONWARD

, , ,
CMP .
, , ,
. MEM -215,
WRD 215-1. (MEM) , (WRD) , ,
, (MEM)<(WRD), .
:
100 ... 000
- 011 ... 111
000 ... 001
, ,
N. :
, -2 15-(215-1)=-215-215+1 =-216+1. V,
.
, N , ,
, 0 ,
. , N , V
1, . , :
BPL , N V
0, 1, , I, 0.
: NV=0.
BGE , (Branch if Greater than or Equal).
CMP
MEM,WRD
BGE
ONWARD
...
P. 1. ,
BPL, BMI, BVS BVC.
2*. , V,
VSET, JSR PC,VSET R0
,
V.
BGE BLT , (Branch
if Less Than). To BLT , N
V : NV=1. BGT , (Branch if
Greater Than), , BGE,
Z : Z(NV)=0 .
BLE , (Branch if Less or Equal).
. ,
, 1, ,
1, PDP-11. 1
, , .
C,
PS.
, MOV C, ,
V. TST C , , V.
INC DEC C ( V?).
ADD C,
, ; .

P. 1. C CLR, COM NEG?


2. , C ADD
, .
SUB CMP C,
; . ,
57:
000 ... 101
- 000 ... 111
111 ... 110
, 5
. 2 0
1 , . ,
, 1.
, , 1,
C. , ,
V .
P. 1. , C
SUB .
2. C SUB CMP,
?
, C: BCS ,
C (Branch if C is Set) BCC , (Branch if C is
Clear). : BCS , BLO (Branch if
LOwer , ), BCC , BHIS (Branch if Higher or Same
, ).
, , R0,
R1. , , :
LOOP:
CLR
(R0)+
CMP
R1,R0
BPL
LOOP
, , , R0 60000, R1
170000, , ,
, . CMP R0,
60002, 107776.
, , N, BPL
. , ,
( ,
).
, CMP
170002. :
170000
- 170002
177776

170000 , , C. , R0,
, 170000,
,

C 0. , :
LOOP:
CLR
.(R0)+
CMP
R1,R0
BCC
LOOP
BHIS , BCC.
BLOS , (Branch if LOwer or Same)
, C Z ( ) : CZ=1.
BHI (Branch if Higher , ).
.
-.
00024 ( ?). 0, 1, 2 3
, C, V, Z N
. ,
, .
: CLC, CLV, CLZ, CLN SEC,
SEV, SEZ, SEN. CCC,
SCC. 000240 NOP ( )
.
(
&) ( !). ,
CLV!CLC , 1 ,
CLV CLC ( ). ,
V C.
P. 1. ) CLV? ) CLC?
2. CLV&CLC?
3. SEV!CLC?
. MOV, CLR, INC, DEC, NEG, BIT,
BIC, BIS, COM, TST CMP .
B (MOVB, CLRB ..),
1, .
, ,
.
.
, MEM ,

MOVB
#-2,MEM
000376. ( -
MEM )
MOVB
#-2,MEM+1
, ,
, 1. , MEM 177000. (.
376000 !)
P. MEM
MOVB #-1,MEM+1, ?
.
, N ,

( , ).
CMPB C , 1
. ,
ADD SUB .
, ,
.
MOVB . ( ,
.)

. MOVB
.
,
, .

, , , 1, 2. ,
, , 2
, : SP PC
.
P. ,
PDP-11, ?
, , JSR RTS, SP
.
.
SWAB (SWAp Bytes) . MEM 000376,
SWAB
MEM
177000. SWAB V C, N Z
. , SWAB
, , N .
.
, . ,
, .. , ,
1, . , ,
.
( ), (0 1) , ,
, . ,
(?) , - ,
.
, R1,
R0 , R1 ,
. R0, R1
R0: 0, 1, .
R0 R2 , (
R1)
XOR
R2,R0
R1. ,
.
C.

ASL (Arithmetic Shift Left)


- : 15
C; 14 15; 13 14 ..
, . .
:

ASL . N Z
. V
, (N C) ;
V . , V=NC.
P. 1. ASL ,
?
2. V ?
ASL ASLB.
C .
, ASL,
.
ASR (Arithmetic Shift Right) C
,
. 15 14,
.

ASRB .
. ,
.
P. 1.
ASR?
2. ?
3. V ?
4. ?
ROL (ROtate Left) ROLB
:

;
C, C .
ROR (ROtate Right)
RORB

;
C, C .
N, Z V ,
.
P. ,
, V=NC?
, ,
, X , ,
X,
. 2.4 , 9
11. , MOV X,R0
ROR R0 9 11
0 2. BIC #177770,R0 R0.
:
MOVB
X+1,R0
ROR
R0
BIC
#177770,R0

PDP-11 : Wulf et al., The Design
of an Optimizing Compiler (American Elsevier, 1975). ,
, , ,
.
Y
X Y X:
MOV
Y,R0
ROLB
X
ROR
R0
RORB
X
MOVB
R0,X+1
, , .
, .
P. 1. , ) C, ) N,
X
, . X .
2. , R0 , ,
, X.
. .
,
.
PC. , , 2000 BNE LABEL,
LABEL 2010. , PC
, .. 2002. 20102002=6 ( !) . ,

, . (,
.) BNE 1
. , BNE LABEL
001003.
, ,
,
. ,
2010 BNE LOOP, LOOP 2000.
2012. ,
2000-2012=-12 -5 (!) . ,
. -5 ( )
373, BNE LOOP 001373.
, , ,
.
, , 177, 200
(D 128) , 200,
-200 177 (D 127)
.
.
P. 1. BEQ
0014. BEQ LABEL,
2006, LABEL ) 2000, ) 1712, ) 2076?
2. -?
, SOB15 (Subtract One and Branch if
nonzero , ). 077 ( 9 15
), 6 8, 0 5.
,
. , SOB .

, . SOB .
, , MEM WRD
, :
MOV
#MEM,R0
MOV
#(WRD-MEM)/2+1,R1
LOOP:
CLR
(R0)+
SOB
R1,LOOP
P. 1.
SOB?
2. SOB ?
3. :
) , MEM ();
) , MEM 1000 MEM .

3.4.
3.1 3.2,
15

, .
.
3.2 ,
, R2,
, R1. , NUM
, , (R2), (R1).
,
. NUM ,
. , ,
NUM R1 R2.
. ,
, , .
.
, , , , ,
JSR.
, ,
.
,
, .
, ,
.
, SQRT .
, .
, , R1,
, R2. ,
NUM. WRD ,
MEM,
MOV
#MEM,R1
MOV
#WRD,R2
JSR
PC,SQRT
, SQRT
:
MOV
(R1),R1
R1,
MOV
R1,(R2)
RTS
PC
, , ,
MEM, .
JSR,
PC:
JSR
R5,SQRT
.WORD MEM,WRD
R1
MOV
@(R5)+,R1
R1
MOV
R1,@(R5)+
,
; RTS R5 ,
. -,
.

, , JSR,
WRD:
JSR
R5,SQRT
.WORD 7
; 7
.WORD WRD
; WRD

MOV
(R5)+,R1
.
,
SP , .
, . ,
SP , .
.
P. 1.
? ,
: ) ; ) ; )
; )
?
2. : ) ; )
; ) ; )
.
3. ?
?
. , ,

. , ,
,
, ,
,
.
,
. ,
, .

, .
, X=3, ,
X 3. X3 X:=3
: X 3
: 3 X. X ,
, X. X
,
X. , Y=X+1 :
MOV
X,Y
INC
Y
X=X+1 -
INC X.
PDP-11 X=3
MOV #3,X, . , ,
:

MOV
THREE.X
...
...
THREE: .WORD 3
, , .
,
.
. , ,
, MOV #3,X,
3 ( ),
.
PDP-11,
, ,
Y=X+3 -
MOV
X,Y
ADD
THREE,Y
THREE , 3, , ,
, 3.
,
, ,
. , ,
3=3+3 , .
:
MOV
THREE,THREE
ADD
THREE,THREE

. 3
6. ,
.
PDP-11, , 3=3+3 ( )
MOV #3,#3, . ?
,

Y=SQRT(X)
X. ,
X,
,
MOV
X,R0
X. , X .
, Y . SQRT ,
, , =
. , SQRT , Y=,
, MOV R0,Y, X
R0.
,
. , , :
CALL SQRT(X,Y)
X
Y. Y , ,
.
, .
,

, :
CALL EXCH(X,Y)
, X Y ,
,
. ,
. , X Y .
,
-,
.
DIFSUM(X, Y),
X = X-Y
Y = 2*Y+X
X Y X, Y. ,
, X ,
. X Y -
MOV
X,R0
;
MOV
Y,R1
;
SUB
R1,R0
ADD
R1,R1
ADD
R0,R1
MOV
R0,X
;
MOV
R1,Y
;
RTS
PC

MOV
#X,R0
;
MOV
#Y,R1
;
SUB
(R1),(R0)
ADD
(R1),(R1)
ADD
(R0),(R1)
RTS
PC
, DIFSUM(X, X).
P. 1. ,
, : ) - ) ?
2. ,
.
.
,
. PDP-11
,
.
;
, , .WORD 7,
. , , ,
, 10.
, ,

MOV
PS,-(SP)
MOV
PC,-(SP)
.. PS PC ,
, ,

:
MOV
10,PC
MOV
12,PS
10 12 , .
, 10,
, .
,
.
() .

.
, , PDP-11 MUL
DIV . ,
, 10. ,
, MUL DIV;
. , ,
.WORD.
, ,
PDP-11, . ,
. ,
. ,

. ,
MUL DIV. ,
; , -
.
,
MUL DIV, ,
.
, MUL DIV,
, ,
.

, .
, SERV
MOV #SERV,10. ( ?) ,
,
(?)
() . SERV
( ) , .
, : MUL DIV. MUL 070
, - .
DIV, 071.
, - SERV
.
MUL DIV,
, ,
.
.
,

X:
MUL
Y,R
R , Y , , ,
. , ( X)
,
, .
R ,
, ( ?),
, , MOV R,R0. ,
, R MUL, MOV
. , 68
MUL MOV:
MOV
X,R0
BIC
#177077,R0
ADD
R0,L1
L1:
MOV
R0,R0
( , , R R0?)
, 3.3, ,
, MOV,
?
.
( 0 5) X ( 6 11) MOV R1:
MOV
X,R1
BIC
#177700,R1
SWAB
R1
ASR
R1
ASR
R1
ADD
R1,L2
L2:
MOV
R0,R1
, , , L2
,
ADD.
, MUL ,
R1. ( , ,
R1?) , ,
MUL . MOV (
L2), , , ,
L2. , MUL
:
MOV
X+2,L2+2
L2:
MOV
R0,R1
HALT
, : L26 ( ?)
, .
P. , , ,
MUL , , X+2,
L2+2. , MOV
X+2,L2+2 , MUL . (
HALT NOP, .)
, MUL
( 6 PC) -

( 7 PC) , X+2
X
.
P *. .
.

RTI (ReTurn from Interrupt), ,
:
MOV
(SP)+,PC
MOV
(SP)+,PS
. , ,
, 10
12, ,
.
P *. ,
.
. ,
3 PC .
, @#, . ,

CLR
@#10
, CLR 10,
CLR
@(PC)+
.WORD 10
( CLR 10?) PC
, 10; , ,
@(PC), 10 . -
PC .
. ,
MEM 140, CLR @#MEM
:
005037
000140'
( CLR MEM?)
, ( 10
) , ,
,
. , ,
, , , CLR @#10,
-.
P. CLR @#MEM -?
, -
, ,
, .
.ENABL AMA


.
. ,

. .ENABL AMA ,
.DSABL AMA.
- .
,
, . PS PC
, .
,
. , ,
.
PDP-11 EMT (EMulator Trap).
EMT 30. , PS PC
30 32.
, , ,
, (
) .
EMT 104000. ,

EMT. ,
. ,
, EMT. ,
EMT
340
104340 .TTINR
RT-11. R0 C;
, C , .
, .TTYIN,

EMT
340
BCS
.-2
.TTOUTR EMT 341,
.TTYOUT
EMT
341
BCS
.-2
R0 ,
; 3.5.
30
EMT.
R0 R5, 14(SP). R0:
MOV
14(SP),R0
EMT 2(R0).
EMT :
MOV
-(R0),-(SP)
4.5.
R0:
MOVB
(SP)+,R0
EMT (,
SP 2). ,

, - .
,
, n-.
TABLE 400 , TABLE+<2*n>
(0n377) EMT n. ,
R0 ( ?) :
MOV
TABLE(R0),PC
JMP. 0001
,
. . ,
MOV
JMP
.@TABLE(R0)
, JMP, JSR, PC
, . , ,
MOV, JMP
. , JMP (R0) MOV R0,PC,
JMP @(R0) MOV (R0),PC, JMP,
MOV @(R0),PC, . , JMP R0 ,
PDP-11 ,
4 ( ,
10;
). JMP .
, JMP @(R0)+ PC
R0; JSR.
JSR PC,@(SP)+?
EMT
, ,
DEC .
TRAP, EMT
. PC 34, PS 36.
104400,
.
. ,
TRAP JSR.
,
RTI, RTS.
TRAP , JSR, , .
.
,
( .OBJ) ( .SAV).
,
. ,
. , ,
,
. , ,
. ,
TRAP, ,
JSR (, ,
). , :

.
P. ,
.
. BPT (Break Point Trap),
000003, 14. ,

.
BPT , ODT.
, X ,
X,
MOV
#3,X
, , BPT.
X,
, ODT.
.
, X, (
?) RTI.
,
. ,
BPT, ,
. ODT
14: T
PS. T , ,
PS, 1 .

BIS
#20,2(SP)
RTI
, , RTI T,
, , ,
. RTI ,
, .
, , T PS ,
14. .
P. 1. ,
, - 2(PS)?
2. , RTI, T?
3. ,
T?

3.5.
,
.
. 3.3, PDP-11
ADD. ,
, . ,
, :

ADDB
X,Y
. ,
X Y ,
Y.
, ,
. ,
.
ADDB V.
,
.
,
, :
MOVB
X,L1+1
MOVB
Y,L2+1
ADD
L1,L2
...
...
L1:
.WORD 0
L2:
.WORD 0
( -
, ,
MOVB ).
ADD L2+1 .
Y, V! ,
MOVB L2+1,Y . .
BVS, V 1,
Y SEV.
P. ADDB
, , ,
ADDB, , ,
. , ,
JSR
R5,ADDB
.WORD X,Y
,
ADDB
X,Y
1.4,
.
; .LIST ME
, .
, ADDB,
ADDB
X,Y
.

(). .MACRO,
:
.MACRO ADDB
X,Y
,
, . ,
.
, .

, ,
.MACRO, ,
. ,
X Y.
.MACRO
( ), .
, ,
. .ENDM,
. .ENDM

.ENDM ADDB
. ,
.TTINR, 3.4,
.MACRO .TTINR
EMT
340
.ENDM
, .TTINR ,
R0 ( EMT),
.MACRO .
. ADDB : X Y.
, , .

.
.MACRO , ADDB
X , Y .
, - ,
ADDB
LABEL: ADDB
@MEM,WRD+1
MEM WRD , - .
@MEM X
.MACRO.
LABEL X @MEM.
MOVB X, L1+1, :
LABEL: MOVB
@MEM,L1+1
Y, , WRD+1.
:
MOVB
WRD+1,L2+1
, .
, ,
,
. , ADDB X
Y, .
,
X Y . ,

, , ,
, .
P. ADDB .
, ADDB. ,

.LIST ME .
. .
, .
. ,
.TTYIN,
, :
.MACRO .TTYIN X
EMT
340
BCS
.-2
MOVB
R0,X
.ENDM

.TTYIN
MEM
...
...
.TTYIN
WRD
:
EMT
340
BCS
.-2
MOVB
R0,MEM
...
...
EMT
340
BCS
.-2
MOVB
R0,WRD
, .TTYIN,
.MCALL .
,
, ,
:
.MACRO .TTYIN X
L1:
EMT
340
BCS
L1
MOVB
R0,X
.ENDM
.TTYIN
L1, ,
.

, , .
, ,
.MACRO,
?.
:
.MACRO .TTYIN X
?L1
, . ,
.
,
n$, 64$. , , ,
, , $, .
. 3.7 ,

ADDB ,
. , ,
<WRDMEM>&"ZX ,
>
, &"ZX
, L1,
, ,
, , ,
. ,
,
.
,
. , ,
.
P. :
) SWAP X,Y X Y;
.
) FILCMP X,Y , X Y
.
, , Y.
) IREAD N,Y N
Y.
) PRINT X ASCII
X,
. , ,
MEM, : PRINT MEM PRINT #MEM.
) ) .
IREAD .TTYIN,
PRINT .TTYOUT. ,
.
MACTST MACRO V03.01 5-JAN-79 09:52:22 PAGE
1
2
3
.MACRO
4
5
6
7
8
9
10
L1:
11
L2:
12
L3:
13
14
L4:
15
.ENDM
16
17 000000
START:
000000 117767 000124 000027
000006 116767 000302 000023
000014 066767 000014 000014
000022 102406

1
.TITLE
.LIST
ADDB
MOVB
MOVB
ADD
BVS
MOVB
BR
.WORD
.WORD
MOVB
SEV

MACTST
ME
X,Y
?L1,?L2,?L3,?L4
X,L1+1
Y,L2+1
L1,L2
L3
L2+1,V
L4
0
0
L2+1,Y

ADDB
MOVB
MOVB
ADD
BVS

@MEM,<<WRD-MEM>&"ZX>
@MEM,64$+1
<WRD-MEM>&"ZX,65$+1
64$,65$
66$

000024
000032
000034
000036
000040
000046
000050
18 000050
000050
000056
000064
000072
000074
030102
000104
000106
000110
000116
000120

116767
000406
000000
000000
116767
000262

000007

177773

000002

000002

64$:
65$:
66$:

MOVB
BR
.WORD
.WORD
MOVB
SEV

65$+1,<WRD-MEM>&"ZX
67$
0
0
65$+1,<WRD-MEM>&"ZX

ADDB
MOVB
MOVB
ADD
BVS
MOVB
BR
.WORD
.WORD
MOVB
SEV

MEM-WRD,@MEM
MEM-WRD,68$+1
@MEM,69$+1
68$,69$
70$
69$+1,@MEM
71$
0
0
69$+1,@MEM

67$:
116767 177776 000027
117767 000046 000023
066767 000014 000014
102406
116777 000007 000026
000406
000000
000000
116777 177773 000012
000262

68$:
69$:
70$:
71$:

. 3.7. ADDB.
. 3.7 ,
. ,
,
( ?):
.MACRO ADDB
JSR
R5,XADDB
WORD
X,Y
.ENDM
, (
X), . ,
:
EMT.
. ,
, ,
.
.RADIX,
2, 4, 8, 10 ,

. ,
.RADIX 10
CMP
#1000,MEM
MEM 1000 .
.TTYIN .RADIX 10,
EMT 340 340,
.
( 340 EMT).
^ ( , CONTROL), ,
( , ).
B (binary ), O (octal ) D (decimal
).
EMT
^O340

. .TTYIN RT-11
.MACRO .TTYIN CHAR
EMT
^O340
BCS
.-2
.IF NB <CHAR>
.IF DIF <CHAR>,R0
MOVB
%0,CHAR
.ENDC
.ENDC
.ENDM
( ). ,
MOVB %0,CHAR .
, .
.IF ,
, ( ), .
,
. .
.IF,
.
.
.IF NB ,
,
(Non Blank). .TTYIN MEM (
CHAR), .IF NB (CHAR) ,
, .
, , .TTYIN. ,
CHAR, ,
, .ENDC (END Conditional),
.IF. .IF
, .ENDC,
. .IF NB
.ENDC, .IF DIF .
, .TTYIN :
EMT
^O340
BCS
.-2
, EMT R0, , ,
.TTYIN .TTYIN R0
MOVB R0,R0.
MOVB .TTYIN,
.TTYIN R0. ; , .IF NB
MOVB. .IF DIF (IF
DIFferent ), ,
, , .
(
). ,
. ,
.
, , SWAP
:
.MACRO SWAP
X,Y

SWAP MEM,MEM

- .
, ,
-,
.IF DIF <X>,<Y>
( .ENDC)
.ENDM.
X Y R0,
:
MOV
X,R0
MOV
Y,X
MOV
R0,Y
, , :
.IF DIF <X>,R0
MOV
X,R0
.ENDC
MOV
Y,X
.IF DIF <Y>,R0
MOV
R0,Y
.ENDC
, .IIF (Immediate IF);
.ENDC .
.MACRO SWAP
X,Y
.IF DIF <X>,<Y>
.IIF DIF <X>,R0
MOV
X,R0
MOV
Y,X
.IIF DIF <Y>,R0
MOV
R0,Y
.ENDC
.ENDM
.IF DIF : ,
.IF IDN (IF arguments are IDeNtical). .IF NB
.IF B (IF Blank ).
. .IF B .IF NB
, . .IF IDN .IF DIF
, . , , MEM
100, WRD 200, SWAP
MEM+100,WRD .
MEM+100 WRD ,
100.
P.
() .TTYIN %0
() REG0=%0
.TTYIN REG0
, . .IF NE (IF Not Equal to
zero )
:
.IF NE X-Y
, .
, .IF NE ,
.
SWAP .IF DIF (X), (Y)

.IF NE XY. , MEM


100, WRD 200.
SWAP
MEM+100,WRD
, .
SWAP
WRD-MEM,MEM
: 100, .
( , ?)
( MEM)
, WRDMEM
MEM, ,
.
, SWAP MEM, R0 ,
MEM R0, PDP-11 ,
.
,
: (NE); (GT); (LE);
(LT); (GE).
, ,
-
(?).
.

,
.IF .
, , STORE ,
STORE MEM, MEM ,
MEM : MOV #MEM,(SP), STORE R, R ,
: MOV R,(SP).

.
, .
.NTYPE ,
. : ,
.NTYPE ,
, .
; ,
, , . ,
.MACRO STORE
X
.NTYPE
A,X
A,
0 77 ,
,
X .
,
, .. .NTYPE , 0
7. ,
.NTYPE
A,X
.IF EQ A&70
,
. MOV X,(SP).

:
.MACRO STORE
X
.NTYPE
A,X
.IF EQ A&70
MOV
X,-(SP)
.IFF
MOV
#X,-(SP)
.ENDC
.ENDM
.IFF : , ,
, .
, .IFF ) ,
.IF EQ, , ,
.
P. 1. STORE, .IF EQ
.IF NE.
2*. STORE ,
.
3. BMOV,
, MOVB, , ,
.
4. AND
.
. ,
, .
, ,
.

. ,
. .IF DF (IF
DeFined), ,
. .IF NDF. ,
, - .
, STARTUP ,
.IF NDF Q
Q=0
STARTUP
.ENDC
Q ,
, , , .IF NDF
.
MACRO-11

Q=0 ( Q
). Q ,
STARTUP .
Q ,
. .MACS, RT-11,
, , , ,
...V1=3.


.IF NDF ...V1
.MCALL .MACS
.MACS
.ENDC
, , .
BR,
- , JMP, :
.MACRO J
X
.IF
BR
X
.IFF
JMP
X
.ENDC
.ENDM
( ?) ,
LABEL: ...
...
...
J
LABEL
: ,
LABEL., BR,
. , , :
J
LABEL
...
...
LABEL: ...
.
, , LABEL
, LABEL
. .
Q .
, -, ,
LABEL . ,
LABEL,
. JMP
BR. , ,
.
(
),
.
MOV (
ADDB), .. JMP, ,
;
P.

4. PP P
4.1. -

, .TTYIN,
.TTYOUT .PRINT. ,
EMT, ,
-.
,
, ,
-.
- .
. ,
,
, PDP-11.
B ,
. ,
, .
, .
. ASCII
,
.
, .

. 177566.
( ) , ,
. 777566 17777566.
177566 ( , ).
4.5.
,
. , :
TPB=177566
START: MOVB
#102,TPB
HALT
.END START
TPB .
,
HALT, .EXIT.
.
. PDP-11 ,
,
. ,
. , .
, . ,
, .
:
112737 MOVB
#102,@#177566

000102
177566
000000 HALT
1000.
, .
,
, .
(
, )
1000. , , ,
( PDP-11
). 1000 (),
9 (),
. ( L)
1000
( 1).
. 112737
D, .
1000 .
D .
2.
D ..
, L,
1000 (E).
.
L , ,
HALT, (S).
1000- , B,
.

.
177700 R0 177707 PC. :
, .
D E
. , ,
, .
PDP-11 . ,
, PDP-11/04
. , BOOT
( ) 11/04.
, ,
().
,
, .
11/04 $.
, L 1000
, D 112737 $ D 102,
, ..
E ( )
E. S .
, .


.
,
.
. PDP-11/04
RT-11.
DX $,
RT-11 .,
.
P. - ,
, R0, R4, SP PC .
, ,

.EXIT.
. ,
.
-
MOV
#MESSGE,R1
LOOP:
TSTB
(R1)
BEQ
DONE
MOVB
(R1)+,TPB
BR
LOOP
...
...
MESSGE: .ASCIZ /TESTING OUTPUT/
( , ,
.PRINT?) . ,
, ,
MESSGE, MOVB .
,
-:
, .
, , ,
. ,
, .
.
, ,
, .
,
TPS. ,
, TPB. ;
,
. , TPB ,
TPS . ,
. :
TPS=177564
TPB=177566
...
MOV
#MESSGE,R1

LOOP:

TSTB
(R1)
BEQ
DONE
1$:
TSTB
TPS
BPL
1$
MOVB
(R1)+,TPB
BR
LOOP
, TPS
, .
. .
P. 1.
.
2.
.
3. ,
1$ .
. ,
,
. , , :
TKS=177560
;
TKB=177562
;
ASCII .
,
, . ,
, ,
TKB TPB. , .
, ASCII TKB.
1 TKS, ,
TKB. TKS ,
TPS. . ,
, ,
.
, .
TKB, TKS
. ,
. ,
R1, :
LOOP:
TSTB
TKS
BPL
LOOP
MOVB
TKB,(R1)+
BR
LOOP
TKS ,
, :
MOV
#TKS,R2
LOOP:
TSTB
(R2)
BPL
LOOP
MOVB
2(R2),(R1)+
BR
LOOP

.
, , .

, -
LOOP. , . ,
,
LINE FEED. ,

MOVE
TKB,(R1)
CMPB
#12,(R1)+
BNE
LOOP
TKB;
. ( ,
ASCII, .)
LINE FEED 212 ,
. : #12
BICB #200,(R1). (
?)
,
, . ,
, . ,
TKS
. .
.
P. 1. ,
, 2000,
.
2. , .. ,
. ,
) ;
)
3. , .
( .)
4. # ,
.
. , ,
, ,
, .
, ,
. ,
, .
.
, 16. ,
,
. PDP-11
( ), .. .
.
, , ,
( )
.
16

bootstrap.
, . . .

,
, .

,
.
,
, ,
.
. ,
,
, ,
, .
,
.
, .
, ,
.
,
. ,
( ).
,
. , , ,
.
. PRB=177552
, TKB. PRS=177550 TKS.
,
.
,
.
, ,
.
.
PDP-11 11/03
, ,
, 077776.
. 4.1. . ,
,
.
077744
077750
077754
077756
077760
077762
077770
077774
077776

016701
000026
012702
000352
005211
105711
100376
116162
000002
077400
005267
177756
000765
177550

START:

MOV

77776,R1

S1:

MOV

#352,R2

INC
TSTB
BPL
MOVB

(R1)
(R1)
LOOP
2(R1),77400(R2)

INC

77752

BR
.WORD

S1
PRS

LOOP:

. 4.1. .
R1 PRS. LOOP
,
PRB . , INC (R1)
PRS . S1
.
. S1 ,
77752 R2. R2 352.

77400(R2)=77400+352=77752. , ,
352, .
, .
,
. , , , ,
,
.

, . 351.
, 351 77752.
,
BR S1 352, . ,
, , .
, , .
, , 351 .
, 352,
, 77752. ,
S1 77752 , ,
R2. ,
.
.
,
. ,
77600. ,
R2, MOVB 77600.
, 200.
77752 R2 ,
177.
, 351, ..., 351, 177
77752 R2 200.
, ! 77400 (R2)
,
77752 R2,
. ,
351, ..., 351, 177, , 77600,
.
,
. ,
:
. - ,
.

.
. 77744,
77746 77750 , .
, , , .
77752. ,
77752 352. 373,
S1 77752 374.
, 77600, ..
. 701.
R2 374,
77400+374=77774. , MOVB BR S1;
000701 BR 77600 ().

4.2.
, ,
, .
: RT-11
, , .
, ; ,
.
, .
,
.
: - ,
^C .. ,
.
,
.
,
. ,
, PC. ,
^C . , ^C
.
?
. ,
PDP-11. : , ,
, , ,
, , , (,
).
.
PDP-11
. PDP-11.
, .
,
, ,
( ),
. PDP-11 . 4.2.
.
, . ,
.

( )
.
, ,
, .
. ,
,
. ,
.

. 4.2. PDP-11.
, .
. ,
,
.

. .
, , ( ),
.
, ,
.
,
.
. , , ,
. , ,
. ,
, (, ,
), ..
: 60.
.
, .
.
. , PS
177776 (
).
. ,
, PC
, PS . , ,
, PC PS, .

:
MOV
PS,-(SP)
MOV
PC,-(SP)

MOV
60,PC
MOV
62,PS
, ,
. PC ,
, , . 60
, ,
.
.
, . 60
, .
,
, SP.
, .
. ,
, .
, .

. TKS.
, , .
,
. RT-11
, :
.TITLE TKOFF
TKS=177550
START: BIC
#100,TKS
1$:
BR
1$
.END START
.
,
^C
, ,
. , RT-11
.EXIT ,
, .
P. 1. - ,

.
2. TPS .
? ,
TPS? ?
TKS TPS.
, ,
.
,
. ,
.
,
:

START:

MOV
60,R0
MOV
#SERV,60
1$:
BR
1$
SERV:
MOV
R0,60
.EXIT
.
60
R0.
PC SERV,
60,
, .
,
PS - 62. ,
, ,
.EXIT. , ,
,
RTI. , PC PS ,
, . ,
TRAP, :
(SP).
P. 1. ,
, X, , X .
2. , ?
, , ,
, . ,
:
.
60 ,
SERV ,
. 4.1.
60 .

, R2:
SERV:
MOVB
TKB,(R2)+
RTI
,
TKS. , ,
.
, -
( -).
P. 1.
. -.
2. ,
, . ,
, ?
3. .TTYIN.
4.
.

5*. ,
,
, ,
.
. ,
.
2.3 ? ?
6. . 5 ,
( ),
.
. , ,
,
.
, ,
, -
.

,
, ,
TPB ( , TPB). ,
, TPB .
, !
, , ,
.
,
BIS #100,TPS, ,
.
. , ,
, ,
.
P. ,
?
64.
B . .
4.3. , PS ,
, .

START:

SERV:

.TITLE BPRINT
R1=%1
TPS=177564
TPB=177566
MOV
64,R1
MOV
#SERV,64
BIS
#100,TPS
HALT
MOVB
#102,TPB
BIC
#100,TPS
MOV
R1,64
RTI
.END START

. 4.3. .
P. 1. .
2. .
3. .TTYOUT.
,

64, .
, , , ,
, . , ,
, .
60 .
.
.
, ,
. 64
,
. .
,
,
. ,
( R0), , , ,
. ,
RTI
. .
,
- .
-
. - , , ,
,

P. 1*. ,
,
. ,
.
2. , -
.
( ).
, , 1 ..
, , ,
2, 1 ..
, , .
. . (: .)
. ,
, . ,
, .
, ,

0 7. 4,
5, 6 7. . ,
4, ,
. ( LSI-11 0 1,
1.)
, 0 7 ( 0 1
LSI-11). .
, ,
.
5, 6 7
PS ( LSI-11 7). ,
PS.
, ,
. PDP-11/45 11/55
SPL
(Set Priority Level):
SPL 7
PDP-11/45, ,
,
SPL . , ,
.
SPL,
MOVB
#340,PS
; 7
, , .
MOV, , PDP-11
PS, . ,
BIS.
LSI-11 ,
PS (Move From PS) PS (Move To PS),
PS:
MTPS
#300
;
P. 1. ,
.
2. , ( 0 7)
.
3. ,
. (: .)
4*. ,
.
, , ,
, . PS
.
. ,
. , , ,
, 4.

MOVB
#200,PS

MOVB
#200,62

. , , ,
, , .

, , ,
, . ,
62 340,
7, . , PS

.
,
. ,
, TKB,
TKB .
,
. , -
,
. , ,
, RTI .
,
, . ,
, ,
RTS RTI, .
P. 1.
?
2. -,
.

, ,
.
. , ,
, ,

.
, , . ,
. .

. ,

.
, , ,
, . , .
: 60 50
. 100
102. 177546; , ,
.

. , ,
1/60 ,
,

.
,
, .
P. 1. ?
2. (^G) .
?
? ( WAIT;
, PC
.)
3. , .
4. ,
.
T.
, .
, ,
.
, T , 1 2(SP)
RTI. , PDP-11
T RTI TRAP.
BIS
#20,PS
, D.
,
, T,
. , RTI T, ,
RTI ,
17. , SPL,
, , SPL.
, ( ODT), T,
, , RTI ,
. , RTI
, , .
, ,
PS PC. T
, ,
, RTI.
,
T . ,
.
, RTT18
RTI. , RTT
. ,
T .
, , ,
, , . ,
.
RTT ,
17

PDP-11/04,
34, 45, 55. . "PDP-11/04/34, 45/55 Processor Handbook". . .
18
.

; , ,
.
RTI.
,
,
.
.

4.3.


, .
,
. ,
, -
. -
. , -
, 4.4.
. -
RT-11. 1.4, ,
, , .
RT-11 .
3B. ,
( , ),

RT-11. .
RT-11 3 3B,
,
.MCALL, ,
SYSMAC.SML. -
.
1.4,
. PDP-11,
MACRO-11 RT-11 2 SYSMAC.SML.
, 2 ,
, , ,
EMT,
.
, , ,
- . -
. ,
, EMT,
, ;
EMT . ( ?)

2, ..V2..,
. ,
. ,
.MCALL ..V2..

...
...
START: ..V2..

. ,
..V2.. ..V1.. ( ,
, .)
P. , ..V2.. .

50- . ,

, .
, -,
, ,
.
. PDP-11
ASCII, 50- .
, , , . (), $
(. .). , , ,
50 ().
50
(). XY : X 50, Y . X
30, Y 31, XY : (3050)+31 = 1731 (
). YX (3150)+30=1750+30=2000.
50- XYZ :
(30 50 50) + (31 50) + 32 = 113000 + 1750 + 32 = 115002
, XYZ
PDP-11. , 50-
999, :
(47 50 50) + (47 50) + 47 = 171700 + 3030 + 47 = 174777
PDP-11. , 50 16- ,
.

P. ,
50- .
.RAD50 50-
.
.ASCII. ,
(, , 0).
( # ):
114750 .RAD50
/XY/
;/XY#/
001731 .RAD50
/#XY/
. ,
, ,
. ,
, , -, .
.
, .
, ,
.FETCH. ,
, .FETCH.
, .
.FETCH : ,
, , .
,
.FETCH #HNDLER,#DEVNAM
DEVNAM
, HNDLER.
: .
DEVNAM 50- .
: RP04 DK; RK06 DM; DEC DT;
CT; CR; PC.
RP04,
DEVNAM: .RAD50
/DK/
, . HNDLER
.END,
. .FETCH
. ,
R0 HNDLER .
, :
.MCALL .FETCH
...
START: ...
...
.FETCH #HNDLER,#DEVNAM
...
DEVNAM: .RAD50
/DK/
...
...
HNDLER:
.END START
, . (
? ?)

:
.FETCH
#HNDLER,#DEV1
.FETCH
R0,#DEV2
.FETCH
R0,#DEV3
.. : HNDLER
;
, .
RT-11 C
, . -
,
(, ) .
C BCS
,
,
.
P. ,
?
. ,
IOTEST.DAT. ,
:
FILNAM: .RAD50
/DK/
.RAD50
/IOTESTDAT/
,
FILNAM: .RAD50
/DK#IOTESTDAT/
( # ) ,
. ,
, . ,
IO.DAT, .RAD50 /IO####DAT/
, . , ,
, ,
.RAD50.
FILNAM , ,
.FETCH. , , .ENTER.

.
.ENTER,
FILNAM, .
.ENTER , . RT-11
0 377 ().
:
-.
.ENTER , .
, .
. .
, , 0
.ENTER
?,#0,?,?
? - . , 0
.
, ,

CLR
R1
.ENTER
?,R1,?,?
, , R0,
.ENTER R0 ;
EMT-, . ( ,
FILNAM) .
-.
. ,

IOBLK: .BLKW
10
.
.ENTER .
.ENTER EMT.
.ENTER ,
.
.MCALL .ENTER
...
START: ...
...
.ENTER
#IOBLK,#0,#FILNAM,?
...
FILNAM: .RAD50
/DK/
.RAD50
/IOTESTDAT/
...
IOBLK: .BLKW
10
, .
, .
1,
. ,
IOTEST.DAT , :
.ENTER
#IOBLK,#0,#FILNAM,#-1
BCS ,
ENTER FAILED ( ) ,
.
IOTEST.DAT ,
. , , ,
.
.CLOSE, :
.CLOSE
#0
, C ,
. .CLOSE
BCS. .CLOSE, -, R0,
.
P. 1. ,
IOTEST.DAT. ? ?
2. - IOTEST.DAT.
, .
3. .
IOTEST.DAT, .
.

.
.ENTER .CLOSE ,
- . , ,
, B ASCII.
, .ENTER,
.WRITW. ; ,
.ENTER: EMT- ,
.ENTER:
.WRITW
#IOBLK,#0,?,?,?
, ,
. -

MEM:
.WORD
102

.WRITW
#IOBLK,#0,#MEM,?,?
, .
.WRITW 1.
, .
, .
.
256 () . ( )
0. :
.WRITW
#IOBLK,#0,#MEM,#1,#0
P. 1. .
2. , B C.
. IOTEST.DAT?
, TYPE
IOTEST.DAT, ,
.
.
, IOTEST.DAT .
, . , MEM
101, R2 , :
MOV
#32,R1
LOOP:
.WRITW #IOBLK,#0,#MEM,#1,R2
BCS
WERR
INC
R2
INC
MEM
SOB
R1,LOOP
.WRITW R2.
R2 , .WRITW
, .
, Z ASCII.
,
( ),
.
.
ASCII
MEM

.WRITW
#IOBLK,#0,#MEM,#13.,#0
, ,
; 13.=^D13=15.
. ,
MEM. .IRPC19.
:
.IRPC
X,ABCDEFGHIJKLMNOPQRSTUVWXYZ
.ASCII /X/
ENDM
X , ,
.IRPC.
:
.ASCII /A/
.ASCII /B/
..
.ASCII /Z/
.
.LIST ME,
.NLIST ME. .IRPC
, .IRPC
.LIST ME. .IRPC
, R0 R5
:
.IRPC X,012345
MOV
R'X,-(SP)
.ENDM
' MACRO-11 ;
RX.
'
MOV
R0,-(SP)
MOV
R1,-(SP)
..
MOV
R5,-(SP)
.IRP. :
.IRP
X,<R0,R1,R2,R3,R4,R5>
MOV
X,-(SP)
.ENDM
.
.IRPC , .IRP
, .
-.
,
, . ,
.WRITW 256 () ,
. , .WRITW
, .
400 () . ,
19

Indefinitely RePeat with Character substitution ,


, .

. OBUF
. , , , ,
CALC R0.
:
MOV
OBUF,R1 ;R1
MOV
#400,R2
;R2-
LOOP:
JSR
PC,CALC
;
MOV
R0,(R1)+
; R0
SOB
R2,LOOP
.WRITW #IOBLK,#0,OBUF,#400,#0
, , , , .
, OBUF.
,
.
P. 1. , ,
:
) 1 2000;
) 0 2000;
) m n, m n .
2. , ,
$ (), .
3*. . 2 ,
.
4. , ,
.
, ^B; ,
^A, .. ( .)
5. ?
.WRITW .
, . ,
, , ,
2 .WRITW.
.
.LOOKUP. .
.LOOKUP .ENTER
, .LOOKUP , . ,
, ,
.LOOKUP #IOBLK,#0,#FILNAM
FILNAM , IOBLK, ,
.
, .READW
. .READW .WRITW
, .
.
, .WRITW .LOOKUP.
,
.
.

C, ,
, .
.LOOKUP R0 , ,
. ,
.
P. 1. , ,
. 1 (. ) 1 2000.
2. , 1001 1400
3001 3400, .
. .READW .WRITW
,
. 4.2,
-.
.READ .WRITE (
). , , , ,
.
: , , ,
.
,
. ,
. ,
, , - .
, ,
. ,
.WRITE , .
,
-, :

R1
MOV #BUFF1,R1.
. , R3 ,
LOOP: ;
.WRITE #IOBLK,#0,R1,#400,R3
;
INC
R3
;
MOV
-2(R1),R1
;
BR
LOOP
;
, , ,
, ,
.
.

,
. .
.
,
- , ,
.
-. ( ?) ,
.READ .WRITE , .

.WAIT.
, -
.
.READC .WRITC.
: , ,
.
.READ .WRITE,
. , - ,

, .READC
.WRITC.
P. 1. ,
.
.
2. ,
. (: , . 1.)
3.
?

4.4.


.
.
RK06.

. ,

, .
RK06 ,
( RK611) .
, ,
. ,
( ),
5 . , , ,
.
2400, 33 .
,
.

, .
. 4.4.

. 4.4. RK06.
, .
():
,
. .
,
-.
411 ()
, .
. 4.4. ,
: 107520 () .
. ,
200 1. -, ,
. , ,
,
, 200,
. , ,
1.
.
, .
. ,
D. MOV, BIS
BIC . , RK06,
177440 177476.
.
, .
, , .
,

( 0 7), . ,
1. , ,
,
- .
0 2
2 RK06; 177450,
RKCS2. , - ,
.
, 1:
RKCS1=177440. , 1 :
MOV
#RKCS1,R1
1$:
TSTB
(R1)
BPL
1$
MOV
#1,RKCS2
,
, , .
,
.
RKCS1,
. 3.
(
). , ,
.
MOV
#3,(R1) ;R1 RKCS1
2$:
TSTB
(R1)
BPL
2$
,
. : , ,
, .
RKDS=177452.
, ,
( , ). 15
,
. RKDS
,
. 0 7 ,
.
, .
, .
.
MOV
RKDS,R2
COM
R2
BIT
#100301,R2
BNE
1$
;
BIT :
BIT #100301,RKDS, BEQ 1$, ,
, .
RKCS2.

. -
1$.
, ,

. , CHKDSK PC
.
CHKDSK ,
, (
). ,
RKDC=177460:
MOV
#200.,RKDC
RKCS1 17,
:
MOV
#17,RKCS1
, 16. RKCS1
: 14 ,
. ,
, .
.
, .
. 4.4. 411
. ,
, . (,
) , RK06 .
,
( DEC, ,
), ,
, .
, .
22 .
256 .
,
20 . ,
, .
, .
- , , ,
, .
, , .
. , ,
1. 256
1 400 (). , , ,
OBUF, OBUF OBUF+776 1 400.
, .
, ; RK06
.
, 10 RKCS1:
JSR
PC,CHKDSK
;
MOV
#11,RKCS1
;
, CHKDSK
, ,
, .

.

. :
1. , .
2. , .
, , .
3. CHKDSK, . 2.
. ,
, ,
. RKDC :
MOV
#100.,RKDC
RKDA=177446.
( 1) , ( 13)
. , , RKDA .
RKBA=177444 ,
.
.
RKWC=177442 ,
.
400 , RKWC 400.
, , 22 RKCS1,
. , ,
:
JSR
PC,CHKDSK ;
MOV
#100.,RKDC
; 100
MOV
#1,R0
; 1
SWAB
R0
;
ADD
#13.,R0
; 13
MOV
R0,RKDA
MOV
#OBUF,RKBA
;
MOV
#-400,RKWC
;
MOV
#23,RKCS1
;
, .
. ,

( 1 ).
,
. RKBA ,
,
, .
-
.
1
RKWC, , 2
RKBA, ,
. RKWC ,
. ,
, RKWC RKBA
.
,
RKDA, .
RKDA 21 (), 1
, RKDA

.
RKDA ,
RKDA RKDC.
,
.
, ,
RKWC. , ,
.
RKWC ,
. , ,
, RKDA RKDC ,
.
.
20 RKCS1.
.
, .
RKBA 16 ,
. 8 9 RKCS1
16 17
. 8 9 RKCS1 0, RKBA ( 16 17 ),
.
,
( ), RKBA 177566:
8 9 RKCS1. ,

.
. RK06
RKCS1. , ,
.
.
,
MOV
#123,RKCS1
: .
RK06 , 210.
210
, 212 ,
. , ,
. ,
, 212 .
,
: , .
. ,
.
, ,
, ,
. , ,
. 14 RKCS1,

.
,
, 4 RKCS1.
.

.
, ,
. ,
, ,
( RKDS).
, DSKRDY ,
, , , 1, .
CHKDSK :
CHKDSK: TST
DSKRDY
BPL
CHKDSK
, ,
. ,
CHKDSK, .
, , DSKRDY (CLR DSKRDY), ,
.
CHKDSK,
DSKRDY, ,
, .
SERV:
BIT
#40000,RKCS1
; ?
BEQ
1$ ; :
DEC
DSKRDY
;
BIC
#100100,RKCS1
;
1$:
RTI
( , DSKRDY
1?) ,
. , ,
BIC #100,RKCS1 .
(
15 RKCS1), RK06 (
, );
. ,
, .
P. 1. - ,
, CHKDSK .
2. , ; ,
( 6 RKCS1);
.
3. .
( , ,
, ).
.
.
, .
,

. 15 RKCS1,
, , .
, .
, ,
, :
SERV:
TST
RKCS1
BMI
IOERR
;
. ,

410- , .
, RKER=177454.
,
,
. . ,
15 RKCS1,
. , ,
, ,
, . RESET
-.
P. 1.

.
2*.
.

4.5.
PDP-11
0 177777 .. 216=65536 .
,
210=1024( = O 2000). , PDP-11
64 32 .
PDP-11
,
. ,
PDP-11 32 , ,
. 4 , , , PDP-11
28 .
.
PDP-11
, . ,
2 18=256 128 . 4 ,
- , 124
. , , (
), ,
.
, ,
, , , , - ,
.

, : 32
. 28 .
56=O 160000 ( ), 0
157776. :
. , CLR @#100000
100000.
. ,
.
-, ,
4 , .. 760000
777776. , 777566.
PDP-11, -
MOVB @#102,777566 . ,
MOVB #102,@#177566 , .
, 160000
177776, , 17-
18- .
,
. ,
, ,
. , MOVB #102,177566,
, ,
, MOVB #102,@#177566.
177566. ,
, ( )
( ). ,
.
, 0 157776 :
. 160000 177776
:
.
PDP-11 28
.
. ,
, .
PDP-11 ,
, .
.
11/34,
. .
. PDP-11/34
,
, . 32 ,
4 .

. :

0
000000-017776

1
2
3
4
5
6
7

020000-037776
040000-057776
060000-077776
100000-117776
120000-137776
140000-157776
160000-177776
:
. : KPAR0
KPAR7 KPDR0 KPDR7; .
() :

KPAR
KPDR

0
772340
772300
1
772342
772302
2
772344
772304
3
772346
772306
4
772350
772310
5
772352
772312
6
772354
772314
7
772356
772316
11/34 ,
.
, . , ,
, ,
() .
PDP-11/34 ,
, .
, .
.
HALT .
,
0; SR0,
777572.
, , ,
SR0
177572. :
SR0=177572
...
BIS
#1,@#SR0
:
SR0=177572
KPAR7=172356
...
CLR
KPAR7
BIS
#1,@#SR0
BIC
#1,@#SR0
, KPAR7,
.

, , ,
.
KPAR7, ,
, -.
,
.
, ,
.
SR0 177572
777572. , BIS .
BIC .
777572 .
177572.
177572 777572.
, , 177572 ,
KPAR7, , .
KPAR7 . BIC
,
.
.
KPAR7, .
-
.
.
.
, ,
. 13- 15-
. . 177566.
13- 15- 1, 7, ..
. KPAR7
7. 0- 11-
( 11/34 ).
6 .
13 ( 0- 12-)
. ,
, .
, .
.
KPAR7 7600.
() 177566. :

17566. ,
( ) 0 17777, 8 (=O 2000)
4 . KPAR7 (.. 7600) 6 ,
, 760000. ,
, ,

+

760000
+ 17566

777566

.
:

, ( 0- 5-)
. KPAR
100. 100 , ,
,
.
. 200
. ,
.
. 000100 017776
, .
020000 020076 .
,
,
. (
).
BIS
#77400,@#KPDR7
, 200
. 200 .
KPDR
, .
1,
; , - .
1, 0, ,
; , . ,
, , :
.
,
MOV
#7600,@#KPAR7
BIC
#6,@#KPDR7
BIS
#1,@#SR0
- (
). , KPAR7
, BIC
.
, .

.
, #6 #77400 BIC .
, 760076
.
, -
. .
, ,
.
B,
34566.
1 14566. , 34566
777566, KPAR1 ,
:

-

777566
- 14566
763000

, KPAR7 7630. ,
, ,
KPAR1=172342
KPDR1=172302
SR0=177572
TPB=34566
;!
START: MOV
#7630,@#KPAR1
MOV
#77406,@#KPDR1
BIS
#1,@#SR0
MOVB
#102,@#TPB
HALT
.END START
P. 1.
KPDR7?
2. , 17000 20000
.
17000.
. ,
,
,

.
- , :
. (
) 250. ,

.
MOV
#SERV,@#250
SERV
. ,
250 . ,
250 ,
, .

P. 1. ,
KPAR0?
2. ,
MOV
#SERV,@#55550
. ,
KPAR2 ( KPAR0) ?
,
, ,
. , ,

MOV
#60000,@#250
TST
@#60000
. 60000,
.
60000
.
.
250.
60000 ,
. , ,
; ..
.
P. , 250 60000,
,
TST @#250?
.
,
. 11/34 :
().
,
.
, ,
.
, HALT
.
4 10. ( , ;
, .
, RSX-11
4, 11/34
.)
14- 15- PS.
777776. 0,
. , . 11/34
, ,
PDP-11 .
11/45 , ,
, PS.
11/34

, ,
. PS
,
: ,
.
, ,
. ,
, . :

UPAR
UPDR

0
777640
777600
1
777642
777602
2
777644
777604
3
777646
777606
4
777650
777610
5
777652
777612

777654
777614
7
777656
777616
,
, , .

. .
, ( ),
-.

-. ,
,
, .
B. TRAP . ,
,
:
MOV
#TRP,@#34
MOV
#340,@#36
TRP
7,
. ,

. , -

.
.
TRP
TRP:
MOVB
#102,@#TPB
RTI
, TPB - . ,
KPAR7 , , TPB=177566.
TRP .
,
.
. JMP TRP,

. , , TRP, , .
P. ,
,
.
:
BIS
#140000,@#PS
, PS 777776 .
-
250 .
, ,
250 252, 252 . ( ?)
TRAP.
PS PC PC 34, PS 36,
. 14- 15-
36 , PS .
, MOVB TRP, B .
RTI PC PS,
.
P. .
,

777566, ,
.

.
. 3.4 ,
EMT EMT.
, EMT ,
. EMT R0 R5 ,
14(SP). R0:
MOV
14(SP),R0
EMT 2(R0),
. EMT, ,
. , 2000
.
MOV
-(R0),-(SP)
2000
. ,
.

MFPI (Move From Previous Instruction space).
.
,
( ).

. EMT :
MFPI
-(R0)


MTPI (Move T Previous Instruction space).
,
. , ,
,
12 13:
14 15 PS. MFPI MTPI 12- 13- PS,
, .
P. 1. TRAP 'X,
, .
2*. , MFPI
MTPI.
. .
,
.
: ,
.
, SP=%6,
SP (Stack Pointer)
, ,
, .
,
.
, 14- 15-
, ,
PC PS .
RTI. ,
, RTI
. , MFPI MTPI
,
.

. , ,
. -,
, :
MFPI
SP
, , MFPI MTPI
( 0),
.
,
@(SP), .. ,
. ,
MFPI
@(SP)+
, .
, , MFPI MTPI SP
, ,

.
P. 1*. ,
,
.
2*. MFPI MTPI ,
.

A. ODT
ODT on line (On line Debugging Technique),
DEC PDP-11. ,
, .
ODT ,
.

ODT
, ODT
ODT.OBJ. . ,
TEST.MAC ODT. ,
TEST.OBJ ODT:
TEST,TEST=ODT,TEST
.
: TEST.SAV TEST.MAP. ,
TEST ODT. ,
,
.
,
ODT , .
:
RUN TEST
,
, TEST. ,
*, ,
.
,
. ODT
^C ,
.


ODT

. ,
, . , MEM,
, . .MAP
; ,
,
.
, , .MAP
. (..
)
.GLOBL START
...
START: ...

. ,
MAIN.MAC SUB.MAC ,
, SUB.MAC SUBRTN.
, .GLOBL
SUBRTN.

.END.
, .
.END.
,
,
ODT.


ODT,
. , ( ODT).
ODT
.MAP. .
,
*.
, , MEM 162. ,
, . .MAP ,
6316, ODT MEM
6500 (=6316+162).
,
,
. ODT
, 0 7.
.
(6316) ,
6316; R ( ), 6316 0.
*.
0, ,
. ,
, .
,
, . 72
CLR R1. 0,72/( ), ODT
: 005001. / ODT , ,
, . , , ,
:
72 .
, . ,
, , : CLR @R1.
005001 , .. 005011,
. ,
, . ,
. , ODT ,
-.
.. , ,

: , ODT.
.
, RUBOUT
. ,
*.
.
. /
, ,
. .
( )
: (LINE FEED), ^, , @, >
<. .

LINE FEED,
, ,
. , , CLR R1, 72,
MOV R3,MEM. 72
0,000074/010007. ,
74 . 74 ,
, .
^ ,
: ,
.
MEM 162, 74
0,000076/000062. ,
MEM .
, .
, , : (72+2)+62=162.

: ,
.
. ,
76 0,000162/000000 ,
MEM . ,
.
, , ,
- ,
PC. ,
ODT, .
, ,
.
MOV R3,@#MEM,
76 MEM: 0,000076/006500.
MEM, @.
0,000162/000000,
, .
, MEM, , ,
.WORD .
@ ,
.
JSR JMP

.
,
.
>. , , 200
BNE MEM. MEM 162,
0,000200/001370,
, . >
, ODT 0,000162/000000. ,
, .
, .
> , ,
, .
,
. , 200
BNE LABEL, LABEL 316. 200
0,200/, ODT 001370. ;O
316.
0,316;O. 000114 046,
.
, ,
.
, 001046,
. , 46
( 1046 ).
, @ > .
,
, . <
.
220 JSR PC,PRINT.
PRINT 222, ,
, .
. ,
<. 224, ..
PRINT , .
< ,
.
, / $
. , $3/ R3.
,
. ^
. @, >
<. ,
. , ,
, @ > .
$S (
) . ,
$3/. $S .
ODT ASCII
50- . \ ,
, , ASCII. ,
MEM

MEM:
.WORD
"AB
0,162/ 041101, , 0,162\,
101=A. , ^
. ,
:
0,000163
\102 =B
/ ODT .
\.
50- , , /,
.
X ( ), 50 . ,
ODT
() ( 50- ) .


;G ,
. , 0,0;G, ,
, .
, ,
, ,
.
;G
, . ,
.
330,
* 0,330;G.
ODT,
.
,
. .
, , .
,
: ;B. *.
0 7. ,
, .
, 0,620;6B 6 620 ,
- . ,
, * ;
6B, . ,
. ,
;B.
, - , $B/,
. , ,
.
;G
;P (
) *.
. ODT
, , BPT

(BreakPoint Trap) , . ,
,
. , , JSR PC,@TABLE,
TABLE . JSR PC,TABLE,
.
,
0,0;B.
0,0;G. ,
, , ,
.
,
,
, : B0;0,000000, ,
; .
.
;1S. B ,
, -
;S, .
, ;P
. ,
ODT B8;0,000004,
.
, ,
, , .
, ,
.

, ;P ..
;P ;S,
0,0;G .
, .
;P EMT TRAP, ,
,
. , , . 4,
.
.
n;P, n , n
, .

;P (
;S).
, .
.
(
,
).
,
, . ,
, .
.
;B , .

ODT ,
. ,
. , 1,

, .
, r ,
r. , r;P, r
, r,
;P. , 1;P ;P
. ,
. , ODT
$ , .
,
. , .
.
, $.

. P

,
PDP-11. MACRO-11
, . ,
,
. ,
,
.
,
.

MUL DIV
.
MUL MEM,R R, .
, R
. :
MOV
#1100,R2
MUL
#1000,R2
, , 1 15
18 . R3, R2.
, MUL
100000, 4:
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
31
R2
16 15
R3
0

MUL ,
, 15-
. , ,
.
DIV ,
:
MOV
#1,R0
MOV
#100007,R1
DIV
#400,R0
300007 R0 R1.
DIV (600) R0, (7) R1.
MOV #1000,R0,
. , 200100007 400 400200.
V.
P. ,
; .


,
, PDP-11.

. ( ),
.
, , 35
.
,
.
log1020.3, 2117 , 1035. ,
117 .
128 , , .

, .
, , MEM
MEM+16 ( !). 1,
MEM MEM+14, , MEM+16
1, . 400000,
, .. MEM+14.
128- .
, 1 1 .
,
.
, , ,

,
: .
PDP-11,
,
.
.

, ,
. , .
.
MPBLK: .BLKW
120
MPVAR: .WORD
MPBLK
, ,

MPBLK. MP,
VAR :
MP
VAR

.MACRO MP
X
ADD
#20,MPVAR
MOV
MPVAR,X
BR
.+2
X:
.WORD 0
.ENDM
( ?)
, VAR ,
8 .
.

,
, . , ,
MPCLR
VAR
VAR,
.MACRO MPCLR X
?L1
MOV
X,R1
MOV
#10,R0
L1:
CLR
-(R1)
SOB
R0,L1
.ENDM
P. , MPMOV VARA,VARB
MPINC.
, ( ),
1, 1 . INC
, , ,
. 15- ,
( );
.
ADD, C
. MPINC
. , C 1, .
ADC: C
.
, C .
ADC ADD,
.. .
,
.MACRO MPINC
X
?L1
MOV
X,R1
MOV
#10,R0
SEC
L1:
ADC
-(R1)
SOB
R0,L1
.ENDM
P. 1. SBC C ,
, SUB. MPDEC.
2. MPASL MPASR,
2. (. C
.)
3. , ,
.
4*.
.
, MPINC. 1
( C), ;
1 ..
1 :
,

.
.
, .. ,
216=65 536!

. ,
. ,
ADD,
ADC. MPINC, ,
..
. . .1. ,
ADC
.MACRO

L1:
L2:

MPADD
MOV
MOV
MOV
CLC
MOV
MOV
ADC
SOB
BVS
MOV
MOV
ADD
SOB
BVS

X,Y
X,R1
Y,R2
#10,R0

?L1,?L2

R2,-(SP)
R0,-(SP)
-(R2)
R0,L2
ERROR
(SP)+,R0
(SP)+,R2
-(R1),-(R2)
R0,L1
ERROR

.ENDM

. .1. .
V, . ,
, (..
, ).
P. 1. MPSUB.
2. MPTST MPCMP ,
. MPADD MPSUB,
?

. ,
, 0 ,
. SXT20 (Sign eXTend) , N , ,
1. N C. , MEM
X ,
MOV
X,R1
MOV
#7,R0
MOV
MEM,-(R1)
L1:
SXT
-(R1)
SOB
R0,L1
20

,
, MPMUL MPDIV.
.
,
. ,
. , , ,

. .


.
. ,
, , . ,
,
, , , .
, D 12.34 1()+2()+3( )+4(
).
,
.
, O 12.34 1()+2()+3( )+4(
)=8+2+3/8+4/64.
.
. , B 0.
(10)=B 0.101010...=D 1/2+1/8+1/32+...=D 2/3 ( )21.
P. 1/10. ,
.
, , ,
, . D 123456
D 234567 , D
12345600 D 0.0234567.
.
. .
,
.
MACRO-11 ,
,
, .
PDP-11 .
, , ,
.
, .
, . , ,

21

: O octal (), D decimal () B binary


(). . .

. ,
123.45 0.12345 X 103 0.012345 X
104 .. . ,
,
. PDP-11
.
1.
( ). , 6-
0.1.

, .
E, (,
). .FLT2 (
) .FLT4 ( ). ,
MEM:
.FLT2
-2.1E-3
D
0.0021, , MEM.
, , . 7- 14-
.
, O 200. , ,
D 1/10. ,
D 1/10 = 3/32(1+1/16+1/64+...) =
= B 0.0001100110011...
= 2-3B 0.110011001100...
, O 2003=175=B 01111101 ,
, :

.. 037314.
146314.
.
, D 2 -127,
, , ,
128.
,
, . ,
, D 27+3 , ,
. ,
: D 27=O 33=2 5O 0.66; D 3=22O 0.6.
,
. 3 : D 3=2 5O 0.06. (,
.) :

25O 0.66 + 25O 0.06 = 25O 0.74


,
. ^ F
( , F), :
MOV
^F27,MEM
, ,
D 3
. , , .
.
, , . D 27+6,
, .
O 205. ,
, 0.11011000. , 7-
: O 130. D 6 O 203,
O 100.
O 60 ( ).
O 210,
.

, .
, .
, .

.
,
. , ADDF
, ADDD
.
,
.
,
. ,
: , . ,
,
F0=%0
.. AC0 . .
, . , :
MEM:
.FLT2
27
.FLT2
6
; MEM+4
, ,

LDF
MEM,F0
:
ADDF
MEM+4,F0
, :
STF
F0,WRD

, .

.

ASCII

NULL
CONTROL-A
CONTROL-B
CONTROL-C
CONTROL-D
CONTROL-E
CONTROL-F
BELL
BACKSPACE
TAB
LINE FEED
VERT TAB
FORM FEED
CARR RETN
CONTROL-N
CONTROL-O
CONTROL-P
CONTROL-Q
CONTROL-R
CONTROL-S
CONTROL-T
CONTROL-U
CONTROL-V
CONTROL-W
CONTROL-X
CONTROL-Y
CONTROL-Z
ESCAPE
CONTROL-\
CONTROL-]
CONTROL-^
CONTROL-_
SPACE
!
"
#
$
%
&
'
(
)

0
1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
20
21
22
23
24
25
26
27
30
31
32
33
34
35
36
37
40
41
42
43
44
45
46
47
50
51

*
+
,
.
/
0
1
2
3
4
5
6
7
8
9
:
;
<
=
>
?
@
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T

52
53
54
55
56
57
60
61
62
63
64
65
66
67
70
71
72
73
74
75
76
77
100
101
102
103
104
105
106
107
110
111
112
113
114
115
116
117
123
121
122
123
124

U
V
W
X
Y
Z
[
\
]
^
_
`
a
b

d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
{
|
}
~
RUBOUT

125
126
127
130
131
132
133
134
135
136
137
140
141
142
143
144
145
146
147
150
151
152
153
154
155
156
157
160
161
162
163
164
165
166
167
170
171
172
173
174
175
176
177

PDP-11
DD = 6- , SS = 6- , R = 3-
, X = 0 , , X=1

CLR (B)
DEC (B)
INC (B)
NEG(B)
TST (B)

X050DD
X053DD
X052DD
X054DD


1
1

X057DD

COM (B) X051DD


ASR (B) X062DD ;

ASL (B)

X063DD ;
0

ADC (B) X055DD C


SBC (B) X056DD C
SXT
0067DD N
ROR (B) X060DD 1
C
ROL (B)

X061DD 1
C

SWAB

0003DD


N, V, C = 0; Z=1
N, Z, V = 0/1
N, Z, V = 0/1
N, Z, V = 0/1
C = 0, 0, C = 1
N, Z = 1/0
V, C = 0
N, Z = 1/0 , V = 0, C = 1
N, Z = 1/0
C
V N C
N, Z = 1/0
C
V N C
1/0 ( )
1/0 ( )
Z=1, N = 0, V = 0
N, Z = 1/0
C
V N C
N, Z = 1/0
C
V N C
N, Z = 1/0
, V, C = 0

: PC PC + (2 ). : + .
.

000400
001400
100400
103400
102400
002400
003400
101400

MOV (B)
ADD
SUB
CMP (B)
BIS (B)
BIT(B)
BIC (B)
MUL

X1SSDD
06SSDD
16SSDD
X2SSDD
X5SSDD
X3SSDD
X4SSDD
070RSS

BR
BEQ
BMI
BCS
BVS
BLT
BLE
BLOS

DIV

071RSS

XOR

074RDD

JSR
004RDD
RTS
00020R

Z=1
N=1
C=1
V=1
NV=1
Z(NV)=1
CZ=1

BNE
BPL
BCC
BVC
BGE
BGT
BHI

001000
100000
103000
102000
002000
003000
101000

Z=0
N=0
C=0
V=0
NV=0
Z (NV)=0
C=0 Z=0




( )
( )
( )
(~ )
, R . pe.,
R
, R . pe., R

, PC , PC
PC,


N, Z=1/0 , V = 0
1/0 ( )
1/0 ( )
1/0 ( )
N, Z = 1/0 , V = 0
N, Z = 1/0 , V = 0
N, Z=1/0 , V = 0
1/0 ( )
1/0 ( )
N, Z = 1/0 , V = 0

P PP

SPL
JMP
SOB

L
PC
XX=; 1
; 0,
EMT
104000 PS, PC , PC, PS 30, 32
104377
TRAP 104400 PS, PC , PC, PS 34, 36
104777
BPT
000003
PS, PC , PC, PS 14, 16
RTI
000002
PC, PS
RTT
000006
PC, PS , . .
MFPI 0065SS


MTPI 0066DD


HALT 000000

WAIT 000001

RESET 000005

PP

CLC
CLV
CLZ
CLN
CCC

00023L
0001DD
077RXX

000241
000242
000244
000250
000257

C
V
Z
N

SEC
SEV
SEZ
SEN
SCC

000261
000262
000264
000270
000277

32
36
16


N, Z = 1/0 ,
V=0
N, Z=1/0 , V = 0

C
V
Z
N

p p MACRO-11
,
ADC(B) 252
INC 36
ADD 37
.IRP, .IRPC 207, 208
.ASCII, .ASCIZ 107, 109
.ASECT, .CSECT 125, 126
JMP 155
ASL(B), ASB(B) 139
JSR 98
BCC, BCS 135
BGE 133
BHIS 135
BIC(B), BIS(B), BIT(B) 127129
BLE 134
.BLKB, .BLKW 73, 125
BLO 135
BLT 133
BPL 59, 132
BPT 157
BR 61
BVC, BVS 132
CCC, CLC, CLN, 136
CLR(B) 54, 136
CLV, CLZ 136
CMP (B) 63, 120, 137
COM (B) 129
DEC (B) 60
DZV 53, 249
EMT 154
.ENABL, .DSABL 153 154
.END 41
.ENDC 166
.ENDM 160
.EVEN 110

.LIST, .NLIST 45, 207


.MACRO 160
.MCALL 42
MFPI, MTPI 235
MOV(B) 33, 108, 137
MUL 54, 248
NEG (B) 62
.NTYPE 170
.RADIX 165
.RAD50 200
RESET 222
ROL(B), ROR (B) 140
RTI 152
RTS 103
RTT 197
SBC (B) 252
SCC, SEC, SEN, SEV, SEZ 136
SOB 142
SPL, MTPS 193, 194
SUB 37
SWAB 138
SXT 253
.TITLE 45
TRAP 156
TST(B) 64

.GLOBL 239
HALT 70

WAIT 196
.WORD, .BYTE 70, 109

.IF, .IFF, .IIF 166, 168, 170

XOR 129


....................................................................................................3
.........................................................................................................................4
1. ..................................................................................................................................7
1.1. ......................................................................................................7
1.2. ...............................................................................................................................10
1.3. ................................................................................17
1.4. ......................................................................................................24
2. ....................................................................................................................................30
2.1. ...............................................................................................................................30
2.2. ...............................................................................................................36
2.3. ..................................................................................................................................43
2.4. .......................................................................................................................51
3. PP PP....................................................................................................61
3.1. .....................................................................................................................61
3.2. ....................................................................................................................................71
3.3. ...............................................................................81
3.4. ...........................................................................................92
3.5. ................................................................................102
4. PP P....................................................................................113
4.1. - .................................................................113
4.2. ........................................................................................................................120
4.3. .................................129
4.4. ...........................138
4.5. .........................................................................................................145
A. ODT.....................................................................................................................156
ODT...............................................................................................................................156
....................................................................................................................156
.........................................................................................157
..........................................................................................................160
. P..................................................................................................163
MUL DIV................................................................................................................163
..............................................................................163
.................................................................................167
ASCII...................................................................................................................................170
PDP-11...............................................................................................................170
p p MACRO-11.....................................................................173


- PDP-11: PPP
P P

..
. .
..
..
..
..
3909
24.02.84. 20.07.84. 60901/16 2.
. . 8,50 . . . . . 17. . .-. 17,52. .-. . 15,28. . 1/3226.
50 000 . 328. 1 . 10 .

P 129820, , -110, , 1- ., 2
2
.
P , . 198052, . , -52,
, 29
. . P ,
. 113054, , , 28
OCR - Arseny Gordin