A89: Re: Using ASM in C (new message)


[Prev][Next][Index][Thread]

A89: Re: Using ASM in C (new message)




> a while back, someone said that l could use the graphlib's fillrect call from
> my C program.  lt went like this:
>
>  _main()
> {
>  clr_scr();
>  fill(10,10,135,10,0);
>  idle_loop();
> };
>
> void fill(x,y,width,height,color)
> int x,y,width,height,color;
> {
> asm("
>  move.w 8(%sp),%d0
>  move.w 10(%sp),%d1
>  move.w 12(%sp),%d2
>  move.w 14(%sp),%d3
>  move.w 16(%sp),%d4
>      ");
> fillrect();
> };
>
> what l'm curious about are the n(%sp) values above, where n is one of those
> numbers.  l know that the % stands for a register, but what do the 8 - 16
> numbers and the sp (register?) mean?  Thanks.

sp is the same as a7, i.e. the current stack pointer (usp or ssp).
The 8-16 numbers are 16-bit displacements, so 10(%sp) means the value in address
a7+10 (note: not the same as (a7)+10  !)


 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92 Plus at http://c625.sparta.lu.se
Random PQF Quote follows:

Consider the situation. There you are, forehead like a set of balconies,
worrying about the long-term effects of all this new 'fire' stuff on the
environment, you're being chased and eaten by most of the planet's large
animals, and suddenly tiny versions of one of the worst of them wanders
into the cave and starts to purr.
        -- Why humans like cats
           (Terry Pratchett, The Unadulterated Cat)




References: