Arg passing - shame for ImgCraft

Discussion and support of the compiler from ImageCraft for the M8C.

Moderator: richard@imagecraft.com

Arg passing - shame for ImgCraft

Postby rosaldorosa » Thu Dec 09, 2010 10:18 pm

I'm calling function(char x).
As expected arg should be passed in Acumulator as:
MOV A,[X+0]
PUSH A
CALL _function
ADD SP,0xFF
MOV [X+4],A

But now the function itself doesn see argument itself, nor A is never POP:
_function:
work --> X+0
x --> X-4
PUSH X
MOV X,SP
ADD SP,0x1
MOV A,[X-4]

DOes anyone see a baby logic behind?
rosaldorosa
The Big Cheese
The Big Cheese
 
Posts: 232
Joined: Sun Feb 21, 2010 10:51 pm

Re: Arg passing - shame for ImgCraft

Postby slandrum » Mon Dec 13, 2010 6:53 am

A is pushed before the function call.

After the function call, instead of a pop, the code just modifies the stack pointer, since the value that was pushed is not needed.

In the function, the argument A that was pushed is retrieved off of the stack. To access the stack indirectly, the X register is used, so it also needs to be preserved on the stack. It also looks like the function reserves one extra slot on the stack for a local variable.

At a glance everything looks OK. The generated code code probably be tighter.
slandrum
The Big Cheese
The Big Cheese
 
Posts: 453
Joined: Fri Feb 29, 2008 11:38 am
Location: California

Re: Arg passing - shame for ImgCraft

Postby rosaldorosa » Thu Dec 16, 2010 3:09 am

I've finally figured out that it's OK.
Thanks
robert
rosaldorosa
The Big Cheese
The Big Cheese
 
Posts: 232
Joined: Sun Feb 21, 2010 10:51 pm


Return to “%s” ImageCraft ICCv7 for M8C Compiler

Who is online

Users browsing this forum: No registered users and 1 guest