[cc65] Newbie question, using cc65 for Apple II assembly

From: Mark Lemmert <mark.lemmert1gmail.com>
Date: 2015-11-15 01:39:58
Hello,

cc65 looks great from what I have seen so far! I recently learned 6502
assembly on a physical Apple IIe and have been using Liza as my compiler. I
am excited to take advantage of the great capabilities of cc65.

I am hoping somebody can offer some pointers on assembling code for the
Apple II.

I have been able to get the cc65 software installed on my windows 7 PC and
I was able to compile hello.c in the example on this intro page (
http://cc65.github.io/doc/intro.html), convert it to a disk image using
Apple Commander, and brun the program successfully using AppleWin.

However, I tried to use the hello program as a template and any assembly
code I try to write myself does not work. Does anybody have any suggestions?

Any ideas are much appreciated. Thank you!


Here is a quick overview of what I have tried:

I used the command cc65 -O -t apple2 hello.c to get a copy of the assembly
source for the example program (hello.s), included below for quick
reference.

I tried modifying hello.s by deleting the assembly code between
.segment CODE and .endproc, and adding my own code. I literally just added
one line, lda #$20, keeping the format with columns, etc. as in the
example. I also tried removing the .import statements, and various other
modifications to the text above int_near_main but nothing worked.

After making the changes to hello.s I used the ld65 tool to create the file
for apple commander, just as in the example.

My method for evaluating the results was, in AppleWin bload test, A$6000,
enter the apple monitor (call -151), enter 6000L, and observe whether the
machine instruction equivalent to my assembly code was there.



====assembly source code for hello.s====

;
; File generated by cc65 v 2.13.3
;
.fopt compiler,"cc65 v 2.13.3"
.setcpu "6502"
.smart on
.autoimport on
.case on
.debuginfo off
.importzp sp, sreg, regsave, regbank, tmp1, ptr1, ptr2
.macpack longbranch
.forceimport __STARTUP__
.import _printf
.import _text
.export _main

.segment "RODATA"

L0001:
.byte $25,$73,$0A,$00

; ---------------------------------------------------------------
; int __near__ main (void)
; ---------------------------------------------------------------

.segment "CODE"

.proc _main: near

.segment "CODE"

lda #$20
lda     #<(L0001)
ldx     #>(L0001)
jsr     pushax
lda     #<(_text)
ldx     #>(_text)
jsr     pushax
ldy     #$04
jsr     _printf
ldx     #$00
txa
lda #$20
rts

.endproc

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Nov 15 01:40:07 2015

This archive was generated by hypermail 2.1.8 : 2015-11-15 01:40:09 CET