parameter passing in registers changed to be
[fw/sdcc] / src / z80 / main.c
1 #include "z80.h"
2
3 static char _defaultRules[] =
4 {
5 #include "peeph.rul"
6 #include "peeph-z80.rul"
7 };
8
9 Z80_OPTS z80_opts;
10
11 static char *_z80_keywords[] = { NULL };
12
13 static void _z80_init(void)
14 {
15     z80_opts.sub = SUB_Z80;
16 }
17
18 static int regParmFlg = 0; /* determine if we can register a parameter */
19
20 static void _z80_reset_regparm()
21 {
22     regParmFlg = 0;
23 }
24
25 static int _z80_reg_parm(link *l)
26 {
27         /* for this processor it is simple
28        can pass only the first parameter in a register */
29     if (regParmFlg)
30         return 0;
31
32     regParmFlg = 1;
33     return 1;
34
35 }
36
37 static bool _z80_parseOptions(int *pargc, char **argv, int *i)
38 {
39     return FALSE;
40 }
41
42 static void _z80_finaliseOptions(void)
43 {
44     port->mem.default_local_map = data;
45     port->mem.default_globl_map = data;
46 }
47
48 static void _z80_setDefaultOptions(void)
49 {    
50     options.genericPtr = 1;   /* default on */
51     options.nopeep    = 0;
52     options.stackAuto = 1;
53     options.mainreturn = 1;
54     options.noregparms = 1;
55     /* first the options part */
56     options.intlong_rent = 1;
57
58     optimize.global_cse = 1;    
59     optimize.label1 = 1;
60     optimize.label2 = 1;
61     optimize.label3 = 1;
62     optimize.label4 = 1;    
63     optimize.loopInvariant = 1;
64     optimize.loopInduction = 0;
65 }
66
67 static const char *_z80_getRegName(struct regs *reg)
68 {
69     if (reg)
70         return reg->name;
71     assert(0);
72     return "err";
73 }
74
75 /** $1 is always the basename.
76     $2 is always the output file.
77     $3 varies
78     $l is the list of extra options that should be there somewhere...
79     MUST be terminated with a NULL.
80 */
81 static const char *_linkCmd[] = {
82     "link-z80", "-nf", "$1", NULL
83 };
84
85 static const char *_asmCmd[] = {
86     "as-z80", "-plosgff", "$1.o", "$1.asm", NULL
87 };
88
89 /* Globals */
90 PORT z80_port = {
91     "z80",
92     "Zilog Z80",                /* Target name */
93     {
94         FALSE,
95     },
96     {   
97         _asmCmd,
98         "-plosgff",             /* Options with debug */
99         "-plosgff",             /* Options without debug */
100     },
101     {
102         _linkCmd
103     },
104     {
105         _defaultRules
106     },
107     {
108         /* Sizes: char, short, int, long, ptr, fptr, gptr, bit, float, max */
109         1, 1, 2, 4, 2, 2, 2, 1, 4, 4
110     },
111     {
112         "_XSEG",
113         "_STACK",
114         "_CODE",
115         "_DATA",
116         "_ISEG",
117         "_XSEG",
118         "_BSEG",
119         "_RSEG",
120         "_GSINIT",
121         "_OVERLAY",
122         "_GSFINAL",
123         NULL,
124         NULL
125     },
126     { 
127         -1, 0, 0, 8, 0
128     },
129     /* Z80 has no native mul/div commands */
130     {  
131         0
132     },
133     _z80_init,
134     _z80_parseOptions,
135     _z80_finaliseOptions,
136     _z80_setDefaultOptions,
137     z80_assignRegisters,
138     _z80_getRegName,
139     _z80_keywords,
140     0,  /* no assembler preamble */
141     0,  /* no local IVT generation code */
142     _z80_reset_regparm,
143     _z80_reg_parm
144 };
145