@Database "LITTEL.guide"

@Node Main "LITTEL v0.14"
 

                  LITTEL Language v0.14b,15b

                  @{" Introduction              " link intro}
                  @{" Requirements              " link requ}
                  @{" Installation              " link install}
                  @{" Feautures                 " link feautures}
                  @{" The Instructions/Keywords " link keywords}
                  @{" What the startupcode does " link startcode}
                  @{" Some Rules                " link syntaxrules}
                  @{" Calling Subroutines       " link callsub}
                  @{" Using Data                " link usingdata}
                  @{" Currrent Bugs/Limitations " link buglim}
                  @{" Copying/Using/Disclaimer  " link disc}
                  @{" About the implementation  " link implement}
                  @{" Examples                  " link examples}
                  @{" History                   " link history}
                  @{" The Author                " link author}

                    Copyright © Leif Salomonsson '99

@EndNode

@Node intro "Introduction"

   Its a small and simple language, similar to assembler,
   but with some higher-level 'instructions' or keywords
   that make things like loops and conditional things much
   easyer. The simple integer-instructions also, compared
   to 68k-assembler, is easier to use, have common
   'adressing-modes' and so on. The main idea from the
   beginning was to make a kind of cpu independant, but
   still lowlevel and fast language as a 'base-language'
   for building higher level languages on top of.
   For now it uses PhxAss/Lnk by Frank Wille to
   assemble executables for Amiga 68k.

@EndNode

@Node requ "Requirements"

   Amiga OS 2 +
   68000 +
   PhxAss 4.39
   PhxLnk

@EndNode

@Node install "Installation"

   Copy Litteldrawer whwrever you want.
   Assign Littel: to the drawer.
   Make sure you have an assign for incdir:  (asm includes)

@EndNode

@Node feautures "Feautures"

   * The LITTEL language currently supports 68000 and higher CPUs.
   * Stackbased and registerbased params.
   * PROCs in littel witch recieves params on the stack uses RTD (68010+)
   * Can use external standard objectfiles .o .lib (regbased and/or stackbased params)
   * Easy library use.  (regbased params)
   * Local and Global variables.
     Only LONGs for variables (like in E)
   * All kinds of variables and registers can be used
     directly as PTRs with optional offset.
     (ex D4[B].offset = the byte D4 points at + offset)
   * All instructions are INLINE.
   * Its small and simple.
   * Read on and try it.

@EndNode

@Node keywords "The Keywords (or instructions)"


 LITTEL is still in beta and anything may change!

 dvc = direct value, like : $FFFE/123/-2048/5/etc
 any = STACK/localVar/_globaVar/%parameter/Dx/Ax/localVar[]/_globalvar[]/%paramater[]/Dx[]/Ax[]

      ****************************
      *DATA TRANSFER INSTRUCTIONS*
      ****************************

 COPY source:any/dvc       dest:any
 SWAP target1:any          target2:any
 SAVEREGS                  [reglist]    default is D1-D5/A0-A3
 LOADREGS                  [reglist]

      *************************
      *ARITMETHIC INSTRUCTIONS*
      *************************

 MUL  with:any/dvc         target/dest:any     altdest:any
 DIV  with:any/dvc         target/dest:any     altdest:any
 SHL  steps:any/dvc        target/dest:any     altdest:any
 SHR  steps:any/dvc        target/dest:any     altdest:any
 ADD  source:any/dvc       target/dest:any     altdest:any
 SUB  source:any/dvc       target/dest:any     altdest:any
 INC  amount:dvc           target:any
 DEC  amount:dvc           target:any
 ABS  target/dest:any      altdest:any
 NEG  target/dest:any      altdest:any
 MAX  source1:any/dvc      source2:any/dvc     dest:any
 MIN  source1:any/dvc      source2:any/dvc     dest:any
 LIMIT min:any/dvc         max:any/dvc         target:any

      ********************
      *LOGIC INSTRUCTIONS*
      ********************

 BGET bitnum:any/dvc       source:any/dvc      dest:any (0 or <>0)
 BCLR bitnum:any/dvc       target/dest:any     altdest:any
 BSET bitnum:any/dvc       target/dest:any     altdest:any
 BCHG bitnum:any/dvc       target/dest:any     altdest:any
 OR   source:any/dvc       target/dest:any     altdest:any
 XOR  source:any/dvc       target/dest:any     altdest:any
 AND  source:any/dvc       target/dest:any     altdest:any
 NOT  target/dest:any      altdest:any

      *******************
      *MISC INSTRUCTIONS*
      *******************

 DOPROC name                 <param param pa...>
 CALL   address:any/dvc      offset:dvc
 ADR    globalblockname      dest:any
 PADR   procname             dest:any
 RETURN list of any/dvc

      *******************
      *LABELING KEYWORDS*
      *******************

 PROC name:name

 GVAR _name:first letter '_'   // global var

 STRING anyname_anycase "this is a string!"  // null-terminated string

 LBLK/WBLK/BBLK anyname_anycase nrofelements:dvc
                                        // long/word/byte - block
                                        // uninitialised

                                        // l/w/b - block
                                        // initialised
 LONGS/WORDS/BYTES anyname_anycase listofelements: ex. 10,-16,54,32,100

      ******************************
      *CONDITIONAL/LOOPING KEYWORDS*
      ******************************

      ?? = EQ/NE/GT/LT/GE/LE

 IF any/dvc ?? any/dvc
 ELSE  // no letting this one out !
 ENDIF

 SELECT Dx     // only Dx can be used here! may change
 CASE any/dvc
 CASE any/dvc
 C...
 DEFAULT      // no letting this one out!
 ENDSELECT

 WHILE any/dvc ?? any/dvc
 ENDWHILE

 REPEAT
 ENDREPEAT any/dvc ?? any/dvc

      ******************
      *SUPPORT KEYWORDS*
      ******************

 OPENLIBRARY namewithout".library" ver:dvc

 CLOSELIBRARY namewithout".library"

      ****************************************
      *MISC COMPILER CONTROL/SUPPORT KEYWORDS*
      ****************************************

 #const Constantname EQU value   // declare constant, first letter uppercase

                                // import (xref)
 #xref name

                                // export (xdef)
 #xdef name

 #incdir "path"  // not ready, LITTEL searches incdir: for now

 #include "file"  // include asm .i type files with constants

 #mode EXE(default) / OBJECT  // create .o file

                 // define path for .o and such files
 #linkdir "path"  // not ready, LITTEL searches LITTEL:lib/ for now

 #link "file.o/file.lib"

 #insert "src.l" // not ready yet! inserts littel src at spot.

 #nostartup  // 15b : dont link in startupcode, know what youre doin :)

