-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
  82-ROM.TXT      A Programmer's Guide to TI-82 ROM Calls       Version 0.5
            Copyright (c) 1999 Mattias Lindqvist & Dines Justesen
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------

This file lists routines found in the TI82 ROM. All the adresses are from 
ROM version 19.0, and some of them will not work with other versions. Not all
of the functions listed has been tested in an assembly program. If you do
find any errors please mail information on which function your called, what
address you used and what it was supposed to do.

Suggestion, additions and corrections to this document is very welcome, mail
them to the address listed below. The newest version of this document can
always be foudn an the home page listed below.

Dines Justesen
email: c958362@student.dtu.dk
www  : htt://www.student.dtu.dk/~c958362


All number in this document is in hex, except where denoted by a d. Below is
a list of symbols used in the text.

 Bit x,(Addr+y) Test bit x of byte at Addr+y, and set flags
 Set x,(Addr+y) Set bit x of the byte at Addr+y
 Res x,(Addr+y) Reset bit x of the byte at Addr+y
 (addr)         The contents of the memory location addr
 x -> y         When used with a 16 bit register it means that x is a pointer
                to y. When used with a FP stack element or OP1..OP6 it means
                that x is stored in y. (quite confusing, storing should be
                changed to LD).

---- CALL 0000 ---- Startup code --------------------------------------------
Input : none
Result : This is the code executed when the calc is first turned on.

---- CALL 0007 ---- Call general interrupt handler --------------------------
Note : the function calls the interrupt handler at 0038

---- CALL 0008 ---- OP1 -> OP2 ----------------------------------------------

---- CALL 000B ---- Bit 0,(IY+7) --------------------------------------------

---- CALL 0010 ---- Search for varialbe by name -----------------------------
Note : Assumes that the var is not a program (or type 6). This function calls
       2143, see that for information on how to call this.

---- CALL 0013 ---- Is graph mode function ----------------------------------
Result : Bit 4,(IY+2)

---- CALL 0018 ---- Push value in OP1 on FP stack ---------------------------

---- CALL 001B ---- Do not use graph mem ------------------------------------
Result : Set 0,(IY+3)

---- CALL 0020 ---- (HL) -> OP1 ---------------------------------------------

---- CALL 0023 ---- A = (8BCB) or (8BCB) ------------------------------------

---- CALL 0028 ---- OP1 = OP1*OP2 -------------------------------------------

---- CALL 002B ---- A=(8BCB)=0 ----------------------------------------------

---- CALL 0030 ---- OP1 = OP1+OP2 -------------------------------------------

---- CALL 0033 ---- LD HL,(HL) ----------------------------------------------
Input: HL -> data word
Result:	HL = data word
	A = L

---- CALL 0038 ---- Interrupt handler ---------------------------------------

---- CALL 0081 ---- Has the ON key been pressed ? ---------------------------
Result: Bit 4,(IY+09)

---- CALL 0086 ---- Is graph mode polar -------------------------------------
Result: Bit 5,(IY+02)

---- CALL 008B ---- Is graph mode seq ---------------------------------------
Result: Bit 7,(IY+02)

---- CALL 0090 ---- Is graph mode param -------------------------------------
Result: Bit 6,(IY+02)

---- CALL 0095 ---- CP HL,DE ------------------------------------------------
Input: DE and HL holds valus to compare.
Result: Falgs set. No registers destroyed.

---- CALL 009B ---- Display : -----------------------------------------------

---- CALL 00A1 ---- Unpack one digit of HL to A -----------------------------

---- CALL 00B3 ---- Update busy counter -------------------------------------

---- CALL 0103 ---- APD -----------------------------------------------------
Input: none
Result: The calc is turned off is enough time has gone for APD. (used by
         the interrupt handler to manage APD)

---- CALL 0129 ---- Halt ----------------------------------------------------
Input: none
Result: The HALT instruction is executed

---- CALL 012B ---- Reset APD counter----------------------------------------
Input: none
Result: (800A)=0074h

---- CALL 0131 ---- Keyboard handler 1 --------------------------------------
Input: nothing
Result: All memory locations concerning keypresses are update. This funcion
        is called by the interrupt handler to update the keybuffer.

---- CALL 0173 ---- More than one key pressed -------------------------------
Input: none
Result: (8002)=FFh \ More than one key pressed
        (8004)=5h  /


---- CALL 017E ---- Read key from port --------------------------------------
Input: none
Result: A = Key. Carry set if more then one pressed

---- CALL 01B8 ---- Read information from keyboard --------------------------
Input: A = key group mask
Result: A = B = key press data

---- CALL 01C7 ---- Store keystroke in buffer -------------------------------
Input: A = Key to store
Result: (8000) = Scancode
        (8006) = Scancode if not zero
        Set 3,(IY+0)

---- CALL 01d4 ---- Read current keystroke from buffer ----------------------
Input: Nothing
Result: A = Scancode of key currently pressed
        HL = Pointer to buffer
        Res 3,(IY+000)

