Post B1EYGess7ZXVNUp1ge by harold@mastodon.gamedev.place
(DIR) More posts by harold@mastodon.gamedev.place
(DIR) Post #B1EYGess7ZXVNUp1ge by harold@mastodon.gamedev.place
2025-12-14T07:57:54Z
0 likes, 0 repeats
Imagine a processor that can push and pop relatively efficiently, but cannot efficiently do random-access on the stack. Also, you only have approximately 3 and half registers. You can swap one of them with top-of-stack but it's on the slower side. Or don't imagine, because it's real..Hypothetically (or not), how would you deal with that in a compiler?(allocating local variables globally and making functions non-reentrant is considered cheating)
(DIR) Post #B1EYGh02FuSRwIBm88 by wolf480pl@mstdn.io
2025-12-14T08:35:01Z
0 likes, 0 repeats
@haroldmale a compiler for a language with no variablesor for a purely functional, language, and inline all variables at compile time
(DIR) Post #B1EYLxvOku2vsbXBnk by wolf480pl@mstdn.io
2025-12-14T08:36:01Z
0 likes, 0 repeats
@haroldalso, is his processor evn turing-comlete?
(DIR) Post #B1EZ4SM0yu5mzpCOC8 by harold@mastodon.gamedev.place
2025-12-14T08:44:02Z
0 likes, 0 repeats
@wolf480pl yes, in the sense in which that is usually meant, or you could consider it a finite state machine with a lot of states (this is usually not a productive debate..)
(DIR) Post #B1EZESaIylusbgeYXw by wolf480pl@mstdn.io
2025-12-14T08:45:52Z
0 likes, 0 repeats
@haroldoh, because you can access arbitrary stack offsets, it's just slow?
(DIR) Post #B1EZH4awd2gZ4aCM2C by wolf480pl@mstdn.io
2025-12-14T08:46:21Z
0 likes, 0 repeats
@haroldor do you have some RAM in addition to the stack?
(DIR) Post #B1EZRA0lLThYle5IY4 by harold@mastodon.gamedev.place
2025-12-14T08:48:08Z
0 likes, 0 repeats
@wolf480pl both, it's just that there's no built-in addressing mode for "load/store to stack but with an offset" and you have to do some silly manual computation of the address and sacrifice a register to do that in
(DIR) Post #B1EZgABD08eBdM7lwm by wolf480pl@mstdn.io
2025-12-14T08:50:52Z
0 likes, 0 repeats
@haroldok, what addressing modes do I have?
(DIR) Post #B1Ea4aHxa3djYivXfM by harold@mastodon.gamedev.place
2025-12-14T08:55:14Z
0 likes, 0 repeats
@wolf480pl spoiling the mystery but it's an 8080
(DIR) Post #B1EallWNh4nmqfGMIy by wolf480pl@mstdn.io
2025-12-14T09:03:06Z
0 likes, 0 repeats
@haroldok so absolute and register-indirect, but no base+offset :/ I'd use the start of RAM as extra registers
(DIR) Post #B1FeGr1Nmy1tu7EtvM by ignaloidas@not.acu.lt
2025-12-14T21:17:02.260Z
0 likes, 0 repeats
@wolf480pl@mstdn.io @harold@mastodon.gamedev.place FWIW turing machines arguably work kinda like this, since the memory is not random access, so it's certainly quite comparable
(DIR) Post #B1Fes23BkI44pCoOFk by wolf480pl@mstdn.io
2025-12-14T21:23:45Z
0 likes, 0 repeats
@ignaloidas @harold Yes, but a stack machine is strictly weaker than a turing machine. To simulate a real turing machine you need at least 2 stacks that you can independently pop and push.