3 ms·
Part of the tedium is only having a few registers so programming in assembly begins to resemble solving the towers of Hanoi puzzle. But, it's certainly somethi
by JustSomeNobody 9y ago
Part of the tedium is only having a few registers so programming in assembly begins to resemble solving the towers of Hanoi puzzle. But, it's certainly something every programmer should give a try at some point, if for no other reason than just a mental exercise.
- wolfgke 9y ago> Part of the tedium is only having a few registers so programming in assembly begins to resemble solving the towers of Hanoi puzzle. Solving the towers of Hanoi puzzle can be done completely mechanically (exercise: derive the really simple algorithm). Programming in such a constrained environment is something where you have to think for yourself, since I am not aware of any mechanical solution.
- jontro 9y agoA mechanical solution would be using other languages like C
- wolfgke 9y agoUsing C you cannot get the advantages that 6502 assembly provides. On the other hand, to stay with towers of Hanoi, one can show that the simple mechanical algorithm that one can derive for it, will solve the problem with a minimum possible number of moves.
- mywittyname 9y agoSo, what the c compiler does.
- rbanffy 9y ago> resemble solving the towers of Hanoi puzzle That's the relaxing part.
- SilasX 9y agoHave you done http://nand2tetris.org http://nand2tetris.org ? It involves (virtually) building up a CPU that has two registers, which I'm guessing the minimum possible.
- rbanffy 9y agoYou'll need some internal state (one register?) and a program counter. If instructions are long enough, you can encode the address of the next instruction in the instruction itself (sort of a perverse VLIW where everything ends with a jump to a given address) and ditch the program counter. You can make tests destructive, so your status bits end up overwriting the register - it would force some "interesting" programming techniques, but it seems doable. But remember: there is always a lot of state flying around that's not exposed to the programmer through architectural registers.
- a1369209993 9y agoYou could make every operation of the form (op src dst nxt). Something like https://codegolf.stackexchange.com/questions/11880/build-a-working-game-of-tetris-in-conways-game-of-life https://codegolf.stackexchange.com/questions/11880/build-a-w..., where results are always written to ram and 'register' indexes are just addresses. You'd still need some transient/architectural registers to hold the current instruction/memory address/alu input-output on its way though the cpu though.