Don't like to read? you can learn while you
watch and listen instead!
Every Lesson in this series has a matching YOUTUBE video... with
commentary and practical examples
Visit the authors Youtube
channel, or Click the icons to the right when you see them
to watch the Lessons video!
You may have a computer in your
phone, but once upon a time computers weren't so small!
The IBM System 370 was the successor to the 360 and was a room
sized computer.
You can forget your Mouse, HD Display and SD card, the 370 read it
input from punched cards, and sent its output to a printer and
terminal monitor!
Fortunately thanks to modern computing, we can emulate a System
370 machine with the Hercules
emulator, so we won't need a small warehouse for our cpu tower!
The IBM360
(I can't find a 370 photo on wikipedia!)
Because IBM hate us and want us to suffer, the official documents refer
to the leftmost bit of a 32 bit value as bit 0 - on any other CPU it
would usually be considered bit 31. We'll use
the more common convention in these tutorials.
We'll specify LSB and MSB to be clear... LSB 0 will be the rightmost
bit... MSB 31 will be the leftmost
IBM Documentation written by drunk madmen
Bit 31 is Least significant rightmost bit
Bit 0 is Most significant leftmost bit
Bit: 0.1.2.........29.30.31
MSB
--------- LSB
Everyone else in the entire world ever
Bit 0 is Least significant rightmost bit
Bit 31 is Most significant leftmost bit
Bit: 31.30.29.........2.1.0
MSB
--------- LSB
Most
Significant Bts
Least
Significant Bits
Normal
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
Power PC
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Bit Value
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
512
256
128
64
32
16
8
4
2
1
Registers
The CPU has 16 32 bit registers (R0-R15 /
AKA 1-15)
Register
Details (suggested purpose)
R0
Subroutine Parameter / Hardwired Zero with
addressing commands
R1
Subroutine Parameter / Parameter List
R2
Sometimes a Subroutine Parameter
R3
R4
R5
R6
R7
R8
R9
R10
R11
R12
R13
Save Area for subroutines (like a stack)
R14
Return Address
R15
Entry point register
Some are used by the OS, however Registers
R2 - R11 are free for your use.
Register R0 is often a hardwired Zero in
addressing... EG: "L R1,3(R0,R2)" is just actually "L R1,3(R2)"
There is no stack, but R13 is used as a
pointer to a 'Save Area' to back up or restore registers during a sub
SAVE
(14,12)
;Back up ALL
Regs 14-15, 0-12 to Save area at (13)
RETURN
(14,12)
;Restore all Regs and return to address in reg 14
Two values are a range, with wrap around if
A is higher than B, so (14,12) means
14,15,0,1,2,3,4,5,6,7,8,9,10,11,12 (everything but 13!)
Save area should be 18 words (72 bytes)
The command when the command
"STM 14,12,12(13)" is seen 12(13) skips 12 bytes from the
address in 13, This is because the first 3 words are reserved by the OS
for the previous save area and other things.
Values
Character
Purpose
Notes
Example
B
Binary
DC
B'11110000'
Value &F0
C
Character
Character in EBDIC... not ASCII!
DC
C'ABC'
Value &C1,&C2,&C3 (EBDIC)
L
Length
Get the length of a value (or command line)
TEST BR R3
Two byte command
DC
A(L'TEST)
Defined as 00002
X
Hexadecimal
DC
X'FF'
Value 255
=
Immediate In LORG pool
Define value at LTORG, and put pointer in code
L
R1,=X'FF'
This will point to the LTORG section
LTORG
A Value of 255 will be put here
H
Halfword
16 bit Value
DC
H'256'
Value &0100
F
FullWord
32 bit Value
DC
F'256'
Value &00000100
L
Literal
Fixed Literal {Repeat}{Type}L{Total}
Type {Type} is defined, padded to {Total}
and duplicated {Repeat} times
DC
4CL3'A' Value &C14040,&C14040,&C14040
EBDIC
Ascii is too boring for the IBM 370 - so it
uses EBDIC!... OK actually EBDIC is designed to be convenient for punched
cards.
0
1
2
3
4
5
6
7
8
9
A
B
C
D
E
F
0x
NUL
SOH
STX
ETX
SEL
HT
RNL
DEL
GE
SPS
RPT
VT
FF
CR
SO
SI
1x
DLE
DC1
DC2
DC3
RES/ENP
NL
BS
POC
CAN
EM
UBS
CU1
IFS
IGS
IRS
IUS/ITB
2x
DS
SOS
FS
WUS
BYP/INP
LF
ETB
ESC
SA
SFE
SM/SW
CSP
MFA
ENQ
ACK
BEL
3x
SYN
IR
PP
TRN
NBS
EOT
SBS
IT
RFF
CU3
DC4
NAK
SUB
4x
SP
¢
.
<
(
+
5x
&
!
$
*
)
;
¬
6x
-
/
¦
,
%
_
>
?
7x
`
:
#
@
'
=
"
8x
a
b
c
d
e
f
g
h
i
±
9x
j
k
l
m
n
o
p
q
r
Ax
~
s
t
u
v
w
x
y
z
Bx
^
[
]
Cx
{
A
B
C
D
E
F
G
H
I
Dx
}
J
K
L
M
N
O
P
Q
R
Ex
\
S
T
U
V
W
X
Y
Z
Fx
0
1
2
3
4
5
6
7
8
9
EO
SVCs
SVC Number
Macro
0
EXCP
XDAP
1
PRTOV
WAIT
WAITR
2
POST
3
EXIT
4
GETMAIN (TYPE 1) (get storage below 16
megabytes - with R operand)
5
FREEMAIN (TYPE 1)
6
LINK
LINKX
7
XCTL
XCTLX
8
LOAD
9
DELETE
10
FREEMAIN (free storage below 16 megabytes)
GETMAIN (get storage below 16 megabytes - with R operand)
JOB:
Class = Time slicing class (A=Default) PRTY = Priority
MSGCLASS = Output class (A-z / 0-9)
MSGLEVEL= (statements,messages) .... 1,1 = output all
Region= Memory to allocate in 1024 byte blocks (eg 128K)
DD:
* = Prompt for input (//ddname DD *)
UNIT = device / group containing data set