;;; -*- TI-Asm -*- ;;; ;;; Mimas - Assembly language IDE for the TI-83 Plus ;;; ;;; Copyright (C) 2010 Benjamin Moody ;;; ;;; This program is free software: you can redistribute it and/or ;;; modify it under the terms of the GNU General Public License as ;;; published by the Free Software Foundation; either version 3 of the ;;; License, or (at your option) any later version. ;;; ;;; This program is distributed in the hope that it will be useful, ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;;; General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with this program. If not, see . ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Source file structures and bytecode ;;; ;;; Program header structure (keep this synchronized with program ;;; template in data.asm; also note mem allocation code in ;;; program.asm) PROGHEADER_TYPE equ 5 ; Program type PROGHEADER_FLAGS equ 6 ; Program flags PROGHEADER_SYMBOL_START equ 8 ; Offset to start of symbol ; table (3-byte entries ; permanently allocated for ; symbols) PROGHEADER_SYMBOL_STRING_START equ 10 ; Offset to start of string ; data (packed strings, ; dynamically allocated and ; stored in alphabetical ; order) PROGHEADER_CONSTANT_START equ 12 ; Offset to start of constant ; data (packed strings and ; corresponding values, used ; in precompiled headers only) PROGHEADER_IMPORT_START equ 14 ; Offset to start of import ; table (9-byte entries ; holding names of external ; files to link with) PROGHEADER_SECTION_TABLE_START equ 16 ; Offset to start of section ; table (13-byte entries ; holding section metadata) PROGHEADER_SECTION_TABLE_END equ 18 ; Offset to end of section table PROGHEADER_LENGTH equ 20 PROGHEADER_CODE_END equ PROGHEADER_SYMBOL_START PROGHEADER_SYMBOL_END equ PROGHEADER_SYMBOL_STRING_START PROGHEADER_SYMBOL_STRING_END equ PROGHEADER_CONSTANT_START PROGHEADER_CONSTANT_END equ PROGHEADER_IMPORT_START PROGHEADER_IMPORT_END equ PROGHEADER_SECTION_TABLE_START ;;; Program types PROGTYPE_GENERIC equ 0 ; No builtin symbols PROGTYPE_TI83P equ 1 ; Builtin symbols for 83+/84+ ;;; Program flags PROGFLAG_LOCKED equ 1 ; Program is locked (used for ; precompiled headers) ;;; Section header structure SECTHEADER_SECTION_TYPE equ 0 ; Section type SECTHEADER_DATA_START equ 1 ; Start of section data SECTHEADER_DATA_END equ 3 ; End of section data SECTHEADER_NAME equ 5 ; Name of section SECTHEADER_LENGTH equ 13 ;;; Section types SECTION_HEADER equ 0 ; place section in "header" segment SECTION_CODE equ 1 ; place section in "code" segment SECTION_DATA equ 2 ; place section in "data" segment SECTION_FOOTER equ 3 ; place section in "footer" segment SECTION_DISABLED equ 80h ; don't compile section at all NUM_SEGMENTS equ 4 SEGMENT_MASK equ 03h ;;; Instruction types (low 6 bits are length of argument data) T_NORMAL equ 000h ; normal Z80 instruction; second byte ; is instruction code (I_xx; defined ; in instrs.inc) T_LABEL equ 040h ; set label at current location; ; second + third bytes are the label ; number (note arg length is always 1; ; this might change, e.g. to allow for ; a displacement) T_COMMENT equ 080h ; comment at current location; second ; through nth bytes are packed text T_SPECIAL equ 0C0h ; special instruction; second byte is ; instruction code (S_xx) ;;; Special instruction codes (keep these synchronized with ;;; specialInstructionTable and specialInstructionMnemonicTable in ;;; data.asm) ;;; (Note: S_ASCII through S_INCBIN use special data formats; S_ASCII ;;; through S_JQ use special display formats) S_ASCII equ 81h ; insert literal characters S_ASCIZ equ 82h ; insert literal characters plus a zero S_HEX equ 83h ; insert literal bytes S_INCBIN equ 84h ; include binary file contents S_BCALL equ 05h ; B_CALL S_BJUMP equ 06h ; B_JUMP S_BREAK equ 07h ; break here when debugging S_BREAK_ccc equ 08h ; conditional breakpoint S_EQU equ 09h ; set symbol to expression S_JQ_n equ 0Ah ; auto jump S_JQ_cc_n equ 0Bh ; conditional auto jump S_ALIGN equ 0Ch ; set program counter to next address ; that is a multiple of the argument S_ASSERT equ 0Dh ; halt assembly if expression is nonzero S_BLOCK equ 0Eh ; skip N bytes forward S_BYTE equ 0Fh ; insert arguments as bytes S_ELSE equ 10h ; invert current conditional S_ENDIF equ 11h ; end of conditional S_IF equ 12h ; begin conditional (assemble ; subsequent code if argument ; evaluates to nonzero) S_IFDEF equ 13h ; begin conditional (assemble ; subsequent code if argument has been ; assigned a value) S_IFNDEF equ 14h ; opposite of IFDEF S_ORG equ 15h ; set current load and exec PC S_RORG equ 16h ; set current exec PC only S_WORD equ 17h ; insert arguments as little-endian ; words S_last equ 17h ;;; Expression codes X_SYMBOL equ 00h ; 00xxxxxx xxxxxxxx = (big endian) ; reference to a symbol ;;; Special values X_SPECIAL equ 40h ; 0100tttt = special constant value X_EXECPC equ X_SPECIAL ; [40] current exec address (RORG) X_LOADPC equ X_SPECIAL + 1 ; [41] current load address (ORG) X_PREV_ANON equ X_SPECIAL + 2 ; [42] previous anonymous label X_NEXT_ANON equ X_SPECIAL + 3 ; [43] next anonymous label ;;; Byte value formats X_BYTE equ 50h ; 0101tttt xxxxxxxx = unsigned byte value X_DEC8 equ X_BYTE ; [50] decimal constant X_HEX8 equ X_BYTE + 1 ; [51] hexadecimal constant X_OCT8 equ X_BYTE + 2 ; [52] octal constant X_BIN8 equ X_BYTE + 3 ; [53] binary constant X_CHAR equ X_BYTE + 4 ; [54] character X_ENUM8 equ X_BYTE + 5 X_SYSFLAG equ X_ENUM8 ; [55] system flag offset (note: ; triggers special display mode when ; used as first arg to SET/RES/BIT) X_SCANCODE equ X_ENUM8 + 1 ; [56] raw keypad scancode X_DATATYPE equ X_ENUM8 + 2 ; [57] variable data type X_KEY equ X_ENUM8 + 3 ; [58] one-byte GetKey code X_KEY_FB equ X_ENUM8 + 4 ; [59] extended GetKey code (ExtendEcho3) X_KEY_FC equ X_ENUM8 + 5 ; [5A] extended GetKey code (ExtendEcho2) ;;; Word value formats X_WORD equ 60h ; 0110tttt xxxxxxxx xxxxxxxx = word value X_DEC16 equ X_WORD ; [60] decimal constant X_HEX16 equ X_WORD + 1 ; [61] hexadecimal constant X_OCT16 equ X_WORD + 2 ; [62] octal constant X_BIN16 equ X_WORD + 3 ; [63] binary constant X_ROMCALL equ X_WORD + 4 ; [64] B_CALL address X_SYSADDR equ X_WORD + 5 ; [65] system ROM or RAM address ;;; (7x and 8x expression codes are reserved for future use, possibly ;;; for larger integer, float or string types) ;;; Unary operators X_UNARY equ 90h ; 1001tttt = unary operator X_LSB equ X_UNARY ; [90] (A & $ff) X_MSB equ X_UNARY + 1 ; [91] (A >> 8) X_MINUS equ X_UNARY + 2 ; [92] -A X_COMPLEMENT equ X_UNARY + 3 ; [93] ~A X_NOT equ X_UNARY + 4 ; [94] !A X_PAREN equ X_UNARY + 5 ; [95] (A) (internal only) X_REGVAL equ X_UNARY + 6 ; [96] reg #A (internal only) X_ARGVAL equ X_UNARY + 7 ; [97] argument value (internal only) ;;; Binary operators X_BINARY equ 0A0h ; 101ttttt = binary operator X_MUL equ X_BINARY ; [A0] A * B X_DIV equ X_BINARY + 1 ; [A1] A / B (signed) X_MOD equ X_BINARY + 2 ; [A2] A % B (signed) X_ADD equ X_BINARY + 3 ; [A3] A + B X_SUB equ X_BINARY + 4 ; [A4] A - B X_LSHIFT equ X_BINARY + 5 ; [A5] A << B (unsigned) X_RSHIFT equ X_BINARY + 6 ; [A6] A >> B (unsigned) X_GREATER equ X_BINARY + 7 ; [A7] A > B (signed) X_LESS equ X_BINARY + 8 ; [A8] A < B (signed) X_GE equ X_BINARY + 9 ; [A9] A >= B (signed) X_LE equ X_BINARY + 10 ; [AA] A <= B (signed) X_EQUAL equ X_BINARY + 11 ; [AB] A == B X_NE equ X_BINARY + 12 ; [AC] A != B X_AND equ X_BINARY + 13 ; [AD] A & B X_XOR equ X_BINARY + 14 ; [AE] A ^ B X_OR equ X_BINARY + 15 ; [AF] A | B ;;; Simple integer arguments X_DEC6 equ 0C0h ; 11xxxxxx = unsigned 6-bit value ;;; Register numbers X_REG_B equ X_DEC6 X_REG_C equ X_DEC6 + 1 X_REG_D equ X_DEC6 + 2 X_REG_E equ X_DEC6 + 3 X_REG_H equ X_DEC6 + 4 X_REG_L equ X_DEC6 + 5 X_REG_iHL equ X_DEC6 + 6 ; (HL) X_REG_A equ X_DEC6 + 7 X_REG_BC equ X_DEC6 + 08h X_REG_DE equ X_DEC6 + 0Ah X_REG_HL equ X_DEC6 + 0Ch X_REG_SP equ X_DEC6 + 0Eh X_REG_IX equ X_DEC6 + 10h X_REG_IY equ X_DEC6 + 12h X_REG_AF2 equ X_DEC6 + 14h ; AF' X_REG_AF equ X_DEC6 + 16h X_REG_I equ X_DEC6 + 18h X_REG_R equ X_DEC6 + 19h X_REG_IXH equ X_DEC6 + 1Ch X_REG_IXL equ X_DEC6 + 1Dh X_REG_IYH equ X_DEC6 + 24h X_REG_IYL equ X_DEC6 + 25h X_COND_NZ equ X_DEC6 + 28h X_COND_Z equ X_DEC6 + 29h X_COND_NC equ X_DEC6 + 2Ah X_COND_C equ X_DEC6 + 2Bh X_COND_PO equ X_DEC6 + 2Ch X_COND_PE equ X_DEC6 + 2Dh X_COND_P equ X_DEC6 + 2Eh X_COND_M equ X_DEC6 + 2Fh ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Debug file structure ;;; DEBUGHEADER_SYMBOL_START equ 5 DEBUGHEADER_LENGTH equ 7