forked from davidgiven/cpm65
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathasm.txt
89 lines (66 loc) · 2.88 KB
/
asm.txt
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
CP/M-65 Assembler
=================
An assembler comes with CP/M-65. It's pretty stupid but it does work. It's an
in-memory assembler, so you need enough spare RAM to hold the program you're
currently assembling --- you need 1/2 to 1/3 the amount of RAM as the source
file is big. This makes it unsuitable for large programs, but does make it
pretty fast. It will generate CP/M-65 relocatable binaries so once assembled
you should be able to run them on any machine.
Syntax
------
It supports the normal 6502 opcodes (currently, no 65c02 opcodes) and the usual
addressing modes. Labels are defined with `label:`. Equates can be made with
`VALUE = expression`. Label forward references are supported; equate forward
references are not.
Branch instructions will be automatically expanded to 5-byte long branches if
out of range (see `.expand` below).
Expression parsing works now, mostly. Operator precedence is undefined, so use
parentheses. You can use these operators: `+` `-` `*` `/` `%` `&` `|` `^` `~`
`<` `>`.
The following pseudoops are available:
.byte ...
Takes a list of numbers, or string constants, and emits them.
.word ...
Takes a list of number, and emits them (in little-endian format).
.fill number
Emits `number` zeroes.
.zp symbol, number
Defines an area of zero page of length `number`, defining `symbol` to point
to it. This must be done before use.
.bss symbol, number
Defines an area of bss of length `number`, defining `symbol` to point to
it. This must be done before use.
.include "string"
Includes a file.
.expand 0/1
Turns off/on branch expansion.
Structured programming
----------------------
In addition, there is a set of structured programming operations. Each block
will create a new scope. Code inside the scope can refer to labels outside the
scope, but not vice versa --- this allows easy local labels.
**Note:** due to the primitive nature of the assembler, if you have a forward
reference inside a block to a label outside it, the assembler cannot
automatically resolve the forward reference. Use `.label` to declare labels
ahead of time to get around this.
.zproc <symbol>
.zendproc
Defines a procedure (or other scope). `symbol` points to it.
.zloop
.zbreak <conditional>
.zendloop
Creates an infinite loop. `.zbreak` will jump out of the loop. If a
conditional is supplied --- e.g. `cc` or `ne` --- then it will jump
conditionally.
.zrepeat
.zbreak <conditional>
.zuntil <conditional>
As for `.zloop`, but with a conditional terminator.
.zif <conditional>
.zendif
A simple if..endif (with no else, currently). You can break from loops from
within this.
.label <symbol>
Declares a label before use. This is ueful for forward references in cases
where the assembler can't handle these automatically.
vim: ts=4 sw=4 et