Closed binji closed 6 years ago
Thanks for the feedback!
Thanks again, i'll update the specs as soon as i find a spare hour :)
I think you get unsigned mul for free, since it's sign-agnostic as long as you assume 2's complement.
i added ports as a polling and blocking workaround. i think for most things this will be sufficient.
Ah, I didn't notice that port_read is blocking. OK, seems like it could work :-)
sp always points at the last pushed value, so for pop i have to read, then subtract
That doesn't line up with how you define push currently:
Write the 32-bit value word2 to the stack at address sp, then decrease sp by 4
Sadly, ou only get addition/substraction for free :/
I'm gonna fix up the push semantics!
Nope, multiply works too! We use that fact in WebAssembly. You can also see that the same code is generated in godbolt.
Ah, I remembered x86 imul
and assumed there was a reason for it that I can't ignore.
I do need signed/unsigned cmp
though!
Yeah, the high 32-bits and flags only make sense for signed, but the low 32-bits are the same for signed or unsigned. And you're right about cmp!
Though you could make the argument that having unsigned makes things more complicated. AIUI Java originally had only signed integers (Though it sounds like they have some support for unsigned now) and I guess it mostly works. I found this SO answer that mentions the design choice.
Since Wee is supposed to be a learning environment, I believe it's important to expose students to two's complement. Having the defaults signed, but offering unsigned variants when necessary seems like a good compromise imo.
I've added:
cmp
and consorts work (NaN & Infinity handling TBD)stackalloc
to simplify stack allocationReally appreciate that you took the time to give feedback on this somewhat dry matter. Thanks!
Hi, just saw your twitter post and thought I'd take a look!
First off, this is very cool!
Some initial thoughts/comments:
bits 10-13
I think?mov <bytes>, rn; sub sp, rn, sp
which uses an extra register.