Quellcode durchsuchen

xcomp: add XPACK

pull/102/head
Virgil Dupras vor 4 Jahren
Ursprung
Commit
13771d8c92
5 geänderte Dateien mit 30 neuen und 5 gelöschten Zeilen
  1. +1
    -1
      blk/262
  2. +6
    -0
      blk/267
  3. +16
    -0
      blk/268
  4. +4
    -1
      forth/core.fs
  5. +3
    -3
      tools/stripfc.c

+ 1
- 1
blk/262 Datei anzeigen

@@ -1 +1 @@
263 LOAD 265 LOAD
263 LOAD 265 LOAD 268 LOAD

+ 6
- 0
blk/267 Datei anzeigen

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

+ 16
- 0
blk/268 Datei anzeigen

@@ -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+ !
;

+ 4
- 1
forth/core.fs Datei anzeigen

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


+ 3
- 3
tools/stripfc.c Datei anzeigen

@@ -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();


Laden…
Abbrechen
Speichern