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:
- Numbers are recognised by their prefix: a minus sign or a decimal digit. They are by default written in decimal but can have an eventual suffix to specify the base:
- d (decimal)
- h (hexadecimal)
- o (octal optional)
- b (binary)
- Each number must fit in the desired field. All numbers are considered signed but can be written using unsigned numbers for convenience.
- Imm9 range: -256 to 511
- Imm8 range: -128 to 255
- Imm4 range: -8 to 15 (8 to 15 may output a warning)
The user must be careful that the number is not sign-extended to an invalid value, in particular with Imm4.
It should be clearer, easier to implement and use, but I'm disappointed it couldn't be better.
.
.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.