A85: Example header for the compiler


[Prev][Next][Index][Thread]

A85: Example header for the compiler




BTW, the other person I am working with to make this compiler is Keith
Batten.  He is on this list as well as assembly-86 if I recall correctly.
 It looks like we might call our compiler ZEn, which stands for Z80
Ensemble, though if all goes well, we'd have to change it because the 92,
the computer (most of them), and I believe the 89 don't use Z80 assembly
code.  Anyway, here's the header:

-----------> READ THIS!!!

-----------> This is for ZShell 4.0

-----------> Feel free to send me your ideas and even .asm code I can use
-----------> If you send code, and it's not for something dumb like the
-----------> operator + for an integer, but something custom like
displaying
-----------> text on the screen with either left, right, etc.
justification
-----------> then send your name and any other info you want included if
I
-----------> choose to use your code, so you can receive proper credit

// A # symbol means to put the following line of code directly in the
.asm
//    at the top of the file with all other #'s found in the file
// They will be put in the order they were found in
// You can use a # without anything after it to make the compiled code
//    look better as shown here

##include "ti-85.h"
#
#.org 0

// Notice how comments are inserted by using two front-slashes or a semi-
//    colon.  Comments using the slashes will not be inserted into the
//    artificially generated .asm file.  Comments using semi-colons that
//    are not nested within a function, etc. will be put at the very top
//    of the .asm file (even before the #'s).  Nested semi-colon comments
//    will be inserted as they are encountered.  This allows information
//    to be given to a user reading the .asm file.  Also nice if someone
//    Wants their name to be given credit every time their donated
function
//    is used =)

// In a .zpp source file, the message that will be displayed in the shell
//    that tells something about the program will be set like this:
//    main("Description here")

// Use these for info about the calc
// Should be things not defined in the above include file(s)

[GRAPH_X 128]                 // Horizontal pixels on the graph screen
[GRAPH_Y 64]                  // Vertical pixels on the graph screen
[TEXT_X 21]                   // Horizontal characters on the text screen
[TEXT_Y 8]                    // Vertical characters on the text screen

// The asm declaration for temporary variables might vary
// The typedef will probably be a class containing each type's info:
// Each typedef will have a variable type in <>, probably a string
// Each typdef will have a name, which means the name of the variable
//    that follows the type in the .zpp code
// There will be a static integer that keeps track of how many variables
//    have been declared in the .zpp code
// Suppose this next example is the 9th variable declared in the file.
// Here's an example of a declaration of an int in a .zpp file:
//    int var1;
// The class will have the following data contained within
//    DefinedType.name = "var1"
//    DefinedType.vartype = "int"
//    DefinedType::count = 9
// Code put in brackets [] will be processed by the compiler then written
//    to the location of the first bracket [.  There will be a limit on
//    what the compiler will calculate.  Probably adding, subtracting,
//    multiplying?, dividing?.  And even then, there will be
restrictions.
// From here on out, data types will probably have <> around them
// Right now I'm not sure if you can read in hex (80df) as a string and
//    convert it to an integer.  If you can all the better.  If not, I
//    could write one myself, or limit compiler calculation from files to
//    be only with base-10 style decimals.  I know you can write hex to a
//    file so that won't be a problem.

typedef <int>
{
   [name] = $[$80df + count]
   ;[name] = $[hex(32991 + count)] 
}

// Special note on this type;  it's used for functions that take actual
data
//    data as a parameter, not the name of a location where data is
stored.
//    You can see how it is used in the ope
_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]

rator = declaration.
// You should only use this type when making libraries, not in a .zpp
file.
// Compiling this might be a little long, because when you write
something
//    like myfunc(5), I could have it check for data types of type 5, and
//    when it's not found I assume it's of type user and write it as it
is,
//    but what if someone makes a data type called 5.  That would be
stupid
//    and I should really disallow using numbers, apostrophes, quotes,
//    brackets of any type, etc. in a data type, function name, etc.

typedef <notype> { [name] }

typedef <char>
{
// This might be similar to an int, but I'm not sure of the
implementation.
}

// Now that we have some types defined we can expand to allow operators
// Notice there is a space on either side of the actual operator
// This function allows you to make a statement like this:
//    int inta;
//    inta = 2;
// In the .zpp file.  There is a seperate operator = for doing this:
//    int inta;
//    int intb;
//    inta = 2;
//    intb = inta;
// The above code snip-it raises an interesting question.  Should I allow
//    commas in the declaration of variables like this:
//       int inta, intb;
// It would be extra work, I'm not sure how much, but it might be worth
it
//    if I want a really good looking, user friendly interface.
// You probably DON'T have to user rhs and lhs for operators, but it's
//    easy to remember which is which. (lhs = left hand side, rhs = right
//    hand side)  Pretty nifty, huh?
// Here is an example of how using an operator = in a .zpp would look:
//    int inta;
//    int intb;
//    inta = 2;
//    intb = 0;
// This would compile as so:
//    inta = $80df
//    intb = $80e0
//    main:
//       ld a, 2
//       ld (inta), a
//       sub a
//       ld (intb), a
// Note how inta is declared above main.  This makes code look neater in
//    a synthetic .asm file.

operator = (<int> lhs, <user> rhs)
{
// Allowing if statements in compiler calculations could allow efficient
code
// If an if statement is true, print only the next line of code
// sub a is faster and smaller than ld a, 0
   [?(rhs == 0)]
   sub a
   [?(rhs != 0)]
   ld a, rhs
// This next line will always be printed to the .asm
   ld (lhs), a
}

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]