---- CALL 01E1 ---- Alpha stuff ---------------------------------------------
Used to update cursor information

---- CALL 01E8 ---- More alpha stuff ----------------------------------------
Used to update cursor information

---- CALL 0462 ---- Call function at (8116) and (8118) ----------------------
Result: Cals 46D and 473 and bit stuff.

---- CALL 046D ---- Call function at (8116) page (8120) ---------------------
Result: The function is called. HL is destroyed.
        The rom page will be changed to (8120).

---- CALL 0473 ---- Call function at (8118) page (8120) ---------------------
Result: The function is called, and a lot of bit stuff.

---- CALL 04B4 ---- Call function at (811A) page (8120) ---------------------
Result: The function is called. The functions does not destroy any registers
        but, HL will be the adr of the function when the function os called.
        The rom page will be changed to (8120).

---- CALL 04B9 ---- Call function at (811E) page (8120) ---------------------
Result: Bit 5,(IY+4). The function is called. Destroys HL. The rom page is
        changed to what it was before on return from function. Before the
        function is called A=B=(8161)

---- CALL 04CA ---- Call function at (811C) page (8120) ---------------------
Result: The functions is called. Destroys HL and A. The rom page is changed
        back to what it was before on return from the function.

---- CALL 04DC ---- Call function at (8114) page (8120) ---------------------
Result: The function is called. The functions does not destroy any registers
        but, HL will be the adr of the function when the function os called.
        The rom page will be changed to (8120).

---- CALL 04ED ---- Homescreen error handler --------------------------------

---- CALL 05C5 ---- Turn off calc f1 ----------------------------------------
Input: none
Result: The display is turned off, the checksum at 8145 is updated and calc
        halted. (Used for APD)

---- CALL 0641 ---- Has the ON key been pressed -----------------------------
Result: Set 4,(IY+9)

---- CALL 0684 ---- Reset calc ----------------------------------------------
Input: none
Output: The whole calc is reset.

---- CALL 0779 ---- Init system pointers ------------------------------------
Result: 8D0A, 8D0C, 8D0E are set to 8D24 (beginning of user mem)
        8D10, 8D12, 8D18 are set to FE6E (start of vat)
        8553 = 40H and 8554 = 60h

---- CALL 079A ---- Calc checksum between 8D24 and FE70 ---------------------
Result: Checksum memory between 8D24 and FE70
        HL = checksum
        IX = FE71
        BC = 0
        DE = -HL

---- CALL 07CC ---- Inittialize calculator ----------------------------------
Called from 0000, initializes the calc.

---- CALL 07F3 ---- Delay for screen ops ------------------------------------
Input: none
Result: Nothing (HL incresed and decreased, but flags not alterd)
        This function should be called after each operation the display
        controller performs.

---- CALL 1901 ---- HL=HL*9 -------------------------------------------------
Input: HL holds number
Result: HL=9*HL
        BC=HL

---- CALL 190B ---- Get type of OP1 -----------------------------------------
Result : A = (OP1) and 0Fh

---- CALL 1A19 ---- Copy (HL) -> (DE) ---------------------------------------

---- CALL 1A88 ---- Copy (HL) -> OP1 ----------------------------------------

---- CALL 1B36 ---- Write BC times 0 to (HL) --------------------------------
Input: Hl holds pointer, BC holds number of bytes
Result: BC bytes of 0 is written to (HL)

---- CALL 1B3C ---- Get upper nible -----------------------------------------
Input: C hold value
Result: A = upper nible of C

---- CALL 1B44 ---- A=C*4 ---------------------------------------------------
Input: C holds value to be multiplied
Result: A = 4*C

---- CALL 1DAD ---- Get constant from table 4 -------------------------------
Input: B holds number of constant to get
Result: OP2 holds the constant from the table at 1444. If OP5 is negative
        then an offset of 8 is used.

---- CALL 1DB5 ---- Get constant from table 3 -------------------------------
Input: B holds number of constant to get
Result: OP4 holds the constant from the table at 13C4. If OP5 is negative
        then an offset of 8 is used.

---- CALL 1DCB ---- Copy var number c ---------------------------------------
Input: HL points to start of table. B=size of vars and C= var number to get
       De points to place to copy the variable. A= offset from begining.
Result: The variable is copied to de

---- CALL 1DD9 ---- Get constant from table 2 -------------------------------
Input: A holds number of constant to get
Result: Constant number a from the table at E7B is copied to OP4
        (the constants are all 8 bytes)

---- CALL 1DEF ---- Get constant from table ---------------------------------
Input: A holds number to get
Result: The constant is placed in OP1
        The constants are the following:
        #        Value             Name
        --------------------------------
        0: 57.29577951308232       180/Pi
        1:  1.570796326794897      Pi/2
        2:  0.7853981633974483     Pi/4
        3:  0.4342944816032518     Log e
        4:  3.141592653589800      Pi
        5:  0.01745329251994330    Pi/180
        6:  2.302585092994046      ln 10

