diff --git a/blk/262 b/blk/262 index 4003147..bb7e6d5 100644 --- a/blk/262 +++ b/blk/262 @@ -1 +1 @@ -263 LOAD 265 LOAD +263 LOAD 265 LOAD 268 LOAD diff --git a/blk/267 b/blk/267 new file mode 100644 index 0000000..74a7e59 --- /dev/null +++ b/blk/267 @@ -0,0 +1,6 @@ +XPACK - pack source code + +The goal of this word is to pack source code in tight places, +such as on the boot section of an EEPROM. It takes a block +number, reads it and packs it to HERE. It normalizes all +whitespaces to a single space and ignore comments. diff --git a/blk/268 b/blk/268 new file mode 100644 index 0000000..57d20d5 --- /dev/null +++ b/blk/268 @@ -0,0 +1,16 @@ +: XPACK ( blkno -- ) + BLK@ + BLK( 0x2e RAM+ ! ( boot ptr ) + ['] (boot<) 0x08 RAM+ ! ( C<* override ) + BEGIN + WORD + 0x2e RAM+ @ BLK( 1024 + < IF + DUP LIT< ( S= IF + DROP [COMPILE] ( + ELSE + SCPY 0x20 H@ 1- C! + THEN 0 ( loop again ) + ELSE 1 ( stop looping ) THEN + UNTIL + 0 0x08 RAM+ ! +; diff --git a/forth/core.fs b/forth/core.fs index 981338f..fc98f78 100644 --- a/forth/core.fs +++ b/forth/core.fs @@ -18,7 +18,8 @@ : BEGIN H@ ; IMMEDIATE : AGAIN COMPILE (br) H@ - , ; IMMEDIATE : UNTIL COMPILE (?br) H@ - , ; IMMEDIATE -: ( BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE +: _ BEGIN LIT< ) WORD S= UNTIL ; IMMEDIATE +40 CURRENT @ 4 - C! ( Hello, hello, krkrkrkr... do you hear me? Ah, voice at last! Some lines above need comments BTW: Forth lines limited to 64 cols because of default @@ -27,6 +28,8 @@ "_": words starting with "_" are meant to be "private", that is, only used by their immediate surrondings. + 40 is ASCII for '('. We do this to simplify XPACK's task of + not mistakenly consider '(' definition as a comment. LITS: 34 == litWord LITA: 36 == addrWord COMPILE: Tough one. Get addr of caller word (example above diff --git a/tools/stripfc.c b/tools/stripfc.c index 01a224c..e994de5 100644 --- a/tools/stripfc.c +++ b/tools/stripfc.c @@ -13,7 +13,7 @@ by more than once space or by a newline. Hackish, but works. int main() { - int spccnt = 2; // if the first char is a (, consider it a comment opener. + int spccnt = 1; // if the first char is a (, consider it a comment opener. int incomment = 0; int c; c = getchar(); @@ -24,7 +24,7 @@ int main() // doesn't like when they're not there... putchar(c); } - spccnt += 2; + spccnt += 1; } else if (c == ' ') { spccnt++; } else { @@ -33,7 +33,7 @@ int main() incomment = 0; } } else { - if ((c == '(') && (spccnt > 1)) { + if ((c == '(') && spccnt) { putchar(' '); spccnt = 0; int next = getchar();