+/lc3tools
git clone https://git.julia.blue/+/lc3tools
56ee5e5
master
1define int and long as short, long double and double as float 2 3string literals go in rom or data, if literals match, maybe use pointers to the same ones to save space. if it needs to be modified use char array instead of char pointer. 4 5global and static go in data 6 7local (auto) goes on stack 8 9C89 options: -Wall -Wextra -std=c89 -pedantic 10and if i really want: -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition 11 12http://icecube.wisc.edu/~dglo/c_class/vstorage.html 13 14lea doesn't set comparison flag 15 16Newton raphson sqrt 17 18Profiler check line nums 19 20freestanding just needs limits stddef stdarg and float 21stdlib, stdio, math, string, etc. are extra 22 23array of structs stores inline not pointers 24 25struct as arg is by VALUE (gets coppied) and takes up space for every field 26 27async keyboard reading using interupts instead of traps? 28 29R6 is stack pointer 30R5 is frame pointer 31R4 is static/global/bss? 32R3 is function jump table 33 34new layout: 350 (ret) (arg0) temp 361 temp 372 temp 383 temp (CFF or RFF addr) 394 temp (0000 0000 0000 0000) 40 ^^^ ^.......^ 41 ||| 8 bit func id 42 ||Invoke R0 43 |Invoke R1 44 Invoke R2 455 FP 466 SP 477 IP 48 49Frame layout (grows down but diagrammed backwards): 50 51... <----- Stack pointer 52local arrays/structs? 53locals (max of 15 bytes) 54lastFP <----- Frame pointer 55retaddr 56args (max of 15 bytes) 57... (retval should end up here with sp pointing to it. or 1 lower if void) 58prev frame 59 60little intermediate language or straight to assembler macros 61 62no trigraphs because... who the heck cares about trigraphs anyways 63 64no preprocessor meta language 65 66Notes from the c89 draft: 67 68translation phases: 691. unimportant trigraph stuff (skip) 702. line continuations 713. from raw text to preprocessing tokens 724. execute directives and expand macros (skip) 735. convert escape sequences in string literals 746. concatenate string literals 757. convert preprocessing tokens to actual tokens and compile 768. linkage (skip) 77 78four kinds of scopes: function, file, block, and function prototype 79 80preprocessing token are: header names, identifiers, preprocessing numbers, character constants, string literals, operators, punctuators 81 82tokens are: keywords, identifiers, constants, string literals, operators, and punctuators 83 84namespaces (and how to disambiguate): 85labels (syntax of declaration and use) 86struct/enum tags (following struct or enum keywords) 87struct members (. or ->) 88ordinary identifiers (declared in ordinary declarators or as enumeration constants) 89 90storage durations: 91static if out of functions or with storage-class specifier. init just once before startup 92auto any time else 93 94types: 95"Even if the implementation defines two or more basic types to have the same representation, they are nevertheless different types." 96char = int_8 97signed char = NONE 98short = int_16 99int = int_16 100long = int_16 101unsigned _ = NONE 102float = MAYBE 103double = NONE 104long double = NONE