BLUE
kissa.bsky.social
@kissa.bsky.social
Tomfoolery, nincompoopery, programming
37 followers374 following39 posts
kissa.bsky.social

Operands are now simply 8 bits and denote memory addresses 0x00 to 0xff. I have a slightly more complex design in mind but let's get some syntax defined first. This also details how to address lower and higher parts of registers:

Syntax

[M] means the word at memory address M.

[M].b means the byte at memory address M. When read, it is sign-extended
to a word.

<reg> is equivalent to [addressof <reg>], where <reg> is one of registers
(a, b, c, d, x, y, i, j, p, q, sp, pc), and addressof <reg> is the memory
address of the register according to the table below.

<reg>.hi is equivalent to [address of <reg>].b
<reg>.lo is equivalent to [address of <reg> + 1].b

Table of registers and their addresses:

a:  0x0    a.hi:  0x0    a.lo:  0x1
b:  0x2    b.hi:  0x2    b.lo:  0x3
c:  0x4    c.hi:  0x4    c.lo:  0x5
d:  0x6    d.hi:  0x6    d.lo:  0x7
x:  0x8    x.hi:  0x8    x.lo:  0x9
y:  0xa    y.hi:  0xa    y.lo:  0xb
i:  0xc    i.hi:  0xc    i.lo:  0xd
j:  0xe    j.hi:  0xe    j.lo:  0xf
p:  0x10   p.hi:  0x10   p.lo:  0x11
q:  0x12   q.hi:  0x12   q.lo:  0x13
sp: 0x14   sp.hi: 0x14   sp.lo: 0x15
pc: 0x16   pc.hi: 0x16   pc.lo: 0x17

Finally:

<regi> is one of x, y, i, j
<rega> is one of p, q, sp, pc
1

kissa.bsky.social

What we have now is direct addressing, e.g. [0x1234]. This extends the design with indirect addressing using either immediate or an index register, allowing things like [pc + 5] and [p + i]. Also byte addressing is supported with syntax [0x1234].b

Operand format:

Direct addressing (word), values 0..63:
00mmmmmm: [M], where M is number 0-63

Direct addressing (byte), values 64..127:
01mmmmmm: [M].b, where M is number 0-63

Indirect addressing with immediate offset (word), values 128..175:
10ooooaa: [<rega> + O], where <rega> is selected with bits 'aa' and O is
the range 0b0000-0b1011, represented by bits 'oooo', mapped to values -6 to 5

Indirect addressing with index register (word), values 176..191:
1011iiaa: [<rega> + <regi>], where <rega> is selected with bits 'aa' and
<regi> is selected with bits 'ii'

Indirect addressing with immediate offset (byte), values 192..239:
11ooooaa: [<rega> + O].b, where <rega> is selected with bits 'aa' and O is
range 0b0000-0b1011 mapped to values -6 to 5

Indirect addressing with index register (byte), values 240..255:
1111iiaa: [<rega> + <regi>].b, where <rega> is selected with bits 'aa' and
<regi> is selected with bits 'ii'
0
kissa.bsky.social
@kissa.bsky.social
Tomfoolery, nincompoopery, programming
37 followers374 following39 posts