Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.apple2.programmer > #870
| From | "Bill Buckels" <bbuckels@mts.net> |
|---|---|
| Newsgroups | comp.sys.apple2.programmer |
| Subject | Aztec C AS65 assembler and BRUNABLE program Example available for download |
| Date | 2013-09-15 21:25 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <l15q6a$uuo$1@speranza.aioe.org> (permalink) |
Now available for download at the following link:
http://www.aztecmuseum.ca/extras/AS65BIN.zip
Just unzip into your AppleX/PROGRAMS directory and you can muck with this to
your heart's content.
This post is not really about building C Programs. It is more about using
the Aztec AS65 cross-assembler to build pure little assembly programs in MOS
6502 and 65C02. Aztec C65 is a 2 pass compiler. Everything in C is
translated to assembler then assembled so the assembler is also targetted at
complicated segmented programs, but that doesn't mean you can't make simple
programs with it... you just need to RTFM and then ignore anything that does
not apply (as always)! This is admittedly a little like running over a fly
with a semi-truck but what the heck!
This example uses a simple Assembly Language program (a Hello World program)
and the Aztec C65 assembler and linker to create a tiny (28 byte) BIN file
that can be loaded and run in either BASIC.SYSTEM or from within an Aztec C
SYS program (also provided). Comes with disk images and source code.
The Hello World program is as follows:
x--- snip ---x
; Hello.a65
;
; Hello World in Aztec C's AS65 assembler
; By Bill Buckels 2013
;
; BRUN from BASIC.SYSTEM or load and run in
; an Aztec C65 ProDOS SYS program.
;
; Note: There is no ORG command in AS65 because the Aztec C
; Linker sets the BASE Address, and the Address for the
; CODE and DATA segments... in this case they are all
; the same: $1000
; AS65 hello.a65
; LN65 -O hello.bin hello.r -b 1000 -C 1000 -D 1000
; AS65 does not know about commands for the Apple II Monitor
; So I have used an equate for COUT
COUT EQU $FDED
; I have kept everything in one segment... that's all
; we need for a simple program.
CSEG
LDX #12 ; load pointer to end of string into X
LOOP LDA MSG,X ; load character at pointer into A
ORA #$80 ; set hi-bit for ascii string ( |= 0x80)
JSR COUT ; print the character
DEX ; decrement string pointer
BPL LOOP ; branch on plus, loop until X is negative
RTS ; return to BASIC (or Aztec C)
MSG FCC "!DLROW ,OLLEH"
END
x--- snip ---x
The C Program to load and run the above is as follows:
#include <fcntl.h>
brun(name)
char *name;
{
int fh;
/* load subroutine */
if ((fh = open(name,O_RDONLY,0xc3))==-1) return -1;
read(fh,(char *)0x1000,0x1000);
close(fh);
#asm
jsr $1000 ; call subroutine
#endasm
return 0;
}
main()
{
crt80();
brun("HELLO.BIN");
getch();
_exit();
}
Not much more to say about this one except that I have been somewhat terse
and arbitrary, but bedtime draws near. I should mention that I bload the BIN
program at the page starting at $1000 below $2000 which is where the SYS
programs go (see above).
The assembler manual is included in the documentation for the 3.2b compiler
available from the Aztec C website.
That's about it. I guess a person could write a bunch of these little
programs and just page them in and out of auxmem as needed by a larger
program instead of using overlays, but that is a topic for another evening.
All the best,
Bill
Back to comp.sys.apple2.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Aztec C AS65 assembler and BRUNABLE program Example available for download "Bill Buckels" <bbuckels@mts.net> - 2013-09-15 21:25 -0500 Re: Aztec C AS65 assembler and BRUNABLE program Example available for download "Bill Buckels" <bbuckels@mts.net> - 2013-09-16 18:09 -0500
csiph-web