LANGUAGE
By the mid 1980s people were used to full screen editors (GW Basic is from
1983, for example), but a minimal teletype style system where the only editing
is entering a new line with the same number has its merits.
Several different implementation styles of Basic were done: pure text
interpreters, tokenized interpreters, two level interpreters and compilers.
A new option would be an incremental compiler. In such a system the memory
would hold a machine language version of the user’s program plus some helper
tables mapping line numbers and variable names to memory positions.
When listing the program it would be decompiled as needed. When a new line
is entered, it is translated to machine language and replaces the old
code (if any) and all the rest of the program is patched to take into
account changed addresses as everything after the new code would have to
be slightly moved.
Each line could be a Basic statement (or more than one if colons are used)
or an assembly language instruction (also allowing more than one), in which
case the “compilation” is trivial.
Several Basic added named subroutines with actual arguments and that made
a huge difference compared to only GOSUB. They often added more control
structures and made line numbers optional, but the standard IF and FOR are
enough for most cases.
An alphabetical list of assembly instructions
As 0d add d,s ; d += s
As 2d addc d,s ; d += s + carry
2d ii addci d,#i; d += i + carry
0d ii addi d,#i ; d += i
As 7d and d,s ; d &= s
7d ii andi d,#i ; d &= i
As 9d asr d,s ; d >>= s
B3 ii bc ; if c = 1 then pc += i
B1 ii beq ; if z = 1 then pc += i
BC ii bhi ; higher unsigned if !(z=1 | c=0) then pc += i
B8 ii bge ; if n^v = 0 then pc += i
BA ii bgt ; if !(z=1 | n^v) then pc += i
BB ii ble ; if z=1 | n^v then pc += i
BD ii bls ; lower or same unsgined if z=1 | c=0 then pc += i
B9 ii blt ; if n^v = 1 then pc += i
B5 ii bn ; if n = 1 then pc += i
B2 ii bnc ; if c = 0 then pc += i
B0 ii bne ; if z = 0 then pc += i
B6 ii bnv ; if v = 0 then pc += i
B4 ii bp ; if n = 0 then pc += i
BF ii br ii ; pc += i
FB brk ; push PC, push Status, PC = *0 , Status = *3
B7 ii bv ; if v = 1 then pc += i
BE ii call ii ; push pc , pc += i
88-8B callr A-D ; push pc , pc = d
F0 cc ; c = 0
F4 cn ; n = 0
F2 cv ; v = 0
F6 cz ; z = 0
84-87 dec A-D ; d -= 1 (24 bits)
F8 di ; ei = 0
F9 ei ; ei = 1
80-83 inc A-D ; d += 1 (24 bits)
8C-8F jumpr A-D ; pc = d
E? ld d,s ; d = *s (24 bits)
As 8d lsl d,s ; d <<= s
As 4d mov d,s ; d = s
4d ii movi d,#i ; d = i
C? movl d,s ; d = s (24 bits)
As Dd muh d,s ; d = ((unsigned) d * (unsigned) s) >> 8
As Cd mul d,s ; d = (0x00FF) d * s
As Ed mus d,s ; d = (d * s) >> 8
As 6d or d,s ; d |= s
6d ii ori d,#i ; d |= i
94-97 pop A-D
9C-9E pop PC, SP, Status
90-93 push A-D
98-9A push PC, SP, Status
As Bd rot d,s ; d = (d << s ) | (d >> (8 - s))
As Fd rotc d,s ; t = (d >> (8 - s)) & 0x01
FA rti ; pop Status , pop PC
F1 sc ; c = 1
As Ad shr d,s ; (unsigned) d >>= s
; d = carry << s - 1 | d << s | (d >> (9 - s))
; carry = t
F5 sn ; n = 1
D? st d,s ; *d = s (24 bits)
As 1d sub d,s ; d -= s
As 3d subb d,s ; d -= s - carry
1d ii subi d,#i ; d -= i
3d ii subbi d,#i; d -= i - carry
F3 sv ; v = 1
F7 sz ; z = 1
As 5d xor d,s ; d ^= s
5d ii xori d,#i ; d ^= i