From a134a75572f71eb4f34098f083b88b03ad07c368 Mon Sep 17 00:00:00 2001 From: xPaw Date: Tue, 10 Mar 2015 19:56:35 +0200 Subject: [PATCH 1/2] Remove scpack --- compiler/libpc300/AMBuilder | 39 --- compiler/libpc300/sc5-in.scp | 160 --------- compiler/libpc300/sc5.c | 2 +- compiler/libpc300/sc7-in.scp | 632 +---------------------------------- compiler/libpc300/sc7.c | 84 +---- compiler/libpc300/scexpand.c | 68 ---- compiler/libpc300/scpack.c | 450 ------------------------- 7 files changed, 21 insertions(+), 1414 deletions(-) delete mode 100755 compiler/libpc300/scexpand.c delete mode 100644 compiler/libpc300/scpack.c diff --git a/compiler/libpc300/AMBuilder b/compiler/libpc300/AMBuilder index a2eacea6..901ebc63 100644 --- a/compiler/libpc300/AMBuilder +++ b/compiler/libpc300/AMBuilder @@ -1,42 +1,6 @@ # vim: set sts=2 ts=8 sw=2 tw=99 et ft=python: import os.path -# Build the packing binary garbage. -scpack = AMXX.Program(builder, 'scpack') -if builder.target_platform == 'windows': - scpack.compiler.linkflags.remove('/SUBSYSTEM:WINDOWS') - scpack.compiler.linkflags.append('/SUBSYSTEM:CONSOLE') -scpack.sources = ['scpack.c'] -scpack = builder.Add(scpack) - -# Generate pack files. -packed_files = ['sc5', 'sc7'] -packed_includes = [] -for packed_file in packed_files: - # The absolute path to sc5-in.scp etc. - in_path = os.path.join(builder.currentSourcePath, '{0}-in.scp'.format(packed_file)) - - # The output file relative to the output folder, i.e. sourcepawn/compiler/sc5.scp. - out_path = os.path.join(builder.buildFolder, '{0}.scp'.format(packed_file)) - - # The absolute path to the build folder, i.e. /Users/.../sourcepawn/compiler. - build_folder = os.path.join(builder.buildPath, builder.buildFolder) - - # scpack runs in ./sourcepawn/compiler/scpack/ so we build relative paths - # from there. - scpack_argv = [ - os.path.join(builder.buildPath, scpack.binary.path), - os.path.relpath(in_path, build_folder), - os.path.relpath(os.path.join(builder.buildPath, out_path), build_folder), - ] - - _, (entry,) = builder.AddCommand( - inputs = [scpack.binary, in_path], - argv = scpack_argv, - outputs = ['{0}.scp'.format(packed_file)], - ) - packed_includes += [entry] - binary = AMXX.Library(builder, 'amxxpc32') binary.compiler.includes += [ @@ -44,8 +8,6 @@ binary.compiler.includes += [ os.path.join(builder.buildPath, builder.buildFolder), ] -binary.compiler.sourcedeps += packed_includes - if builder.target_platform in ['mac', 'linux']: binary.compiler.defines += ['ENABLE_BINRELOC'] binary.compiler.postlink += ['-lm', '-lpthread'] @@ -70,7 +32,6 @@ binary.sources = [ 'scstate.c', 'sclist.c', 'sci18n.c', - 'scexpand.c', 'pawncc.c', 'libpawnc.c', 'prefix.c', diff --git a/compiler/libpc300/sc5-in.scp b/compiler/libpc300/sc5-in.scp index 25c52a0f..8d840fe5 100644 --- a/compiler/libpc300/sc5-in.scp +++ b/compiler/libpc300/sc5-in.scp @@ -17,28 +17,9 @@ * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: sc5.scp 2167 2005-11-19 09:16:27Z dvander $ */ -SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); - -#define SCPACK_TABLE errstr_table -/*-*SCPACK start of pair table, do not change or remove this line */ -unsigned char errstr_table[][2] = { - {101,32}, {111,110}, {116,32}, {105,110}, {97,114}, {116,105}, {100,32}, {115,32}, {101,110}, {101,114}, {97,108}, {133,129}, {37,115}, {34,140}, {141,34}, {117,110}, - {115,105}, {110,111}, {114,101}, {121,32}, {97,110}, {111,114}, {97,116}, {109,136}, {100,101}, {139,32}, {115,116}, {101,134}, {109,98}, {41,10}, {118,138}, {114,97}, - {143,99}, {145,130}, {32,142}, {102,160}, {117,115}, {98,108}, {111,108}, {97,32}, {115,144}, {163,153}, {105,134}, {132,159}, {149,32}, {158,170}, {115,121}, {117,151}, - {174,156}, {103,32}, {176,166}, {103,175}, {131,173}, {132,179}, {116,104}, {101,120}, {137,32}, {101,100}, {111,102}, {99,104}, {105,135}, {171,147}, {152,102}, {116,111}, - {186,32}, {97,165}, {99,129}, {181,130}, {101,10}, {115,10}, {112,146}, {164,130}, {98,128}, {162,10}, {44,32}, {109,199}, {109,97}, {193,128}, {34,32}, {129,32}, - {116,97}, {100,105}, {144,122}, {190,131}, {118,132}, {101,135}, {154,150}, {102,105}, {212,105}, {101,108}, {117,108}, {99,111}, {109,150}, {58,201}, {216,205}, {132,97}, - {119,105}, {111,112}, {97,115}, {225,137}, {194,154}, {178,162}, {110,32}, {138,32}, {148,32}, {198,168}, {131,177}, {203,200}, {104,97}, {183,233}, {108,111}, {109,112}, - {148,130}, {108,128}, {229,157}, {142,157}, {40,242}, {110,117}, {118,128}, {116,137}, {116,10}, {102,149}, {227,150}, {101,151}, {245,156}, {111,32}, {145,32} -}; -/*-*SCPACK end of pair table, do not change or remove this line */ - static char *errmsg[] = { -#ifdef SCPACK /*001*/ "expected token: \"%s\", but found \"%s\"\n", /*002*/ "only a single statement (or expression) can follow each \"case\"\n", /*003*/ "declaration of a local variable must appear in a compound block\n", @@ -127,100 +108,9 @@ static char *errmsg[] = { /*086*/ "unknown automaton \"%s\"\n", /*087*/ "unknown state \"%s\" for automaton \"%s\"\n", /*088*/ "number of arguments does not match definition\n" -#else - "\267pect\233\277k\210:\242\312bu\202fo\217\206\216\012", - "\201l\223\247s\203g\361\326\373\202(\254\355\201) c\350f\246\356w ea\273 \042c\342e\042\012", - "\230cl\337\231\300\247\356c\347\336\313appe\204 \203 \247\333\357o\217\206\245ock\012", - "\251\216 \274\241i\357l\373t\271\012", - "\251\314\223\241\354\366\265t\305", - "\353a\250gn\233\277 \350\253y\012", - "\372\254c\224\241\310\222\323\271\012", - "\353\247\344\360\355\201; \342sum\233z\211o\012", - "\264\275\322\200(nega\205\366\254z\211o\235", - "\264\251\254\230cl\337\213\012", - "\264out\220d\200\243\213\305", - "\264\251c\212l\312\241\247\255add\222s\305", - "\376\210tr\223po\203\202(\376pu\245ic \243\213s\235", - "\264\326\373t; \241\203 s\340t\273\012", - "\042\276a\332t\316c\342\200\353\266\200l\342\202c\342\200\203 s\340t\273 \326\373\370", - "m\332\205p\361\276a\332t\207\203 \042s\340t\273\042\012", - "\217\323\233\262\311", - "\203i\205\212iza\231d\226\247\267ce\271\207\230cl\204\233\322\304", - "\241\247lab\331\335", - "\264\262 nam\200\216\012", - "\262 \212\222ad\223\323\271\335", - "\353l\236u\200(n\201-\344\224t\235", - "\275a\250gn\227\202\353\220\357\361a\250gn\227\370", - "\042b\222ak\316\254\042\302t\203ue\316\274ou\202\300\302t\267\370", - "\251head\352\321ff\211\207from pro\277typ\304", - "\376\334\273\352\042#if...\042\012", - "\264\273\337ct\270\344\224\370", - "\264subscrip\202(\241\350\275\254\277\375m\224\223subscripts)\335", - "\264\355\201\312\342sum\233z\211o\012", - "\333\357o\217\206\326\373\202\241c\356s\233a\202\266\200\210\206\300\327l\304", - "\217k\221w\346\321\222c\205v\304", - "\275\203\230x ou\202\300bo\217d\207(\336\363", - "\275\353\203\230x\233(\336\363", - "\303do\325\241\354\366\247\276a\332\202\236u\200(\303%d\235", - "\303typ\200mis\334\273 (\303%d\235", - "e\357t\223\326\373\370", - "\264\232r\352(po\250\245\223n\201-\367m\203\226\233\232r\203g\235", - "\267t\237 \273\337c\367\207\317l\203\304", - "\344\360\262 \354\207\376\322\304", - "duplic\226\200\042c\342e\316lab\331 (\236u\200%d\235", - "\264\331lip\220s\312\275\322\200\274\241k\221wn\012", - "\264\333\234\203a\231\300cl\342\207speci\327\211\305", - "\273\337ct\270\344\360\267ce\271\207r\224g\200f\254pack\233\232r\203g\012", - "po\220\213\347p\337me\367\207\313\306c\271\200\212l nam\233p\337me\367\305", - "\277\375m\224\223\251\265t\305", - "\217k\221w\346\275\322\200(\336\363", - "\275\322\325d\375\241\334\273\312\254\230\232\203a\231\275\274\277\375sm\212l\012", - "\275\321\227\220\201\207d\375\241\334\273\012", - "\264l\203\200\302t\203ua\213\012", - "\264r\224g\304", - "\264subscript\312\244\200\042[ ]\316\372\225\207\317\314j\254\321\227\220\201\305", - "m\332\205-\321\227\220\201\347\253y\207\353f\332l\223\203i\205\212iz\271\012", - "\267ce\271\352\314ximum \374\270\300\321\227\220\201\305", - "\217\334\273\233c\356s\352b\237c\304", - "\232\204\202\300\251bod\223\340\266ou\202\251head\211\012", - "\253ys\312\356c\347\330\301\325\224\206\251\265t\207c\224\241\310pu\245ic (\336\363", - "\217f\203ish\233\355\317be\371\200\333\357il\270\321\222c\205v\304", - "duplic\226\200\265t; sam\200\303\274p\342s\233t\340c\304", - "\251\303\314\223\241\354\366\247\276a\332\202\236u\200(\336\363", - "m\332\205p\361\042#\331se\316\321\222c\205v\325betwe\210 \042#if ... #\210\321f\042\012", - "\042#\331seif\316\321\222c\205\366f\246\356w\207\350\042#\331se\316\321\222c\205v\304", - "\374\270\300\343\224d\207do\325\241\327\202\266\200\372\225\012", - "\251\222s\332\202\320\261\300\372\225\242 \353\216\012", - "c\224\241\273\224g\200\306\323\233\372\225\305", - "\251\303\314\223\201l\223\354\366\247s\203g\361\320\261(\303%d\235", - "\251\303\314\223\241\310\247\222f\211\210c\200\303\254\350\275(\303\363", - "\336c\224\241\310bo\266 \247\222f\211\210c\200\224\206\350\275(\336\363", - "\264\237\213\347\374\270\306ci\220\317\203 #p\237g\314\012", - "\237\213\347\374\270\371\314\202\212\222ad\223\323\271\012", - "\237\213\347\374\270supp\225\202wa\207\241\210\301\271\012", - "\244\211-\323\233\372\254\353\230cl\204\233be\371\200\244\200(\251\363", - "\042\322e\272\316\372\254\274\264\317\042\243\213\316\262\305", - "\251\303\353\350\275(\303\363", - "#\323\200p\226\367\346\313\232\204\202\340\266 \350\212p\354be\205c \273\337c\367\012", - "\203pu\202l\203\200\277\375l\201\261(aft\270subs\205tu\213s\235", - "\256n\320x \211r\254\203 \266\200\355\201\312\254\264\251c\212l\012", - "m\212\371m\233UTF-8 \210\333d\203g\312\254c\225rupt\233\327le: \214\012", - "\251\244\325bo\266 \042\222turn\316\224\206\042\222tur\346<\236ue>\042\012", - "\203\302\220\232\210\202\222tur\346typ\325(\275& n\201-\253y\235", - "\217k\221w\346\262\312\254\241\247\344\360\262 \364", - "c\224\241\320k\200\247\320\261a\207\247\276a\332\202\236u\200f\254\350\203\230x\233\275p\337met\270\364", - "\244\211-\323\233\372\225\207\224\206na\205\366\243\213\207\314\223\241\354\366\326e\305", - "\247\251\314\223\201l\223b\331\201\261\277 \247s\203g\361au\277\334\317\364", - "\326\200\302flict: \201\200\300\266\200\326\325\274\212\222ad\223a\250gn\233\277 a\221\266\270i\357l\373\320\231\364", - "\376\326\325\204\200\323\233f\254\251\216\012", - "\217k\221w\346au\277\334\201\311", - "\217k\221w\346\326\200\216 f\254au\277\334\201\311", - "\374\270\300\265t\207do\325\241\334\273 \323i\213\012" -#endif }; static char *fatalmsg[] = { -#ifdef SCPACK /*100*/ "cannot read from file: \"%s\"\n", /*101*/ "cannot write to file: \"%s\"\n", /*102*/ "table overflow: \"%s\"\n", @@ -239,24 +129,9 @@ static char *fatalmsg[] = { /*109*/ "invalid path: \"%s\"\n", /*110*/ "assertion failed: %s\n", /*111*/ "user error: %s\n", -#else - "c\224\241\222a\206from \327le\335", - "c\224\241writ\200\277 \327le\335", - "t\315ov\211f\356w\335", - "\203suf\327ci\210\202mem\225y\012", - "\264\342se\234l\270\203\232ruc\231\216\012", - "\365m\211ic ov\211f\356w\312\267ce\271\352capacity\012", - "\333\357il\233scrip\202\267ce\271\207\266\200\314ximum mem\225\223\322\200(%l\206bytes\235", - "\277\375m\224\223\211r\254messag\325\317\201\200l\203\304", - "\333\230pag\200\314pp\352\327\361\241fo\217d\012", - "\264p\226h\335", - "\342s\211\231fail\271: \214\012", - "\244\270\211r\225: \214\012" -#endif }; static char *warnmsg[] = { -#ifdef SCPACK /*200*/ "symbol \"%s\" is truncated to %d characters\n", /*201*/ "redefinition of constant/macro (symbol \"%s\")\n", /*202*/ "number of arguments does not match definition\n", @@ -292,39 +167,4 @@ static char *warnmsg[] = { /*232*/ "output file is written, but with compact encoding disabled\n" /*233*/ "symbol \"%s\" is marked as deprecated: %s\n", /*234*/ "recursive function \"%s\"\n", -#else - "\345 \274tr\240\226\233\277 %\206\273\337c\367\305", - "\222\323i\231\300\344\224t/\314cr\375\364", - "\374\270\300\265t\207do\325\241\334\273 \323i\213\012", - "\262 \274nev\270\244\271\335", - "\262 \274a\250gn\233\247\236u\200\266a\202\274nev\270\244\271\335", - "\222d\217d\360\333\230: \344\360\355\317\274z\211o\012", - "\222d\217d\360te\232: \344\360\355\317\274n\201-z\211o\012", - "\217k\221w\346#p\237g\314\012", - "\251\340\266 \320\261\222s\332\202\244\233be\371\200\323i\213\312\371c\352\222p\204s\304", - "\251\216 sho\332\206\222tur\346\247\236u\304", - "po\250\245\200\244\200\300\262 be\371\200\203i\205\212iza\213\335", - "po\250\245\223\217\203t\210\230\206a\250gn\227\370", - "po\250\245\223\217\203t\210\230\206bit\340s\200\343a\213\012", - "\320\261mis\334\273\012", - "po\250\245\223\247\042\344\316\275\303wa\207\203t\210\230d\335", - "\355\317\354\207\376effec\370", - "ne\232\233\333m\227\370", - "\356os\200\203d\210\320\213\012", - "\246\206\232y\361pro\277typ\325\244\233\340\266 \341\213\347semic\246umn\305", - "\356c\347\336\216 s\354dow\207\247\336a\202\247\306c\271\352lev\331\012", - "\355\317\340\266 \320\261ov\211rid\200\313appe\204 betwe\210 p\204\210\266ese\305", - "lab\331 nam\200\216 s\354dow\207\320\261nam\304", - "\374\270\300\321git\207\267ce\271\207\237\213\347\374\270\306ci\220\201\012", - "\222d\217d\360\042\322e\272\042: \303\322\200\274\212way\2071 \364", - "\203\230\367m\203\226\200\275\322\200\203 \042\322e\272\316\355\317\364", - "\217\222a\273\315\333\230\012", - "\247\336\274a\250gn\233\277 its\331f \364", - "m\225\200\203i\205\212l\211\207\266\350\210um \327\331d\305", - "l\210g\266 \300\203i\205\212l\270\267ce\271\207\322\200\300\266\200\210um \327\331d\012", - "\203\230x \320\261mis\334\273 \364", - "\376i\357l\373\320\231f\254\326\200\216 / \251\216\312\376f\212l-back\012", - "\326\200speci\327ca\231\317\371w\204\206\230cl\337\231\274ig\221\222d\012", - "outpu\202\327\361\274writt\210\312bu\202\340\266 \333\357ac\202\210\333d\352\321s\301\271\012" -#endif }; diff --git a/compiler/libpc300/sc5.c b/compiler/libpc300/sc5.c index b6234ee5..19ae236c 100755 --- a/compiler/libpc300/sc5.c +++ b/compiler/libpc300/sc5.c @@ -41,7 +41,7 @@ #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */ #endif -#include +#include "sc5-in.scp" #if defined _MSC_VER #pragma warning(pop) diff --git a/compiler/libpc300/sc7-in.scp b/compiler/libpc300/sc7-in.scp index c100cf74..4b6b0d0d 100644 --- a/compiler/libpc300/sc7-in.scp +++ b/compiler/libpc300/sc7-in.scp @@ -18,32 +18,16 @@ * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. - * - * Version: $Id: sc7.scp 1724 2005-07-24 20:00:55Z dvander $ */ -SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]); - #define SCPACK_TERMINATOR , /* end each section with a comma */ #define SCPACK_TABLE sequences_table -/*-*SCPACK start of pair table, do not change or remove this line */ -unsigned char sequences_table[][2] = { - {32,37}, {114,105}, {112,129}, {46,130}, {128,49}, {132,33}, {97,100}, {46,97}, {135,108}, {136,116}, {111,134}, {108,138}, {50,33}, {115,104}, {128,140}, {137,33}, - {46,115}, {117,141}, {112,145}, {131,133}, {139,144}, {112,143}, {131,142}, {115,116}, {131,33}, {59,36}, {134,100}, {111,149}, {112,155}, {110,151}, {111,157}, {99,158}, - {146,152}, {112,33}, {120,161}, {101,162}, {153,163}, {148,150}, {137,133}, {46,99}, {122,101}, {168,114}, {154,114}, {110,100}, {101,113}, {147,160}, {51,33}, {128,174}, - {103,33}, {133,164}, {104,176}, {99,178}, {120,179}, {172,33}, {106,169}, {173,165}, {154,33}, {108,167}, {117,171}, {115,175}, {186,187}, {156,184}, {141,185}, {111,188}, - {98,191}, {105,100}, {115,103}, {115,108}, {193,120}, {182,133}, {114,33}, {166,165}, {190,131}, {137,142}, {171,33}, {97,202}, {169,111}, {139,147}, {159,147}, {139,150}, - {105,33}, {146,167}, {101,115}, {210,115}, {114,116}, {148,147}, {172,133}, {189,139}, {32,140}, {52,33}, {196,170}, {159,183}, {170,183}, {199,192}, {108,196}, {97,198}, - {195,211}, {46,208}, {194,212}, {200,216}, {112,223}, {46,98}, {118,101}, {153,228}, {111,230}, {109,232}, {146,143}, {204,152}, {99,144}, {159,150}, {97,149}, {203,156}, - {224,33}, {159,166}, {194,181}, {195,181}, {201,180}, {226,198}, {156,203}, {128,217}, {215,225}, {100,101}, {238,239}, {105,110}, {115,119}, {252,250}, {154,167} -}; -/*-*SCPACK end of pair table, do not change or remove this line */ #define seqsize(o,p) (opcodes(o)+opargs(p)) typedef struct { - char *find; - char *replace; + const char *find; + const char *replace; int savesize; /* number of bytes saved (in bytecode) */ } SEQUENCE; static SEQUENCE sequences_cmp[] = { @@ -69,109 +53,59 @@ static SEQUENCE sequences_cmp[] = { * pop.alt - */ { - #ifdef SCPACK "load.s.pri %1!push.pri!load.s.pri %2!pop.alt!", "load.s.pri %2!load.s.alt %1!", - #else - "\224\267\234", - "\245\224\246", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!push.pri!load.s.pri %2!pop.alt!", "load.s.pri %2!load.alt %1!", - #else - "\213\267\234", - "\245\213\246", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.s.pri %1!push.pri!load.pri %2!pop.alt!", "load.pri %2!load.s.alt %1!", - #else - "\224\255\317\234", - "\317\224\246", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!push.pri!load.pri %2!pop.alt!", "load.pri %2!load.alt %1!", - #else - "\213\255\317\234", - "\317\213\246", - #endif seqsize(4,2) - seqsize(2,2) }, /* (#1#) The above also occurs with "addr.pri" (array * indexing) as the first line; so that adds 2 cases. */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!pop.alt!", "addr.alt %1!load.s.pri %2!", - #else - "\334\234", - "\252\307", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.pri %2!pop.alt!", "addr.alt %1!load.pri %2!", - #else - "\252\255\317\234", - "\252\246\317", - #endif seqsize(4,2) - seqsize(2,2) }, /* And the same sequence with const.pri as either the first * or the second load instruction: four more cases. */ { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!pop.alt!", "load.s.pri %2!const.alt %1!", - #else - "\333\234", - "\245\361", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.pri %2!pop.alt!", "load.pri %2!const.alt %1!", - #else - "\237\255\317\234", - "\317\361", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.s.pri %1!push.pri!const.pri %2!pop.alt!", "const.pri %2!load.s.alt %1!", - #else - "\224\255\355\234", - "\355\224\246", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!push.pri!const.pri %2!pop.alt!", "const.pri %2!load.alt %1!", - #else - "\213\255\355\234", - "\355\213\246", - #endif seqsize(4,2) - seqsize(2,2) }, /* The same as above, but now with "addr.pri" (array @@ -179,23 +113,13 @@ static SEQUENCE sequences_cmp[] = { * the second. */ { - #ifdef SCPACK "addr.pri %1!push.pri!const.pri %2!pop.alt!", "addr.alt %1!const.pri %2!", - #else - "\252\255\355\234", - "\252\246\355", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "addr.pri %1!push.pri!zero.pri!pop.alt!", "addr.alt %1!zero.pri!", - #else - "\252\255\353\234", - "\252\246\353", - #endif seqsize(4,1) - seqsize(2,1) }, /* ??? add references */ @@ -208,33 +132,18 @@ static SEQUENCE sequences_cmp[] = { * so add another two cases. */ { - #ifdef SCPACK "move.pri!push.pri!load.s.pri %1!pop.alt!", "load.s.pri %1!", - #else - "\351\230\240\325\234", - "\325", - #endif seqsize(4,1) - seqsize(1,1) }, { - #ifdef SCPACK "move.pri!push.pri!load.pri %1!pop.alt!", "load.pri %1!", - #else - "\351\230\240\315\234", - "\315", - #endif seqsize(4,1) - seqsize(1,1) }, { - #ifdef SCPACK "move.pri!push.pri!const.pri %1!pop.alt!", "const.pri %1!", - #else - "\351\230\240\316\234", - "\316", - #endif seqsize(4,1) - seqsize(1,1) }, /* More optimizations for chained relational operators; the @@ -264,163 +173,83 @@ static SEQUENCE sequences_cmp[] = { * ;$exp - */ { - #ifdef SCPACK "xchg!sgrtr!swap.alt!and!pop.alt!;$exp!", "sless!pop.alt!and!;$exp!", - #else - "\264\365\375\244", - "\360\366\244", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sless!swap.alt!and!pop.alt!;$exp!", "sgrtr!pop.alt!and!;$exp!", - #else - "\264\360\375\244", - "\365\366\244", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sgeq!swap.alt!and!pop.alt!;$exp!", "sleq!pop.alt!and!;$exp!", - #else - "\264\362\375\244", - "\363\366\244", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sleq!swap.alt!and!pop.alt!;$exp!", "sgeq!pop.alt!and!;$exp!", - #else - "\264\363\375\244", - "\362\366\244", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sgrtr!swap.alt!and!pop.alt!jzer %1!", "sless!pop.alt!and!jzer %1!", - #else - "\264\365\375\305", - "\360\366\305", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sless!swap.alt!and!pop.alt!jzer %1!", "sgrtr!pop.alt!and!jzer %1!", - #else - "\264\360\375\305", - "\365\366\305", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sgeq!swap.alt!and!pop.alt!jzer %1!", "sleq!pop.alt!and!jzer %1!", - #else - "\264\362\375\305", - "\363\366\305", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sleq!swap.alt!and!pop.alt!jzer %1!", "sgeq!pop.alt!and!jzer %1!", - #else - "\264\363\375\305", - "\362\366\305", - #endif seqsize(5,0) - seqsize(3,0) }, { - #ifdef SCPACK "xchg!sgrtr!jzer %1!;$exp!", "jsgeq %1!;$exp!", - #else - "\264\365\266\261", - "j\302\254\261", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "xchg!sless!jzer %1!;$exp!", "jsleq %1!;$exp!", - #else - "\264\360\266\261", - "j\303\254\261", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "xchg!sgeq!jzer %1!;$exp!", "jsgrtr %1!;$exp!", - #else - "\264\362\266\261", - "j\342r\261", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "xchg!sleq!jzer %1!;$exp!", "jsless %1!;$exp!", - #else - "\264\363\266\261", - "j\340\261", - #endif seqsize(3,1) - seqsize(1,1) }, { - #ifdef SCPACK "xchg!sgrtr!;$exp!", "sless!;$exp!", - #else - "\264\365\244", - "\360\244", - #endif seqsize(2,0) - seqsize(1,0) }, { - #ifdef SCPACK "xchg!sless!;$exp!", "sgrtr!;$exp!", - #else - "\264\360\244", - "\365\244", - #endif seqsize(2,0) - seqsize(1,0) }, { - #ifdef SCPACK "xchg!sgeq!;$exp!", "sleq!;$exp!", - #else - "\264\362\244", - "\363\244", - #endif seqsize(2,0) - seqsize(1,0) }, { - #ifdef SCPACK "xchg!sleq!;$exp!", "sgeq!;$exp!", - #else - "\264\363\244", - "\362\244", - #endif seqsize(2,0) - seqsize(1,0) }, /* The entry to chained operators is also opt to optimization @@ -439,83 +268,43 @@ static SEQUENCE sequences_cmp[] = { * and all permutations... */ { - #ifdef SCPACK "load.s.pri %1!load.s.alt %2!xchg!", "load.s.pri %2!load.s.alt %1!", - #else - "\325\224\364", - "\245\224\246", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.s.pri %1!load.alt %2!xchg!", "load.pri %2!load.s.alt %1!", - #else - "\325\213\364", - "\317\224\246", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.s.pri %1!const.alt %2!xchg!", "const.pri %2!load.s.alt %1!", - #else - "\325\237\364", - "\355\224\246", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!load.s.alt %2!xchg!", "load.s.pri %2!load.alt %1!", - #else - "\315\224\364", - "\245\213\246", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!load.alt %2!xchg!", "load.pri %2!load.alt %1!", - #else - "\315\213\364", - "\317\213\246", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!const.alt %2!xchg!", "const.pri %2!load.alt %1!", - #else - "\315\237\364", - "\355\213\246", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.s.alt %2!xchg!", "load.s.pri %2!const.alt %1!", - #else - "\316\224\364", - "\245\361", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.alt %2!xchg!", "load.pri %2!const.alt %1!", - #else - "\316\213\364", - "\317\361", - #endif seqsize(3,2) - seqsize(2,2) }, /* Array indexing can merit from special instructions. @@ -543,7 +332,7 @@ static SEQUENCE sequences_cmp[] = { * 1. instruction addr.pri can also be const.pri (for * global arrays) * 2. the bounds instruction can be absent - * 3. when "n4" (the shift value) is the 2 (with 32-bit cels), use the + * 3. when "n4" (the shift value) is the 2 (with 32-bit cells), use the * even more optimal instructions LIDX and IDDXADDR * * If the array index is more complex, one can only optimize @@ -560,212 +349,112 @@ static SEQUENCE sequences_cmp[] = { #if !defined BIT16 /* loading from array, "cell" shifted */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!load.i!", "addr.alt %1!load.s.pri %2!bounds %3!lidx!", - #else - "\334\300\343\370", - "\252\335\336!", - #endif seqsize(8,4) - seqsize(4,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!load.i!", "const.alt %1!load.s.pri %2!bounds %3!lidx!", - #else - "\333\300\343\370", - "\237\335\336!", - #endif seqsize(8,4) - seqsize(4,3) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!load.i!", "addr.alt %1!load.s.pri %2!lidx!", - #else - "\334\343\370", - "\252\307\336!", - #endif seqsize(7,3) - seqsize(3,2) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!load.i!", "const.alt %1!load.s.pri %2!lidx!", - #else - "\333\343\370", - "\237\307\336!", - #endif seqsize(7,3) - seqsize(3,2) }, #endif /* loading from array, not "cell" shifted */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!load.i!", "addr.alt %1!load.s.pri %2!bounds %3!lidx.b %4!", - #else - "\334\300\310\367\370", - "\252\335\336\345\367", - #endif seqsize(8,4) - seqsize(4,4) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!load.i!", "const.alt %1!load.s.pri %2!bounds %3!lidx.b %4!", - #else - "\333\300\310\367\370", - "\237\335\336\345\367", - #endif seqsize(8,4) - seqsize(4,4) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!load.i!", "addr.alt %1!load.s.pri %2!lidx.b %3!", - #else - "\334\310\257\370", - "\252\307\336\345\257", - #endif seqsize(7,3) - seqsize(3,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!load.i!", "const.alt %1!load.s.pri %2!lidx.b %3!", - #else - "\333\310\257\370", - "\237\307\336\345\257", - #endif seqsize(7,3) - seqsize(3,3) }, #if !defined BIT16 /* array index calculation for storing a value, "cell" aligned */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!", "addr.alt %1!load.s.pri %2!bounds %3!idxaddr!", - #else - "\334\300\343\275", - "\252\335\332!", - #endif seqsize(7,4) - seqsize(4,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri 2!pop.alt!add!", "const.alt %1!load.s.pri %2!bounds %3!idxaddr!", - #else - "\333\300\343\275", - "\237\335\332!", - #endif seqsize(7,4) - seqsize(4,3) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!", "addr.alt %1!load.s.pri %2!idxaddr!", - #else - "\334\343\275", - "\252\307\332!", - #endif seqsize(6,3) - seqsize(3,2) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!shl.c.pri 2!pop.alt!add!", "const.alt %1!load.s.pri %2!idxaddr!", - #else - "\333\343\275", - "\237\307\332!", - #endif seqsize(6,3) - seqsize(3,2) }, #endif /* array index calculation for storing a value, not "cell" packed */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!", "addr.alt %1!load.s.pri %2!bounds %3!idxaddr.b %4!", - #else - "\334\300\310\367\275", - "\252\335\332\345\367", - #endif seqsize(7,4) - seqsize(4,4) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!shl.c.pri %4!pop.alt!add!", "const.alt %1!load.s.pri %2!bounds %3!idxaddr.b %4!", - #else - "\333\300\310\367\275", - "\237\335\332\345\367", - #endif seqsize(7,4) - seqsize(4,4) }, { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!", "addr.alt %1!load.s.pri %2!idxaddr.b %3!", - #else - "\334\310\257\275", - "\252\307\332\345\257", - #endif seqsize(6,3) - seqsize(3,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!shl.c.pri %3!pop.alt!add!", "const.alt %1!load.s.pri %2!idxaddr.b %3!", - #else - "\333\310\257\275", - "\237\307\332\345\257", - #endif seqsize(6,3) - seqsize(3,3) }, #if !defined BIT16 /* the shorter array indexing sequences, see above for comments */ { - #ifdef SCPACK "shl.c.pri 2!pop.alt!add!loadi!", "pop.alt!lidx!", - #else - "\343\327\320", - "\234\336!", - #endif seqsize(4,1) - seqsize(2,0) }, { - #ifdef SCPACK "shl.c.pri 2!pop.alt!add!", "pop.alt!idxaddr!", - #else - "\343\275", - "\234\332!", - #endif seqsize(3,1) - seqsize(2,0) }, #endif { - #ifdef SCPACK "shl.c.pri %1!pop.alt!add!loadi!", "pop.alt!lidx.b %1!", - #else - "\276\223\327\320", - "\234\336\345\205", - #endif seqsize(4,1) - seqsize(2,1) }, { - #ifdef SCPACK "shl.c.pri %1!pop.alt!add!", "pop.alt!idxaddr.b %1!", - #else - "\276\223\275", - "\234\332\345\205", - #endif seqsize(3,1) - seqsize(2,1) }, /* For packed arrays, there is another case (packed arrays @@ -783,23 +472,13 @@ static SEQUENCE sequences_cmp[] = { * case is already handled (see #1#) */ { - #ifdef SCPACK "addr.pri %1!push.pri!load.s.pri %2!bounds %3!pop.alt!", "addr.alt %1!load.s.pri %2!bounds %3!", - #else - "\334\300\234", - "\252\335", - #endif seqsize(5,3) - seqsize(3,3) }, { - #ifdef SCPACK "const.pri %1!push.pri!load.s.pri %2!bounds %3!pop.alt!", "const.alt %1!load.s.pri %2!bounds %3!", - #else - "\333\300\234", - "\237\335", - #endif seqsize(5,3) - seqsize(3,3) }, /* Declaration of simple variables often follows the sequence: @@ -810,23 +489,13 @@ static SEQUENCE sequences_cmp[] = { * ;$exp - */ { - #ifdef SCPACK ";$lcl %1 %2!stack -4!const.pri %3!stor.s.pri %2!;$exp!", ";$lcl %1 %2!push.c %3!;$exp!", - #else - "\231lcl\204\216\227ack -\331\237\203\257\227or\220\226\244", - "\231lcl\204\216\321\257\244", - #endif seqsize(3,3) - seqsize(1,1) }, { - #ifdef SCPACK ";$lcl %1 %2!stack -4!zero.pri!stor.s.pri %2!;$exp!", ";$lcl %1 %2!push.c 0!;$exp!", - #else - "\231lcl\204\216\227ack -\331\353\227or\220\226\244", - "\231lcl\204\216\321 0!\244", - #endif seqsize(3,2) - seqsize(1,1) }, /* During a calculation, the intermediate result must sometimes @@ -839,56 +508,31 @@ static SEQUENCE sequences_cmp[] = { * so add another two cases. */ { - #ifdef SCPACK "push.pri!load.s.pri %1!pop.alt!", "move.alt!load.s.pri %1!", - #else - "\240\325\234", - "\351\217\325", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "push.pri!load.pri %1!pop.alt!", "move.alt!load.pri %1!", - #else - "\240\315\234", - "\351\217\315", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "push.pri!const.pri %1!pop.alt!", "move.alt!const.pri %1!", - #else - "\240\316\234", - "\351\217\316", - #endif seqsize(3,1) - seqsize(2,1) }, { - #ifdef SCPACK "push.pri!zero.pri!pop.alt!", "move.alt!zero.pri!", - #else - "\240\353\234", - "\351\217\353", - #endif seqsize(3,0) - seqsize(2,0) }, /* saving PRI and then loading from its address * occurs when indexing a multi-dimensional array */ { - #ifdef SCPACK "push.pri!load.i!pop.alt!", "move.alt!load.i!", - #else - "\240\213\341\234", - "\351\217\213\341", - #endif seqsize(3,0) - seqsize(2,0) }, /* An even simpler PUSH/POP optimization (occurs in @@ -897,13 +541,8 @@ static SEQUENCE sequences_cmp[] = { * pop.alt - */ { - #ifdef SCPACK "push.pri!pop.alt!", "move.alt!", - #else - "\240\234", - "\351\217", - #endif seqsize(2,0) - seqsize(1,0) }, /* And what to think of this PUSH/POP sequence, which occurs @@ -913,13 +552,8 @@ static SEQUENCE sequences_cmp[] = { */ //??? //{ -// #ifdef SCPACK // "push.alt!pop.alt!", // ";$", /* SCPACK cannot handle empty strings */ -// #else -// "\225\237", -// "\353", -// #endif // seqsize(2,0) - seqsize(0,0) //}, /* Functions with many parameters with the same default @@ -937,33 +571,18 @@ static SEQUENCE sequences_cmp[] = { * a function call causes each argument to be optimized individually */ //{ -// #ifdef SCPACK // "const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!", // "const.pri %1!push.r.pri 5!;$par!", -// #else -// "\327\327\254", -// "\352\221.r\2745!", -// #endif // seqsize(10,5) - seqsize(2,2) //}, //{ -// #ifdef SCPACK // "const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!", // "const.pri %1!push.r.pri 4!;$par!", -// #else -// "\327\327", -// "\352\221.r\274\326", -// #endif // seqsize(8,4) - seqsize(2,2) //}, //{ -// #ifdef SCPACK // "const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!const.pri %1!push.pri!;$par!", // "const.pri %1!push.r.pri 3!;$par!", -// #else -// "\327\254", -// "\352\221.r\274\247", -// #endif // seqsize(6,3) - seqsize(2,2) //}, /* User-defined operators first load the operands into registers and @@ -979,83 +598,43 @@ static SEQUENCE sequences_cmp[] = { * This gives 2 x 4 cases. */ { - #ifdef SCPACK "const.pri %1!const.alt %2!push.pri!push.alt!", "push.c %1!push.c %2!", - #else - "\316\237\311\240\352", - "\321\205\321\216", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!const.alt %2!push.alt!push.pri!", "push.c %2!push.c %1!", - #else - "\316\237\311\352\240", - "\321\216\321\205", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.alt %2!push.pri!push.alt!", "push.c %1!push %2!", - #else - "\316\213\311\240\352", - "\321\205\222\216", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.alt %2!push.alt!push.pri!", "push %2!push.c %1!", - #else - "\316\213\311\352\240", - "\222\216\321\205", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!const.alt %2!push.pri!push.alt!", "push %1!push.c %2!", - #else - "\315\237\311\240\352", - "\222\205\321\216", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!const.alt %2!push.alt!push.pri!", "push.c %2!push %1!", - #else - "\315\237\311\352\240", - "\321\216\222\205", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!load.alt %2!push.pri!push.alt!", "push %1!push %2!", - #else - "\315\213\311\240\352", - "\222\205\222\216", - #endif seqsize(4,2) - seqsize(2,2) }, { - #ifdef SCPACK "load.pri %1!load.alt %2!push.alt!push.pri!", "push %2!push %1!", - #else - "\315\213\311\352\240", - "\222\216\222\205", - #endif seqsize(4,2) - seqsize(2,2) }, /* Function calls (parameters are passed on the stack) @@ -1078,53 +657,28 @@ static SEQUENCE sequences_cmp[] = { * if this shortcut is used. Check for the ;$par comment. */ { - #ifdef SCPACK "load.s.pri %1!push.pri!;$par!", "push.s %1!;$par!", - #else - "\224\255\347", - "\222\220\205\347", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "load.pri %1!push.pri!;$par!", "push %1!;$par!", - #else - "\213\255\347", - "\222\205\347", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.pri %1!push.pri!;$par!", "push.c %1!;$par!", - #else - "\237\255\347", - "\321\205\347", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "zero.pri!push.pri!;$par!", "push.c 0!;$par!", - #else - "\353\240\347", - "\321 0!\347", - #endif seqsize(2,0) - seqsize(1,1) }, { - #ifdef SCPACK "addr.pri %1!push.pri!;$par!", "pushaddr %1!;$par!", - #else - "\252\255\347", - "\222\252\205\347", - #endif seqsize(2,1) - seqsize(1,1) }, /* References with a default value generate new cells on the heap @@ -1133,13 +687,8 @@ static SEQUENCE sequences_cmp[] = { * push.pri - */ { - #ifdef SCPACK "move.pri!push.pri!", "push.alt!", - #else - "\351\230\240", - "\352", - #endif seqsize(2,0) - seqsize(1,0) }, /* Simple arithmetic operations on constants. Noteworthy is the @@ -1158,43 +707,23 @@ static SEQUENCE sequences_cmp[] = { * eq - */ { - #ifdef SCPACK "const.alt %1!add!", "add.c %1!", - #else - "\361\270", - "\376\205", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.alt %1!sub!", "add.c -%1!", - #else - "\361sub!", - "\376 -%1!", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.alt %1!smul!", "smul.c %1!", - #else - "\361smul!", - "smu\271\205", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.alt %1!eq!", "eq.c.pri %1!", - #else - "\361\265", - "\254\247\223", - #endif seqsize(2,1) - seqsize(1,1) }, /* Some operations use the alternative subtraction operation --these @@ -1208,23 +737,13 @@ static SEQUENCE sequences_cmp[] = { * sub.alt - */ { - #ifdef SCPACK "const.pri %1!load.s.alt %2!sub.alt!", "load.s.pri %2!add.c -%1!", - #else - "\316\224\311sub\217", - "\245\376 -%1!", - #endif seqsize(3,2) - seqsize(2,2) }, { - #ifdef SCPACK "const.pri %1!load.alt %2!sub.alt!", "load.pri %2!add.c -%1!", - #else - "\316\213\311sub\217", - "\317\376 -%1!", - #endif seqsize(3,2) - seqsize(2,2) }, /* With arrays indexed with constants that come from enumerations, it happens @@ -1233,13 +752,8 @@ static SEQUENCE sequences_cmp[] = { * add.c n2 - */ { - #ifdef SCPACK "add.c %1!add.c %2!", "add.c %1+%2!", - #else - "\376\205\376\216", - "\376\204+%\214", - #endif seqsize(2,2) - seqsize(1,1) }, /* Compare and jump @@ -1282,123 +796,63 @@ static SEQUENCE sequences_cmp[] = { * jzer n1 - */ { - #ifdef SCPACK "eq!jzer %1!", "jneq %1!", - #else - "\265\305", - "jn\326", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "eq!jnz %1!", "jeq %1!", - #else - "\265jnz\205", - "j\326", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "neq!jzer %1!", "jeq %1!", - #else - "n\265\305", - "j\326", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "neq!jnz %1!", "jneq %1!", - #else - "n\265jnz\205", - "jn\326", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "less!jzer %1!", "jgeq %1!", - #else - "l\323!\305", - "jg\326", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "leq!jzer %1!", "jgrtr %1!", - #else - "l\265\305", - "jg\324r\205", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "grtr!jzer %1!", "jleq %1!", - #else - "g\324\306\305", - "jl\326", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "geq!jzer %1!", "jless %1!", - #else - "g\265\305", - "jl\323\205", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "sless!jzer %1!", "jsgeq %1!", - #else - "\360\305", - "j\302\326", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "sleq!jzer %1!", "jsgrtr %1!", - #else - "\363\305", - "j\342r\205", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "sgrtr!jzer %1!", "jsleq %1!", - #else - "\365\305", - "j\303\326", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "sgeq!jzer %1!", "jsless %1!", - #else - "\362\305", - "j\340\205", - #endif seqsize(2,1) - seqsize(1,1) }, /* Test for zero (common case, especially for strings) @@ -1411,23 +865,13 @@ static SEQUENCE sequences_cmp[] = { * jneq n1 - */ { - #ifdef SCPACK "zero.alt!jeq %1!", "jzer %1!", - #else - "\314\217j\326", - "\305", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "zero.alt!jneq %1!", "jnz %1!", - #else - "\314\217jn\326", - "jnz\205", - #endif seqsize(2,1) - seqsize(1,1) }, /* Incrementing and decrementing leaves a value in @@ -1444,83 +888,43 @@ static SEQUENCE sequences_cmp[] = { * and decrements. */ { - #ifdef SCPACK "inc %1!load.pri %1!;$exp!", "inc %1!;$exp!", - #else - "\373c\205\315\244", - "\373c\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "load.pri %1!inc %1!;$exp!", "inc %1!;$exp!", - #else - "\315\373c\261", - "\373c\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "inc.s %1!load.s.pri %1!;$exp!", "inc.s %1!;$exp!", - #else - "\373\354\205\325\244", - "\373\354\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "load.s.pri %1!inc.s %1!;$exp!", "inc.s %1!;$exp!", - #else - "\325\373\354\261", - "\373\354\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "dec %1!load.pri %1!;$exp!", "dec %1!;$exp!", - #else - "\371c\205\315\244", - "\371c\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "load.pri %1!dec %1!;$exp!", "dec %1!;$exp!", - #else - "\315\371c\261", - "\371c\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "dec.s %1!load.s.pri %1!;$exp!", "dec.s %1!;$exp!", - #else - "\371\354\205\325\244", - "\371\354\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "load.s.pri %1!dec.s %1!;$exp!", "dec.s %1!;$exp!", - #else - "\325\371\354\261", - "\371\354\261", - #endif seqsize(2,2) - seqsize(1,1) }, /* ??? the same (increments and decrements) for references */ @@ -1549,63 +953,33 @@ static SEQUENCE sequences_cmp[] = { * time, but anyway... */ { - #ifdef SCPACK "const.pri 0!stor.pri %1!;$exp!", "zero %1!;$exp!", - #else - "\237\203 0!\227or\223\244", - "\314\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "const.pri 0!stor.s.pri %1!;$exp!", "zero.s %1!;$exp!", - #else - "\237\203 0!\227or\220\223\244", - "\314\220\261", - #endif seqsize(2,2) - seqsize(1,1) }, { - #ifdef SCPACK "zero.pri!stor.pri %1!;$exp!", "zero %1!;$exp!", - #else - "\353\227or\223\244", - "\314\261", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "zero.pri!stor.s.pri %1!;$exp!", "zero.s %1!;$exp!", - #else - "\353\227or\220\223\244", - "\314\220\261", - #endif seqsize(2,1) - seqsize(1,1) }, { - #ifdef SCPACK "const.pri 0!", "zero.pri!", - #else - "\237\203 0!", - "\353", - #endif seqsize(1,1) - seqsize(1,0) }, { - #ifdef SCPACK "const.alt 0!", "zero.alt!", - #else - "\237\211 0!", - "\314\217", - #endif seqsize(1,1) - seqsize(1,0) }, /* ----- */ diff --git a/compiler/libpc300/sc7.c b/compiler/libpc300/sc7.c index 37f18b88..536f5e88 100755 --- a/compiler/libpc300/sc7.c +++ b/compiler/libpc300/sc7.c @@ -51,7 +51,7 @@ #pragma warning(disable:4125) /* decimal digit terminates octal escape sequence */ #endif -#include +#include "sc7-in.scp" #if defined _MSC_VER #pragma warning(pop) @@ -334,65 +334,15 @@ SC_FUNC void stgset(int onoff) * are embedded in the .EXE file in compressed format, here we expand * them (and allocate memory for the sequences). */ -static SEQUENCE *sequences; +static SEQUENCE *sequences = sequences_cmp; SC_FUNC int phopt_init(void) { - int number, i, len; - char str[160]; - - /* count number of sequences */ - for (number=0; sequences_cmp[number].find!=NULL; number++) - /* nothing */; - number++; /* include an item for the NULL terminator */ - - if ((sequences=(SEQUENCE*)malloc(number * sizeof(SEQUENCE)))==NULL) - return FALSE; - - /* pre-initialize all to NULL (in case of failure) */ - for (i=0; i=0 && var -#include -#include "sc.h" - -#define STACKSIZE 16 - -SC_FUNC int strexpand(char *dest, unsigned char *source, int maxlen, unsigned char pairtable[128][2]) -{ - unsigned char stack[STACKSIZE]; - short c, top = 0; - int len; - - assert(maxlen > 0); - len = 1; /* already 1 byte for '\0' */ - for (;;) { - - /* Pop byte from stack or read byte from the input string */ - if (top) - c = stack[--top]; - else if ((c = *(unsigned char *)source++) == '\0') - break; - - /* Push pair on stack or output byte to the output string */ - if (c > 127) { - assert(top+2 <= STACKSIZE); - stack[top++] = pairtable[c-128][1]; - stack[top++] = pairtable[c-128][0]; - } - else { - len++; - if (maxlen > 1) { /* reserve one byte for the '\0' */ - *dest++ = (char)c; - maxlen--; - } - } - } - *dest = '\0'; - return len; /* return number of bytes decoded */ -} - -#if 0 /*for testing*/ -#include "sc5.scp" - -int main (int argc, char **argv) -{ - int i; - char str[128]; - - for (i=0; i<58; i++) { - strexpand(str, errmsg[i], sizeof str, SCPACK_TABLE); - printf("%s", str); - } /* for */ - return 0; -} -#endif - diff --git a/compiler/libpc300/scpack.c b/compiler/libpc300/scpack.c deleted file mode 100644 index 459532b7..00000000 --- a/compiler/libpc300/scpack.c +++ /dev/null @@ -1,450 +0,0 @@ -/* compress.c -- Byte Pair Encoding compression */ -/* Copyright 1996 Philip Gage */ - -/* This program appeared in the September 1997 issue of - * C/C++ Users Journal. The original source code may still - * be found at the web site of the magazine (www.cuj.com). - * - * It has been modified by me (Thiadmer Riemersma) to - * compress only a section of the input file and to store - * the compressed output along with the input as "C" strings. - * - * Compiling instructions: - * Borland C++ 16-bit (large memory model is required): - * bcc -ml scpack.c - * - * Watcom C/C++ 32-bit: - * wcl386 scpack.c - * - * GNU C (Linux), 32-bit: - * gcc scpack.c -o scpack - */ - -#include -#include -#include -#include -#include - -#if UINT_MAX > 0xFFFFU - #define MAXSIZE 1024*1024L -#else - #define MAXSIZE UINT_MAX /* Input file buffer size */ -#endif -#define HASHSIZE 8192 /* Hash table size, power of 2 */ -#define THRESHOLD 3 /* Increase for speed, min 3 */ - -#define START_TOKEN "#ifdef SCPACK" /* start reading the buffer here */ -#define NAME_TOKEN "#define SCPACK_TABLE" -#define SEP_TOKEN "#define SCPACK_SEPARATOR" -#define TERM_TOKEN "#define SCPACK_TERMINATOR" -#define TEMPFILE "~SCPACK.TMP" -static char tablename[32+1] = "scpack_table"; -static char separator[16]=","; -static char terminator[16]=""; - -int compress(unsigned char *buffer, unsigned buffersize, unsigned char pairtable[128][2]) -{ - unsigned char *left, *right, *count; - unsigned char a, b, bestcount; - unsigned i, j, index, bestindex, code=128; - - /* Dynamically allocate buffers and check for errors */ - left = (unsigned char *)malloc(HASHSIZE); - right = (unsigned char *)malloc(HASHSIZE); - count = (unsigned char *)malloc(HASHSIZE); - if (left==NULL || right==NULL || count==NULL) { - printf("Error allocating memory\n"); - exit(1); - } - - /* Check for errors */ - for (i=0; i 127) { - printf("This program works only on text files (7-bit ASCII)\n"); - exit(1); - } - - memset(pairtable, 0, 128*2*sizeof(char)); - - do { /* Replace frequent pairs with bytes 128..255 */ - - /* Enter counts of all byte pairs into hash table */ - memset(count,0,HASHSIZE); - for (i=0; i bestcount) { - bestcount = count[i]; - bestindex = i; - } - } - - /* Compress if enough occurrences of pair */ - if (bestcount >= THRESHOLD) { - - /* Add pair to table using code as index */ - a = pairtable[code-128][0] = left[bestindex]; - b = pairtable[code-128][1] = right[bestindex]; - - /* Replace all pair occurrences with unused byte */ - for (i=0, j=0; i= 128 || *bufptr == '"' || *bufptr == '\\') - fprintf(output, "\\%03o", *bufptr); - else - fprintf(output, "%c", *bufptr); - bufptr++; - } /* while */ - fprintf(output, "\""); - needseparator = 1; - bufptr++; /* skip '\0' */ - } /* while */ - fprintf(output, "%s\n",terminator); - bufptr++; - - /* skip the input file until the #endif section */ - while (fgets(str,sizeof str,input)!=NULL) { - if (strmatch(str,"#endif",NULL)) { - fprintf(output,"%s",str); - break; /* done */ - } /* if */ - } /* while */ - } /* while - !feof(input) */ -} - -static void usage(void) -{ - printf("Usage: scpack [output file]\n"); - exit(1); -} - -int main(int argc, char **argv) -{ - FILE *in, *out; - unsigned char *buffer; - unsigned buffersize, orgbuffersize; - unsigned char pairtable[128][2]; - - if (argc < 2 || argc > 3) - usage(); - if ((in=fopen(argv[1],"rt"))==NULL) { - printf("SCPACK: error opening input %s\n",argv[1]); - usage(); - } /* if */ - if (argc == 2) { - if ((out=fopen(TEMPFILE,"wt"))==NULL) { - printf("SCPACK: error opening temporary file %s\n",TEMPFILE); - usage(); - } /* if */ - } else { - if ((out=fopen(argv[2],"wt"))==NULL) { - printf("SCPACK: error opening output file %s\n",argv[2]); - usage(); - } /* if */ - } /* if */ - - buffer = (unsigned char *)malloc(MAXSIZE); - if (buffer == NULL) { - printf("SCPACK: error allocating memory\n"); - return 1; - } /* if */ - /* 1. read the buffer - * 2. compress the buffer - * 3. copy the file, insert the compressed buffer - */ - buffersize = readbuffer(in, buffer); - orgbuffersize = buffersize; - if (buffersize > 0) { - buffersize = compress(buffer, buffersize, pairtable); - writefile(in, out, buffer, buffersize, pairtable); - printf("SCPACK: compression ratio: %ld%% (%d -> %d)\n", - 100L-(100L*buffersize)/orgbuffersize, orgbuffersize, buffersize); - } else { - printf("SCPACK: no SCPACK section found, nothing to do\n"); - } /* if */ - fclose(out); - fclose(in); - /* let the new file replace the old file */ - if (buffersize == 0) { - if (argc == 2) - remove(TEMPFILE); - else - remove(argv[2]); - } else if (argc == 2) { - remove(argv[1]); - rename(TEMPFILE,argv[1]); - } /* if */ - return 0; -} From 8b06e5bdcdf2e6d326474d16801f3e4a09d6e051 Mon Sep 17 00:00:00 2001 From: xPaw Date: Tue, 10 Mar 2015 20:37:57 +0200 Subject: [PATCH 2/2] Remove strexpand --- compiler/libpc300/sc5.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/compiler/libpc300/sc5.c b/compiler/libpc300/sc5.c index 19ae236c..f7071f8f 100755 --- a/compiler/libpc300/sc5.c +++ b/compiler/libpc300/sc5.c @@ -115,8 +115,6 @@ static short lastfile; } } /* if */ - strexpand(string,(unsigned char *)msg,sizeof string,SCPACK_TABLE); - if (errline>0) errstart=errline; /* forced error position, set single line destination */ else