Hacker News new | past | comments | ask | show | jobs | submit login

On the Commodore 64, it was the only option. It had minimal support for a thing it called a "subroutine", but what it really was was a GOTO that pushed the source on to the stack and could be RETURN'd to that source. In particular, no concept of return value, no concept of parameters; everything's global. Modification of global values prior to the "call" is the argument passing, and modification of global values is the "return".

Commodore 64 BASIC, and 8-bit BASIC in general, was fully in the paradigm that Dijkstra was referring to when he wrote Goto Considered Harmful. (Not exclusively, of course.)




The 6502 processor itself also has very poor "stack" support, the hardware-supported stack is limited to 256 bytes at a fixed location. It's one of the things that make it hard to compile a modern language like C for the architecture, so even among compiled languages one would prefer something FORTRAN/BASIC-like.


To be fair, the 256 byte stack can essentially be used in assembly as 256 registers, which is also one of the features (along with indirect addressing) that make assembly on it awesome.

My relatively poorly researched impression of it is that it's half-way to portable C, with a proto-stack and pointers, essentially.


You're thinking of zero page ($0000-$00ff), not the stack $0100-$01FF).


Yes I am! Thanks!


The on-chip stack on the 6502 was not intended to be used for implementing the stack for programming language procedure calls; it was intended to provide system extension functions that provide things missing in the 6502 instruction set,(for example, multiply), which had to be implemented with multiple instructions. For "modern" languages like C, 16-bit 2's complement integer arithmetic was expected but the 6502 native instructions were for 8-bit numbers.


It was “GOSUB” if I remember correctly!! Ah good old times!!




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: