In the second episode of the RP2040 Emulator coding live-stream we had an ambitious goal: implement UART so we can see debug prints from the simulated program.
We loaded the hello_uart example program, looked at the disassembly, and started implementing the instructions in a TDD (test-driven development) manner, similar to the first live-stream:
- LDR (Load Register) - both literal and immediate variants
- TST, which also means we had to implement the APSR (flags) register
- BNE.N - in fact, we took care of all the conditional branches!
- LDRSH
- CMP - just as with LDR, we did both literal and immediate variants
We also took care of implementing CPU Read Hooks, which allow peripherals to intercept memory reads from their mapped regions. This allowed us to mimic the behavior of the UARTFR, indicating to the simulated code that the UART hardware is ready to receive the next character.
You can watch the complete episode here:
And check out the project's code on GitHub: https://github.com/wokwi/rp2040js
If you don't want to miss out the next episode, make sure to sign up and get a reminder when it goes live!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.