Page 1 of 1

Mixing C and asm?

Posted: Mon Mar 08, 2010 8:22 pm
by FluBBa
Is it possible to mix C with asm using HuC, are there any examples on how to do it?

I'm trying to reverse-enginer the arcadecard and cd-rom, documenting as much as possible and one of the things is I want to read out the "scsi"-response messages when there's an error.
I found out how to emulate no-disc and cover-open by testing different settings in my emulator. After a TestUnitReady command fails (status =2) a RequestSense command will give 0x0B in SenseCode (last byte of response) for no-disc and 0x0D for cover-open errors.
I want to know what happens if you try to send illegal cd-rom commands or try to read past the end of a data-track.

Re: Mixing C and asm?

Posted: Mon Mar 08, 2010 8:45 pm
by MooZ
Yes that's possible.
If you want to add some asm in your C code put #asm before and #endasm after your code.

Code: Select all

#incbin(junk,"data.bin");

char bozo;

main()
{
#asm
    ; bozo = junk[0];
    clx
    cla
    __farptr_i _junk
    __fgetb
    sta _bozo
#endasm
}

Re: Mixing C and asm?

Posted: Tue Mar 09, 2010 11:10 am
by FluBBa
Thanks I'll give it a try.