X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fcodegen.h;h=15a6872bce4a64976a776f9841e0681ded30cfe0;hb=c130e597b013e37c94afd6651be1e8859ba7e5ac;hp=9eaf1b429f1ceb233be03aff191ef01177ff73ac;hpb=9d1940a124482b8c77e4c2a79c1d2a9c206bcf94;p=cc65 diff --git a/src/cc65/codegen.h b/src/cc65/codegen.h index 9eaf1b429..15a6872bc 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@musoftware.de */ +/* (C) 1998-2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -37,15 +37,17 @@ #define CODEGEN_H - -/* ##### */ -#include "dataseg.h" -#include "codeseg.h" + +/* common */ +#include "coll.h" + +/* cc65 */ +#include "segments.h" /*****************************************************************************/ -/* data */ +/* Data */ /*****************************************************************************/ @@ -70,7 +72,6 @@ #define CF_TEST 0x0080 /* Test value */ #define CF_FIXARGC 0x0100 /* Function has fixed arg count */ #define CF_FORCECHAR 0x0200 /* Handle chars as chars, not ints */ -#define CF_SHORT 0x0400 /* Use short addressing */ #define CF_REG 0x0800 /* Value is in primary register */ /* Type of static address */ @@ -86,14 +87,13 @@ /* Compiler relative stackpointer */ extern int oursp; -/* Segments */ -extern DataSeg* DS; -extern CodeSeg* CS; +/* Forward */ +struct StrBuf; /*****************************************************************************/ -/* Pre- and postamble */ +/* Files, pre- and postamble */ /*****************************************************************************/ @@ -101,8 +101,8 @@ extern CodeSeg* CS; void g_preamble (void); /* Generate the assembler code preamble */ -void g_postamble (void); -/* Generate assembler code postamble */ +void g_fileinfo (const char* Name, unsigned long Size, unsigned long MTime); +/* If debug info is enabled, place a file info into the source */ @@ -112,9 +112,6 @@ void g_postamble (void); -void g_usecode (void); -/* Switch to the code segment */ - void g_userodata (void); /* Switch to the read only data segment */ @@ -124,28 +121,22 @@ void g_usedata (void); void g_usebss (void); /* Switch to the bss segment */ -void g_codename (const char* Name); -/* Set the name of the CODE segment */ - -void g_rodataname (const char* Name); -/* Set the name of the RODATA segment */ - -void g_dataname (const char* Name); -/* Set the name of the DATA segment */ - -void g_bssname (const char* Name); -/* Set the name of the BSS segment */ +void g_segname (segment_t Seg, const char* Name); +/* Set the name of a segment */ /*****************************************************************************/ -/* Functions handling local labels */ +/* Functions handling local labels */ /*****************************************************************************/ -void g_defloclabel (unsigned label); -/* Define a local label */ +void g_defcodelabel (unsigned label); +/* Define a local code label */ + +void g_defdatalabel (unsigned label); +/* Define a local data label */ @@ -164,6 +155,9 @@ void g_defexport (const char* Name, int ZP); void g_defimport (const char* Name, int ZP); /* Import the given label */ +void g_importmainargs (void); +/* Forced import of a special symbol that handles arguments to main */ + /*****************************************************************************/ @@ -195,7 +189,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); @@ -227,7 +224,7 @@ void g_scale (unsigned flags, long val); void g_enter (unsigned flags, unsigned argsize); /* Function prologue */ -void g_leave (int flags, int val); +void g_leave (void); /* Function epilogue */ @@ -238,6 +235,9 @@ void g_leave (int flags, int val); +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 */ @@ -252,10 +252,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); @@ -282,7 +282,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); @@ -304,32 +304,18 @@ 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 */ -/*****************************************************************************/ -/* Compares of ax with a variable with fixed address */ -/*****************************************************************************/ - - - -void g_cmplocal (unsigned flags, int offs); -/* Compare a local variable to ax */ - -void g_cmpstatic (unsigned flags, unsigned label, unsigned offs); -/* Compare a static variable to ax */ - - - /*****************************************************************************/ /* Special op= functions */ /*****************************************************************************/ -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 */ @@ -339,7 +325,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 */ @@ -352,7 +338,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 */ /*****************************************************************************/ @@ -360,7 +346,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 */ @@ -372,7 +358,10 @@ void g_addaddr_static (unsigned flags, unsigned long label, unsigned offs); void g_save (unsigned flags); +/* Copy primary register to hold register. */ + void g_restore (unsigned flags); +/* Copy hold register to primary. */ void g_cmp (unsigned flags, unsigned long val); /* Immidiate compare. The primary register will not be changed, Z flag @@ -380,24 +369,25 @@ void g_cmp (unsigned flags, unsigned long val); */ void g_test (unsigned flags); +/* Test the value in the primary and set the condition codes */ + void g_push (unsigned flags, unsigned long val); +/* Push the primary register or a constant value onto the stack */ + void g_swap (unsigned flags); +/* Swap the primary register and the top of the stack. flags give the type + * of *both* values (must have same size). + */ void g_call (unsigned Flags, const char* Label, unsigned ArgSize); /* Call the specified subroutine name */ -void g_callind (unsigned Flags, unsigned ArgSize); -/* Call subroutine with address in AX */ +void g_callind (unsigned Flags, unsigned ArgSize, int Offs); +/* Call subroutine indirect */ 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 */ @@ -439,14 +429,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 */ + + + +/*****************************************************************************/ +/* Switch statement */ +/*****************************************************************************/ + + + +void g_switch (Collection* Nodes, unsigned DefaultLabel, unsigned Depth); +/* Generate code for a switch statement */ + + + +/*****************************************************************************/ +/* User supplied assembler code */ +/*****************************************************************************/ + + + +void g_asmcode (struct StrBuf* B); +/* Output one line of assembler code. */ @@ -456,7 +477,7 @@ void g_zerobytes (unsigned n); -void g_strlen (unsigned flags, unsigned long val, unsigned offs); +void g_strlen (unsigned flags, unsigned long val, long offs); /* Inline the strlen() function */