diff --git a/CHANGELOG.org b/CHANGELOG.org index 1de2ee4..d44eda5 100644 --- a/CHANGELOG.org +++ b/CHANGELOG.org @@ -17,6 +17,7 @@ * Current ** Added Added the ability to remove watch points in the webide +Added program to search for unusual characters that are not human detectable ** Changed Expanded stage0 web IDE to include the PC and instruction counter @@ -26,6 +27,7 @@ Fixed behavior of R@ thanks to reepca Updated changed checksums for stage2 FORTH Corrected behavior when using the web IDE and attempting to set registers that don't exist Fixed regression in hex.c caused by refactoring +Fixed output of large negative numbers in hex ** Removed Removed stage1_assembler-0's need for Memory and reduced size of program while at it diff --git a/High_level_prototypes/asm.c b/High_level_prototypes/asm.c index c0f5666..c5fd384 100644 --- a/High_level_prototypes/asm.c +++ b/High_level_prototypes/asm.c @@ -581,7 +581,7 @@ void eval_immediates(struct Token* p) if(('0' == p->Text[0]) || (0 != value)) { - sprintf(p->Expression, "%04x", value); + sprintf(p->Expression, "%04x", value & 0xFFFF); } } diff --git a/High_level_prototypes/sin.c b/High_level_prototypes/sin.c new file mode 100644 index 0000000..dfd34b2 --- /dev/null +++ b/High_level_prototypes/sin.c @@ -0,0 +1,60 @@ +/* Copyright (C) 2016 Jeremiah Orians + * This file is part of stage0. + * + * stage0 is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * stage0 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with stage0. If not, see . + */ + +#include +#include +#include + +/* Standard C main program */ +int main(int argc, char **argv) +{ + /* Make sure we have a program tape to run */ + if (argc < 2) + { + fprintf(stderr, "Usage: %s $FileName\nWhere $FileName is the name of the file being examined\n", argv[0]); + return EXIT_FAILURE; + } + + FILE* source_file = fopen(argv[1], "r"); + int numbers = 0; + int lowers = 0; + int upppers = 0; + int others = 0; + + int c; + do + { + c = fgetc(source_file); + switch(c) + { + case 48 ... 57: numbers = numbers + 1; break; + case 65 ... 90: upppers = upppers + 1; break; + case 97 ... 123: lowers = lowers + 1; break; + case 9: + case 10: + case 32 ... 47: + case 58 ... 64: + case 91 ... 96: others = others + 1; break; + default: fprintf(stderr, "read %02X\n", c); + } + } while(EOF != c); + + fprintf(stderr, "Found %d numbers\nFound %d uppers\nFound %d lowers\nFound %d others\n", numbers, upppers, lowers, others); + + fclose(source_file); + return EXIT_SUCCESS; +}