8.0 KiB
Concept | SCSC | AS65 | Merlin |
---|---|---|---|
origin | .OR | org | |
target address | .TA | ||
include | .IN | ||
comment | * | ; | |
>1 space | |||
label | at left | ||
equ | .EQ | = | |
equ | |||
binary | %00000001 | ||
macro | .MA macro_name | macro_name macro | |
.EM | endm | ||
if | .DO | if foo = 1 | |
.ELSE | endif | ||
[.ELSE] (toggle) | |||
.FIN | |||
data | |||
- word (LE) | .DA expr | ||
- byte (LSB) | .DA #expr | ||
- byte (MSB) | .DA /expr | ||
ascii string | |||
- normal use | .AS "foo" | ||
- arb. delimeter | .AS dfood | ||
- high bit set | .AS -"foo" | ||
- last high bit opposite | .AT "foo" | ||
hex string | .HS | ||
reserve space (block storage) | .BS <bytes> |
Things to ignore
Concept | SCSC | AS65 |
---|---|---|
title | .TI <lines/page>,title | |
file | .TF filename |
AS65 notes
SCSC notes
.DO – Conditional Assembly 5-9 .ELSE – Conditional Assembly 5-9 .FIN – Conditional Assembly 5-9 .MA – Macro Definition 5-11 .EM – End of Macro 5-11
Edasm notes
http://mirrors.apple2.org.za/ftp.apple.asimov.net/images/programming/assembler/EDASM.DSK
How to run
Boot from the disk type "- edasm.system"
Differences from manual
The manual claims that "MSB ON" is the default.
:ASM FOO.TXT SOURCE FILE #01 =>FOO.TXT 0000:41 42 43 1 ASC "ABC" 0003: 2 MSB OFF 0003:41 42 43 3 ASC "ABC" 0006: 4 MSB ON 0006:C1 C2 C3 5 ASC "ABC"
Sweet 16
http://amigan.1emu.net/kolsen/programming/sweet16.html http://twimgs.com/informationweek/byte/archive/Apple-II-Description/The-Apple-II-by-Stephen-Wozniak.pdf
R0 | Accumulator |
R12 | Subroutine stack pointer |
R13 | Comparison results |
R14 | Status (prior result register << 8 + carry bit) |
R15 | PC |
00 | Return to 6502 mode | RTN | 1 | |
01 | Branch always | BR | 2 | |
02 | Branch if no carry | BNC | 2 | |
03 | Branch if carry | BC | 2 | |
04 | Branch if plus | BP | 2 | |
05 | Branch if minus | BM | 2 | |
06 | Branch if zero | BZ | 2 | |
07 | Branch if nonzero | BNZ | 2 | |
08 | Branch if minus 1 | BM1 | 2 | |
09 | Branch if not minus 1 | BNM1 | 2 | |
0A | Break | BK | 1 | BRK |
0B | Return from subroutine | RS | 1 | PC <- [—-R12] |
0C | Branch to subroutine | BS | 2 | [R12++++] <- PC(R15); PC(R15) += offset |
0D | - | |||
0E | - | |||
0F | - | |||
1n | Set | SET R7 | 3 | Rn <- constant |
2n | Load | LD R7 | 1 | R0 <- Rn |
3n | Store | ST R7 | 1 | Rn <- R0 |
4n | Load indirect | LD @R7 | 1 | R0 <- byte[Rn++] |
5n | Store indirect | ST @R7 | 1 | byte[Rn++] <- R0 |
6n | Load double indirect | LDD @R7 | 1 | R0 <- word[Rn++++] |
7n | Store double indirect | STD @R3 | 1 | word[Rn++++] <- R0 |
8n | Pop indirect | POP @R3 | 1 | R0 <- byte[–Rn] |
9n | Store pop indirect | STP @R3 | 1 | byte[–Rn] <- R0 |
An | Add | ADD R3 | 1 | R0 <- R0 + Rn |
Bn | Sub | SUB R3 | 1 | R0 <- R0 - Rn |
Cn | Pop double indirect | POPD @R3 | 1 | R0 <- word[—-Rn] |
Dn | Compare | CPR R3 | 1 | R13 <- A0 - Rn |
En | Increment | INR R3 | 1 | Rn++ |
Fn | Decrement | DCR R3 | 1 | Rn– |
Horrible error messages
redbooka
CPY $#0 COMMENT TEXT
The plan
- Make instructions simple data.
- Make the first pass do almost everything: pass two just sees data variants.
It's a bit tricky:
-
Parse instruction.
- Set the current label to the current address, unless it's an equate
- Set the org/target immediately, updating current address.
- Force equates to evaluate immediately.
- Evaluate instructions.
How it works now
asm.Load for each line: Flavor.ParseInstr(…) passInst Set address if ORG in.Compute Update addr asm.Pass2 passInst