@EndNode

@Node startcode "The startup code of LITTEL v0.14b does :"

   Startup Code Opens :
         _execBase
         _dosBase
         _graphicsBase
         _intuitionBase
         _utilityBase
         _stdin_
         _stdout_
         _arg_

   ...and initializes smalldata.

   Includes for dos and exec are automatic.

@EndNode

@Node syntaxrules "Some Rules"

   LITTEL v0.14

   The only allowed commenting is
   commenting preceeded by '//'
   // this is a comment

   EVERY single line of code starts with an instruction or keyword!

   Only ONE keyword/instruction is allowed per line !

   Local Vars must begin with a-z

   Global Vars must begin with _

   Stackparameters (received) begins with %

   Dataregs begins with D followed by 0-7

   AdrRegs begins with A followed by 0-7

   Constants must begin with A-Z

   Direct Values : %01010, 2000, -3000, $FFFe, -$19, etc..

   PROC name. name can be anyname anycase.

   The first PROC in source is the 'main' procedure

   VAR declarations in PROC must end with ENDVAR
   PARAM declarations in PROC must end with ENDPARAM

   Dont forget the last END in the source !

   PTRs [] :
      With no character between the brackets
      its treated as a PTR TO LONG.
      Valid PTR sizes : L or W or B (LONG, WORD, BYTE)
      ex. myptr[B]
      Illegal : mywindow[w].height
      Legal : mywindow[W].height

      Ptrs can have offsets added to them :
      myptr[].offset
      offset must be direct value or constant.

   NO SPACEes in any names!
   NO SPACEes in following : mywindow[W].height
     this is illegal : mywindow[ W ].height
                       mywindow[] .height
                       etc..

   Between keywords and arguments there can be as much spaces you want.

   Calling a PROC with parameters :

      DOPROC procname any/dvc any/dvc any/dvc ...... etc. Max 7 params (for now)!
      ex. DOPROC myproc 1 2 A0 D4 _myGlobal

      Add FLUSH after the last parameter if the routine you are calling
      doesnt cleanup the parameters on stack.

   The register A4 and A5 is used internally by LITTEL. NO TOUCHING!
   Also registers D6, D7 and A6 is used for scratch by various
   instructions. So dont put anything in them an expect it to be there :)

   See examples for more information.

@EndNode