---- CALL 1DF4 ---- Get constant from table ---------------------------------
Input: A holds number to get
Result: The constant is placed in OP2
        The constants are the following:
        #        Value             Name
        --------------------------------
        0: 57.29577951308232       180/Pi
        1:  1.570796326794897      Pi/2
        2:  0.7853981633974483     Pi/4
        3:  0.4342944816032518     Log e
        4:  3.141592653589800      Pi
        5:  0.01745329251994330    Pi/180
        6:  2.302585092994046      ln 10

---- CALL 1F12 ---- Is variable informaiton in OP1 for ANS ??? --------------

---- CALL 1F18 ---- HL=H*L --------------------------------------------------
Input: HL holds number to be multiplied
Result: HL=H*L
        DE=L

---- CALL 1F29 ---- Check that OP1 is real (else error) ---------------------

---- CALL 1F84 ---- (88AE)=(8D0E) -------------------------------------------

---- CALL 1FC5 ---- Bit 0,(IY+7) -----------------------------------------------
Note: Calls errorhandler if cleared

---- CALL 1FCC ---- Bit 4,(IY+9) --------------------------------------------
Note: Calls errorhandler if the ON key has been pressed

---- CALL 1FD3 ---- BIT 5,(IY+9) --------------------------------------------

---- CALL 1FD8 ---- BIT 1,(IY+3) --------------------------------------------

---- CALL 1FDD ---- Get upper nible of OP1 byte 1 ---------------------------
Result: A=(OP1)=4 MSBs

---- CALL 204E ---- Is (8121) = 40, 4A, 43, 49, 45, 4B or 4C (rets which) ---

---- CALL 2061 ---- Is var in OP1 type 5/6 ----------------------------------

---- CALL 206A ---- Comapre DE with 003F ------------------------------------

---- CALL 2071 ---- Test (IY+14) bit 0 and 2 --------------------------------
Input: none
Result: Returns zero if bit 2 is set or bit 0 is cleared. Otherwise it
        returns nz. Zero=split screen on.

---- CALL 2079 ---- BIT 0,(IY+14) -------------------------------------------

---- CALL 207E ---- RES 2,(IY+14) -------------------------------------------

---- CALL 2083 ---- SET 0,(802A) --------------------------------------------

---- CALL 20B6 ---- Write 7 to port 10 --------------------------------------
Input: none
Result: The value 7 is writen to port 10

---- CALL 20C0 ---- Write 5 to port 10 --------------------------------------
Input: none
Result: The value 5 is written to port 10

---- CALL 20C5 ---- Get # of bytes availble ---------------------------------
Input: none
Result: HL = number of bytes availble
        BC = Pointer to end of user mem

---- CALL 20D7 ---- Get length of name at (HL) ------------------------------
Input: (HL) holds name as zero terminated string (8 bytes long)
Result: A holds length

---- CALL 20DA ---- Get length of name at OP1+1 -----------------------------
Input: OP1+1 or (8029) holds name as zero terminated string (8 bytes long)
Result: A holds length

---- CALL 20EB ---- Search for program by name ------------------------------
Searches the program VAT for a program. info in OP1.
Result: HL = pointer to VAT entry
        DE = Pointer to data space

---- CALL 213E ---- Serach for variable by token/name -----------------------
Seraches VAT to find variable. infor in op1. works for all types.
Result: HL = pointer to VAT entry
        DE = Pointer to data space

---- CALL 2143 ---- Search for variable by token ----------------------------
Same as rst 10. Does not work for programs. Info in OP1.
Result: HL = pointer to VAT entry
        DE = Pointer to data space
        A = (OP1) = type of var

---- CALL 21A5 ---- Create VAT info at (8D12) -------------------------------
Input: OP1 holds data to write to VAT.
Result: The values is added to the VAT starting at (8D12).
        HL = pointer DE = pointer

---- CALL 21FE ---- Allocate memory -----------------------------------------
Input: BC = number of bytes. AF holds something too?
Result: the memory is allocated

---- CALL 2272 ---- Move memory up ------------------------------------------
Input: De points to the place to insert HL bytes
Result: The bytes are inserted, and system pointers are updated

---- CALL 227C ---- Move memory up ------------------------------------------
Input: De points to the place to insert HL bytes
Result: The bytes are inserted, but system pointers are not updated

---- CALL 2297 ---- Is memory availble --------------------------------------
Input: HL = Number of bytes to get
Result: DE = Number of bytes to get
        HL = Number of bytes you can have extra
        Carry clear on succes

---- CALL 22C8 ---- Is memory availble 2 ------------------------------------
Input: HL = Size of variable data
       OP1 = holds variable information on the var
       If the variable is a  program then A = length of name
Result: Carry clear if you can get it set otherwise.
Note: This function check that there is room for the data and the vat entry.

---- CALL 22DD ---- Create Variable -----------------------------------------
Same as 22e0 but different parameters ?

