cpu/f2mc16: Add and fix several instructions #12427
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Added instructions required to emulate Tomy Prin-C. Also added some fatal errors in order to not silently ignore missing instructions.
The following bugs were fixed:
ADD A, #imm8
/SUB A, #imm8
: bits 8 to 15 of A must be zero-extended;ADDL A, @RWx + disp8
/SUBL A, @RWx + disp8
/CMPL A, @RWx + disp8
/ANDL A, @RWx + disp8
: 8-bit displacement fetched as 4 instead of 1 byte;ADDSP #imm8
: 8-bit immediate must be sign-extended;BLE
/BGT
/BHI
: Operatoror
must have precedence over checked condition value;EXT
: Z flag was set on PC instead of PS;MOVW @RWx + disp8, #imm16
: 8-bit displacement fetched as 2 instead of 1 byte;MOV A, @RWx + RW7
/MOV @RWx + RW7, A
: PC incremented by 3 instead of 2 bytes;MOV @RWx + RW7, #imm8
: Operand fetched with 3-bit instead of 1-bit mask, also missing fetch to 8-bit immediate (reused previous variable value);MOVSI ADB, DTB
/FILSI ADB
: Only first loop iteration was computed, and PC was only conditionally set (also took the chance to generalize these instructions for all banks);MOVW @RWx + disp16, #imm16
/ADD @RWx, A
/ORW A, @RWx
: Operand fetched with 7-bit instead of 3-bit mask;MOVX A, @RWx + disp8
: missing NZ flags update;Adjusted instructions with incorrect number of cycles:
ASRW A, R0
/LSRW A, R0
/LSR A, R0
: used 5 instead of 1 additional cycles per iteration;LSLL A, R0
: 6 cycles were discounted again when R0 != 0;