@Node callsub "Calling Subroutines"

   A subroutine in LITTEL looks like :

   PROC name
      <code>
   ENDPROC   

   If using callbackhooks from other code then Littel
   u must get the A4 register if you want to use any globals
   or librarybases. Do it with GETA4 first thing in PROC
   after (any) variables or params declarations.


   There are two ways of calling in LITTEL.

   Using DOPROC or CALL

   1. DOPROC procname
    like BSR in assembler, it branches to a labeled subroutine.
    You can put params after the procname. All PROCs created
    in LITTEL automatically flushes the params on stack, (if any)
    by using RTD. So there is a special DOPROC-keyword, 'FLUSH'
    that you must put after the params when calling external #imported
    functions if they do not flush the params by them selfes.
    Parameters are put on the stack in _reverse_ order. (C-style ?)
    No registers are saved by default. If external functions could
    trash A4 or A5 then you must save them first!

    By using the instruction 'PADR procname dest' you can get the adr of
    a labeled subroutine. Example of use : callbackhooks.

   2. CALL address offset
    This one you will likely use for calling libraries.
    address can be anything, register or ptr or variablel etc.
    offset can be a direct value or constant.
    If not calling libraries but just an address you can put just
    0 as offset.
    The internal registers A4/A5 will get saved before CALLing.

   Registers D0-D5/A0-A3 can ofcource also be used for parameterpassing
   at any time!

@EndNode

@Node usingdata "Using Data"

   Variables

     All variables in LITTEL are of the 32bit LONG Type (signed).

       Definition

         Local to PROC

           VAR name
           VAR name
           V....
           ENDVAR

           PARAM %name
           PARAM %name2
           P.....
           ENDPARAM

         Global outside of PROC

           GVAR _name

         Registers

           D0 D1 D2 D3 D4 D5
           A0 A1 A2 A3

         Variables as PTRs

           PTR TO LONG

             myvar[] D0[] _global[] A0[] %param1[]
             myvar[] D0[L] _global[L] A0[] %param1[L] ..etc

           PTR TO WORD, BYTE

             anyvariable[W]
             anyvar[B]
             D3[W] ..etc..

           PTRs with Offset

             myptr[L/W/B].Offset
             mywindow[W].w_Heigth
             myptr[B].1200
             myptr[L].-32000
             etc..


   Blocks

     Currently in LITTEL all blocks of data are Global.
     By using the ADR instruction you get the address of
     such a block. 

   BlockTypes

     Initialized

       STRING name 'string!'
       LONGS name val,val,val,val,val....
       WORDS
       BYTES

     UnInitialized

       LBLK name nrofelements
       WBLK
       BBLK

     Example

       STRING my "mooo"

       ADR my ptr // put address of the STRING my in ptr
       COPY ptr[B] D0 // get first char ('m') from my to D0

@EndNode


@Node buglim "Current Bugs / Limitations"

 Very little errorchecking!

 SELECT crashes compiler sometimes

 ABS producing bad code

 If u dont give lc any arguments it crashes
 Also be sure to type lc15 namewithout.l or it crashes!

 something else ?

@EndNode

@Node examples "Examples"

   // Hello World in LITTEL :)

   STRING hello "hello world!\n"

   PROC main
      ADR hello D1       // address of our hellostring in D1
      COPY 13 D2                // len of string to D2
      CALL _dosBase WriteChars  // print it
   ENDPROC

   END  // dont forget this one

   Please look into the Examples drawer.

@EndNode

@Node history "History"

   Sorry for very uncomplete history

v0.11b ***********************

 introduced  Global vars

 added FUNC, DOFUNC

 added some security checks..

v0.12b ***********************
       991119

 new naming stuff :
 local vars : first two letters lowercase, a-z
 constants  : first letter uppercase A-Z
 global vars : first letter '_'
 FUNC/PROC/STRING, BLK, DC names : anycase, anything

 new ADR syntax : ADR STRING/BLK/DC/FUNC/PROC name xx

 string_name:
 proc_name:
 func_name
 blk_name:
 dc_name:

  done! :) -> even better :
 STRING, PROC, FUNC, LBLK, WBLK, BBLK, LONGS, WORDS, BYTES

 globals working

 added SWAP instruction

 now u can have the same name of local vars in diffrent PROCs.

 found bug that didnt allow '=' anywhere in src.

 extremely experimental ELSE ! hell.. not working..discarding it.

 Added OPT LARGE in sources

 nnow ELSE is working! New format for IF..:
 IF
 ELSE  -> must be there!
 ENDIF

 added DEFAULT in SELECT block.. DEFAULT MUST be there!

 changing CALL name offset -> CALL adr offset