---- CALL 22E0 ---- Create Variable -----------------------------------------
Input:
Result: Does evrything

---- CALL 234D ---- Create Real variable ------------------------------------
Input: only name ?
Result: It is created

---- CALL 238B ---- Create Variable -----------------------------------------
Also initializes length field of data area

---- CALL 23CA ---- Reszie Variable -----------------------------------------
Input: HL = current size of variable. DE = new size of variable.
       (8087) and (8089) -> variable. OP1 holds variable info.
Result: The variables size is adjusted to the new size.

---- CALL 23F9 ---- Update system pointers 1 --------------------------------
Updates a lot of system pointers

---- CALL 241A ---- Update system pointers 2 --------------------------------
Updates a lot of system pointers

---- CALL 254B ---- Update system pointers 3 --------------------------------
Updates a lot of system pointers

---- CALL 26A9 ---- Update (8CF2) -------------------------------------------
BC is added to (8CF2) if (8CF2) is > DE

---- CALL 26AF ---- Get actual size of var in bytes -------------------------
Input: A = type of var (MS nibble has to be 0)
       BC holds length word of the var
Result: DE = actual number of bytes (including the length field)

---- CALL 26B3 ---- Get actual size of var in bytes -------------------------
Input: HL points to the variable
       A = type of var
Result: HL = pointer to the var
        DE = actual number of bytes (including the length field)

---- CALL 2848 ---- Is memory availble --------------------------------------
Input: HL = Number of bytes to get
Result: Same as 2297, but error handler called on error.

---- CALL 284F ---- BC=-BC --------------------------------------------------
Input: Bc holds number
Result: BC=HL=-BC
        A=0

---- CALL 28F7 ---- Initialize error handler --------------------------------
Input: HL points to error handler
Results: error handler is installed

---- CALL 291D ---- Pop current error handler -------------------------------
Input: none
Result: The current error handler is removed and the previous one is
        reinstalled
---- CALL 292D ---- Compare strings -----------------------------------------
Input: HL and DE points to strings
Result: BC holds number of bytes which are the same

---- CALL 2940 ---- Copy zero terminted string ------------------------------
Input: HL = string to be copied
       DE = string to copy to
Result: the string is copied

---- CALL 2948 ---- Concatenate zero terminted string -----------------------
Input: HL = string to be concatenated
       DE = place to write string
Result: The string at (HL) is appended to the string at (DE)

---- CALL 294F ---- Compare length indexed strings --------------------------
Input: HL and DE points to strings
Result: Flags set

---- CALL 2975 ---- Find bit in bitstream -----------------------------------
Input: HL = Base addres
       A = # bit from base adr
Result: HL = adres of byte
        A = mask need to select bit

---- CALL 2DE8 ---- Save var info for Y-Var in OP1 --------------------------
Input: (854D) hold the number of the var to get (starting from 1)
Result: The functions loads the variable information of the var into OP1.
        (IY+2) is used to select which var is chosen.

The select which var to create your self use one of the functions below.
2DBF Yt
2DC8 Xt
2DDE Y
2DE3 r
2DFA Un/Vn
Before calling the function the number of the var to create has to be in
(854D). So calling 2DBF with (854D)=2 will leave the variable information
for Yt2 in OP1.

---- CALL 2E02 ---- Selftest ------------------------------------------------
Result: The selftest is run

---- CALL 2E60 ---- Call rom function ---------------------------------------
Uses 2E87 for return.

---- CALL 2E8F ---- Jump to rom function ------------------------------------

---- CALL 3752 (14CB2) ---- Print char in A with out translation ------------
Input: A holds char to display
Result: The char is display at the current position

---- CALL 37E8 (152A2) ---- Display char in A using small font --------------
Input: A holds char to display
Result: The char is displayed using the small font. ((8215) and (8216) holds
        the position to write it)

---- CALL 37EE (153DC) ---- Print ASCIIZ string at (HL) using small font ----
Input: Hl -> ASCIIZ string
Result: The string is displayed using the small font. ((8215) and (8216)
        holds the position to write it)

---- CALL 37F4 (15401) ---- Print B chars from (HL) using small font --------
Input: B holds number of chars to display, HL -> string
Result: The first B chars of the string is displayed using the small font.
         ((8215) and (8216) holds the position to write it)

---- CALL 3836 (155E0) ---- Get pointer to string from token 1 --------------
Input: DE holds token
Result: HL points to length indexed string. A holds length of string.

---- CALL 383C/382A (155E5) ---- Get pointer to string from token 2 ---------
Input: DE holds token
Result: HL points to length indexed string.

---- CALL 3878 (1588B) ---- Copy name of token followed by =? ---------------
Input: OP1 holds token to get name of
Result: The buffer at (81DF) holds a ASCIIZ strgin containgin the name of
        the token followed by =?

---- CALL 387E (158AE) ---- Print list of tokens at 8087 --------------------
Input: none
Result: The list of tokens pointed to by (8087) is display on the display.
        The first word of the list is the number of bytes the tokens take
        up, after that the tokens in the order in which they should be
        printed.

