12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481 |
- ; Ubicom IP2K CPU description. -*- Scheme -*-
- ; Copyright (C) 2002, 2009, 2011 Free Software Foundation, Inc.
- ;
- ; Contributed by Red Hat Inc;
- ;
- ; This file is part of the GNU Binutils.
- ;
- ; 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, write to the Free Software
- ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
- ; MA 02110-1301, USA.
- (define-rtl-version 0 8)
- (include "simplify.inc")
- ; define-arch must appear first
- (define-arch
- (name ip2k) ; name of cpu family
- (comment "Ubicom IP2000 family")
- (default-alignment aligned)
- (insn-lsb0? #t)
- (machs ip2022 ip2022ext)
- (isas ip2k)
- )
- ; Attributes.
- (define-attr
- (for insn)
- (type boolean)
- (name EXT-SKIP-INSN)
- (comment "instruction is a PAGE, LOADL, LOADH or BREAKX instruction")
- )
- (define-attr
- (for insn)
- (type boolean)
- (name SKIPA)
- (comment "instruction is a SKIP instruction")
- )
- ; Instruction set parameters.
- (define-isa
- (name ip2k)
- (comment "Ubicom IP2000 ISA")
- (default-insn-word-bitsize 16)
- (default-insn-bitsize 16)
- (base-insn-bitsize 16)
- )
- ; Cpu family definitions.
- (define-cpu
- ; cpu names must be distinct from the architecture name and machine names.
- (name ip2kbf)
- (comment "Ubicom IP2000 Family")
- (endian big)
- (word-bitsize 16)
- )
- (define-mach
- (name ip2022)
- (comment "Ubicom IP2022")
- (cpu ip2kbf)
- )
- (define-mach
- (name ip2022ext)
- (comment "Ubicom IP2022 extended")
- (cpu ip2kbf)
- )
- ; Model descriptions.
- (define-model
- (name ip2k) (comment "VPE 2xxx") (attrs)
- (mach ip2022ext)
- (unit u-exec "Execution Unit" ()
- 1 1 ; issue done
- () ; state
- () ; inputs
- () ; outputs
- () ; profile action (default)
- )
- )
- ; FIXME: It might simplify things to separate the execute process from the
- ; one that updates the PC.
- ; Instruction fields.
- ;
- ; Attributes:
- ; XXX: what VPE attrs
- ; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
- ; ABS-ADDR: absolute address (for reloc and disassembly purposes?)
- ; RESERVED: bits are not used to decode insn, must be all 0
- ; RELOC: there is a relocation associated with this field (experiment)
- (dnf f-imm8 "imm8" () 7 8)
- (dnf f-reg "reg" (ABS-ADDR) 8 9)
- (dnf f-addr16cjp "addr16cjp" (ABS-ADDR) 12 13)
- (dnf f-dir "dir" () 9 1)
- (dnf f-bitno "bit number" () 11 3)
- (dnf f-op3 "op3" () 15 3)
- (dnf f-op4 "op4" () 15 4)
- (dnf f-op4mid "op4mid" () 11 4)
- (dnf f-op6 "op6" () 15 6)
- (dnf f-op8 "op8" () 15 8)
- (dnf f-op6-10low "op6-10low" () 9 10)
- (dnf f-op6-7low "op6-7low" () 9 7)
- (dnf f-reti3 "reti3" () 2 3)
- (dnf f-skipb "sb/snb" (ABS-ADDR) 12 1)
- (dnf f-page3 "page3" () 2 3)
- ;(define-ifield (name f-page3) (comment "page3") (attrs) (start 2) (length 3)
- ; (encode (value pc) (srl WI value 13))
- ; (decode (value pc) (sll WI value 13))
- ;)
- ; To fix the page/call asymmetry
- ;(define-ifield (name f-page3) (comment "page3") (attrs) (start 2) (length 3)
- ; (encode (value pc) (srl WI value 13))
- ; (decode (value pc) (sll WI value 13))
- ;)
- ; Enums.
- ; insn-op6: bits 15-10
- (define-normal-insn-enum insn-op6 "op6 enums" () OP6_ f-op6
- (OTHER1 OTHER2 SUB DEC OR AND XOR ADD
- TEST NOT INC DECSZ RR RL SWAP INCSZ
- CSE POP SUBC DECSNZ MULU MULS INCSNZ ADDC
- - - - - - - - -
- - - - - - - - -
- - - - - - - - -
- - - - - - - - -
- - - - - - - - -
- )
- )
- ; insn-dir: bit 9
- (define-normal-insn-enum insn-dir "dir enums" () DIR_ f-dir
- ; This bit specifies the polarity of many two-operand instructions:
- ; TO_W writes result to W regiser (eg. ADDC W,$fr)
- ; NOTTO_W writes result in general register (eg. ADDC $fr,W)
- (TO_W NOTTO_W)
- )
- ; insn-op4: bits 15-12
- (define-normal-insn-enum insn-op4 "op4 enums" () OP4_ f-op4
- (- - - - - - - LITERAL
- CLRB SETB SNB SB - - - -
- )
- )
- ; insn-op4mid: bits 11-8
- ; used for f-op4=LITERAL
- (define-normal-insn-enum insn-op4mid "op4mid enums" () OP4MID_ f-op4mid
- (LOADH_L LOADL_L MULU_L MULS_L PUSH_L - CSNE_L CSE_L
- RETW_L CMP_L SUB_L ADD_L MOV_L OR_L AND_L XOR_L)
- )
- ; insn-op3: bits 15-13
- (define-normal-insn-enum insn-op3 "op3 enums" () OP3_ f-op3
- (- - - - - - CALL JMP)
- )
-
- ; Hardware pieces.
- ; Bank-relative general purpose registers
- ; (define-pmacro (build-reg-name n) (.splice (.str "$" n) n))
- (define-keyword
- (name register-names)
- (enum-prefix H-REGISTERS-)
- (values
- ; These are the "Special Purpose Registers" that are not reserved
- ("ADDRSEL" #x2) ("ADDRX" #x3)
- ("IPH" #x4) ("IPL" #x5) ("SPH" #x6) ("SPL" #x7)
- ("PCH" #x8) ("PCL" #x9) ("WREG" #xA) ("STATUS" #xB)
- ("DPH" #xC) ("DPL" #xD) ("SPDREG" #xE) ("MULH" #xF)
- ("ADDRH" #x10) ("ADDRL" #x11) ("DATAH" #x12) ("DATAL" #x13)
- ("INTVECH" #x14) ("INTVECL" #x15) ("INTSPD" #x16) ("INTF" #x17)
- ("INTE" #x18) ("INTED" #x19) ("FCFG" #x1A) ("TCTRL" #x1B)
- ("XCFG" #x1C) ("EMCFG" #x1D) ("IPCH" #x1E) ("IPCL" #x1F)
- ("RAIN" #x20) ("RAOUT" #x21) ("RADIR" #x22) ("LFSRH" #x23)
- ("RBIN" #x24) ("RBOUT" #x25) ("RBDIR" #x26) ("LFSRL" #x27)
- ("RCIN" #x28) ("RCOUT" #x29) ("RCDIR" #x2A) ("LFSRA" #x2B)
- ("RDIN" #x2C) ("RDOUT" #x2D) ("RDDIR" #x2E)
- ("REIN" #x30) ("REOUT" #x31) ("REDIR" #x32)
- ("RFIN" #x34) ("RFOUT" #x35) ("RFDIR" #x36)
- ("RGOUT" #x39) ("RGDIR" #x3A)
- ("RTTMR" #x40) ("RTCFG" #x41) ("T0TMR" #x42) ("T0CFG" #x43)
- ("T1CNTH" #x44) ("T1CNTL" #x45) ("T1CAP1H" #x46) ("T1CAP1L" #x47)
- ("T1CAP2H" #x48) ("T1CMP2H" #x48) ("T1CAP2L" #x49) ("T1CMP2L" #x49) ; note aliases
- ("T1CMP1H" #x4A) ("T1CMP1L" #x4B)
- ("T1CFG1H" #x4C) ("T1CFG1L" #x4D) ("T1CFG2H" #x4E) ("T1CFG2L" #x4F)
- ("ADCH" #x50) ("ADCL" #x51) ("ADCCFG" #x52) ("ADCTMR" #x53)
- ("T2CNTH" #x54) ("T2CNTL" #x55) ("T2CAP1H" #x56) ("T2CAP1L" #x57)
- ("T2CAP2H" #x58) ("T2CMP2H" #x58) ("T2CAP2L" #x59) ("T2CMP2L" #x59) ; note aliases
- ("T2CMP1H" #x5A) ("T2CMP1L" #x5B)
- ("T2CFG1H" #x5C) ("T2CFG1L" #x5D) ("T2CFG2H" #x5E) ("T2CFG2L" #x5F)
- ("S1TMRH" #x60) ("S1TMRL" #x61) ("S1TBUFH" #x62) ("S1TBUFL" #x63)
- ("S1TCFG" #x64) ("S1RCNT" #x65) ("S1RBUFH" #x66) ("S1RBUFL" #x67)
- ("S1RCFG" #x68) ("S1RSYNC" #x69) ("S1INTF" #x6A) ("S1INTE" #x6B)
- ("S1MODE" #x6C) ("S1SMASK" #x6D) ("PSPCFG" #x6E) ("CMPCFG" #x6F)
- ("S2TMRH" #x70) ("S2TMRL" #x71) ("S2TBUFH" #x72) ("S2TBUFL" #x73)
- ("S2TCFG" #x74) ("S2RCNT" #x75) ("S2RBUFH" #x76) ("S2RBUFL" #x77)
- ("S2RCFG" #x78) ("S2RSYNC" #x79) ("S2INTF" #x7A) ("S2INTE" #x7B)
- ("S2MODE" #x7C) ("S2SMASK" #x7D) ("CALLH" #x7E) ("CALLL" #x7F))
- )
- (define-hardware
- (name h-spr)
- (comment "special-purpose registers")
- (type register QI (128))
- (get (index) (c-call QI "get_spr" index ))
- (set (index newval) (c-call VOID "set_spr" index newval ))
- )
- ;;(define-hardware
- ;; (name h-gpr-global)
- ;; (comment "gpr registers - global")
- ;; (type register QI (128))
- ;;)
- ; The general register
- (define-hardware
- (name h-registers)
- (comment "all addressable registers")
- (attrs VIRTUAL)
- (type register QI (512))
- (get (index) (c-call QI "get_h_registers" index ))
- (set (index newval) (c-call VOID "set_h_registers" index newval ))
- )
- ; The hardware stack.
- ; Use {push,pop}_pc_stack c-calls to operate on this hardware element.
- (define-hardware
- (name h-stack)
- (comment "hardware stack")
- (type register UHI (16))
- )
- (dsh h-pabits "page bits" () (register QI))
- (dsh h-zbit "zero bit" () (register BI))
- (dsh h-cbit "carry bit" () (register BI))
- (dsh h-dcbit "digit-carry bit" () (register BI))
- (dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
- ; Operands
- (define-operand (name addr16cjp) (comment "13-bit address") (attrs)
- (type h-uint) (index f-addr16cjp) (handlers (parse "addr16_cjp") (print "dollarhex_cj"))) ; overload lit8 printer
- (define-operand (name fr) (comment "register") (attrs)
- (type h-registers) (index f-reg) (handlers (parse "fr") (print "fr")))
- (define-operand (name lit8) (comment "8-bit signed literal") (attrs)
- (type h-sint) (index f-imm8) (handlers (parse "lit8") (print "dollarhex8")))
- (define-operand (name bitno) (comment "bit number") (attrs)
- (type h-uint) (index f-bitno) (handlers (parse "bit3")(print "decimal")))
- (define-operand (name addr16p) (comment "page number") (attrs)
- (type h-uint) (index f-page3) (handlers (parse "addr16_cjp") (print "dollarhex_p")))
- (define-operand (name addr16h) (comment "high 8 bits of address") (attrs)
- (type h-uint) (index f-imm8) (handlers (parse "addr16") (print "dollarhex_addr16h")))
- (define-operand (name addr16l) (comment "low 8 bits of address") (attrs)
- (type h-uint) (index f-imm8) (handlers (parse "addr16") (print "dollarhex_addr16l")))
- (define-operand (name reti3) (comment "reti flags") (attrs)
- (type h-uint) (index f-reti3) (handlers (print "dollarhex")))
- (dnop pabits "page bits" () h-pabits f-nil)
- (dnop zbit "zero bit" () h-zbit f-nil)
- (dnop cbit "carry bit" () h-cbit f-nil)
- (dnop dcbit "digit carry bit" () h-dcbit f-nil)
- ;;(dnop bank "bank register" () h-bank-no f-nil)
- (define-pmacro w (reg h-spr #x0A))
- (define-pmacro mulh (reg h-spr #x0F))
- (define-pmacro dph (reg h-spr #x0C))
- (define-pmacro dpl (reg h-spr #x0D))
- (define-pmacro sph (reg h-spr #x06))
- (define-pmacro spl (reg h-spr #x07))
- (define-pmacro iph (reg h-spr #x04))
- (define-pmacro ipl (reg h-spr #x05))
- (define-pmacro addrh (reg h-spr #x10))
- (define-pmacro addrl (reg h-spr #x11))
- ; Pseudo-RTL for DC flag calculations
- ; "DC" = "digit carry", ie carry between nibbles
- (define-pmacro (add-dcflag a b c)
- (add-cflag (sll QI a 4) (sll QI b 4) c)
- )
- (define-pmacro (sub-dcflag a b c)
- (sub-cflag (sll QI a 4) (sll QI b 4) c)
- )
- ; Check to see if an fr is one of IPL, SPL, DPL, ADDRL, PCL.
- (define-pmacro (LregCheck isLreg fr9bit)
- (sequence()
- (set isLreg #x0) ;; Assume it's not an Lreg
- (if (or (or (eq fr9bit #x5) (eq fr9bit #x7))
- (or (eq fr9bit #x9)
- (or (eq fr9bit #xd) (eq fr9bit #x11))))
- (set isLreg #x1)
- )
- )
- )
- ; Instructions, in order of the "Instruction Set Map" table on
- ; pp 19-20 of IP2022 spec V1.09
- (dni jmp "Jump"
- ()
- "jmp $addr16cjp"
- (+ OP3_JMP addr16cjp)
- (set pc (or (sll pabits 13) addr16cjp))
- ()
- )
- ; note that in call, we push pc instead of pc + 1 because the ip2k increments
- ; the pc prior to execution of the instruction
- (dni call "Call"
- ()
- "call $addr16cjp"
- (+ OP3_CALL addr16cjp)
- (sequence ()
- (c-call "push_pc_stack" pc)
- (set pc (or (sll pabits 13) addr16cjp)))
- ()
- )
- (dni sb "Skip if bit set"
- ()
- "sb $fr,$bitno"
- (+ OP4_SB bitno fr)
- (if (and fr (sll 1 bitno))
- (skip 1))
- ()
- )
- (dni snb "Skip if bit clear"
- ()
- "snb $fr,$bitno"
- (+ OP4_SNB bitno fr)
- (if (not (and fr (sll 1 bitno)))
- (skip 1))
- ()
- )
- (dni setb "Set bit"
- ()
- "setb $fr,$bitno"
- (+ OP4_SETB bitno fr)
- (set fr (or fr (sll 1 bitno)))
- ()
- )
- (dni clrb "Clear bit"
- ()
- "clrb $fr,$bitno"
- (+ OP4_CLRB bitno fr)
- (set fr (and fr (inv (sll 1 bitno))))
- ()
- )
- (dni xorw_l "XOR W,literal"
- ()
- "xor W,#$lit8"
- (+ OP4_LITERAL OP4MID_XOR_L lit8)
- (sequence ()
- (set w (xor w lit8))
- (set zbit (zflag w)))
- ()
- )
- (dni andw_l "AND W,literal"
- ()
- "and W,#$lit8"
- (+ OP4_LITERAL OP4MID_AND_L lit8)
- (sequence ()
- (set w (and w lit8))
- (set zbit (zflag w)))
- ()
- )
- (dni orw_l "OR W,literal"
- ()
- "or W,#$lit8"
- (+ OP4_LITERAL OP4MID_OR_L lit8)
- (sequence ()
- (set w (or w lit8))
- (set zbit (zflag w)))
- ()
- )
- (dni addw_l "ADD W,literal"
- ()
- "add W,#$lit8"
- (+ OP4_LITERAL OP4MID_ADD_L lit8)
- (sequence ()
- (set cbit (add-cflag w lit8 0))
- (set dcbit (add-dcflag w lit8 0))
- (set w (add w lit8))
- (set zbit (zflag w)))
- ()
- )
- (dni subw_l "SUB W,literal"
- ()
- "sub W,#$lit8"
- (+ OP4_LITERAL OP4MID_SUB_L lit8)
- (sequence ()
- (set cbit (not (sub-cflag lit8 w 0)))
- (set dcbit (not (sub-dcflag lit8 w 0)))
- (set zbit (zflag (sub w lit8)))
- (set w (sub lit8 w)))
- ()
- )
- (dni cmpw_l "CMP W,literal"
- ()
- "cmp W,#$lit8"
- (+ OP4_LITERAL OP4MID_CMP_L lit8)
- (sequence ()
- (set cbit (not (sub-cflag lit8 w 0)))
- (set dcbit (not (sub-dcflag lit8 w 0)))
- (set zbit (zflag (sub w lit8))))
- ()
- )
- (dni retw_l "RETW literal"
- ()
- "retw #$lit8"
- (+ OP4_LITERAL OP4MID_RETW_L lit8)
- (sequence ((USI new_pc))
- (set w lit8)
- (set new_pc (c-call UHI "pop_pc_stack"))
- (set pabits (srl new_pc 13))
- (set pc new_pc))
- ()
- )
- (dni csew_l "CSE W,literal"
- ()
- "cse W,#$lit8"
- (+ OP4_LITERAL OP4MID_CSE_L lit8)
- (if (eq w lit8)
- (skip 1))
- ()
- )
- (dni csnew_l "CSNE W,literal"
- ()
- "csne W,#$lit8"
- (+ OP4_LITERAL OP4MID_CSNE_L lit8)
- (if (not (eq w lit8))
- (skip 1))
- ()
- )
- (dni push_l "Push #lit8"
- ()
- "push #$lit8"
- (+ OP4_LITERAL OP4MID_PUSH_L lit8)
- (sequence ()
- (c-call "push" lit8)
- (c-call VOID "adjuststackptr" (const -1))
- )
- ()
- )
- (dni mulsw_l "Multiply W,literal (signed)"
- ()
- "muls W,#$lit8"
- (+ OP4_LITERAL OP4MID_MULS_L lit8)
- (sequence ((SI tmp))
- (set tmp (mul (ext SI w) (ext SI (and UQI #xff lit8))))
- (set w (and tmp #xFF))
- (set mulh (srl tmp 8)))
- ()
- )
- (dni muluw_l "Multiply W,literal (unsigned)"
- ()
- "mulu W,#$lit8"
- (+ OP4_LITERAL OP4MID_MULU_L lit8)
- (sequence ((USI tmp))
- (set tmp (and #xFFFF (mul (zext USI w) (zext USI lit8))))
- (set w (and tmp #xFF))
- (set mulh (srl tmp 8)))
- ()
- )
- (dni loadl_l "LoadL literal"
- (EXT-SKIP-INSN)
- "loadl #$lit8"
- (+ OP4_LITERAL OP4MID_LOADL_L lit8)
- (set dpl (and lit8 #x00FF))
- ()
- )
- (dni loadh_l "LoadH literal"
- (EXT-SKIP-INSN)
- "loadh #$lit8"
- (+ OP4_LITERAL OP4MID_LOADH_L lit8)
- (set dph (and lit8 #x00FF))
- ()
- )
- (dni loadl_a "LoadL addr16l"
- (EXT-SKIP-INSN)
- "loadl $addr16l"
- (+ OP4_LITERAL OP4MID_LOADL_L addr16l)
- (set dpl (and addr16l #x00FF))
- ()
- )
- (dni loadh_a "LoadH addr16h"
- (EXT-SKIP-INSN)
- "loadh $addr16h"
- (+ OP4_LITERAL OP4MID_LOADH_L addr16h)
- (set dph (and addr16l #x0FF00))
- ()
- )
- ;; THIS NO LONGER EXISTS -> Now LOADL
- ;;(dni bank_l "Bank literal"
- ;; ()
- ;; "bank #$lit8"
- ;; (+ OP4_LITERAL OP4MID_BANK_L lit8)
- ;; (set bank lit8)
- ;; ()
- ;;)
- (dni addcfr_w "Add w/carry fr,W"
- ()
- "addc $fr,W"
- (+ OP6_ADDC DIR_NOTTO_W fr)
- (sequence ((QI result) (BI newcbit) (QI isLreg) (HI 16bval))
- (set newcbit (add-cflag w fr cbit))
- (set dcbit (add-dcflag w fr cbit))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (LregCheck isLreg (ifield f-reg))
- (if (eq isLreg #x1)
- (sequence()
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- (set 16bval (addc HI 16bval w cbit))
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set result (reg h-spr (ifield f-reg)))
- )
- (set result (addc w fr cbit)) ;; else part
- )
- (set zbit (zflag result))
- (set cbit newcbit)
- (set fr result))
- ()
- )
- (dni addcw_fr "Add w/carry W,fr"
- ()
- "addc W,$fr"
- (+ OP6_ADDC DIR_TO_W fr)
- (sequence ((QI result) (BI newcbit))
- (set newcbit (add-cflag w fr cbit))
- (set dcbit (add-dcflag w fr cbit))
- (set result (addc w fr cbit))
- (set zbit (zflag result))
- (set cbit newcbit)
- (set w result))
- ()
- )
- (dni incsnz_fr "Skip if fr++ not zero"
- ()
- "incsnz $fr"
- (+ OP6_INCSNZ DIR_NOTTO_W fr)
- (sequence ((QI isLreg) (HI 16bval))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- ; Create the 16 bit value
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- ; Do 16 bit arithmetic.
- (set 16bval (add HI 16bval 1))
- ; Separate the 16 bit values into the H and L regs
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set fr (reg h-spr (ifield f-reg)))
- )
- (set fr (add fr 1)) ; Do 8 bit arithmetic.
- )
- (if (not (zflag fr))
- (skip 1)))
- ()
- )
- (dni incsnzw_fr "Skip if W=fr+1 not zero"
- ()
- "incsnz W,$fr"
- (+ OP6_INCSNZ DIR_TO_W fr)
- (sequence ()
- (set w (add fr 1))
- (if (not (zflag w))
- (skip 1)))
- ()
- )
- (dni mulsw_fr "Multiply W,fr (signed)"
- ()
- "muls W,$fr"
- (+ OP6_MULS DIR_TO_W fr)
- (sequence ((SI tmp))
- (set tmp (mul (ext SI w) (ext SI fr)))
- (set w (and tmp #xFF))
- (set mulh (srl tmp 8)))
- ()
- )
- (dni muluw_fr "Multiply W,fr (unsigned)"
- ()
- "mulu W,$fr"
- (+ OP6_MULU DIR_TO_W fr)
- (sequence ((USI tmp))
- (set tmp (and #xFFFF (mul (zext USI w) (zext USI fr))))
- (set w (and tmp #xFF))
- (set mulh (srl tmp 8)))
- ()
- )
- (dni decsnz_fr "Skip if fr-- not zero"
- ()
- "decsnz $fr"
- (+ OP6_DECSNZ DIR_NOTTO_W fr)
- (sequence ((QI isLreg) (HI 16bval))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- ; Create the 16 bit value
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- ; New 16 bit instruction
- (set 16bval (sub HI 16bval 1))
- ; Separate the 16 bit values into the H and L regs
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set fr (reg h-spr (ifield f-reg)))
- )
- ; Original instruction
- (set fr (sub fr 1))
- )
- (if (not (zflag fr))
- (skip 1)))
- ()
- )
- (dni decsnzw_fr "Skip if W=fr-1 not zero"
- ()
- "decsnz W,$fr"
- (+ OP6_DECSNZ DIR_TO_W fr)
- (sequence ()
- (set w (sub fr 1))
- (if (not (zflag w))
- (skip 1)))
- ()
- )
- (dni subcw_fr "Subract w/carry W,fr"
- ()
- "subc W,$fr"
- (+ OP6_SUBC DIR_TO_W fr)
- (sequence ((QI result) (BI newcbit))
- (set newcbit (not (sub-cflag fr w (not cbit))))
- (set dcbit (not (sub-dcflag fr w (not cbit))))
- (set result (subc fr w (not cbit)))
- (set zbit (zflag result))
- (set cbit newcbit)
- (set w result))
- ()
- )
- (dni subcfr_w "Subtract w/carry fr,W"
- ()
- "subc $fr,W"
- (+ OP6_SUBC DIR_NOTTO_W fr)
- (sequence ((QI result) (BI newcbit) (QI isLreg) (HI 16bval))
- (set newcbit (not (sub-cflag fr w (not cbit))))
- (set dcbit (not (sub-dcflag fr w (not cbit))))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- ; Create the 16 bit value
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- ; New 16 bit instruction
- (set 16bval (subc HI 16bval w (not cbit)))
- ; Separate the 16 bit values into the H and L regs
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set result (reg h-spr (ifield f-reg)))
- )
- ; Original instruction
- (set result (subc fr w (not cbit)))
- )
- (set zbit (zflag result))
- (set cbit newcbit)
- (set fr result))
- ()
- )
- (dni pop_fr "Pop fr"
- ()
- "pop $fr"
- (+ OP6_POP (f-dir 1) fr)
- (sequence()
- (set fr (c-call QI "pop"))
- (c-call VOID "adjuststackptr" (const 1))
- )
- ()
- )
- (dni push_fr "Push fr"
- ()
- "push $fr"
- (+ OP6_POP (f-dir 0) fr)
- (sequence()
- (c-call "push" fr)
- (c-call VOID "adjuststackptr" (const -1))
- )
- ()
- )
- (dni csew_fr "Skip if equal W,fr"
- ()
- "cse W,$fr"
- (+ OP6_CSE (f-dir 1) fr)
- (if (eq w fr)
- (skip 1))
- ()
- )
- (dni csnew_fr "Skip if not-equal W,fr"
- ()
- "csne W,$fr"
- (+ OP6_CSE (f-dir 0) fr)
- (if (not (eq w fr))
- (skip 1))
- ()
- )
- ;;(dni csaw_fr "Skip if W above fr"
- ;; ((MACH ip2022ext))
- ;; "csa W,$fr"
- ;; (+ OP6_CSAB (f-dir 1) fr)
- ;; (if (gt w fr)
- ;; (skip 1))
- ;; ()
- ;;)
- ;;(dni csbw_fr "Skip if W below fr"
- ;; ((MACH ip2022ext))
- ;; "csb W,$fr"
- ;; (+ OP6_CSAB (f-dir 0) fr)
- ;; (if (lt w fr)
- ;; (skip 1))
- ;; ()
- ;;)
- (dni incsz_fr "Skip if fr++ zero"
- ()
- "incsz $fr"
- (+ OP6_INCSZ DIR_NOTTO_W fr)
- (sequence ((QI isLreg) (HI 16bval))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- ; Create the 16 bit value
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- ; New 16 bit instruction
- (set 16bval (add HI 16bval 1))
- ; Separate the 16 bit values into the H and L regs
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set fr (reg h-spr (ifield f-reg)))
- )
- ; Original instruction
- (set fr (add fr 1))
- )
- (if (zflag fr)
- (skip 1)))
- ()
- )
- (dni incszw_fr "Skip if W=fr+1 zero"
- ()
- "incsz W,$fr"
- (+ OP6_INCSZ DIR_TO_W fr)
- (sequence ()
- (set w (add fr 1))
- (if (zflag w)
- (skip 1)))
- ()
- )
- (dni swap_fr "Swap fr nibbles"
- ()
- "swap $fr"
- (+ OP6_SWAP DIR_NOTTO_W fr)
- (set fr (or (and (sll fr 4) #xf0)
- (and (srl fr 4) #x0f)))
- ()
- )
- (dni swapw_fr "Swap fr nibbles into W"
- ()
- "swap W,$fr"
- (+ OP6_SWAP DIR_TO_W fr)
- (set w (or (and (sll fr 4) #xf0)
- (and (srl fr 4) #x0f)))
- ()
- )
- (dni rl_fr "Rotate fr left with carry"
- ()
- "rl $fr"
- (+ OP6_RL DIR_NOTTO_W fr)
- (sequence ((QI newfr) (BI newc))
- (set newc (and fr #x80))
- (set newfr (or (sll fr 1) (if QI cbit 1 0)))
- (set cbit (if QI newc 1 0))
- (set fr newfr))
- ()
- )
- (dni rlw_fr "Rotate fr left with carry into W"
- ()
- "rl W,$fr"
- (+ OP6_RL DIR_TO_W fr)
- (sequence ((QI newfr) (BI newc))
- (set newc (and fr #x80))
- (set newfr (or (sll fr 1) (if QI cbit 1 0)))
- (set cbit (if QI newc 1 0))
- (set w newfr))
- ()
- )
- (dni rr_fr "Rotate fr right with carry"
- ()
- "rr $fr"
- (+ OP6_RR DIR_NOTTO_W fr)
- (sequence ((QI newfr) (BI newc))
- (set newc (and fr #x01))
- (set newfr (or (srl fr 1) (if QI cbit #x80 #x00)))
- (set cbit (if QI newc 1 0))
- (set fr newfr))
- ()
- )
- (dni rrw_fr "Rotate fr right with carry into W"
- ()
- "rr W,$fr"
- (+ OP6_RR DIR_TO_W fr)
- (sequence ((QI newfr) (BI newc))
- (set newc (and fr #x01))
- (set newfr (or (srl fr 1) (if QI cbit #x80 #x00)))
- (set cbit (if QI newc 1 0))
- (set w newfr))
- ()
- )
- (dni decsz_fr "Skip if fr-- zero"
- ()
- "decsz $fr"
- (+ OP6_DECSZ DIR_NOTTO_W fr)
- (sequence ((QI isLreg) (HI 16bval))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- ; Create the 16 bit value
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- ; New 16 bit instruction
- (set 16bval (sub HI 16bval 1))
- ; Separate the 16 bit values into the H and L regs
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set fr (reg h-spr (ifield f-reg)))
- )
- ; Original instruction
- (set fr (sub fr 1))
- )
- (if (zflag fr)
- (skip 1)))
- ()
- )
- (dni decszw_fr "Skip if W=fr-1 zero"
- ()
- "decsz W,$fr"
- (+ OP6_DECSZ DIR_TO_W fr)
- (sequence ()
- (set w (sub fr 1))
- (if (zflag w)
- (skip 1)))
- ()
- )
- (dni inc_fr "Increment fr"
- ()
- "inc $fr"
- (+ OP6_INC DIR_NOTTO_W fr)
- (sequence ((QI isLreg) (HI 16bval))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- ; Create the 16 bit value
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- ; New 16 bit instruction
- (set 16bval (add HI 16bval 1))
- ; Separate the 16 bit values into the H and L regs
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set fr (reg h-spr (ifield f-reg)))
- )
- ; Original instruction
- (set fr (add fr 1))
- )
- (set zbit (zflag fr)))
- ()
- )
- (dni incw_fr "Increment fr into w"
- ()
- "inc W,$fr"
- (+ OP6_INC DIR_TO_W fr)
- (sequence ()
- (set w (add fr 1))
- (set zbit (zflag w)))
- ()
- )
- (dni not_fr "Invert fr"
- ()
- "not $fr"
- (+ OP6_NOT DIR_NOTTO_W fr)
- (sequence ()
- (set fr (inv fr))
- (set zbit (zflag fr)))
- ()
- )
- (dni notw_fr "Invert fr into w"
- ()
- "not W,$fr"
- (+ OP6_NOT DIR_TO_W fr)
- (sequence ()
- (set w (inv fr))
- (set zbit (zflag w)))
- ()
- )
- (dni test_fr "Test fr"
- ()
- "test $fr"
- (+ OP6_TEST DIR_NOTTO_W fr)
- (sequence ()
- (set zbit (zflag fr)))
- ()
- )
- (dni movw_l "MOV W,literal"
- ()
- "mov W,#$lit8"
- (+ OP4_LITERAL OP4MID_MOV_L lit8)
- (set w lit8)
- ()
- )
- (dni movfr_w "Move/test w into fr"
- ()
- "mov $fr,W"
- (+ OP6_OTHER1 DIR_NOTTO_W fr)
- (set fr w)
- ()
- )
- (dni movw_fr "Move/test fr into w"
- ()
- "mov W,$fr"
- (+ OP6_TEST DIR_TO_W fr)
- (sequence ()
- (set w fr)
- (set zbit (zflag w)))
- ()
- )
- (dni addfr_w "Add fr,W"
- ()
- "add $fr,W"
- (+ OP6_ADD DIR_NOTTO_W fr)
- (sequence ((QI result) (QI isLreg) (HI 16bval))
- (set cbit (add-cflag w fr 0))
- (set dcbit (add-dcflag w fr 0))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- (set 16bval (add HI (and w #xFF) 16bval))
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set result (reg h-spr (ifield f-reg)))
- )
- (set result (addc w fr 0)) ;; else part
- )
- (set zbit (zflag result))
- (set fr result))
- ()
- )
- (dni addw_fr "Add W,fr"
- ()
- "add W,$fr"
- (+ OP6_ADD DIR_TO_W fr)
- (sequence ((QI result))
- (set cbit (add-cflag w fr 0))
- (set dcbit (add-dcflag w fr 0))
- (set result (addc w fr 0))
- (set zbit (zflag result))
- (set w result))
- ()
- )
- (dni xorfr_w "XOR fr,W"
- ()
- "xor $fr,W"
- (+ OP6_XOR DIR_NOTTO_W fr)
- (sequence ()
- (set fr (xor w fr))
- (set zbit (zflag fr)))
- ()
- )
- (dni xorw_fr "XOR W,fr"
- ()
- "xor W,$fr"
- (+ OP6_XOR DIR_TO_W fr)
- (sequence ()
- (set w (xor fr w))
- (set zbit (zflag w)))
- ()
- )
- (dni andfr_w "AND fr,W"
- ()
- "and $fr,W"
- (+ OP6_AND DIR_NOTTO_W fr)
- (sequence ()
- (set fr (and w fr))
- (set zbit (zflag fr)))
- ()
- )
- (dni andw_fr "AND W,fr"
- ()
- "and W,$fr"
- (+ OP6_AND DIR_TO_W fr)
- (sequence ()
- (set w (and fr w))
- (set zbit (zflag w)))
- ()
- )
- (dni orfr_w "OR fr,W"
- ()
- "or $fr,W"
- (+ OP6_OR DIR_NOTTO_W fr)
- (sequence ()
- (set fr (or w fr))
- (set zbit (zflag fr)))
- ()
- )
- (dni orw_fr "OR W,fr"
- ()
- "or W,$fr"
- (+ OP6_OR DIR_TO_W fr)
- (sequence ()
- (set w (or fr w))
- (set zbit (zflag w)))
- ()
- )
- (dni dec_fr "Decrement fr"
- ()
- "dec $fr"
- (+ OP6_DEC DIR_NOTTO_W fr)
- (sequence ((QI isLreg) (HI 16bval))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- ; Create the 16 bit value
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- ; New 16 bit instruction
- (set 16bval (sub HI 16bval 1))
- ; Separate the 16 bit values into the H and L regs
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set fr (reg h-spr (ifield f-reg)))
- )
- ; Original instruction
- (set fr (sub fr 1))
- )
- (set zbit (zflag fr)))
- ()
- )
- (dni decw_fr "Decrement fr into w"
- ()
- "dec W,$fr"
- (+ OP6_DEC DIR_TO_W fr)
- (sequence ()
- (set w (sub fr 1))
- (set zbit (zflag w)))
- ()
- )
- (dni subfr_w "Sub fr,W"
- ()
- "sub $fr,W"
- (+ OP6_SUB DIR_NOTTO_W fr)
- (sequence ((QI result) (QI isLreg) (HI 16bval))
- (set cbit (not (sub-cflag fr w 0)))
- (set dcbit (not (sub-dcflag fr w 0)))
- (LregCheck isLreg (ifield f-reg))
- ;; If fr is an Lreg, then we have to do 16-bit arithmetic.
- ;; We can take advantage of the fact that by a lucky
- ;; coincidence, the address of register xxxH is always
- ;; one lower than the address of register xxxL.
- (if (eq isLreg #x1)
- (sequence()
- ; Create the 16 bit value
- (set 16bval (reg h-spr (sub (ifield f-reg) 1)))
- (set 16bval (sll 16bval 8))
- (set 16bval (or 16bval (and (reg h-spr (ifield f-reg)) #xFF)))
- ; New 16 bit instruction
- (set 16bval (sub HI 16bval (and w #xFF)))
- ; Separate the 16 bit values into the H and L regs
- (set (reg h-spr (ifield f-reg)) (and 16bval #xFF))
- (set (reg h-spr (sub (ifield f-reg) 1))
- (and (srl 16bval 8) #xFF))
- (set result (reg h-spr (ifield f-reg)))
- )
- ; Original instruction
- (set result (subc fr w 0))
- )
- (set zbit (zflag result))
- (set fr result))
- ()
- )
- (dni subw_fr "Sub W,fr"
- ()
- "sub W,$fr"
- (+ OP6_SUB DIR_TO_W fr)
- (sequence ((QI result))
- (set cbit (not (sub-cflag fr w 0)))
- (set dcbit (not (sub-dcflag fr w 0)))
- (set result (subc fr w 0))
- (set zbit (zflag result))
- (set w result))
- ()
- )
- (dni clr_fr "Clear fr"
- ()
- "clr $fr"
- (+ OP6_OTHER2 (f-dir 1) fr)
- (sequence ()
- (set fr 0)
- (set zbit (zflag fr)))
- ()
- )
- (dni cmpw_fr "CMP W,fr"
- ()
- "cmp W,$fr"
- (+ OP6_OTHER2 (f-dir 0) fr)
- (sequence ()
- (set cbit (not (sub-cflag fr w 0)))
- (set dcbit (not (sub-dcflag fr w 0)))
- (set zbit (zflag (sub w fr))))
- ()
- )
- (dni speed "Set speed"
- ()
- "speed #$lit8"
- (+ (f-op8 1) lit8)
- (set (reg h-registers #x0E) lit8)
- ()
- )
- (dni ireadi "Insn memory read with increment"
- ()
- "ireadi"
- (+ OP6_OTHER1 (f-op6-10low #x1D))
- (c-call "do_insn_read")
- ()
- )
- (dni iwritei "Insn memory write with increment"
- ()
- "iwritei"
- (+ OP6_OTHER1 (f-op6-10low #x1C))
- (c-call "do_insn_write")
- ()
- )
- (dni fread "Flash read"
- ()
- "fread"
- (+ OP6_OTHER1 (f-op6-10low #x1B))
- (c-call "do_flash_read")
- ()
- )
- (dni fwrite "Flash write"
- ()
- "fwrite"
- (+ OP6_OTHER1 (f-op6-10low #x1A))
- (c-call "do_flash_write")
- ()
- )
- (dni iread "Insn memory read"
- ()
- "iread"
- (+ OP6_OTHER1 (f-op6-10low #x19))
- (c-call "do_insn_read")
- ()
- )
- (dni iwrite "Insn memory write"
- ()
- "iwrite"
- (+ OP6_OTHER1 (f-op6-10low #x18))
- (c-call "do_insn_write")
- ()
- )
- (dni page "Set insn page"
- (EXT-SKIP-INSN)
- ;"page $page3"
- "page $addr16p"
- ;(+ OP6_OTHER1 (f-op6-7low #x2) page3)
- ;(set pabits (srl page3 13))
- (+ OP6_OTHER1 (f-op6-7low #x2) addr16p)
- (set pabits addr16p)
- ()
- )
- (dni system "System call"
- ()
- "system"
- (+ OP6_OTHER1 (f-op6-10low #xff))
- (c-call "do_system")
- ()
- )
- (dni reti "Return from interrupt"
- ()
- "reti #$reti3"
- (+ OP6_OTHER1 (f-op6-7low #x1) reti3)
- (c-call "do_reti" reti3)
- ()
- )
- (dni ret "Return"
- ()
- "ret"
- (+ OP6_OTHER1 (f-op6-10low #x07))
- (sequence ((USI new_pc))
- (set new_pc (c-call UHI "pop_pc_stack"))
- (set pabits (srl new_pc 13))
- (set pc new_pc))
- ()
- )
- (dni int "Software interrupt"
- ()
- "int"
- (+ OP6_OTHER1 (f-op6-10low #x6))
- (nop)
- ()
- )
- (dni breakx "Breakpoint with extended skip"
- (EXT-SKIP-INSN)
- "breakx"
- (+ OP6_OTHER1 (f-op6-10low #x5))
- (c-call "do_break" pc)
- ()
- )
- (dni cwdt "Clear watchdog timer"
- ()
- "cwdt"
- (+ OP6_OTHER1 (f-op6-10low #x4))
- (c-call "do_clear_wdt")
- ()
- )
- (dni ferase "Flash erase"
- ()
- "ferase"
- (+ OP6_OTHER1 (f-op6-10low #x3))
- (c-call "do_flash_erase")
- ()
- )
- (dni retnp "Return, no page"
- ()
- "retnp"
- (+ OP6_OTHER1 (f-op6-10low #x2))
- (sequence ((USI new_pc))
- (set new_pc (c-call UHI "pop_pc_stack"))
- (set pc new_pc))
- ()
- )
- (dni break "Breakpoint"
- ()
- "break"
- (+ OP6_OTHER1 (f-op6-10low #x1))
- (c-call "do_break" pc)
- ()
- )
- (dni nop "No operation"
- ()
- "nop"
- (+ OP6_OTHER1 (f-op6-10low #x0))
- (nop)
- ()
- )
-
- ; Macro instructions
- (dnmi sc "Skip on carry"
- ()
- "sc"
- (emit sb (bitno 0) (fr #xB)) ; sb status.0
- )
- (dnmi snc "Skip on no carry"
- ()
- "snc"
- (emit snb (bitno 0) (fr #xB)) ; snb status.0
- )
-
- (dnmi sz "Skip on zero"
- ()
- "sz"
- (emit sb (bitno 2) (fr #xB)) ; sb status.2
- )
- (dnmi snz "Skip on no zero"
- ()
- "snz"
- (emit snb (bitno 2) (fr #xB)) ; snb status.2
- )
- (dnmi skip "Skip always"
- (SKIPA)
- "skip"
- (emit snb (bitno 0) (fr 9)) ; snb pcl.0 | (pcl&1)<<12
- )
- (dnmi skipb "Skip always"
- (SKIPA)
- "skip"
- (emit sb (bitno 0) (fr 9)) ; sb pcl.0 | (pcl&1)<<12
- )
|