Close

Updated number syntax

A project log for YGREC8

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

yann-guidon-ygdesYann Guidon / YGDES 11/07/2023 at 14:240 Comments

Meeting Lionel helped discuss solutions, in particular the syntax of the assembler.

Numbers are signed but in certain cases we need an unsigned number, I proposed this new syntax:

[-+][0-9A-Fa-f]+[bBdDhHoO]?
[0-9][0-9A-Fa-f]*[bBdDhHoO]?

(if you speak regex and/or want to write a Flex parser)

In short: a number is recognised by its first character, either a + or - or a decimal digit. The eventual suffix determines the base.

The new feature is the "+" prefix that forces a positive number, which may exceed the limit for signed numbers. This is practical when using masks for example:

AND +F0h D1
OUT +511 A2

This wouldn't work with the original syntax because F0h wraps around to the negative range and would throw an error. So what the + does is tweak the parser and assembler to transform the data into a negative number "internally" so it passes the requirements for a valid number.


Screw it.

It's too inconvenient to implement and use, in the end. So I'm back to the old convention used by the YASEP. Here is the new manual's description:

It should be clearer, easier to implement and use, but I'm disappointed it couldn't be better.

.
.

Discussions