;;; -*- 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 . ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Extra TI-83+ OS definitions ;;; _BufToBtm equ 4921h ; move to end of edit buffer _BufToTop equ 4927h ; move to start of edit buffer _ChkErrBreak equ 42A0h ; throw error if ON pressed _ClrCursorHook equ 4F69h ; disable cursor hook _CreateVar equ 4E70h ; create proggish var of type A _IsAtTop equ 4930h ; check if (editTop) = (editCursor) _IsEditFull equ 492Ah ; check if edit buffer is full _Push2BOper equ 4B5Bh ; push BC on OPS _RestoreTR equ 458Bh ; copy indicMem to top right corner of LCD _SaveOScreen equ 45FAh ; copy LCD to saveSScreen _SaveTR equ 4588h ; copy top right corner of LCD to indicMem _SetCursorHook equ 4F60h ; set + enable cursor hook _UnarchiveVar equ 4FDEh ; unarchive variable (OP1 = name; HL -> ; VAT; ADE -> data) _VPutBlank equ 48F1h ; display a space (20h) in small font usermem_offset equ 89ECh ; size of assembly program alphaUpDnFlag equ 9 appWantAlphaUpDn equ 0 ; set if GetKey should return ; kAlphaUp/kAlphaDown fullScrnTextFlag equ 36 fullScrnTextDraw equ 4 ; set if VPutMap/UserPutMap can use the ; last pixel column kBackspace equ 21h ; TIKB backspace kExtendEcho3 equ 0FBh ; new key prefix LnewDollar equ 0F2h ; new '$' character ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Macros ;;; BCALL macro addr rst 28h ;; UNREACHABLE dw addr endm BJUMP macro addr call 50h ;; UNREACHABLE dw addr endm RAM_CODE_BEGIN macro endaddr call RAMCodeBegin ;; UNREACHABLE db endaddr - $ endm PAGE_1_CALL macro target call Page1Call ;; UNREACHABLE dw target endm SWITCH_NUMBERED_MENU macro MenuInfo ld hl,MenuInfo call ShowNumberedMenuSwitch endm SWITCH_BEGIN macro call SwitchBegin endm SWITCH_CASE macro value, addr db value nolist if ((addr - $) < 0) || ((addr - $) > 255) error "CASE target too far away" endif list db addr - $ endm SWITCH_END macro db 0FFh endm VERTICAL_MENU_ALPHA macro TopRow, NRows, LeftColumn, ArrowColumn, DisplayInit, DisplayItem, GetNext, GetPrev, ShowCursor, HideCursor call RunVerticalMenuAlpha ;; UNREACHABLE db TopRow, NRows, (NRows * 7) + TopRow, LeftColumn, ArrowColumn dw DisplayInit, DisplayItem, GetNext, GetPrev, ShowCursor, HideCursor endm VERTICAL_MENU_NO_ALPHA macro TopRow, NRows, LeftColumn, ArrowColumn, DisplayInit, DisplayItem, GetNext, GetPrev, ShowCursor, HideCursor call RunVerticalMenu ;; UNREACHABLE db TopRow, NRows, (NRows * 7) + TopRow, LeftColumn, ArrowColumn dw DisplayInit, DisplayItem, GetNext, GetPrev, ShowCursor, HideCursor endm VMENU_TOP_ROW equ 0 VMENU_NUM_ROWS equ 1 VMENU_BOTTOM_ROW equ 2 VMENU_LEFT_COLUMN equ 3 VMENU_ARROW_COLUMN equ 4 VMENU_DISPLAY_INIT equ 5 VMENU_DISPLAY_ITEM equ 7 VMENU_GET_NEXT equ 9 VMENU_GET_PREV equ 11 VMENU_SHOW_CURSOR equ 13 VMENU_HIDE_CURSOR equ 15 VMENU_END equ 17 DLG_TEXT macro lbl, buf, flg, len db D_TEXT dw lbl, buf db flg, len endm DLG_OPTION macro lbl, buf, opts db D_OPTION dw lbl, buf, opts endm DLG_END macro db D_END endm jq macro cond,addr if ((addr - $) <= 129) && ((addr - $) >= -126) jr cond,addr else jp cond,addr endif endm jq_ macro addr if ((addr - $) <= 129) && ((addr - $) >= -126) jr addr else jp addr endif endm ASSERT macro cond nolist if !(cond) error "Assertion failed" endif list endm NO_BYTE_CARRY macro startaddr nolist if ($ / 256) != (startaddr / 256) error "NO_BYTE_CARRY zone violated. Try rearranging data." endif list endm ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Internal constants ;;; ;;; Assembly rules (note: these cannot overlap with literal bytes; ;;; i.e., none of these hex values should be present in insts.dat.) R_END equ 81h ; End of an instruction rule R_BYTE equ 82h ; Insert byte argument R_WORD equ 83h ; Insert word argument R_REL equ 84h ; Insert PC-relative argument R_SBYTE equ 85h ; Insert signed byte argument R_SREG equ 87h ; Combine source reg # with next byte R_DREG equ 89h ; Combine destination reg # with next byte R_BITREG equ 8Ah ; Combine source and dest with next byte R_RST equ 8Bh ; Insert byte argument ORed with C7h R_IX equ 0DDh ; Insert DDh, skip next byte ;;; Argument expression categories AC_mask equ 3Ch AC_CONSTANT equ 00h ; Constant integer expression AC_BCDEHLMA equ 04h ; Register B, C, D, E, H, L, (HL), A AC_BCDEHLA equ 08h ; Register B, C, D, E, H, L, A AC_BCDEA equ 0Ch ; Register B, C, D, E, A AC_BDHS equ 10h ; Register BC, DE, HL, SP AC_BDHA equ 14h ; Register BC, DE, HL, AF AC_BDS equ 18h ; Register BC, DE, SP AC_IXHL equ 1Ch ; Register IXH, IXL AC_IYHL equ 20h ; Register IYH, IYL AC_ZCPS equ 24h ; Condition NZ, Z, NC, C, PO, PE, P, M AC_ZC equ 28h ; Condition NZ, Z, NC, C ;;; Operator precedence (see also precedenceTable and ;;; binaryOperatorParenTable in data.asm) PREC_UNARY equ 0 PREC_PRODUCT equ 1 ; * / % PREC_SUM equ 2 ; + - PREC_SHIFT equ 3 ; << >> PREC_COMPARE equ 4 ; < > <= >= PREC_EQUAL equ 5 ; = != PREC_AND equ 6 ; & PREC_XOR equ 7 ; ^ PREC_OR equ 8 ; | MAX_PRECEDENCE equ PREC_OR ;;; Dialog data types D_END equ 0 ; end of dialog D_OPTION equ 1 ; option menu D_TEXT equ 2 ; editable text ;;; Special formatting characters for error messages F_FILENAME equ '&' F_HEX equ '#' F_LABEL equ '_' ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Limitations ;;; MAX_PASSES equ 16 MAX_SYMBOL_LENGTH equ 32 MAX_COMMENT_LENGTH equ 64 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Appearance ;;; SCREEN_WIDTH equ 96 SCREEN_HEIGHT equ 64