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

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



On Wed, 08 Sep 2004 12:09:21 +0100, Alistair J Ross wrote:

> Hello All,
> 
> I'm playing with xKEGS today and It's quite fun. Plus it's the only A2
> emulator I've had working on my Linux box as of current writing.
> 
> 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?).

	Check out comp.sys.apple2.programmer.

> 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 don't necessarily need a full assembler to do simple programs. You
can use the poke command (from Applesoft) to put the numeric equivalent
into memory. You can also go into what is called the monitor (call -151)
and enter the equivalent hex code. If you know what you want, the
mini-assembler is quick too. You only need to use a full assembler program
when your programs get too large or complex to handle easily.

> 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.

	Easy enough. the $FDED and $FDF0 locations contain routines to output
characters to the 40 column screen. It sometimes works for the 80 column
screen too. Let's say your program is going to be located at $C00 and the
string you want to print is at $D00. Enter the mini-assembler. Your first
command does not require a leading space. All others do. Here is an
example to get you going. I'll write this with a label. The mini-assembler
will not take labels. With the mini-assembler you are going to have to
calculate addresses manually..

C00:ldx #0
Label1	lda D00,x
	cmp #0
	beq Done
	jsr FDED
	inx
	jmp Label1
Done	rts

	The string is a null terminated string. The letters to be printed are
standard ASCII + 128. If you have access to 65C02 (or newer) code the jmp
(3 bytes) can be replaced with a bra (2 bytes and no jokes please). The
mini-assembler does not require a "$" in front of hex code but most other
assemblers do.


> 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?

	This is a lot easier.

> Finally, how do I know what hex values represent which operator. In Debug,
> I'm sure that the command DB 'text' would register the string 'text', and
> you could make a loop to print the contents of it out. What are the
> operators for the 6502 (are they the ones in the red book).

	In assembly the first 128 characters are inverse are flashing/mousetext.
The second 128 are normal. In terms of programming in hex... Don't bother.
Program in mini-assembler and "bsave" the code. You can "bload" it later.
If it's a big program use a full assembler and let IT take care of the
work.

	As far as the opcodes go... Buy a book on Apple// assembly. You will
hardly need it after a couple of months.

> Many thanks in advance,
> 
> Alistair Ross

				Later
				Mike