wiz-lang / wiz

A high-level assembly language for writing homebrew software and games on retro console platforms.
http://wiz-lang.org/
Other
409 stars 40 forks source link

Improve mode-switch attributes for 65816 #74

Open Bananattack opened 5 years ago

Bananattack commented 5 years ago

Right now on 65816, you can annotate the expected register-size mode for given block with compile-time attributes, and you can switch modes with various register-size switching run-time commands. It would be nice to have a block attribute that mixes the compiled+run-time aspects together. The proposed attributes would automatically switch modes on block entry, and switch back to the old mode of the enclosing block on scope exit (or back to the function's calling convention on return).

The mode used will be a statically determined / scope-informed at compile-time only, and generate code to perform a switch between known states using this static/lexically-scoped mode at run-time. Any stack-style push/pop of the register mode flags would be done manually (or maybe a distinct attribute that wraps a block in a push/pop of these flags)