X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fcodegen.h;h=a3b6df128f3082ba51a81cbb8d8c34a077d0e384;hb=d54ca8874302376f4e08b0b7b9ae86d9b6fe4f58;hp=704032ea4ad3f088a1340de967f3e8cf30f739c6;hpb=5d0a52b7accc43672275d6331c576c2512b1074b;p=cc65 diff --git a/src/cc65/codegen.h b/src/cc65/codegen.h index 704032ea4..a3b6df128 100644 --- a/src/cc65/codegen.h +++ b/src/cc65/codegen.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998-2001 llrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@cc65.org */ +/* (C) 1998-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -38,6 +38,9 @@ +/* common */ +#include "coll.h" + /* cc65 */ #include "segments.h" @@ -60,6 +63,7 @@ #define CF_INT 0x0001 /* Operation on ints */ #define CF_PTR CF_INT /* Alias for readability */ #define CF_LONG 0x0000 /* Operation on longs */ +#define CF_FLOAT 0x0004 /* Operation on a float */ #define CF_NOKEEP 0x0008 /* Value may get destroyed when storing */ @@ -81,9 +85,6 @@ -/* Compiler relative stackpointer */ -extern int oursp; - /* Forward */ struct StrBuf; @@ -118,8 +119,8 @@ void g_usedata (void); void g_usebss (void); /* Switch to the bss segment */ -void g_segname (segment_t Seg, const char* Name); -/* Set the name of a segment */ +void g_segname (segment_t Seg); +/* Emit the name of a segment if necessary */ @@ -135,6 +136,9 @@ void g_defcodelabel (unsigned label); void g_defdatalabel (unsigned label); /* Define a local data label */ +void g_aliasdatalabel (unsigned label, unsigned baselabel, long offs); +/* Define label as a local alias for baselabel+offs */ + /*****************************************************************************/ @@ -152,6 +156,12 @@ void g_defexport (const char* Name, int ZP); void g_defimport (const char* Name, int ZP); /* Import the given label */ +void g_importstartup (void); +/* Forced import of the startup segment */ + +void g_importmainargs (void); +/* Forced import of a special symbol that handles arguments to main */ + /*****************************************************************************/ @@ -183,7 +193,10 @@ void g_toslong (unsigned flags); void g_tosint (unsigned flags); /* Make sure, the value on TOS is an int. Convert if necessary */ -void g_reglong (unsigned flags); +void g_regint (unsigned Flags); +/* Make sure, the value in the primary register an int. Convert if necessary */ + +void g_reglong (unsigned Flags); /* Make sure, the value in the primary register a long. Convert if necessary */ unsigned g_typeadjust (unsigned lhs, unsigned rhs); @@ -226,6 +239,9 @@ void g_leave (void); +void g_swap_regvars (int StackOffs, int RegOffs, unsigned Bytes); +/* Swap a register variable with a location on the stack */ + void g_save_regvars (int RegOffs, unsigned Bytes); /* Save register variables */ @@ -240,10 +256,10 @@ void g_restore_regvars (int StackOffs, int RegOffs, unsigned Bytes); -void g_getimmed (unsigned Flags, unsigned long Val, unsigned Offs); +void g_getimmed (unsigned Flags, unsigned long Val, long Offs); /* Load a constant into the primary register */ -void g_getstatic (unsigned Flags, unsigned long Label, unsigned Offs); +void g_getstatic (unsigned Flags, unsigned long Label, long Offs); /* Fetch an static memory cell into the primary register */ void g_getlocal (unsigned Flags, int Offs); @@ -270,7 +286,7 @@ void g_leavariadic (int Offs); -void g_putstatic (unsigned flags, unsigned long label, unsigned offs); +void g_putstatic (unsigned flags, unsigned long label, long offs); /* Store the primary register into the specified static memory cell */ void g_putlocal (unsigned Flags, int Offs, long Val); @@ -292,7 +308,7 @@ void g_putind (unsigned flags, unsigned offs); void g_addlocal (unsigned flags, int offs); /* Add a local variable to ax */ -void g_addstatic (unsigned flags, unsigned long label, unsigned offs); +void g_addstatic (unsigned flags, unsigned long label, long offs); /* Add a static variable to ax */ @@ -303,7 +319,7 @@ void g_addstatic (unsigned flags, unsigned long label, unsigned offs); -void g_addeqstatic (unsigned flags, unsigned long label, unsigned offs, +void g_addeqstatic (unsigned flags, unsigned long label, long offs, unsigned long val); /* Emit += for a static variable */ @@ -313,7 +329,7 @@ void g_addeqlocal (unsigned flags, int offs, unsigned long val); void g_addeqind (unsigned flags, unsigned offs, unsigned long val); /* Emit += for the location with address in ax */ -void g_subeqstatic (unsigned flags, unsigned long label, unsigned offs, +void g_subeqstatic (unsigned flags, unsigned long label, long offs, unsigned long val); /* Emit -= for a static variable */ @@ -326,7 +342,7 @@ void g_subeqind (unsigned flags, unsigned offs, unsigned long val); /*****************************************************************************/ -/* Add a variable address to the value in ax */ +/* Add a variable address to the value in ax */ /*****************************************************************************/ @@ -334,7 +350,7 @@ void g_subeqind (unsigned flags, unsigned offs, unsigned long val); void g_addaddr_local (unsigned flags, int offs); /* Add the address of a local variable to ax */ -void g_addaddr_static (unsigned flags, unsigned long label, unsigned offs); +void g_addaddr_static (unsigned flags, unsigned long label, long offs); /* Add the address of a static variable to ax */ @@ -376,18 +392,15 @@ void g_callind (unsigned Flags, unsigned ArgSize, int Offs); void g_jump (unsigned Label); /* Jump to specified internal label number */ -void g_switch (unsigned Flags); -/* Output switch statement preamble */ - -void g_case (unsigned flags, unsigned label, unsigned long val); -/* Create table code for one case selector */ - void g_truejump (unsigned flags, unsigned label); /* Jump to label if zero flag clear */ void g_falsejump (unsigned flags, unsigned label); /* Jump to label if zero flag set */ +void g_drop (unsigned Space); +/* Drop space allocated on the stack */ + void g_space (int space); /* Create or drop space on the stack */ @@ -423,36 +436,45 @@ void g_ge (unsigned flags, unsigned long val); void g_res (unsigned n); /* Reserve static storage, n bytes */ -void g_defdata (unsigned flags, unsigned long val, unsigned offs); +void g_defdata (unsigned flags, unsigned long val, long offs); /* Define data with the size given in flags */ void g_defbytes (const void* bytes, unsigned count); /* Output a row of bytes as a constant */ -void g_zerobytes (unsigned n); -/* Output n bytes of data initialized with zero */ +void g_zerobytes (unsigned Count); +/* Output Count bytes of data initialized with zero */ + +void g_initregister (unsigned Label, unsigned Reg, unsigned Size); +/* Initialize a register variable from static initialization data */ + +void g_initauto (unsigned Label, unsigned Size); +/* Initialize a local variable at stack offset zero from static data */ + +void g_initstatic (unsigned InitLabel, unsigned VarLabel, unsigned Size); +/* Initialize a static local variable from static initialization data */ /*****************************************************************************/ -/* User supplied assembler code */ +/* Switch statement */ /*****************************************************************************/ -void g_asmcode (struct StrBuf* B); -/* Output one line of assembler code. */ +void g_switch (Collection* Nodes, unsigned DefaultLabel, unsigned Depth); +/* Generate code for a switch statement */ /*****************************************************************************/ -/* Inlined known functions */ +/* User supplied assembler code */ /*****************************************************************************/ -void g_strlen (unsigned flags, unsigned long val, unsigned offs); -/* Inline the strlen() function */ +void g_asmcode (struct StrBuf* B); +/* Output one line of assembler code. */