TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ways to implement computer languages on 6502s (1994)

132 pointsby 6502nerdfaceover 8 years ago

12 comments

colandermanover 8 years ago
Well, how much say do we have over the architecture? Paging&#x2F;banking hardware is pretty common on 6502-based systems. Such hardware decouples the virtual address space (what the CPU sees) from the physical address space. Typically they are used to extend memory space (e.g. the Apple &#x2F;&#x2F;e&#x27;s 80-column card) but they can also be used as a mass indirection mechanism (e.g. the NES&#x27;s various &quot;mappers&quot;, which granted are used more by its graphics coprocessor). The act of paging is &quot;instantaneous&quot; since you are just setting a hardware register.<p>So if you are designing the hardware, give it an extra 4 KiB or so (16 pages), mapped through a paging circuit to the zero page. On entry to a function, increment the current page; on exit, decrement. Now you have a way to push all &quot;local variables&quot; that is faster than even pushing all the registers. You could even get fancy and XOR bits 7-4 of the page register with bits 4-7 of the paged address lines, so the compiler can choose anywhere from 16 256-byte frames up to 256 16-byte frames.
评论 #12538885 未加载
russellsproutsover 8 years ago
Coincidentally, I was just reading this the other day. I&#x27;ve been programming for the Nintendo NES. The most common high level language that people use for NES Homebrew development is C with cc65[1]. The output of the compiler is passable, but C is just not well suited to the 6502 processor. Eventually I&#x27;d like to write a compiler for a high level language that used these ideas.<p>[1] <a href="http:&#x2F;&#x2F;cc65.github.io&#x2F;cc65" rel="nofollow">http:&#x2F;&#x2F;cc65.github.io&#x2F;cc65</a>
评论 #12536690 未加载
评论 #12539393 未加载
评论 #12537882 未加载
keithnzover 8 years ago
I remember... WAY back in the day... On the Ataris there was a language called Action! It was pretty good!<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Action!_(programming_language)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Action!_(programming_language)</a>
评论 #12538504 未加载
评论 #12537489 未加载
cmrdporcupineover 8 years ago
&quot;Use fixed zero page locations for locals and parameter passing, simulating a conventional CPU with a large register file. This eliminates most stack operations, except for saving&#x2F;restoring the zero page&quot;<p>The 65c816 allows the &quot;zero page&quot; (called the direct page there) to be relocated anywhere in the lower 64k. So if one targets that platform the saving&#x2F;restoring operation could simply be one of pushing&#x2F;popping the direct page location to&#x2F;from the stack when entering or exiting function stack frames. Then just keep all program code above the 64k boundary.
PieterHover 8 years ago
I implemented a forth based language on C64 in 1983, it was tiny and fast. The 6502 was well suited to this. The REPL nature of forth languages is also perfect for machines with limited offline storage.
larsbrinkhoffover 8 years ago
&gt; I wanted a language that would be (a) faster to program in (than assembly) but be (b) fast when running. It needed to be pretty efficient.<p>Forth. Problem solved.
评论 #12538444 未加载
评论 #12537949 未加载
djmipsover 8 years ago
Not 6502 but the Zardoz 65816 compiler from back in the day (early nineties) had different memory models and one of the best allowed you to use the direct page register (essentially a moveable zero page) to access local variables in your functions. If you made some concessions to how you coded your C, you could end up with reasonably efficient code all things considered. It would be pretty cool to see a C like language that compiled efficiently for a stock 6502.
6502nerdfaceover 8 years ago
The author has more notes on the same topic elsewhere on his website, too (including reviews of Forths for 6502, PLASMA, and others): <a href="http:&#x2F;&#x2F;www.dwheeler.com&#x2F;6502&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.dwheeler.com&#x2F;6502&#x2F;</a>
nemoniacover 8 years ago
So if you implemented a lisp on the 6502, you could run it on this emulator and then it&#x27;d be turtles all the way down?<p><a href="https:&#x2F;&#x2F;github.com&#x2F;kingcons&#x2F;cl-6502" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kingcons&#x2F;cl-6502</a>
wobbleblobover 8 years ago
I once had a pascal compiler for a 6502 machine:<p><a href="http:&#x2F;&#x2F;www.acornelectron.co.uk&#x2F;info&#x2F;electron&#x2F;acornsoft&#x2F;Spascal.html" rel="nofollow">http:&#x2F;&#x2F;www.acornelectron.co.uk&#x2F;info&#x2F;electron&#x2F;acornsoft&#x2F;Spasc...</a>
评论 #12538522 未加载
评论 #12539244 未加载
orionblastarover 8 years ago
I think 6502 machines can do better with a version of BASIC that can compile into machine language binary files. One that has advanced commands for moving sprites and checking for collisions, etc. A BASIC compiler if you will?
评论 #12540916 未加载
评论 #12538105 未加载
评论 #12538076 未加载
评论 #12537003 未加载
评论 #12537422 未加载
pmontraover 8 years ago
This is a 2009 revision of a 1994 article.