Post Reply 
C translator for calculator project
05-06-2019, 07:51 AM
Post: #2
RE: C translator for calculator project
I have a hard time associating the word "readable" with C. How about making your calculator language able to take multiple instructions from each line, with white space, and with comments that don't get compiled, and add structure words. I write my HP-41 programs in a text editor this way before entering them on the 41, with the exception of the structure words. I do use the structure words in assembly language though, using macros. I modeled them mostly (but not completely) after Forth structures; so you have for example BEGIN...WHILE...REPEAT, IF...ELSE...END_IF, FOR...NEXT (actually that one is from BASIC), the CASE structure (called switch...case in C), etc.. They're nestable too. Most labels are eliminated, and most branch instructions are hidden. In most cases, there's no penalty, either in run speed or in memory taken, because the macros are assembling the same things you would write out by hand if you had to, only now you don't have to look at the ugly internal details anymore. You still can jump or do other unstructured things if you want to, for those few situations where you don't have the perfect program flow control structure and don't want to take the time to form one you'll only use once. I have examples in the last 40% of my page on simple multitasking methods, at http://wilsonminesco.com/multitask/ , more discussion of the structures at http://wilsonminesco.com/StructureMacros/ , and more on the internal details of how to work a stack in the assembler itself to accomplish all this, at http://wilsonminesco.com/stacks/pgmstruc.html . (These articles are 6502-oriented, but can be applied more widely.)

http://WilsonMinesCo.com (Lots of HP-41 links at the bottom of the links page, http://wilsonminesco.com/links.html )
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
C translator for calculator project - Dan - 05-06-2019, 05:18 AM
RE: C translator for calculator project - Garth Wilson - 05-06-2019 07:51 AM



User(s) browsing this thread: 1 Guest(s)