aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-10-13 00:44:15 -0700
committerH. Peter Anvin <hpa@zytor.com>2018-10-13 00:48:15 -0700
commit56decf5009cf8d54af6eaa477f6c1557a1a5a893 (patch)
treeaa686e270169d466b94becee48177039c7a9bd78
parentd538d0709dae408326cc833ef5a59ae45083a362 (diff)
downloadabcdisk-56decf5009cf8d54af6eaa477f6c1557a1a5a893.tar.gz
abcdisk-56decf5009cf8d54af6eaa477f6c1557a1a5a893.tar.xz
abcdisk-56decf5009cf8d54af6eaa477f6c1557a1a5a893.zip
bac80: change stringstmt() -> stringdata()
stringstmt() sounds like bacstmt() just with additional encapsulation for a string (e.g. what one would expect for the loader code. Call it stringdata() to make it clear that it does not preserve data boundaries and can generate an arbitrary number of statements, whereas bacstmt() always creates exactly one BASIC statement. To avoid namespace collision, rename blk.stringdata to blk.stringptr.
-rw-r--r--bac80.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/bac80.c b/bac80.c
index 160e5e5..b4225b1 100644
--- a/bac80.c
+++ b/bac80.c
@@ -8,7 +8,7 @@ struct basic_block {
int outbytes; /* Bytes already written to file */
int bofaoffs; /* Current address relative to BOFA */
uint16_t lineno;
- uint8_t *stringdata; /* Accumulating string data, pointer to len */
+ uint8_t *stringptr; /* Accumulating string data, pointer to len */
uint8_t data[253];
};
@@ -27,7 +27,7 @@ static void writeblock(struct basic_block *blk, bool final)
blk->bofaoffs += blk->bytes;
blk->outbytes += 253;
blk->bytes = 0;
- blk->stringdata = false;
+ blk->stringptr = NULL;
}
/*
@@ -37,14 +37,14 @@ static void closestring(struct basic_block *blk)
{
uint8_t *p = blk->data + blk->bytes;
- if (!blk->stringdata)
+ if (!blk->stringptr)
return;
*p++ = 0xbb; /* Drop expression */
*p++ = 0x0d; /* Terminating CR */
blk->bytes += 2;
- blk->stringdata = NULL;
+ blk->stringptr = NULL;
}
/*
@@ -52,19 +52,19 @@ static void closestring(struct basic_block *blk)
* merged into common strings and strings can be broken up between
* blocks.
*/
-static void stringstmt(struct basic_block *blk, const uint8_t * data, int len)
+static void stringstmts(struct basic_block *blk, const uint8_t * data, int len)
{
while (len) {
int copylen;
uint8_t *p = blk->data + blk->bytes;
- if (!blk->stringdata) {
+ if (!blk->stringptr) {
if (blk->bytes >= 253 - 1 - 8) {
/* Not enough space for any string */
writeblock(blk, false);
continue;
}
- blk->stringdata = p;
+ blk->stringptr = p;
*p++ = 8; /* Overhead per statement */
p = set16(p, ++blk->lineno);
*p++ = 0xcb; /* String */
@@ -85,7 +85,7 @@ static void stringstmt(struct basic_block *blk, const uint8_t * data, int len)
memcpy(p, data, copylen);
- p = blk->stringdata;
+ p = blk->stringptr;
p[0] += copylen;
p[5] += copylen;
@@ -101,7 +101,7 @@ static void bacstmt(struct basic_block *blk, const uint8_t * data, int len)
{
uint8_t *p;
- if (blk->stringdata)
+ if (blk->stringptr)
closestring(blk); /* Close any open string data */
if (len > 253 - 1 - 4 - blk->bytes)
@@ -212,15 +212,15 @@ int writebac80(FILE * out, const uint8_t * data, int len, int origin,
bacstmt(&blk, run_prefix, sizeof run_prefix);
/* Emit the restart prefix, if applicable */
- stringstmt(&blk, restart_prefix, pfxlen);
+ stringstmts(&blk, restart_prefix, pfxlen);
/* Emit the actual binary data */
- stringstmt(&blk, data, len);
+ stringstmts(&blk, data, len);
/* Emit relocation information */
if (have_relocs) {
- stringstmt(&blk, (const uint8_t *)"\1", 1); /* EOFA marker */
- stringstmt(&blk, relocdata, reloclen);
+ stringstmts(&blk, (const uint8_t *)"\1", 1); /* EOFA marker */
+ stringstmts(&blk, relocdata, reloclen);
}
/* Emit STOP statement to indicate end of data blocks */