On 3/9/18 8:56 AM, Tauno Voipio wrote:
> On 9.3.18 11:30, The Natural Philosopher wrote:
>> On 09/03/18 09:17, Richard Kettlewell wrote:
>>> The Natural Philosopher writes:
>>>> On 08/03/18 17:33, mm0fmf wrote:
>>>>> On 08/03/2018 15:27, Martin Gregorie wrote:
>>>>>> On Thu, 08 Mar 2018 13:34:57 +0000, The Natural Philosopher wrote:
>>>>>>> I would at least put in a bit more
>>>>>>>
>>>>>>> int myfunction(int bufflth, char* buff)
>>>>>>> {
>>>>>>> return (int)buff[bufflth-1];
>>>>>>> }
>>>>>>>
>>>>>>> So you know where on the stack buff and bufflth are...
>>>>>>
>>>>>> Why would you want to know that? All the assembler operations
>>>>>> using the
>>>>>> arguments will be inside myfunction() and, unless the code is
>>>>>> calculating
>>>>>> a result to be returned and used elsewhere, the returned value is
>>>>>> probably to report success or failure.
>>>>>>
>>>>>
>>>>> If it returns success or failure, why return 1 of 4 billion possible
>>>>> values?
>>>>
>>>> Another personm who has never coded assmebler for C..
>>>>
>>>> It not what you are rurining, its how to access (bufflth, char* buff)
>>>> which are LOCAL stack based variables.
>>>
>>> The first few args are passed in registers on many modern systems. See
>>> e.g.
>>>
http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf
>>>
>>> for instance.
>>>
>>
>> Even so, the method still reveals WHICH registers
>>
>> But it is not a feature of the ARM per se, merely a convention.
>>
>> I assume gcc follows it, but there is no gurantee
>
> GCC follows the ARM EABI specification:
>
> - stack on 8 byte boundaries,
> - arguments in r0 - r3
> - return value in r0
>
> I still suspect that the OP does not have a clue of the assembly
> code he's attempting to link in.
>
The EABI goes a bit farther, as there are some register the called
function must preserve (if it changes them, it must save them first) and
other register the caller can freely change, and if the callee needs
them preserved must save them before the call. This choice is actually
enshrined in the interrupt processing (at least on some ARMs, I would
have to check if true for all the variants), as an interrupt will save
all the registers that a normal function is allowed to change without
saving, thus making ISR routines normal void fun(void) functions.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|