mirror of
https://github.com/RevCurtisP/C02.git
synced 2025-02-16 14:30:33 +00:00
Added #pragma padding directive
This commit is contained in:
parent
7b15ce426f
commit
cc82237782
10
doc/c02.txt
10
doc/c02.txt
@ -131,6 +131,16 @@ Examples:
|
||||
#pragma origin $0400 //Compiled code starts at address 1024
|
||||
#pragma origin 8192 //Compiled code starts at address 8192
|
||||
|
||||
PRAGMA PADDING
|
||||
|
||||
The #pragma padding directive adds empty bytes to the end of the compiled
|
||||
program. It should be used with target systems that require the object
|
||||
code to be padded with a specific number of bytes.
|
||||
|
||||
Examples:
|
||||
#pragma padding 1 //Add one empty byte to end of code
|
||||
#pragma padding $FF //Add 255 empty bytes to end of code
|
||||
|
||||
PRAGMA VARTABLE
|
||||
|
||||
The #pragma vartable directive forces the variable table to be written.
|
||||
|
@ -31,6 +31,7 @@ void init(void) {
|
||||
concnt = 0; //Number of Constants Defined
|
||||
varcnt = 0; //Number of Variables in Table
|
||||
lblcnt = 0; //Number of Labels in stack
|
||||
padcnt = 0; //Number of Padding Bytes at End
|
||||
curcol = 0; //Current Column in Source Code
|
||||
curlin = 0; //Current Line in Source Code
|
||||
alcvar = TRUE; //Allocate Variables Flag
|
||||
@ -84,6 +85,11 @@ void prolog(void) {
|
||||
|
||||
void epilog(void) {
|
||||
if (!vrwrtn) vartbl(); //Write Variable Table
|
||||
if (padcnt) {
|
||||
SCMNT("PADDING BYTES")
|
||||
sprintf(word, "$%hhX", padcnt);
|
||||
asmlin(STROP, word);
|
||||
}
|
||||
}
|
||||
|
||||
/* Compile Source Code*/
|
||||
|
@ -67,6 +67,8 @@ int infunc; //Inside Function Definition Flag
|
||||
int lsrtrn; //Last Statement was a Return Flag
|
||||
int fcase; //First Case Statement Flag
|
||||
|
||||
int padcnt; //Number of Padding Bytes at End of Program
|
||||
|
||||
void exterr(int errnum); //Print current file name & position and exit
|
||||
void expctd(char *expected); //Print Expected message and exit
|
||||
|
||||
|
@ -80,6 +80,12 @@ void porign(void) {
|
||||
DEBUG("Set origin to %s\n", value)
|
||||
}
|
||||
|
||||
/* Parse Padding Subdirective */
|
||||
void ppddng(void) {
|
||||
padcnt = prsnum(0xFF); //Get Number of Padding Bytes
|
||||
DEBUG("Set padding to %d\n", padcnt)
|
||||
}
|
||||
|
||||
/* Parse Zeropage Subdirective */
|
||||
void prszpg(void) {
|
||||
zpaddr = prsnum(0xFF); //Set Zero Page Address to Literal
|
||||
@ -102,6 +108,8 @@ void pprgma(void) {
|
||||
pascii(); //Parse Ascii
|
||||
else if (wordis("ORIGIN"))
|
||||
porign(); //Parse Origin
|
||||
else if (wordis("PADDING"))
|
||||
ppddng(); //Parse Origin
|
||||
else if (wordis("VARTABLE"))
|
||||
pvrtbl(); //Parse Vartable
|
||||
else if (wordis("ZEROPAGE"))
|
||||
|
@ -3,6 +3,7 @@
|
||||
* Test file for Compiler *
|
||||
********************************************/
|
||||
|
||||
#pragma padding 1
|
||||
|
||||
/* Constants */
|
||||
const #TRUE = $FF, #FALSE = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user