---- CALL 3884 (158DF) ---- Print DONE on end of line -----------------------
Input: none
Result: DONE is written at the end of the current line (like whena basic
        program is finished).

---- CALL 388A (158EB) ---- Print name of var with token pointed to by HL ---
Input: HL->List of tokens DE->End of list
Result: The names of the tokens are printed on the current location on the
        display. This function stops printing when it reaches the token
        which start at DE.

---- CALL 3890 (151A4) ---- Clear LCD ---------------------------------------
Input: none
Result: The LCD is cleared

---- CALL 3896 (14D94) ---- Display number in HL ----------------------------
Input: HL holds number to print
Result: The number is printed at the current possition (right jusified in 5
        spaces, leading zeroes not printed). OP1 is destroyed by this rutine.

---- CALL 38A2 (56654) ---- Print *** FAIL ----------------------------------
Input: Hl points to string (ASCIIZ) to print in front of FAIL
Result: The string is printed followed by the words FAIL

---- CALL 38A8 (56523) ---- Test calculator ---------------------------------
Input: none
Result: Part of the self test is executed and the clac is resat.

---- CALL 38E4 (151E1) ---- Clear text screen -------------------------------
Input: none
Result: The LCD is cleared, and if bit 1 of (IY+0D) is set the text mem is
        set to all spaces.

---- CALL 3914 (14DB8) ---- Print ASCIIZ string -----------------------------
Input: HL -> null-terminated string
       (800C) = row
       (800D) = column
       set 3, (IY+05): display white on black
       res 3, (IY+05): display black on white

---- CALL 391A (15281) ---- Goto top of text screen -------------------------
Input: none
Result: The text cursor is moved to the top of the current text window.

---- CALL 3932 (15430) ---- Turn off busy indicator -------------------------

---- CALL 393E (6523E) ---- Keyboard handler --------------------------------

---- CALL 394A (15417) ---- Turn on busy indicator --------------------------

---- CALL 39E0 (177FE) ---- Store display contence in buffer ----------------
Input: none
Result: The image currently displayed is copied to the backup buffer at 8228

---- CALL 39EC (14D68) ---- Print character with translation ----------------

---- CALL 39F2 (00038) ---- Filler FF's -------------------------------------
Calls interrupt handler


Other Variable functions
------------------------

Create a variable of a specific type. These functions updates ANS ?
23B1 Program
23AD GDB
23A6 Pic
239C Y-var
2397 Y-var length 0
2383 type 4
2375 Matrix
2353 List

Register function
-----------------

The rutines below copies one register (or parts of it) to another register.

1A93 OP1 -> (DE) 9 bytes
1A8E (HL) -> OP2 9 bytes
1A8D (HL) -> OP2 9 bytes (also copies (HL) to OP1)
1A88 (HL) -> OP1 9 bytes
1A80 OP4 -> OP6
1A7B OP5 -> OP3
1A76 OP4 -> OP3
1A6E OP2 -> OP3
1A69 (HL) -> OP3 Digits-e
1A61 OP3 -> OP1 Digits
1A59 OP3 -> OP1 Digits-e
1A51 OP5 -> OP1 Digits-e
1A49 OP3 -> OP2 Digits-e
1A41 OP2 -> OP1 Digits
1A3C OP4 -> OP1 Digits
1A34 OP1 -> OP4 Digits
1A2C OP2 -> OP4 Digits
1A15 (HL) -> (DE)
1A0F OP2 -> OP1
1A07 OP1 -> OP5
19FF OP1 -> OP6
19F7 OP2 -> OP6
19EF OP2 -> OP5
19E7 OP3 -> OP5
19DF OP4 -> OP5
19DA OP3 -> OP1
19D5 OP5 -> OP1
19D0 OP4 -> OP1
19CB OP6 -> OP1
19C3 OP6 -> OP2
19BB OP1 -> OP2
19B3 OP5 -> OP4
19AB OP5 -> OP6
19A3 OP5 -> OP2
199B OP1 -> OP3
1993 OP3 -> OP2
198A OP4 -> OP2
1981 OP2 -> OP4
1978 OP1 -> OP4
196F OP3 -> OP4

Misc functions using the registers

192C Compare OP1,OP2
1926 Compare |OP1|,|OP2|
1921 Compare OP1,(HL)
1919 Compare OP4,OP3
18FC (DE) = 1.0
18F6 (DE) = 0.0
18BB A=(8031)=(8032)=(803C)=(803D)=0 (zero out last 2 bytes of OP1 and OP2)

The following functions subtracts the value shown below from the 2nd byte of
OP1. OP1 is not altered, the value is returned in A. Destroys E.

1FB6 081
1FBD 07F
1FC1 08C
1FB8 A (the register)
1FAE OP2 byte 2

The rutines below write 00 XX 00 00 ... to OP1, where XX is the value indicated

