-
Notifications
You must be signed in to change notification settings - Fork 5
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
Using Local variables #23
Comments
Ah, this would be for local |
It's hard to use We'd probably have to compile two "versions" of every function, one using |
Ah yes, that'll be tricky. Probably not worth it then.
Ah! okay I think I originally misunderstood how variables were accessed between functions. I think there might still be a usecase for globals, maybe. For example in this screenshot, the LDA2 could be replaced by the actual place where the global is stored, keeping LDA/STA for the rest of the accessing points should keep working. It would make for a smaller program, and one access to a global will be slightly faster. It might make the keeping of address of the variable in memory through optimization passes more of a headache tho. |
Hi,
First off, following the changes to chibicc is exhilarating! Amazing work you two.
The following suggestion is taking advantage of not using Harvard Achitecture, I was wondering if maybe instead of storing all the variables after the
main()
jump, it would be possible to store the variables locally. What I mean by that is that you could store the variable where it is first(or most frequently requested) as a literal, and have the variable pointer be at the location of that literal.For example, here, the
timer
variable is stored localy and not only does it not need to be loaded(it's already a literal) - It can also be written using a single byte with STR.The text was updated successfully, but these errors were encountered: