initial contents

This commit is contained in:
David Meyer 2022-03-10 20:40:38 +09:00
commit b04641067f
18 changed files with 562 additions and 0 deletions

42
address.txt Normal file
View File

@ -0,0 +1,42 @@
Memory Address Determination
The effective memory address referenced by a PDP-10 instruction is
determined by the instructions address (Y), index (X), and indirect (I)
fields.
Direct Addressing "Y"
When Y is specified without X or I, the instruction's effective address
is simply Y. The instruction uses the contents of memory location Y.
Indexed Addressing "Y(X)"
When Y and X are specified but I is zero, the effective address is
determined by using Y as a base then moving forward a number of memory
locations corresponding to the current value of accumulator X.
Indirect Addressing "@Y"
When I is set, the effective address is determined by taking the
contents of memory location Y and interpreting it as another memory
location the contents of which will be used by the instruction.
Indirect and indexed addressing can be combined: "@Y(X)"
The Three I's
Unfortunately, three related concepts in MACRO assembly language have
been given similar names: Index, Indirect, and Immediate.
Indexed and indirect addressing are explained above.
Immediate is an optional modifier to some instructions. When the
immediate modifier is specified, the instruction's effective address
is determined as normal, then the value of the effective address
itself is used as the numeric argument to the instruction, instead of
the contents of the effective address as would be used in a
non-immediate MOVE.

21
ex1.mac Normal file
View File

@ -0,0 +1,21 @@
TITLE G018 - Program to type "Hi". Example 1
Comment $ Example 1. Program to type "Hi"
The following program types "Hi" and carriage return line feed (CRLF)
on the terminal.
Gorin, p. 18
$
SEARCH MONSYM ;Add TOPS-20 symbols to MACRO
START: RESET ;RESET the state of I/O devices
HRROI 1,MESAGE ;Copy address of message to register 1
PSOUT ;Output the message
HALTF ;Stop execution here.
MESAGE: ASCIZ /Hi
/
END START ;End of program, start at START

24
ex2a.mac Normal file
View File

@ -0,0 +1,24 @@
TITLE G062 - TRIANGLE Example 2-A
SEARCH MONSYM
Comment $ Program to print a Triangle $
START: RESET
MOVEI 10,5 ;let register 10 be the line number.
;set it to 5.
;print each line
LINE: MOVE 11,10 ;copy the line number to register 11
;print the stars on each line
STARS: HRROI 1,ASTER ;Print one asterisk
PSOUT
SOJG 11,STARS ;decrement star count, loop if more
HRROI 1,NEWLIN ;print carriage return and line feed
PSOUT ; to prepare for the next line.
SOJG 10,LINE ;decrement the line numbe held in 10.
; If the result is positive, do another line
HALTF ;stop here
ASTER: ASCIZ /*/
NEWLIN: ASCIZ /
/
END START

31
ex2b.mac Normal file
View File

@ -0,0 +1,31 @@
TITLE TRI AGAIN - Example 2-B
SEARCH MONSYM
Comment $ A different triangle (Gorin p. 64) $
START: RESET ;begin execution here
MOVEI 12,0 ;initial line count
;here to print each line
LINE: MOVEI 13,0 ;initial character count
;print one character on a line
CHAR: CAML 13,12 ;skip if printing spaces
JRST PSTAR ;go print a star
HRROI 1,BLANK ;print a blank
PSOUT
JRST ELIN ;test for end of line
PSTAR: HRROI 1,ASTER ;print a star
PSOUT
ELIN: CAIGE 13,6 ;have we reached the end of line?
AOJA 13,CHAR ;print the next character
HRROI 1,NEWLIN ;print the carriage return & line feed
PSOUT
CAIGE 12,6 ;finished all lines yet?
AOJA 12,LINE ;no. do more.
HALTF ;all done
BLANK: ASCIZ / /
ASTER: ASCIZ /*/
NEWLIN: ASCIZ /
/
END START

33
ex3.mac Normal file
View File

@ -0,0 +1,33 @@
TITLE ECHO INPUT LINE -- Example 3
SEARCH MONSYM
BUFLEN==40 ;the length of the input buffer.
PROMPT: ASCIZ /Welcome to Echo. Please type a line: /
IBUFR: BLOCK BUFLEN ;reserve space for the input line
START: RESET ;start here. initialize I/O
GETLIN: HRROI 1,PROMPT ;source of the prompt message
PSOUT ;send prompt to the terminal
HRROI 1,IBUFR ;descriptor of the input buffer
MOVEI 2,5*BUFLEN-1 ;character count of the buffer
HRROI 3,PROMPT ;the reprompt pointer for RDTTY
RDTTY ;read one line from the terminal
ERJMP INERR ;in case of error, print a message
MOVE 15,IBUFR ;first five letters of input line
CAMN 15,[ASCII/LEAVE/] ;test to see if user typed LEAVE
JRST STOP ;LEAVE was typed. Halt the program.
HRROI 1,[ASCIZ /The line you typed was: /]
PSOUT
HRROI 1,IBUFR ;point to the input line for PSOUT
PSOUT ;echo (retype) the input line.
JRST GETLIN ;Go get another line.
INERR: HRROI 1,[ASCIZ/Error from RDTTY. I give up
/]
PSOUT ;send an error message and stop.
STOP: HALTF ;stop the program here
JRST STOP ;In case of a CONTINUE command,
; stay stopped.
END START ;specify the start address.

