Re: [cc65] Macros in inline assembler

From: Oliver Schmidt <ol.sc1web.de>
Date: 2012-01-19 21:03:08
Hi Uz,

>> However to work with the inline assembler you
>> have to turn off the C compiler optimizations [...]

> That's not true. For normal code, there's nothing that the optimizer will
> change. One exception is inline asm code that reads or writes volatile memory,
> a second one is self modyfying code. In both cases, this is not an inline
> assembler problem, C code won't work either.

Compiling the code below with -O has the line marked removed. I don't
see the code falling into one the two categories.

Regards,
Oliver

--------------------------------------

#include <stdlib.h>

static unsigned char flames[8*17];

void fire_burn(void)
{
  asm("ldy #$00");
loop1:
  asm("lda %v+7,y", flames);
  asm("clc");
  asm("adc %v+8,y", flames);
  asm("adc %v+9,y", flames);
  asm("adc %v+16,y", flames);
  asm("lsr");
  asm("lsr");
  asm("sta %v,y", flames);
  asm("iny");
  asm("cpy #(8*15)");
  asm("bne %g", loop1);
  asm("ldy #$05");  // removed by optimizer
loop2:
  asm("jsr %v", rand);
  asm("and #$0F");
  asm("sta %v+8*15+1,y", flames);
  asm("dey");
  asm("bpl %g", loop2);
}
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Jan 19 21:03:17 2012

This archive was generated by hypermail 2.1.8 : 2012-01-19 21:03:20 CET