To HLL and Back
Applying High Level Language constructs to 6502 Assembly
An occasional series by Michael Martin
This is a series of brief essays explaining how to use HLL constructs
from high-level languages to your machine language projects. It uses the
6502 chip to develop its examples, and should be of most use to fledgeling
demo/game writers for the NES or Commodore 64.
As of December 2005, the series is basically complete, but feel free to
email me comments about the
essays or to suggest additional topics.
- The Second Step: extended precision
arithmetic, and branch semantics for signed, unsigned, and extended
precision. Level: Beginner. Assumes no knowledge beyond knowledge
of what the opcodes do. Last updated 9 May 2002.
- Structured Programming: If/then/else
constructs, bounded loops (Pascal's for statement),
unbounded loops (C's for statement), non-recursive
procedures, basic use of the page 1 stack, cursor-based arrays,
records, unions, bitfields, global variables, brief coverage of
pointers and efficient looping over large areas of memory. Level:
Advanced beginner. Assumes basic knowledge of at least one
procedural language - C, Pascal, FORTRAN, or any of several advanced
BASICs. Knowledge of an object-oriented language that lets you
ignore the OO features (C++, Java with everything declared
static) should also suffice. Last updated 30 Sep
2002
- Pointers and Indirection: A more
comprehensive look at the indirect addressing modes on the 6502 chip
and how to use them to implement C-style pointers with arithmetic or
the non-computable reference types preferred by many other
languages. Level: Intermediate. Assumes a basic understanding of
all previous material. Last updated 24 Oct 2002.
- Functionals: Code pointers,
object-oriented discipline, dispatch-on-type, jump tables.
Level: Intermediate. Assumes basic familiarity with pointers,
but full command of the material in the "Indirection" essay is
not required. Basic experience with functional languages like
LISP or ML and object-oriented languages like C++ or Java may be
helpful but is not required. Last updated 16 Aug 2005.
- Call stacks. Implementing and using a
full stack, complete with procedure-local variables and allowing for
fully recursive functions. Level: Advanced. Full understanding of this
and all previous material would be basically sufficient to write a
backend for a compiler for C, Pascal, or similar languages. Last
updated 28 Nov 2005.
Back to the retrocoding page