;;; -*- 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 . ;; EmitWord: ;; ;; Write a little-endian word to the output, and increase the program ;; counter by 2. ;; ;; Input: ;; - HL = value to write ;; - (asmLoadPC) = address in program file where word should be placed ;; - (asmExecPC) = final execution address ;; ;; Output: ;; - (asmLoadPC) = next address ;; - (asmExecPC) = next address ;; ;; Destroys: ;; - AF EmitWord: ld a,l call EmitByte ld a,h jr EmitByte ;; EmitByteExec: ;; ;; Write an instruction opcode byte to the output, and increase the ;; program counter. Throw an error, if requested, if exec PC is above ;; C000h. ;; ;; Input: ;; - A = value to write ;; - (asmLoadPC) = address in program file where byte should be placed ;; - (asmExecPC) = final execution address ;; ;; Output: ;; - (asmLoadPC) = next address ;; - (asmExecPC) = next address ;; ;; Destroys: ;; - F EmitByteExec: push af ld a,(asmExecPC + 1) cp 0C0h jr c,EmitByteExec_AddrOK ld a,(asmAllowPCBankC) or a jr nz,EmitByteExec_AddrOK ld hl,emsg_CodeTooLarge ld de,(asmExecPC) call ThrowLineError EmitByteExec_AddrOK: pop af ;; fall through ;; EmitByte: ;; ;; Write a byte to the output, and increase the program counter. ;; ;; Input: ;; - A = value to write ;; - (asmLoadPC) = address in program file where byte should be placed ;; - (asmExecPC) = final execution address ;; ;; Output: ;; - (asmLoadPC) = next address ;; - (asmExecPC) = next address ;; ;; Destroys: ;; - F EmitByte: push hl push de ld hl,(asmExecPC) inc hl ld (asmExecPC),hl ld hl,(asmLoadPC) ld de,(asmMinLoadPC) or a sbc hl,de add hl,de jr nc,EmitByte_NotMinimum ld (asmMinLoadPC),hl EmitByte_NotMinimum: ex de,hl ld hl,(asmMaxLoadPC) or a sbc hl,de ex de,hl jr nc,EmitByte_NotMaximum ld (asmMaxLoadPC),hl EmitByte_NotMaximum: inc hl ld (asmLoadPC),hl bit inFinalPass,(iy + asm_Flag1) jr z,EmitByte_NoOutput bit symbolsChanged,(iy + asm_Flag1) jr nz,EmitByte_Error ld de,(asmMinLoadPC) scf sbc hl,de ;; Flash output not yet implemented ld de,(asmOutputFilePtr) add hl,de ld (hl),a EmitByte_NoOutput: pop de pop hl ret EmitByte_Error: ;; if we ever get here, it's a bug BCALL _ErrDimMismatch ;; UNREACHABLE