-
Notifications
You must be signed in to change notification settings - Fork 47
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
exercise: reimplement writing a string to a stream #22
Conversation
The `write` function is pretty foundational, so many tests now fail. Focus on the immediately failing tests: $ subx translate 05[0-7]*.subx -o a.elf && subx run a.elf test If these pass then everything else should, as well.
I'm switching to a more exposed working dynamic after chatting with Charles Saternos (#19). From now on I'll start a new branch for big features. Branches won't always pass all their tests. Phases have gone weeks in the past before being committed all at once. Developing in a branch gives others the opportunity to see more current progress and jump in more easily. Some 'kata' branches for new contributors to start at: * add two numbers: #21 * write a string to a byte stram: #22 * print a number in decimal to a byte stream: #20
I'm switching to a more exposed working dynamic after chatting with Charles Saternos (#19). From now on I'll start a new branch for big features. Branches won't always pass all their tests. Phases have gone weeks in the past before being committed all at once. Developing in a branch gives others the opportunity to see more current progress and jump in more easily. Some 'kata' branches for new contributors to start at: * add two numbers: #21 * write a string to a byte stram: #22 * print a number in decimal to a byte stream: #20
I'm switching to a more exposed working dynamic after chatting with Charles Saternos (#19). From now on I'll start a new branch for big features. Branches won't always pass all their tests. Phases have gone weeks in the past before being committed all at once. Developing in a branch gives others the opportunity to see more current progress and jump in more easily. Some 'kata' branches for new contributors to start at: * add two numbers: #21 * write a string to a byte stram: #22 * print a number in decimal to a byte stream: #20
I'm switching to a more exposed working dynamic after chatting with Charles Saternos (#19). From now on I'll start a new branch for big features. Branches won't always pass all their tests. Phases have gone weeks in the past before being committed all at once. Developing in a branch gives others the opportunity to see more current progress and jump in more easily. Some 'kata' branches for new contributors to start at: * add two numbers: #21 * write a string to a byte stram: #22 * print a number in decimal to a byte stream: #20
OK, definitely a good intro to streams/strings structures. Besides burning 3 hours trying to track down a silly bug because I mistakingly thought I'd written a 12-byte offset but it was in base-16 (should have been 0xc, not 12) it was pretty straightforward. |
Excellent work! How did you track down the bug? |
I labeled each line of assembly, and checked the output in the trace to ensure it was doing what I expected. e.g.
The trace basically had all the info I needed, I just didn't see it the first few times around. If the trace dumped the comments above the current instruction that'd add the extra metadata to the trace that I needed to identify which instructions were the ones I cared about (perhaps tracing comments with the prefix of DEBUG, or adding a pseudo instruction could help with this?). BTW, Is this implementation making the bootstrap step fail? |
Yeah, I saw the CI failure. Since I'm bundling binaries for the examples it seems useful to ensure they're in sync. Basically I have reproducible builds for some very small examples. The way to keep |
You're right that I've often wished I could print out the current instruction in its entirety. So far it's seemed to take a lot of (duplicate) code, but maybe I should just bite the bullet. One compromise is support for tracing the name of function labels in Unfortunately comments don't make it to the ELF binary. So I'm not sure how I'd add them. |
Maybe I should create a |
The trace now shows source lines where possible! Try it out. Do a
(I renamed the The commit: 02684e8 |
I'm switching to a more exposed working dynamic after chatting with Charles Saternos (#19). From now on I'll start a new branch for big features. Branches won't always pass all their tests. Phases have gone weeks in the past before being committed all at once. Developing in a branch gives others the opportunity to see more current progress and jump in more easily. Some 'kata' branches for new contributors to start at: * add two numbers: #21 * write a string to a byte stram: #22 * print a number in decimal to a byte stream: #20
To see the failing tests:
Feel free to push changes to this branch as you like.
This exercise should get you thinking about arrays and streams of bytes, a couple of foundational data structures for us. It should also focus attention on the couple of instructions in
subx help opcodes
that operate onr8/m8
values.The
write
function is pretty foundational, so many tests now fail in the project as a whole. The above command focuses on the immediately failing tests. If these pass then everything else should, as well.When (when!) you need to debug things, go back and reread https://github.com/akkartik/mu/blob/master/subx/Readme.md#a-few-hints-for-debugging. And, of course, feel free to email me.