48
ex4a.mac Normal file
View File

@ -0,0 +1,48 @@
TITLE REVERSE - Example 4-A
SEARCH MONSYM
Comment $
Program to reverse the characters on each line of input.
Program will stop when an empty line is input.
This program demonstrates the last-in, first-out property
of push-down stacks. Also, it shows the PBIN and PBOUT
JSYS calls.
$
A=1 ;symbolic name for ac 1
P=17 ;symbolic for stack pointer
PDLEN==200 ;define the stack size
PDLIST: BLOCK PDLEN ;reserve space for the stack.
START: RESET
MOVE P,[IOWD PDLEN,PDLIST] ;initialize stack pointer
GETLIN: HRROI A,[ASCIZ/Please type a line: /]
PSOUT
INLOOP: PBIN ;read one character
CAIN A,15 ;skip unless carriage return
JRST INLOOP ;discard carriage return
CAIN A,12 ;skip unless end of line
JRST INDONE ;LF was seen. We are done now.
PUSH P,A ;store character on the stack
JRST INLOOP
;Here at the end of the input line
INDONE: CAMN P,[IOWD PDLEN,PDLIST] ;is the stack empty?
JRST STOP ;empty line, stop running.
HRROI A,[ASCIZ/The reversed line: /]
PSOUT
OUTLOO: POP P,A ;get one character from stack
PBOUT ;send it to the terminal
CAME P,[IOWD PDLEN,PDLIST] ;is the stack empty now?
JRST OUTLOO ;not yet. Loop again.
HRROI A,[ASCIZ/
/]
PSOUT ;send CR and LF.
JRST GETLIN ;repeat
STOP: HALTF ;stop at blank line
JRST STOP ;stay stopped
END START

2
gorin.bib Normal file
View File

@ -0,0 +1,2 @@
Ralph E. Gorin, INTRODUCTION TO DECSYSTEM-20 ASSEMBLY LANGUAGE PROGRAMMING,
Bedford, MA, USA: Digital Press, 1981.

16
hello-mac.txt Normal file
View File

@ -0,0 +1,16 @@
HELLO.MAC - Hello program in MACRO assembly language
PUBLIC:<CONTRIB>HELLO.MAC
PUBLIC:<CONTRIB>HELLO-MAC.TXT
Contributed by David Meyer <papa@twenex.org>/<papa@sdf.org>
March 9, 2022
A minimal example of MACRO source code demonstating character string
output.
To compile, load, and run:
@EXEC PS:<CONTRIB>HELLO.MAC
Make a copy and try your hand at MACRO!

16
hello.mac Normal file
View File

