[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 'Hello world' for monitor mode and an assembler?



Alistair J Ross wrote:

>I'm looking for a little piece of advice from someone who has knowledge of
>writing low level code on the Apple II (Michael Mahon?).

Thanks, Alistair, but I'm sure there are quite a few folks who
frequent this forum who have more A2 coding experience than
I do.  ;-)

Your curiousity andf enthusiasm for learning to use the Apple II
at the machine language level is the major requirement for 
success, and you already have it!

>Basically I want to learn the very basics of the 6502, but more
>particularly, just how to code on the machines level. I know a number of
>high level languages, but every time I go to low level I get confused
>between typing programs into an assembler (I take it I need to get an
>assembler to do this?), and maybe finding out how to just entering the hex
>into the monitor to get the program running. If I need an assembler, what
>one should I use?

You will certainly want an assembler as you begin to write programs
more than a few lines long.  An assembler provides a symbolic way
to create machine code that allows you to easily make changes.

The mini-assembler built into the enhanced //e and IIgs monitors
provides some assistance, such as translating between mnemonics
and hex opcodes and calculating branch displacements, but it does
not provide any capability for labelling data or code, instead requiring
you to keep track of the addresses corresponding to things on a
separate piece of paper.  Since addresses typically change whenever
any code is inserted or removed from a routine, the manual bookkeeping
required to document and modify code created with the mini-assembler
becomes quite onerous for longer routines.

>All I want to do at the moment is enter the monitor (from call-151) and
>type a 'hello world' program which dumps me back to the prompt. However, I
>would love to have a line-by-line step through. I've looked everywhere on
>the net for such a thing and I can't find that little kickstart I need. I
>even bought the Apple II 'Red Book' Reference from Ebay, but it doesn't
>really cover this.
>
>The only time I ever did assembler was using DEBUG in MS DOS a long time
>ago. Now was that assembler, or was that just adding raw hex into the
>system for it to do stuff? Or am I completely confused?

No, you are very close to a correct understanding of what's going on.

The Apple monitor and mini-assembler are similar in many respects
to the MSDOS DEBUG routine.  Both allow you to examine and change
the contents of memory and call programs in memory.

Once you enter the Apple monitor by typing "call-151<return>", you
will see the monitor prompt, the asterisk (*).  This prompt means that
whatever you type in will be interpreted by the monitor (and not by some
other program, like Applesoft BASIC).

Since you have the Red Book (and probably an Apple Reference Manual),
you already have documentation of the commands accepted by the monitor
and what they do.  This would be good to review if you have not already
done so.

You may also know that the lower part of "page 3", the region of memory
from $0300 to $03CF, is commonly used for short machine language
programs, because it is unused for other purposes.