-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rp2040): Fix CMP reg T1 #31
Conversation
Please be patient, one Day I'll learn how to PR only the relevant commits... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for finding all these small flag bugs in the emulator :)
I've added some comments!
src/instructions.spec.ts
Outdated
await cpu.writeUint16(0x20000000, opcodeCMPregT1(r2, r0)); | ||
await cpu.setRegisters({ r0: 0xb71b0000 }); | ||
await cpu.setRegisters({ r2: 0x00b71b00 }); | ||
await cpu.setRegisters({ xPSR: 0x61000000 }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of setting xPSR directly, let's set the specific flags (like we did in the "should execute add sp, r8
instruction and not update the flags" test case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, we can have a single call to setRegisters setting all the registers at once (instead of one call per register)
src/instructions.spec.ts
Outdated
@@ -469,6 +469,19 @@ describe('Cortex-M0+ Instruction Set', () => { | |||
expect(registers.V).toEqual(false); | |||
}); | |||
|
|||
it('should execute an `cmp r2, r0` instruction', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the test name more specific, like: "should execute an cmp r2, r0
instruction and not set any flags when r0=0xb71b0000 and r2=0x00b71b00"
if you need any help with that let me know |
src/instructions.spec.ts
Outdated
@@ -469,6 +469,18 @@ describe('Cortex-M0+ Instruction Set', () => { | |||
expect(registers.V).toEqual(false); | |||
}); | |||
|
|||
it('should execute an cmp r2, r0 instruction and not set any flags when r0=0xb71b0000 and r2=0x00b71b00', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, one more small thing: please add backticks (`) around the instruction name, like in the other tests
found a specific test where CMPregT1 wrongly set the carry