Académique Documents
Professionnel Documents
Culture Documents
Each line of your PSM file should adhere to the following basic syntax. Dont worry too much about getting everything perfect or tidy because the assembler
will look after things like additional spaces and is very tolerant of upper or lower case characters except where it really matters. If you get something wrong
the assembler will show you what it doesnt like and provide advice to help you correct it.
Anything following a
semicolon ; will be treated
as a comment and otherwise
ignored by the assembler.
Hint - The assembler
ignores empty lines so use
an empty comment (just a
semicolon) to preserve a
blank line in the FMT and
LOG files.
Lines only containing
comments will be formatted
in-line with the instructions.
Comments on lines
containing an instruction will
be formatted in a column to
the right of the longest
instruction. Looks nice
Directives.....
CONSTANT name, kk / ADDRESS aaa / NAMEREG oldname, newname / STRING name$, text / TABLE name#, [kk,kk,kk,..] / INST hhhhh
PLEASE SEE all_kcpsm6_syntax.psm which provides a PSM file (albeit not a real program) that further describes all directives and has examples of all
the supported syntax. Since it is a valid PSM file you can assemble it to see the FMT and LOG files as well.
Page 52
The NAMEREG directive is an optional facility that can help you keep track of what data you expect a particular
register to contain. Prior to the NAMEREG directive the resister will have the default name such as sB. Once renamed
only the new name will identify the register and that name is case sensitive exactly as you defined it. Changing the
name has no effect on the contents of the register or how it can be used.
Page 53
sF
sE
sD
sC
sB
NAMEREG Directive
ADD sB, 42
;
NAMEREG sB, Status
;
;
INPUT Status, flags_port
COMPARE Status, 12
;
NAMEREG Status, speed
;
SUB speed, 01
;
NAMEREG speed, sB
;
LOAD sB, 19
16 Registers
All general purpose
All 8-bits
sA
s9
s8
s7
s6
Following the NAMEREG directive only the new is valid and this name is
case sensitive. In this case sB will no longer be recognised.
s4
The NAMEREG directive can be used to change the name again and then
only the new name is valid in the following code. Depending on your way of
thinking this is either useful or something to be avoided!
s2
s5
s3
s1
s0
aaa
kk
pp
p
ss
x
y
Instruction
Page Opcode
Register loading
55
55
71
00xy0
01xkk
16xy0
LOAD sX, sY
LOAD sX, kk
STAR sX, sY
Logical
56
56
57
57
58
58
02xy0
03xkk
04xy0
05xkk
06xy0
07xkk
AND sX, sY
AND sX, kk
OR sX, sY
OR sX, kk
XOR sX, sY
XOR sX, kk
14x06
14x07
14x04
14x00
14x02
14x0E
14x0F
14x0A
14x08
14x0C
67
67
67
67
67
68
68
68
68
68
10xy0
11xkk
12xy0
13xkk
18xy0
19xkk
1Axy0
1Bxkk
ADD sX, sY
ADD sX, kk
ADDCY sX, sY
ADDCY sX, kk
SUB sX, sY
SUB sX, kk
SUBCY sX, sY
SUBCY sX, kk
70
70
37000
37001
08xy0
09xpp
2Cxy0
2Dxpp
2Bkkp
SL0 sX
SL1 sX
SLX sX
SLA sX
RL sX
SR0 sX
SR1 sX
SRX sX
SRA sX
RR sX
0Cxy0
0Dxkk
0Exy0
0Fxkk
1Cxy0
1Dxkk
1Exy0
1Fxkk
Page 54
TEST sX, sY
TEST sX, kk
TESTCY sX, sY
TESTCY sX, kk
COMPARE sX, sY
COMPARE sX, kk
COMPARECY sX, sY
COMPARECY sX, kk
87
88
88
88
88
89
REGBANK A
REGBANK B
STORE
STORE
FETCH
FETCH
DISABLE INTERRUPT
ENABLE INTERRUPT
RETURNI DISABLE
RETURNI ENABLE
Jump
81
81
82
82
28000
28001
29000
29001
83
83
84
84
Instruction
Interrupt Handling
Page Opcode
59
59
60
60
61
61
62
62
Instruction
:
:
:
:
:
:
:
sX,(sY)
sX, ss
sX, (sY)
sX, ss
22aaa
32aaa
36aaa
3Aaaa
3Eaaa
26xy0
JUMP aaa
JUMP Z, aaa
JUMP NZ, aaa
JUMP C, aaa
JUMP NC, aaa
JUMP@ (sX, sY)
Subroutines
92
93
93
93
93
94
96
97
97
97
97
98
20aaa
30aaa
34aaa
38aaa
3Caaa
24xy0
25000
31000
35000
39000
3D000
21xkk
CALL aaa
CALL Z, aaa
CALL NZ, aaa
CALL C, aaa
CALL NC, aaa
CALL@ (sX, sY)
RETURN
RETURN Z
RETURN NZ
RETURN C
RETURN NC
LOAD&RETURN sX, kk
Version Control
100
14x80
HWBUILD sX