A89: Re: ASM to C and vice versa
[Prev][Next][Index][Thread]
A89: Re: ASM to C and vice versa
If your routine doesn't need any parameters you could just put "xdef
yourroutine" in the top of the asm file, and then compile it to a .o file
with a68k, then you declare it in your C-file as "external void
yourroutine();" and then you can use it as any other C-routine.
You also have to specify this .o file in the linking.
I think that IDE that comes with new versions of ti-gcc (or if it is the
other way around) has some feutures for makeing this easy.
If you want to have parameters to your asm-routine, you'll have to
communicate theese on the stack. (you declare your function as "external
void myroutine(int param1, int param2);" or whatever, and then make your
asmroutine read the params from the stack)
You also _always_ have to save d0-d2 and a0-a1 if you change theese, and
restore them before the routine returns.
the other way around should work nice if you just compile the c-file as
normal, to an .o-file and in your asm-file put "xref yourroutine" (note the
difference between xref and xdef)
Then you let the linker put the programs together, just like before.
you can also share variables between the asm code and the c code with xdef
and xref.
///Olle
----- Original Message -----
From: "Josh 'Gage'" <antgage@apk.net>
> Anybody here know how to make C recognize an asm function? here's a
quickie
> example:
>
> line.asm
>
> \DrawLine:
> move.l LCD_MEM,a0 ; Move LCD memory into a0
> move.w #3,d0 ; Move #3 into d0
> ext.l d0 ; clear d0
> mulu.w #30,d0 ; multiply by 30
for
> offsetting
> add.l d0,a0 ; Add Offset to
> LCD_MEM
> move.w #LCD_LINE_BYTES-1,d1 ; Loop Counter == Screen
> Length -1
> \loop:
> move.b #$FF,(a0)+ ; set byte on screen,
> advance to next row of bytes
> dbra.w d1,\loop ; loop until counter
> == -1
> rts ; return
from
> subroutine
>
> in C how can I do the equivalent of:
>
> int _main(void)
> {
> DrawLine();
> }
>
> also, if anyone knows how to make asm recognize a user made c function(all
> ive seen are tios functions), lemme know if you would ;D
Follow-Ups:
References: