Skip to content
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

printf() incorrectly formats numbers (Arduino Mbed Core) #24

Closed
urish opened this issue May 13, 2021 · 1 comment
Closed

printf() incorrectly formats numbers (Arduino Mbed Core) #24

urish opened this issue May 13, 2021 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@urish
Copy link
Contributor

urish commented May 13, 2021

To reproduce, compile the following sketch using the Arduino Mbed Core for RP2040:

void setup() {
  printf("12 is %d\n", 12);
}

void loop() {}

Then run the result in the emulator. This will print to the serial console:

12 is <

Instead of the expected result, 12 is 12.

@urish urish added the bug Something isn't working label May 13, 2021
@urish urish self-assigned this May 13, 2021
@urish
Copy link
Contributor Author

urish commented May 14, 2021

Traced the issue to our LSRS (register) implementation.

Pre-compiled HEX file (of the above) sketch that reproduces the issue: test-printf.ino.hex

Unit test case (passes on the actual silicone, fails in the emulator):

  it('should return zero for `lsrs r2, r3` with 32 bit shift', async () => {
    await cpu.setPC(0x20000000);
    await cpu.writeUint16(0x20000000, opcodeLSRSreg(r2, r3));
    await cpu.setRegisters({ r2: 10, r3: 32 });
    await cpu.singleStep();
    const registers = await cpu.readRegisters();
    expect(registers.r2).toEqual(0);
    expect(registers.Z).toEqual(true);
    expect(registers.C).toEqual(false);
  });

@urish urish closed this as completed in e5b93a3 May 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant