-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
I should preface this by saying that I haven't built your computer yet, but I want to, either in a simulator or on breadboards, and I prefer to dive into the repository and code before getting physical. So, I'm sorry if some (or, hopefully not, all) of my "will" and "should" below are inaccurate or off base.
ldi {dst: reg} 0 => 0b11 @ 0b01 @ 0b00 @ dst[1:0]
This seems to convert ldi $a 0 into 0b11 01 00 00 which microcode.txt tells me is equivalent to sub $a $a instead of the move 0 $a that I would otherwise expect. While that instruction will produce the clearly desired effect of putting 0 into the a register, I think there are a few problems with this:
subsets flags whilemovedoes not. That meansldi $a 0will set the zero flag, butldi $a 1will not clear the zero flag. As a programmer, this is not behavior I would expect or desire.ldi $b 0is converted to0b11 01 00 01which issub $a $b. Should the third crumb0b00here be anotherdst[1:0]instead so that this will produce0b11 01 01 01orsub $b $b?- Both
sub reg regandmove imm regtake 4 steps. This optimization saves a byte of code, but costs some power activating a bunch of extra control lines and circuits. dst[1:0]truncates the dst parameter to 2 bits, soldi $sp 0is accepted by the assembler and produces identical machine code toldi $a 0, and ditto for$pc/$band$out/$c. This line should include{ assert(reg <= 4) ... }or equivalent.
This concern also applies to{op: alu_op} {operand_1: reg} {operand_2: reg} => 0b11 @ op[1:0] @ operand_1[1:0] @ operand_2[1:0]- No example programs use this pattern for any register other than a. The test suite program doesn't use it at all. Every separate line in the assembler definition probably deserves at lease one test case.
I hope at least some of this makes sense and is helpful.
Metadata
Metadata
Assignees
Labels
No labels