1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-06-08 21:29:30 +00:00

Added #pragma padding directive

This commit is contained in:
Curtis F Kaylor 2018-07-24 00:30:00 -04:00
parent 7b15ce426f
commit cc82237782
5 changed files with 27 additions and 0 deletions

View File

@ -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.

View File

@ -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*/

View File

@ -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

View File

@ -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"))

View File

@ -3,6 +3,7 @@
* Test file for Compiler *
********************************************/
#pragma padding 1
/* Constants */
const #TRUE = $FF, #FALSE = 0;