1F5C 52
1F58 5B
1F71 58
1F75 59
1F79 54
1F7B value in register A

The rutines below writes the indicated value to op1 (token)

1F46 __2A0100
1F66 00216200 Real
1F60 03016200 Y-Var
1F51 01 A5D00 List number A
1F3F 03004000 Y-Var
1F35 05002300 System program
1F30 05002100 System program
1F24 __2E0100
    1
Set register to value

1B16 OP1=0.0
1ABF OP1=1.0
1AD7 OP1=2.0
1ACB OP1=3.0
1AC4 OP1=4.0

1B11 OP2=0.0
1AE7 OP2=1.0
1ADC OP2=2.0
1AB7 OP2=3.0
1AB0 OP2=4.0
1AA9 OP2=5.0
1AA2 OP2=8.0

1B0C OP3=0.0
1A9D OP3=1.0
1AD2 OP3=2.0


1B07 OP4=0.0
1A98 OP4=1.0

1AEC (HL)=A

Same as above, but does not change sign byte.

1B1C OP2 = 0.0

The following rutines writes 11 bytes 00.

1B21 OP1
1B26 OP2
1B2B OP3

The functions below shifts the register one digit rigth (div by 10).

1B4A OP2 (does not use extra digit)
1B59 OP2 (does use extra digit)
1B50 OP1 (uses all digits and first digit of exponent)
1B5C (HL) (does use extra digit)

The functions below shifts the register one digit left (mul by 10).

1B76 OP3 (does not use last 2 digits)
1B7B OP1 (does not use last 2 digits)
1B88 OP3 (does not use extra digits)
1B8D OP1 (does not use extra digits)

Write value in register to real.
     type  source dest
1BAA OP2   OP4    OP3   ?
1BB2  1    OP1    OP3   ?
1BB9 b-OP5 OP2    OP3   ?

Exchange registers

1D33 OP1 OP2
1D29 OP1 OP3
1D2E OP1 OP4
1D12 OP1 OP5
1D17 OP1 OP6

1D1C OP2 OP4
1D21 OP2 OP5
1D05 OP2 OP6

1D0A OP5 OP6

1D39 (HL) (DE)

The following functions subtracts one registers from another, the functions
marked with an e uses the exponent too. This is not fp math function, only
uses digits.

1CFC OP1 = OP1 - OP1
1CF3 OP3 = OP3 - OP1
1CED OP4 = OP4 - (HL)
1CC2 (DE)=(DE) - (HL)
1CBC (DE)=(DE) - (HL) e
1CB6 OP1 = OP1 - OP3 e
1CAE OP3 = OP3 - OP1 e
1CA9 OP1 = OP1 - OP2 e
1CA1 OP2 = OP2 - OP1 e

Same as above, but adds.

1C98 OP1 = OP1 + OP3
1C41 OP1 = OP1 + OP3 e
1C38 OP1 = OP1 + OP2
1C33 OP2 = OP2 + OP2
1C2B OP1 = OP1 + OP2 e
1C23 OP2 = OP2 + OP1 e
1C1B OP2 = OP2 + OP4 e


1C88 OP2 = OP2 + OP3 uses sign of OP5 only 4 bytes
1C78 same as above but all digits and exponents

Misc

1D45 Is OP1 0.0
1D4A Is OP2 0.0
1DB5 Transcendal function ??
1EB4 Is OP2 positive
1EBA Is OP1 positive
1EC0 OP2=|OP2|
1EC5 OP1=|OP1|
1EDA Dec exponent of OP1
1EE2 Inc exponent of OP1
1EFE Check exponent of op1 (overflow underflow)
1F0C Is exponent of OP1 >0

FP Stack rutines
----------------

The FP Stack is an upwards growing stack which is used for temporary storage
of real/complex reals.

Std. stack rutines
------------------
26F4 POP OP1
26EF POP OP2
26EA POP OP3
26E5 POP OP4
26E0 POP OP5
26DB POP OP6
26F7 POP (HL)

273E PUSH OP1
2739 PUSH OP2
2734 PUSH OP3
272F PUSH OP4
272A PUSH OP5
2725 PUSH OP6

FPS(X) Represents real number x on the FP Stack, the element at the top is
called number 0.

Adr 0 09 12 1B 24 2D 36 3F 6C
E # 0 1  2  3  4  5  6  7  12

Put value on stack
--------------------
27F7 OP1 -> FPS(1)
280C OP1 -> FPS(2)
2825 OP1 -> FPS(3)
2834 OP1 -> FPS(4)
283E OP1 -> FPS(5)

27ED OP2 -> FPS(1)
2816 OP2 -> FPS(3)

27E8 OP3 -> FPS(1)
281B OP3 -> FPS(3)

2807 OP5 -> FPS(2)
282F OP5 -> FPS(4)

27F2 OP6 -> FPS(1)
2820 OP6 -> FPS(3)

