Close

Assembler v2023!

A project log for YGREC8

A byte-wide stripped-down version of the YGREC16 architecture

yann-guidon-ygdesYann Guidon / YGDES 12/14/2023 at 05:510 Comments

A new breed of assembler is now ready in VHDL. Lionel makes his own in bison+flex, which might lag somewhat, but at least there is a functional command-line tool that eats .Y8 files and generates anotated .HYX dumps, along with optional dumps of the symbol table.

Here is one of the example code samples that pass easily:

; ygrec8/y8/asm.y8/gPEAC.y8
; created by sam. 11 nov. 2023 19:24:01 CET whygee@f-cpu.org
; version sam. 16 déc. 2023 21:34:37 CET
;
; gPEAC perfect moduli < 256/2 (no overflow of byte):
; 2 6 10 26 30 38 50 66 86 114 126
; orbit length is mod^2 + mod

.EQU MOD 10 ; Modulus
.EQU ITERATIONS (MOD * (MOD+1))

.ORG 0 ; default start value

SET MOD A1; mod (110 iterations)
SET ITERATIONS A2 ; loop counter
SET 1 R1 ; X
SET 0 R2 ; Y
SET 0 R3 ; T
ADD R2 R2 ; 0+0=0 : clear the Carry flag

reloop:

; first step
PF R2 IFC ; copy carry flag to carry in
ADD R1 R2

SET A1 R3
SUB R2 R3
SET R3 R2 IFC ; modulo

; second step
PF R1 IFC
ADD R2 R1

ADD -2 A2
OVL -1 IFS ; exit when loop counter expired

SET A1 R3
SUB R1 R3
SET R3 R1 IFC ; modulo

SET reloop PC

This is the result:

$ ./vasmy8 "-gfinput=../../asm.y8/gPEAC.y8"  "-gdump_symbols=1"
:00 ; .ORG 0 ; default start value
5188 ;l14: SET MOD A1; mod (110 iterations)
738B ;l15: SET ITERATIONS A2 ; loop counter
0C86 ;l16: SET 1 R1 ; X
0586 ;l17: SET 0 R2 ; Y
0686 ;l18: SET 0 R3 ; T
2D72 ;l19: ADD R2 R2 ; 0+0=0 : clear the Carry flag
85E2 ;l24: PF R2 IFC ; copy carry flag to carry in
2572 ;l25: ADD R1 R2
0E82 ;l27: SET A1 R3
2E62 ;l28: SUB R2 R3
B582 ;l29: SET R3 R2 IFC ; modulo
84E2 ;l32: PF R1 IFC
2C72 ;l33: ADD R2 R1
7376 ;l35: ADD -2 A2
7F97 ;l36: OVL -1 IFS ; exit when loop counter expired
0E82 ;l38: SET A1 R3
2662 ;l39: SUB R1 R3
B482 ;l40: SET R3 R1 IFC ; modulo
3786 ;l42: SET reloop PC
; SYMBOL TABLE DUMP:
; 'MOD' : user_symbol = 10 (x3)
; 'RELOOP' : address_symbol = 6 (x1)
; 'ITERATIONS' : user_symbol = 110 (x1)
; 'VASMY8_VERSION' : user_symbol = 20231212 (x0)

This is a 1.5 pass assembler: Lines where a symbol is undefined get stored for later and are re-assembled at the end. This creates a .HYX where a sequence of .ORG in reverse order are dumped at the end, which stretches a bit the format's convention but it's not an issue if the file is fed into a tool that will reorder the values (such as the upcoming simulator).

With such a tool, a major milestone is reached: it is now possible to write and assemble larger chunks of code and even whole programs, not just small examples. I'm thinking about the Snake program. This allows a better evaluation of the balance of the instruction set, and eventually adapt it.

The snapshots are as usual on gitlab and this one is also mirrored here at YGREC8_20231214.tbz

The doc must be extended and completed but I'm almost ready for the next milestone: the simulator. Which raises a lot of new questions about its structure and organisation, in particular the interfaces.

Discussions