AM4KBAS
Information
AM4KBAS is pseudo code used in RCA Tiny BASIC running on the Studio IV, similar syntax is used (AMVBAS) when running RCA Tiny BASIC on the VIP.
Definitions
aaaa | 16 bit address |
aa | lower 8 bit of 16 bit address |
kk | 8 bit constant |
n | 4 bit constant |
Vx,Vy,Vz | 8 bit register (x, y or z = 0 to F) |
Rx,Ry,Rz | 16 bit register (x, y or z = 0 to 7), see Note 1. |
[aa],[bb],[cc] | memory value of address 11aa, see Note 2. |
[Ry],[Rz] | Memory value (8 bit) pointed to by 16 bit register (x, y or z = 0 to 7) |
Note 1: V0 to VF are located on 1C00-1C0F. R0-R7 are located on the same memory locations and as such: R0 is build up of V0 as high byte and V1 as low, R1=V2-V3 etc. Register value 'z' specified in the pseudo code is actually z*2, so R1 is indicated by cc02kk.
Note 2: [aa] indicate 2 bytes in memory when using commands with R registers so memory location 1Caa as well as 1Caa+1 will be used.
Syntax
Opcode | Mnemonic | Parameter | Definition |
---|---|---|---|
120zkk | ARD | Rz, kk | Rz = Rz + kk [1C10] = carry |
12aakk | ARD | [aa], kk aa, kk |
[1Caa/1Caa+1] = [1Caa/1Caa+1] + kk [1C10] = carry |
20yz | ARG | Ry, Rz | Ry = Ry + Rz [1C10] = carry |
Cxkk | ARI | Rx, kk | Rx = Rx + kk |
21yz | ARX | Ry, [Rz] Ry, Rz |
Ry = Ry + [Rz] [1C10] = carry |
22yz | AV | Vy, Vz | Vy = Vy + Vz [1C10] = carry |
Exkk | AVI | Vx, kk | Vx = Vx + kk |
390z | CHGS | Rz | Rz = 0 - Rz (change sign) |
39aa | CHGS | [aa] aa |
[1Caa/1Caa+1] = 0 - [1Caa/1Caa+1] (change sign) |
0C | CLRTV | Clear TV screen | |
2Fyz | COLOR | Ry, Vz | Color Vz on location Ry ((Ry.1 = x, Ry.0 = y) |
01aaaa | DO | aaaa | Execute pseudo code at address aaaa, return with RET |
010700 | DO | CBDOUT | Convert binary to decimal and output |
01073D | DO | COLDOT | Color dot |
01078F | DO | DIGIT | Get digit |
0101D7 | DO | GOEZ | Goto address bb in the current page if [1Caa] = 0 |
010143 | DO | IADD | [1Caa/1Caa+1] = [1Caa/1Caa+1] + [1Cbb/1Cbb+1] |
01017F | DO | IFLOAT | [11aa/11aa+1] = [11bb/11bb+1] |
010763 | DO | INTEG | Get integer |
0104ED | DO | ISIGN | Set carry flag [1C10] if [1Caa/1Caa+1] is negative |
010152 | DO | ISUB | [1Caa/1Caa+1] = [1Caa/1Caa+1] - [1Cbb/1Cbb+1] |
010550 | DO | KEYOUT | Output keyword |
010520 | DO | LOOKUP | Lookup keyword |
010737 | DO | SETCOL | Set Color map to one color |
010752 | DO | SKSP | Vy = next character from [Rz] If space is found take next character Rz will point to next character |
0101FD | DO | SYNC | Wait for sync, CPU in IDLE state |
0E | EML | Execute following Machine Language | |
00aaaa | EXEC | aaaa | Execute machine code at address aaaa, return with SEP R4 |
00002C | EXEC | INIT | Initializatioon routine |
3B0zaa | FIX | Rz, [aa] Rz, aa |
Rz = [1Caa/1Caa+1] |
3Baabb | FIX | [aa], [bb] aa, bb |
[1Caa/1Caa+1] = [1Cbb/1Cbb+1] |
3Caabb | FADD | [aa], [bb] aa, bb |
[1Caa/1Caa+1] = [1Caa/1Caa+1] + [1Cbb/1Cbb+1] |
3Faabb | FDIV | [aa], [bb] aa, bb |
[1Caa/1Caa+1] = [1Caa/1Caa+1] / [1Cbb/1Cbb+1] |
3Aaa0z | FLOAT | [aa], Rz aa, Rz |
[1Caa/1Caa+1] = Rz |
3Aaabb | FLOAT | [aa], [bb] aa, bb |
[1Caa/1Caa+1] = [1Cbb/1Cbb+1] |
38aabb | FMOV | [aa], [bb] aa, bb |
[1Caa/1Caa+1] = [1Cbb/1Cbb+1] |
3Eaabb | FMPY | [aa], [bb] aa, bb |
[1Caa/1Caa+1] = [1Caa/1Caa+1] * [1Cbb/1Cbb+1] |
3Daabb | FSUB | [aa], [bb] aa, bb |
[1Caa/1Caa+1] = [1Caa/1Caa+1] - [1Cbb/1Cbb+1] |
04aa | GO | aa | Goto address aa in the current page |
05aa | GOCR | aa | Goto address aa in the current page if ... |
170zaa | GOEZ | Rz, aa | Goto address aa in the current page if Rz = 0 |
17aabb | GOEZ | [aa], bb aa, bb |
Goto address bb in the current page if [1Caa] = 0 |
35aabb | GOEZ | [aa], bb | Goto address bb in the current page if [1Caa] = 0 |
Dxkkaa | GOEQ | Vx, kk, aa | Goto address aa in the current page if Vx = kk |
140ykkaa | GOGE | Vy, kk, aa | Goto address aa in the current page if Vy >= kk |
14kaakkbb | GOGE | [aa], kk, bb aa, kk, bb |
Goto address bb in the current page if [1Caa] >= kk |
150ykkaa | GOLT | Vy, kk, aa | Goto address aa in the current page if Vy < kk |
15aavvbb | GOLT | [aa], kk, bb aa, kk, bb |
Goto address bb in the current page if [1Caa] < kk |
06aa | GONC | aa | Goto address aa in the current page if no carry |
Fxkkaa | GONE | Vx, kk, aa | Goto address aa in the current page if Vx != kk |
5xaa | GONZ | Vx, aa | Goto address aa in the current page if Vx != 0 |
03aaaa | GOTO | aaaa | Goto address aaaa |
4xaa | GOZR | Vx, aa | Goto address aa in the current page if Vx = 0 |
070z | GOX | Rz | Goto address in Rz |
07aa | GOX | [aa] aa |
Goto address [1Caa/1Caa+1] |
0B0yaa | KEY | Vy, aa | Goto address aa in the current page if no key pressed, otherwise return key in Vy |
0Baabb | KEY | [aa], bb aa, bb |
Goto address bb in the current page if no key pressed, otherwise return key in [1Caa] |
09 | KEYT | Key tone - not implemented, key tone is done in the WKEY routine | |
7xaa | LRD | Rx, [aa] Rx, aa |
Rx = [1Caa/1Caa+1] |
26yz | LRG | Ry, Rz | Ry = Rz |
6xaaaa | LRGI | Rx, aaaa | Rx = aaaa |
27yz | LRX | Ry, [Rz] Ry, Rz |
Ry = [Rz/Rz+1] |
28yz | LV | Vy, Vz | Vy = Vz |
9xaa | LVD | Vx, [aa] Vx, aa |
Vx = [1Caa] |
8xkk | LVI | Vx, kk | Vx = kk |
29yz | LVX | Vy, [Rz] Vy, Rz |
vy = [Rz] |
160z | OUTS | Vz | Output character in Vz |
16kk | OUTS | [aa] aa |
Output character on [1Caa] |
0F | OUTSI | Output characters following command until character with b7=1 is detected | |
1B0zkk | POPM | Rz, kk | Pop registers from stack starting with Rz and kk bytes |
1Baakk | POPM | [aa], kk aa, kk |
Pop memory values from stack starting with [aa] and kk bytes |
1A0zvv | PUSHM | Rz, kk | Oush registers to stack starting with Rz and kk bytes |
1Akkvv | PUSHM | [aa], kk aa, kk |
Push memory values to stack starting with [aa] and kk bytes |
190z | RAND | Vz | Vz = random value |
19aa | RAND | [aa] aa |
[aa] = random value |
11 | RCR | Reset carry | |
02 | RETURN | Return from DO | |
1Fyz | RT | [Ry], Vz Ry, Vz |
Read Vz blocks from tape to [Ry] |
10 | SCR | Set carry | |
180zaabb | SHOW | Rz, [aa], [bb] Rz, aa, bb |
Show pattern on [Rz, 5 bytes] on position x = [aa] and y = [bb] |
1Cyl | SHL | Ry, l | Shift left Ry l times |
1Dyl | SHR | Ry, l | Shift right Ry l times |
37aa | SIGN | [aa] aa |
Set carry flag [1C10] if [1Caa/1Caa+1] is negative |
33yz | SKSP | Vy, Rz Vy, Rz |
Vy = next character from [Rz] If space is found take next character Rz will point to next character |
130zkk | SRI | Rz, kk | Rz = Rz - kk |
13aabb | SRI | [aa], kk aa, kk |
[1Caa/1Caa+1] = [1Caa/1Caa+1] - kk |
23yz | SRG | Ry, Rz | Ry = Ry - Rz [1C10] = carry |
24yz | SRX | Ry, [Rz] Ry, Rz |
Ry = Ry - [Rz] [1C10] = carry |
Axaa | STRD | [aa], Rx aa, Rx |
[1Caa] = Rx.1, [1Caa+1] = Rx.0 |
2Axy | STRX | [Ry], Rx Ry, Rx |
[Ry] = Rx.1, [Ry+1] = Rx.0 |
Bxaa | STVD | [aa], Vx aa, Vx |
[1Caa] = Vx |
2Byz | STVX | Vy, [Rz] Vy, Rz |
Vy = [Rz] |
25yz | SV | Vy, Vz | Vy = Vy - Vz [1C10] = carry |
34 | SYNC | Wait for sync, CPU in IDLE state | |
0Akk | TAPE | kk | Tape I/O, kk=0: stop, kk=1: load, kk=2: save |
0D0z | TV | Vz | Vz to TV output |
0Daa | TV | [aa] aa |
[1Caa] to TV output |
2Cyz | VAND | Vy, Vz | Vy = Vy AND Vz |
2Dyz | VOR | Vy, Vz | Vy = Vy OR Vz |
2Eyz | VXOR | Vy, Vz | Vy = Vy XOR Vz |
08 | WKEY | Wait until NO key is pressed and key beep sound | |
1Eyz | WT | [Ry], Rz Ry, Rz |
Write Vz blocks from tape from [Ry] |