Mixing C and asm?

hu, cd, scd, acd, supergrafx discussions.
Post Reply
FluBBa
Posts: 3
Joined: Mon Mar 08, 2010 8:01 pm

Mixing C and asm?

Post 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.
User avatar
MooZ
Site Admin
Posts: 407
Joined: Sun Jun 22, 2008 3:19 pm
Location: Lvl 3
Contact:

Re: Mixing C and asm?

Post 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
}
FluBBa
Posts: 3
Joined: Mon Mar 08, 2010 8:01 pm

Re: Mixing C and asm?

Post by FluBBa »

Thanks I'll give it a try.
Post Reply