I've been working on implementing callable words in #uxntal.
Instead of the typical PUSH->POP->JSR sequence each time you want to run a routine, these tokens are not pushing to the stack - they'll run immediately.
They'll be impractical for doing pointer arithmetic, but save 1 byte for every subroutine call, and will save millions of cycles in a project of the size of a text editor or drawing software.
They don't break compatibility with old roms, and make source files a bit more readable.
Instead of the typical PUSH->POP->JSR sequence each time you want to run a routine, these tokens are not pushing to the stack - they'll run immediately.
They'll be impractical for doing pointer arithmetic, but save 1 byte for every subroutine call, and will save millions of cycles in a project of the size of a text editor or drawing software.
They don't break compatibility with old roms, and make source files a bit more readable.
Devine Lu Linvega
Unknown parent • • •a0 12 34 = #1234, for reference
20 xx xx = !square, think JMP2
40 xx xx = ?square, think JCN2
60 xx xx = square, think JSR2
Andy Alderwick
in reply to Devine Lu Linvega • • •I'm wondering a little about JCN2… we have a lot more JCNs in the project/ dir's files (they're 18× the abundance of JCN2), so while opcode 40 does save cycles, they take up the same amount of space.
One idea that keeps coming back to me is shoe-horning in a opcode for a conditional JSR2 instead of conditional JMP2… I struggle with what the opcode's name could be, but if we use it as “?square” in Uxntal then that might not be so bad!
Devine Lu Linvega
Unknown parent • • •Devine Lu Linvega
in reply to Andy Alderwick • • •Devine Lu Linvega
in reply to Devine Lu Linvega • • •Andy Alderwick
in reply to Devine Lu Linvega • • •It's tricky to know how much having a conditional JSR would save us, because the workarounds to not having it are so varied. But I shouldn't have gone for JCN as the opcode to eliminate to make room for it! 😅
Devine Lu Linvega
Unknown parent • • •Andy Alderwick
in reply to Andy Alderwick • • •If we break out the handling of ((opcode & 0x1f) == 0x00), we could do that again for ((opcode & 0x1f) == 0x02)
Andy Alderwick
in reply to Devine Lu Linvega • • •POP is pretty rare in your pie chart too, so even if POPs were made slower to implement the extra features, that isn't that bad either.
Devine Lu Linvega
in reply to Andy Alderwick • • •Andy Alderwick
in reply to Devine Lu Linvega • • •Devine Lu Linvega
in reply to Andy Alderwick • • •https://users.ece.cmu.edu/%7Ekoopman/stack_computers/sec4_4.html
Stack Computers: 4.4 ARCHITECTURE OF THE NOVIX NC4016
users.ece.cmu.eduAndy Alderwick
in reply to Devine Lu Linvega • • •🥺 🙏
Please don't be both… not again…
Devine Lu Linvega
in reply to Andy Alderwick • • •Devine Lu Linvega
Unknown parent • • •Kira, feral fox 🦊 🏳️⚧️
Unknown parent • • •XXIIVV — uxntal reference
wiki.xxiivv.comKira, feral fox 🦊 🏳️⚧️
Unknown parent • • •instead of
;function JSR2
which assembles to "LIT $ADDR JSR2"
function
assembles to "JSI $ADDR"
The instruction looks ahead of itself and jumps to that address while saving the proper return address on the r-stack.
Devine Lu Linvega
in reply to Kira, feral fox 🦊 🏳️⚧️ • • •Devine Lu Linvega
Unknown parent • • •Reid D. M.
in reply to Devine Lu Linvega • • •Devine Lu Linvega
Unknown parent • • •~Parnikkapore
Unknown parent • • •But yeah, I think it's a better idea to keep only one. Maybe having both would be more "pona", but idk
this feels a lot like the "guix environment" vs "guix shell" situation
DHeadshot's Alt
in reply to Kira, feral fox 🦊 🏳️⚧️ • • •Doesn't that make JSR2 a redundant legacy opcode there just for compatibility? Turning into an x86 situation...
@makeworld @neauoire