Get value from stack
--------------------
27B6 OP1 <- FPS(1)
27CF OP1 <- FPS(2)
27DE OP1 <- FPS(3)
2787 OP1 <- FPS(4)
2791 OP1 <- FPS(5)
275F OP1 <- FPS(6)
2769 OP1 <- FPS(7)
2755 OP1 <- FPS(12)

27B1 OP2 <- FPS(1)
27CA OP2 <- FPS(2)
27D9 OP2 <- FPS(3)
2782 OP2 <- FPS(4)
2773 OP2 <- FPS(5)

27AC OP3 <- FPS(1)
27C5 OP3 <- FPS(2)
2796 OP3 <- FPS(3)

27A7 OP4 <- FPS(1)

279D OP5 <- FPS(1)

27A2 OP6 <- FPS(1)
277D OP6 <- FPS(4)

Misc rutines for the Fp Stack
-----------------------------

2857 Get pointer to first element (number 0)
26FD Delete mem for a cplx real on the stack (2 reals)
2700 Delete mem for a real on the stack
270B Delete HL reals from the stack
2719 Get mem for HL reals on the stack

Error handling
--------------

The error handler is located at 28CD, but the ROM also includes a lot of
functions which load the regs with the need values and then calls this.
Besides that a pointer to the routine placed in the RAM is also used.

To use the error handler the information at 821A has to hold the correct
data. The function at 28F7 is used to update this data, just call this
function with a pointer to the errorhandler in HL. The function will then
update the data at 821A. On return from the function the function
at 291D has to be called if no error occured. If an error occurs and the
error handler is called it will use the information at 821A to set memory
pointers to their correct value and then return to the caller.

Error   ADR
------------
081	285F
082	2863
083	2867
084	286B
085	286F
087	2873 Error: Syntax
09C	2877
088	287B
09B	287F
089	2883
08A	2887
08B	288B
08C	288F
08D	2893
00D	2897 (used in programs)
08E	289B
08F	289F
090	28A3
091	28A7
092	28AB
086	28AF
014	28B3
015	28B7
098	28BB
099	28BF
09A	28C3
01D	28C7
09E	28CB


FP Math functions
-----------------
07F8             CP OP1,OP2 (OP3=OP1 OP4=OP2)
0801             OP1 = MIN(OP1,OP2)
080A             OP1 = MAX(OP1,OP2)
0813             OP1 = OP1+(HL) (no extra digits)
0818             OP1 = |OP1|+|OP2| (no extra digits)
0820             OP1 = INT(OP1)
0831             OP1 = OP2-OP1 (no extra digits)
0836             OP1 = IPART(OP1)
083F             OP1 = OP1*2 (no extra digits)
0842             OP1 = OP1+1 (no extra digits)
0847             OP1 = OP1-1 (no extra digits)
084A             OP1 = OP1-OP2 (no extra digits)
085A/0851        OP1 = OP1+OP2
08F7/0905        Convert OP1 from deg to rad
08FB/090E        Convert OP1 from rad to deg
0925 or RST 0028 OP1 = OP1*OP2 (no extra digits)
092C             OP1 = OP1*OP2 (extra digits)
0924             OP1 = OP1^2
091C             OP1 = OP1*0.5
0917             OP1 = OP1^3
0A5E             OP1 = -OP1
0A6E             OP2 = -OP2
0A84             OP1 = FPART(OP1)
0ACB/0AD5        OP1 = OP1 / OP2
0AD1             OP1 = 1/OP1
0B9C/0BA2        OP1 = SQRT(OP1) ???
0D28             OP1 = LN(OP1)
0D2C             OP1 = LOG(OP1)
0F04             OP1 = e^OP1
0F0E             OP1 = 10^OP1
10E0             OP1 = SIN(OP1)
10E4             OP1 = COS(OP1)
10E8             OP1 = TAN(OP1)
14C8             OP1 = TANH(OP1)??
14CC             OP1 = COSH(OP1)??
14D0             OP1 = SINH(OP1)??
1567             OP1 = ARCCOS(OP1)
156D             OP1 = ARCSIN(OP1)
1578             OP1 = ARCTAN(OP1)

Tabel of data
-------------
051C Data (last byte = 0550) pointers to routines to init apps starts from 40
0E7B Table of 8 byte data
1FF5 Table of token (last byte = 1FFC)
205A Table of ? (last byte = 2060)
1E07 Table of constants
     The constants are the following:
     #        Value             Name
     --------------------------------
     0: 57.29577951308232       180/Pi
     1:  1.570796326794897      Pi/2
     2:  0.7853981633974483     Pi/4
     3:  0.4342944816032518     Log e
     4:  3.141592653589800      Pi
     5:  0.01745329251994330    Pi/180
     6:  2.302585092994046      ln 10
     (AND MAYBE A FEW MORE)

13C4 Data (table to calc transcendal functions)
1444 Data (table to calc transcendal functions)
2990 Data used to find pixel (8 bytes)
18C9 Real 0.50
18D2 Real 0.25
18DB Real 0.75
18E4 Real 0.00
18ED Real 1.00


