RE: [cc65] Possible bug: All labels but first are added to .s file using inline assy

Date view Thread view Subject view

From: Greg Long (cc65_at_maneuveringspeed.com)
Date: 2003-03-08 07:20:05


The problems I reported seem to be indeed as reported, however, I now
realize that the cc65 assembler does not have all its labels global,
unlike assemblers I worked with back in "The Day" listening to the
latest Guns&Roses or that brand new band, Pearl Jam.

So, my goal of being able to call inline assembly from other functions
containing inline assembly won't work.  I guess I'm going to have to use
the Macro assembler for these and declare these functions global.  I'll
start playing with the assembler and dive into the docs.

Still, inline labels do seem to have issues.

-----Original Message-----
From: owner-cc65_at_musoftware.de [mailto:owner-cc65_at_musoftware.de] On
Behalf Of Greg Long
Sent: Friday, March 07, 2003 9:17 PM
To: cc65_at_musoftware.de
Subject: [cc65] Possible bug: All labels but first are added to .s file
using inline assy


Playing around to learn using C and Assembly together, it occurred to me
it would be nice to have a hexout routine I can call both from C and
from Assembly.  Note the C code calls the assembly code.

The code is not ideal, but that's not the point here.  I'm using the c64
cassette buffer as an area to communicate between assembly and C, which
works for now. The problem is, in this example, hexoutchr label is not
inserted into the assembly code at compile time.  I am NOT using -O to
optimize.

As you can tell, I was able to successfully use labels together, but
there are issues: they seem to not completely ignore whitespace...I
found deleting tabs after the "bcc hexoutchr1" line enabled it to
resolve as local and not external (the latter of which generated an
error).

.c file first, .s file to follow:



//source
char hexout_char(unsigned char c)
{
	POKE(998,c);

	asm("jsr hexoutchr");
	return 0;

	//first digit
	asm("hexoutchr: 	nop");
	asm("			lda 998			");
	asm("			lsr				");
	asm("			lsr				");
	asm("			lsr				");
	asm("			lsr				");
	asm("			ora #48			");
	asm("			cmp #58			");
	asm("			bcc hexoutchr1");
	asm("			clc				");
	asm("			adc #7			");
	asm("hexoutchr1:	jsr $ffd2");

	//second digit
	asm("			lda 998			");
	asm("			and #15			");
	asm("			ora #48			");
	asm("			cmp #58			");
	asm("			bcc hexoutchr2");
	asm("			clc				");
	asm("			adc #7			");
	asm("hexoutchr2:	jsr $ffd2		");
	asm("			rts				");

}
//end source

; ---------------------------------------------------------------
; unsigned char hexout_char (unsigned char)
; ---------------------------------------------------------------

.segment	"CODE"

.proc	_hexout_char

	ldy     #$00
	lda     (sp),y
	sta     $03E6
	jsr     hexoutchr
	ldx     #$00
	lda     #$00
	jmp     L0166
	nop			;NOTE MISSING LABEL 'hexoutchr' here.
	lda     998			
	lsr
	lsr
	lsr
	lsr
	ora     #48			
	cmp     #58			
	bcc     hexoutchr1
	clc
	adc     #7			
hexoutchr1:
	jsr     $ffd2
	lda     998			
	and     #15			
	ora     #48			
	cmp     #58			
	bcc     hexoutchr2
	clc
	adc     #7			
hexoutchr2:
	jsr     $ffd2		
	rts
L0166:	jsr     incsp1
	rts

.endproc

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-03-08 07:21:00 CET