@ -0,0 +1,16 @@
TITLE HELLO - Hello program in MACRO assembly language
Comment $
Contributed by David Meyer <papa@twenex.org>/<papa@sdf.org>
March 9, 2022
$
SEARCH MONSYM ;Add TOPS-20 symbols to MACRO
START: RESET ;RESET the state of I/O devices
HRROI 1,[ASCIZ "Hello, world, from MACRO!
"] ;Compile string (including CRLF) and put
; address in AC1
PSOUT ;Output the string
HALTF ;Stop execution here.
END START ;End of program, start at START

17
hw1.mac Normal file
View File

@ -0,0 +1,17 @@
TITLE G024 - Self-Identification
COMMENT / Gorin p. 24 Section 3.3 Exercise (HW1.MAC) /
SEARCH MONSYM
START: RESET
HRROI 1,MESAGE
PSOUT
HALTF
MESAGE: ASCIZ /
My name is David Meyer.
I work at Sumitomo Chemical.
I am studying TOPS-20 assembly language to entertain myself.
/
END START

33
hw2-0.mac Normal file
View File

@ -0,0 +1,33 @@
TITLE HW2 - Print diamond on screen (Homework 2)
SEARCH MONSYM
Comment $ (Gorin p. 65) $
START: RESET
MOVEI 10,7 ;lines in top triangle
MOVEI 12,6 ;first star on line
MOVEI 13,10 ;last star on line
TOP: MOVEI 11,15 ;char. position countdown
AOS 12
SOS 13
TOPCHR: HRROI 1,ASTER
PSOUT
SOJG 11,TOPCHR
HRROI 1,NEWLIN
PSOUT
SOJG 10,TOP
MOVEI 10,6 ;lines in bottom triangle
BOTTOM: MOVEI 11,15
BOTCHR: HRROI 1,ASTER
PSOUT
SOJG 11,BOTCHR
HRROI 1,NEWLIN
PSOUT
SOJG 10,BOTTOM
HALTF
ASTER: ASCIZ /*/
SPACE: ASCIZ / /
NEWLIN: ASCIZ /
/
END START

56
hw2-1.mac Normal file
View File

@ -0,0 +1,56 @@
TITLE HW2 DIAMOND - Homework 2
SEARCH MONSYM
Comment $ (Gorin p. 65) $
START: RESET ;begin execution here
;UPPER TRIANGLE ...
MOVEI 12,6 ;initial line countdown
MOVEI 14,5 ;initial line length
; here to print each line
ULINE: MOVEI 13,0 ;initial character count
AOS 14 ;increment line length
; print one character on a line
UCHAR: CAML 13,12 ;skip if printing spaces
JRST UPSTAR ;go print a star
HRROI 1,BLANK ;print a blank
PSOUT
JRST UELIN ;test for end of line
UPSTAR: HRROI 1,ASTER ;print a star
PSOUT
UELIN: CAMGE 13,14 ;have we reached the end of line?
AOJA 13,UCHAR ;print the next character
HRROI 1,NEWLIN ;print the carriage return & line feed
PSOUT
CAILE 12,1 ;finished all lines yet?
SOJA 12,ULINE ;no. do more.
;LOWER TRIANGLE ...
MOVEI 12,0 ;initial line count
MOVEI 14,15 ;initial line length
; here to print each line
LLINE: MOVEI 13,0 ;initial character count
SOS 14 ;decrement line length
; print one character on a line
LCHAR: CAML 13,12 ;skip if printing spaces
JRST LPSTAR ;go print a star
HRROI 1,BLANK ;print a blank
PSOUT
JRST LELIN ;test for end of line
LPSTAR: HRROI 1,ASTER ;print a star
PSOUT
LELIN: CAMGE 13,14 ;have we reached the end of line?
AOJA 13,LCHAR ;print the next character
HRROI 1,NEWLIN ;print the carriage return & line feed
PSOUT
CAIGE 12,6 ;finished all lines yet?
AOJA 12,LLINE ;no. do more.
HALTF ;all done
BLANK: ASCIZ / /
ASTER: ASCIZ /*/
NEWLIN: ASCIZ /
/
END START

49
hw2.mac Normal file
View File

@ -0,0 +1,49 @@
TITLE HW2 DIAMOND - Homework 2
SEARCH MONSYM
Comment $ (Gorin p. 65)
Accumulator usage:
10 line counter (L: [-6, 6])
11 star pairs on current line (P: [0, 6] (L<=0)
[5, 0] (L>0))
12 filler space counter (F: |L| (initial))
13 star pair counter
$
START: RESET
MOVNI 10,6
MOVEI 11,0
LINE: MOVM 12,10
MOVE 13,11
FILL: JUMPE 12,PAIRS
HRROI 1,SPACE
PSOUT
SOJA 12,FILL
PAIRS: JUMPE 13,ENDLIN
HRROI 1,STRSTR
PSOUT
SOJA 13,PAIRS
ENDLIN: HRROI 1,STRNL
PSOUT
AOJ 10,
CAILE 10,6
JRST END
CAILE 10,0
SOSA 11
AOJ 11,
JRST LINE
END: HALTF
SPACE: ASCIZ / /
STRSTR: ASCIZ /**/
STRNL: ASCIZ /*
/
END START

28
instfmt.txt Normal file
View File

@ -0,0 +1,28 @@
PDP-10 Instruction Format
PDP-10 machine code instructions are stored in 36-bit words with the
following format:
Bits Length Contents
0-8 9 OP: operation code
9-12 4 AC: accumulator
13 1 I: indirect flag
14-17 4 X: index
18-35 18 Y: address
(Input/output instructions have a different format, but are only allowed
in privileged programs.)
Instruction fields are represented in assembly language statements as
follows:
OM (AC, I, Y, X are zero)
OM Y (AC, I, X are zero)
OM AC, (I, Y, X are zero)
OM AC,Y (I and X are zero)
OM AC,Y(X) (I is zero)
OM AC,@Y (I is 1, X is zero)
OM AC,@Y(X) (AC, I, Y, X all non-zero)
(OM: operation code mnemonic name)

60
instruct.txt Normal file
View File

@ -0,0 +1,60 @@
PDP-10 Instructions
MOV - Move full word between accumulator and memory.
MOVE* - Move without modification.
MOVN* - Negate source.
MOVM* - Magnitude (absolute value) of source.
MOVS* - Swap source upper- and lower-half words.
MOV* - Move from memory to AC.
MOV*I - Immediate. Source is value of E itself.
MOV*M - Move from AC to memory.
MOV*S - Move from E to E.
EXCH - Exchange values of AC and E.
JRST - Unconditional jump.
JUMP[c] - Compare AC to zero and jump to E if condition met.
AOJ[c] - Add one to AC, compare result to zero, and jump if condition
met.
SOJ[c] - Substract one from AC, compare result to zero, and jump if
condition met.
AOBJ - Add one to both upper- and lower-half word of AC and jump.
AOBJN - Jump if AC is less than zero.
AOBJP - Jump if AC is greater than or equal to zero.
SKIP[c] - Compare contents of E to zero and skip next instruction if
condition met. If AC is non-zero, set AC to contents of E.
AOS[c] - Add one to E, compare result to zero, and skip next
instruction if condition met. If AC is non-zero, set AC to
contents of E.
SOS[c] - Substract one from E, compare result to zero, and skip next
instruction if condition met. If AC is non-zero, set AC to
contents of E.
CAM[c] - Compare contents of AC and E and skip next instruction if
condition met.
CAI[c] - Compare contents of AC to value of E (immediate) and skip next
instruction if condition met.
[c] - Arithmetic conditions for jump and skip instructions (JUMP, AOJ,
SOJ, SKIP, AOS, SOS, CAM, CAI).
blank - Never jump/skip.
L - Less than.
LE - Less than or equal.
E - Equal.
N - Not equal.
GE - Greater than or equal.
G - Greater than.
A - Always jump/skip (JUMPA is deprecated in favor of JRST).

21
mydtim.mac Normal file
View File

@ -0,0 +1,21 @@
TITLE MYDTIM - Emulate EXEC DAYTIME command
Comment $
Contributed by David Meyer <papa@twenex.org>/<papa@sdf.org>
March 9, 2022
$
SEARCH MONSYM
START: RESET
HRROI 1,[ASCIZ " "] ;Compile single space string and print
PSOUT ; at beginning of line (because DAYTIME
; does)
GTAD ;Set AC1 to current system date/time word
MOVE 2,1 ;Copy date/time from AC1 to AC2
MOVEI 1,.PRIOU ;Set AC1 to output destination (.PRIOU =
; primary output)
HRROI 3,-1 ;Set AC3 to format option
ODTIM
HALTF
END START

47
mydtim.txt Normal file
View File

@ -0,0 +1,47 @@
MYDTIM.MAC - Emulate EXEC DAYTIME command
PUBLIC:<CONTRIB>MYDTIM.MAC
PUBLIC:<CONTRIB>MYDTIM.EXE
PUBLIC:<CONTRIB>MYDTIM.TXT
Contributed by David Meyer <papa@twenex.org>/<papa@sdf.org>
March 9, 2022
MACRO assembly language source demonstrating use of GTAD and ODTIM JSYS
to get system date/time, then format and print it like the EXEC command
DAYTIME.
GTAD
Gets the current system date/time word (the format of which is a
story for another day) and stores it in AC1.
ODTIM
Format and print a date/time.
INPUTS:
AC1: Output destination (.PRIOU for primary output)
AC2: Date/time word (-1 to use current system date/time)
AC3: Date format (-1 for "Weekday, Month dd, yyyy hh:mm:ss"
(like DAYTIME))[*]
(Since ODTIM can be instructed to use the current system date/time by
storing -1 in AC2, the lines:
GTAD
MOVE 2,1
... could be replaced with:
HRROI 2,-1
... eliminating the need to call GTAD directly.)
[*] For more format options, see "ODTIM JSYS 220", TOPS-20 Monitor Calls
Reference Manual, p. 3-295.
Reference:
TOPS-20 Monitor Calls Reference Manual. Nashua, NH: Digital Equipment
Corporation, 1982. Available: Bitsavers' Computing Archive,
http://bitsavers.org/pdf/dec/pdp10/TOPS20/AA-4166E-TM_TOPS-20_Monitor_Calls_Reference_Ver_5_Dec82.pdf [Accessed March 9, 2022].

18
template.mac Normal file
View File

@ -0,0 +1,18 @@
TITLE TEMPLT - MACRO program source file template
Comment $ This is a template for MACRO assembly language source files
$
SEARCH MONSYM ;Add TOPS-20 symbols to MACRO
START: RESET ;RESET the state of I/O devices
;... (program source here) ...
HALTF ;Stop execution here.
DATA: ASCIZ /Program data goes here ...
/
END START ;End of program, start at START