v0.13b ********************************

 getting rid of FUNC
 just PROC
 if a VAR is declared i a PROC then
 we add the link/unlk instructions.. that simple!
 but.. we need ENDVAR
 PROC nisse
 VAR ulla
 VAR albert
 ENDVAR
 <code>

 done!
 optimised PROC/ENDVAR/ENDPROC litle...

 made copy2.e
 simpler but not as optimised.. but that can be done later..
 for now it works fine atleast..

 bugfixed some in copy 2..

 thinking of adding support for parameters to PROCs
 using rtd #paramsize isteda of rts, IF params are used.

 HOPEFULLY.. @param support is now added! :)

v0.14b *********************************''

 lc14 : removing parser, using my own class instead.
 extractwords.e

 adding new 'parametermodes'

 added ABS, NEG, MAX, MIN, LIMIT

 added support for external PROCs/subroutines
 with no own stackcleanup! like powerD.lib for example..
 use FLUSH as last param.

 changed names of STORE_REGS, RESTORE_REGS to
 REGS2STK, STK2REGS
 well its still beta! :)

 things to do : possibly implement "ABCD" -> value

 just remebered.. think the ABS wasnt working right..

 extractwords.e now handles '//' by it self :)

 commented out #export and #mode. no use for them yet anyway.

 added returnvalues after ENDPROC. values in D0/D1/D2....etc

 added RETURN instruction.. put optional values after it.

 created dynamic stringstack, lc14 now only writes to _one_ file. (speedup)
 this will probably later meen that SELECT can handle _any_ type instead of Dx.

 SELECT now handles any type

 Complete rewrite of the COPY instruction (witch other instructions uses)
 much smarter and efficient.

v0.15b

 DEFAULT in SELECT block no longer must be there.

 Added CONT, an alternativ to CASE. CONTinue with this...

 Added #nostartup keyword. guess what it does...
  pretty dangerous to use this switch right now!
  (the smalldata isnt initialized)

 doesnt use the stringstack for tempdata anymore
 but its now alot faster then before, on the bad side :
 more memory is required and memory could get overwritten
 if my very nasty memory-use-prediction should fail :(

 Strange bug in something.. :) the compiler hangs just before exiting.
 code generation is ok...

 Added GETA4. Handy when getting called from other code (callbackhooks).

 Fixed the strange bug. Bug in EC it seems.. Now im not ENDing
 some objects at programend.. One dont have to anyway.. but it
 shouldnt crash.

 Changed 'ADR' into ADR and PADR, for global datablocks and PROCedures
 respectively.

 Fixed the #mode keyword. Now you can create objects .o ! :)
 Use '#mode OBJECT'. This automatically sets #nostartup also.

 #export is back! guess why..

 Changed #export, #import -> #xdef, #xref    :)

 Optimised COPY instruction to the maximum!

 Optimised Stackrestoration when calling external procedures
 using FLUSH.
   MOVE.L (A7)+, D7 times nrofparams  -> LEA nrofparams*4(A7), A7

 SELECT still buggy, compiler crashes... :(

@EndNode

@Node feauture "What the feauture might bring"

   * Higher Level Language Preprocessors as plugins.
     This could be your job! :) contact me if youre interested.

   * Probably caseinsensitive keywords.

   * Maybe PPC support, its just about money.
     As PPC would fits this language perfecly it would rock! :)

   * Exception handling...not sure how to implement it right now.

   * LITTEL as a shared library. Different language frontends
     calls the librarys functions to create code..

   * ADR will probably go away

   * Local blocks of data (not just LONG-vars)

@EndNode

@Node author "The Author"

  suggestions, bugreports or whatever

  leif_salomonsson@swipnet.se

@EndNode

@Node implement "The implementation"

   LITTEL from v0 to this release, v0.15b,
   is/was written completely in E.
   It uses a very simple one-pass technique.
   Just wandering from the top line to the last line,
   parsing the instructions and their arguments
   using my own parser routine. some versions ago,
   I used afc/parser for that.
   The asm-strings from conversionroutines is put into 4 precalcedsized stringbuffers.
   At the end, the buffers are written to the asmfile in a special order.
   The file gets assemled by PhxAss and Linked by PhxLnk.
   All code uses small-data.
   The executable is split into 3 hunks : code, data and bss.

@EndNode

@Node disc "blablabla"

             its freeware anyway
  but i dont want people hacking it and releasing
  their own Littels....  talk to me instead.

  AND.. I will not take ANY responsibility
  for ANYTHING that migth go wrong when/after
  using this compiler. its all AT YOUR OWN RISK!

  The archive may be distributed (untouched) in any way
  as long as no money is earned doing it.

@EndNode

