Re: [cc65] putting "unknown" opcodes into __asm__()

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2008-08-15 23:25:23
Hi!

On Fri, Aug 15, 2008 at 01:02:59AM +0200, Gábor Lénárt wrote:
> I would like to test a self made emulator which knows some "faked" opcodes.
> My software is written in C, and I would like to use internal assembler of
> CC65 to put these fake opcodes, however cc65 reported that .BYTE is not
> supported in internal assembler. However since they're not a valid 6502
> opcode, I am not able to do it otherwise. Is there a way to use custom byte
> stream as the part of the code in the internal assembler of cc65?

There is now way to introduce random bytes using the inline assembler, because
the backend analyzes the code and this wouldn't be possible if arbitrary data
could be inserted.

Maybe abusing data is a possibility? For example:

    static char code[] = {
        0xA9, 0x00,             /* lda #$00 */
        0xA2, 0x00,             /* ldx #$00 */
        0x60                    /* rts */
    };

    static void call_code (void)
    {
        __asm__ ("jsr %v", code);
    }

    int main (void)
    {
        ((void (*)(void)) code) ();
        call_code ();
    }

You can either call the code from inline assembler, or call the code by
casting a pointer to the data to a function pointer.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Aug 15 23:27:11 2008

This archive was generated by hypermail 2.1.8 : 2008-08-15 23:27:13 CEST