Untested Rom functions:
-----------------------
Page 0:
---- CALL 39E6 (16715) ---- Update cursor ??? -------------------------------
---- CALL 38F6 (177E9) ---- Update diplay from backup buffer ----------------
---- CALL 38E4 (151E1) ---- Clear text screen (might affect text mem) -------
---- CALL 38B4 (15193) ---- Clear full LCD (does not check split screen) ----
---- CALL 3872 (15877) ---- Write value at (HL) A times to (DE) (or untill (81DE)=10)
---- CALL 3830 (155A0) ---- Update top rigth corner of screen from buffer at 801E
---- CALL 3824 (1554F) ---- Update current line from buffer at 8C79 ---------
---- CALL 381E (1552C) ---- Update current line from text mem ---------------
---- CALL 3818 (1551D) ---- Update line (810F) from text mem? ---------------
---- CALL 3800/3806 (15485) ---- Copy info to secondary ---------------------
---- CALL 37FA (15470) ---- Copy text stuff to secondary --------------------
---- CALL 37E2 (1528C) ---- Get pointer to current char ---------------------
---- CALL 37D6/37DC (15262) ---- Write spaces to reset for screen (returns to current pos)?
---- CALL 37D0 (1523F) ---- Clear to end of line (does not affect cursor) ---
---- CALL 37CA (151F7) ---- Clear text window -------------------------------
---- CALL 37C4 (151E9) ---- Clear text screen (full)(do not use iy+x) -------
---- CALL 37BE (151DC) ---- Clear full lcd and text screen ------------------
---- CALL 37B8 (15113) ---- Scroll one line up ? ----------------------------
---- CALL 37B2 (150E0) ---- Move cursor one line up -------------------------
---- CALL 37A6/37AC (150CC) ---- Scroll display B lines ---------------------
---- CALL 37A0 (1508E) ---- Scroll display one line (iy+x used) (display+textmem)*
---- CALL 379A (15080) ---- Move cursor to next line (might scroll) ---------
---- CALL 3794 (15004) ---- Goto next line (might scroll uses iy+x) ---------
---- CALL 378E (14FFA) ---- Is it the last line ? ---------------------------
---- CALL 3758 (14DF2) ---- Print length indexed string ---------------------
---- CALL 374C (14C84) ---- Get current byte from display (and set cursor to line in 8011) (returned in A)
---- 389C (56570) ---- Display test (used as part of selftest) --------------
---- 38BA (475BD) ---- (811C)=28F6 ------------------------------------------
---- 38C6 (45AF9) ---- Display graphics mem (can use split screen, does not check if it is ok)

Page 1:
5871 A = A*8+80H
55C8 A = A*16
558A Goto end of line 0
6602 Fill screen with pattern in DE
662A Fill screen with pattern in A and wait for key (does not return if onkey pressed)
57D2 Scroll text screen one line up
584A Delete line in a (line number in a 80 for first)
4DD1 Print length indexed string with translation of last col
5185 BC=16*# of lines in window (IX has to point to 800C)
55CD HL = (B+1)*60H(get pixel number from y-cord)
54A0 copy from second pointers
558A Goto top rigth cornoer of screen
53EF Print b chars from (hl) to display using small font

Page 4:
4166 Find Pixel ! B = X cord C = line returns A = bit mask HL = Offset of byte 800F = Byte command 8011 = Line command
6AB5 Goto start of bottom text line in window (graph cursor)
6CB0 Write space in small font
6BD3 Write labels on axes

Misc other functions
--------------------

2EA3  Display string from token in E
2EAF  Search for variable by name and return pointer to end in hl and pointer to start in de (same params as rst 10)
2F1B  Goto line a and write : Indpnt: (newline) Depend:
2F4B  Read current key stroke (as 1d4), but it also returns value as fp number in OP2 (must be like ti-basic getkey)
3911  Copy real 12345.0 and real 67890.0 to buffer at 8BB8

LINK RUTINES

RECEIVE BYTE : 26ACB
SEND BYTE : 269AD

CALC ON/OFF

38F0 DISPLAY ON
7EA POWER OFF DISPLAY
PORT10=2 DISPLAY OFF

CALL    0361AH          ; 46B7 Resize var in DE to max size (call2 41ee)
CALL    03206H          ; 5EAB Resize var in DE to max size and init as buffer(call 646c8) 
36842 Get pointer to system var in A (returns pointer to data in HL and DE (-> info for lists) a holds type)
313A 268C7 ? list ?
38FC 368DC Store value in OP1 to ANS
2F72 368E2 Store value in OP1 to theta
2F78 368E8 Store value in OP1 to r
2F7E 368EE Store value in OP1 to y
3530 368F4 Store OP1 to 62 21 = table step ? (create if necesarry)
2F84 3690A Store value in OP1 to T
2F8A 36910 Store value in OP1 to x
35FC 36914 Store value on FPS(1) to var in OP1 (STOOTHER)
