Method Of Using Registers - Epson S5U1C17001C Manual

Cmos 16-bit single chip microcontroller (c compiler package for s1c17 family) (ver. 3.1)
Hide thumbs Also See for S5U1C17001C:
Table of Contents

Advertisement

4 C Compiler
4.4.3

Method of Using Registers

The following shows how the xgcc C compiler uses general-purpose registers.
Register
%r0
Register for passing argument (1st word)
Register for storing returned values (8/16-bit data, pointer, 16 low-order bits of 32-bit data)
%r1
Register for passing argument (2nd word)
Register for storing returned values (16 high-order bits of 32-bit data)
%r2
Register for passing argument (3rd word)
%r3
Register for passing argument (4th word)
%r4
Registers that need have to their values saved when calling a function
%r5
%r6
%r7
 Registers for passing arguments (%r0 to %r3)
These registers are used to store arguments when calling a function. Arguments exceeding four words are stored in the stack
before being passed. They are used as scratch registers before storing arguments.
%r0 ← First argument
%r1 ← Second argument
%r2 ← Third argument
%r3 ← Fourth argument
A pair of the registers is used to store a 32-bit (long) argument. With gcc3, the low-order 16 bits are always %r0, %r2, %r4,
and %r6. The high-order 16 bits are always %r1, %r3, %r5, and %r7.
%r1 (high-order 16 bits) and %r0 (low-order 16 bits)
%r3 (high-order 16 bits) and %r2 (low-order 16 bits)
Example:
• First argument: long, second argument: long
foo( long lData1, long lData2 );
%r0 ← lData1 (low-order 16 bits)
%r1 ← lData1 (high-order 16 bits)
%r2 ← lData2 (low-order 16 bits)
%r3 ← lData2 (high-order 16 bits)
• First argument: short, second argument: long
foo( short sData, long lData );
%r0
sData (16 bits)
%r1
Unused
lData
%r2
lData
%r3
• First argument: long, second argument: short, third argument: short
foo( long lData, short sData1, short sData2 );
%r0 ← lData (low-order 16 bits)
%r1 ← lData (high-order 16 bits)
%r2 ← sData1 (16 bits)
%r3 ← sData2 (16 bits)
4-12
Table 4.4.3.1 Method of using general-purpose registers by xgcc
gcc3
sData (16 bits)
lData
lData
(low-order 16 bits)
(high-order 16 bits)
Unused
Seiko Epson Corporation
Method of use
gcc4
(low-order 16 bits)
(high-order 16 bits)
S5U1C17001C Manual
(Rev. 1.0)

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the S5U1C17001C and is the answer not in the manual?

Table of Contents