📄 isp.s
字号:
mov.l (EXC_AREGS,%a6,%d1.w*4),%a0 # put base in a0 btst &0x8,%d0 beq.b addr_ind_index_8bit # for ext word or not? movm.l &0x3c00,-(%sp) # save d2-d5 mov.l %d0,%d5 # put extword in d5 mov.l %a0,%d3 # put base in d3 bra.l calc_mem_ind # calc memory indirectaddr_ind_index_8bit: mov.l %d2,-(%sp) # save old d2 mov.l %d0,%d1 rol.w &0x4,%d1 andi.w &0xf,%d1 # extract index regno mov.l (EXC_DREGS,%a6,%d1.w*4),%d1 # fetch index reg value btst &0xb,%d0 # is it word or long? bne.b aii8_long ext.l %d1 # sign extend word indexaii8_long: mov.l %d0,%d2 rol.w &0x7,%d2 andi.l &0x3,%d2 # extract scale value lsl.l %d2,%d1 # shift index by scale extb.l %d0 # sign extend displacement add.l %d1,%d0 # index + disp add.l %d0,%a0 # An + (index + disp) mov.l (%sp)+,%d2 # restore old d2 rts####################### Immediate: #<data> ########################################################################### word, long: <ea> of the data is the current extension word ## pointer value. new extension word pointer is simply the old ## plus the number of bytes in the data type(2 or 4). ##########################################################################immediate: mov.b &immed_flg,SPCOND_FLG(%a6) # set immediate flag mov.l EXC_EXTWPTR(%a6),%a0 # fetch extension word ptr rts############################ Absolute short: (XXX).W ############################abs_short: mov.l EXC_EXTWPTR(%a6),%a0 # fetch instruction addr addq.l &0x2,EXC_EXTWPTR(%a6) # incr instruction ptr bsr.l _imem_read_word # fetch short address tst.l %d1 # ifetch error? bne.l isp_iacc # yes mov.w %d0,%a0 # return <ea> in a0 rts########################### Absolute long: (XXX).L ###########################abs_long: mov.l EXC_EXTWPTR(%a6),%a0 # fetch instruction addr addq.l &0x4,EXC_EXTWPTR(%a6) # incr instruction ptr bsr.l _imem_read_long # fetch long address tst.l %d1 # ifetch error? bne.l isp_iacc # yes mov.l %d0,%a0 # return <ea> in a0 rts######################################################## Program counter indirect w/ displacement: (d16, PC) ########################################################pc_ind: mov.l EXC_EXTWPTR(%a6),%a0 # fetch instruction addr addq.l &0x2,EXC_EXTWPTR(%a6) # incr instruction ptr bsr.l _imem_read_word # fetch word displacement tst.l %d1 # ifetch error? bne.l isp_iacc # yes mov.w %d0,%a0 # sign extend displacement add.l EXC_EXTWPTR(%a6),%a0 # pc + d16# _imem_read_word() increased the extwptr by 2. need to adjust here. subq.l &0x2,%a0 # adjust <ea> rts########################################################### PC indirect w/ index(8-bit displacement): (d8, PC, An) ## " " w/ " (base displacement): (bd, PC, An) ## PC memory indirect postindexed: ([bd, PC], Xn, od) ## PC memory indirect preindexed: ([bd, PC, Xn], od) ###########################################################pc_ind_ext: mov.l EXC_EXTWPTR(%a6),%a0 # fetch instruction addr addq.l &0x2,EXC_EXTWPTR(%a6) # incr instruction ptr bsr.l _imem_read_word # fetch ext word tst.l %d1 # ifetch error? bne.l isp_iacc # yes mov.l EXC_EXTWPTR(%a6),%a0 # put base in a0 subq.l &0x2,%a0 # adjust base btst &0x8,%d0 # is disp only 8 bits? beq.b pc_ind_index_8bit # yes# the indexed addressing mode uses a base displacement of size# word or long movm.l &0x3c00,-(%sp) # save d2-d5 mov.l %d0,%d5 # put extword in d5 mov.l %a0,%d3 # put base in d3 bra.l calc_mem_ind # calc memory indirectpc_ind_index_8bit: mov.l %d2,-(%sp) # create a temp register mov.l %d0,%d1 # make extword copy rol.w &0x4,%d1 # rotate reg num into place andi.w &0xf,%d1 # extract register number mov.l (EXC_DREGS,%a6,%d1.w*4),%d1 # fetch index reg value btst &0xb,%d0 # is index word or long? bne.b pii8_long # long ext.l %d1 # sign extend word indexpii8_long: mov.l %d0,%d2 # make extword copy rol.w &0x7,%d2 # rotate scale value into place andi.l &0x3,%d2 # extract scale value lsl.l %d2,%d1 # shift index by scale extb.l %d0 # sign extend displacement add.l %d1,%d0 # index + disp add.l %d0,%a0 # An + (index + disp) mov.l (%sp)+,%d2 # restore temp register rts# a5 = exc_extwptr (global to uaeh)# a4 = exc_opword (global to uaeh)# a3 = exc_dregs (global to uaeh)# d2 = index (internal " " )# d3 = base (internal " " )# d4 = od (internal " " )# d5 = extword (internal " " )calc_mem_ind: btst &0x6,%d5 # is the index suppressed? beq.b calc_index clr.l %d2 # yes, so index = 0 bra.b base_supp_ckcalc_index: bfextu %d5{&16:&4},%d2 mov.l (EXC_DREGS,%a6,%d2.w*4),%d2 btst &0xb,%d5 # is index word or long? bne.b no_ext ext.l %d2no_ext: bfextu %d5{&21:&2},%d0 lsl.l %d0,%d2base_supp_ck: btst &0x7,%d5 # is the bd suppressed? beq.b no_base_sup clr.l %d3no_base_sup: bfextu %d5{&26:&2},%d0 # get bd size# beq.l _error # if (size == 0) it's reserved cmpi.b %d0,&2 blt.b no_bd beq.b get_word_bd mov.l EXC_EXTWPTR(%a6),%a0 # fetch instruction addr addq.l &0x4,EXC_EXTWPTR(%a6) # incr instruction ptr bsr.l _imem_read_long tst.l %d1 # ifetch error? bne.l isp_iacc # yes bra.b chk_indget_word_bd: mov.l EXC_EXTWPTR(%a6),%a0 # fetch instruction addr addq.l &0x2,EXC_EXTWPTR(%a6) # incr instruction ptr bsr.l _imem_read_word tst.l %d1 # ifetch error? bne.l isp_iacc # yes ext.l %d0 # sign extend bdchk_ind: add.l %d0,%d3 # base += bdno_bd: bfextu %d5{&30:&2},%d0 # is od suppressed? beq.w aii_bd cmpi.b %d0,&0x2 blt.b null_od beq.b word_od mov.l EXC_EXTWPTR(%a6),%a0 # fetch instruction addr addq.l &0x4,EXC_EXTWPTR(%a6) # incr instruction ptr bsr.l _imem_read_long tst.l %d1 # ifetch error? bne.l isp_iacc # yes bra.b add_themword_od: mov.l EXC_EXTWPTR(%a6),%a0 # fetch instruction addr addq.l &0x2,EXC_EXTWPTR(%a6) # incr instruction ptr bsr.l _imem_read_word tst.l %d1 # ifetch error? bne.l isp_iacc # yes ext.l %d0 # sign extend od bra.b add_themnull_od: clr.l %d0add_them: mov.l %d0,%d4 btst &0x2,%d5 # pre or post indexing? beq.b pre_indexed mov.l %d3,%a0 bsr.l _dmem_read_long tst.l %d1 # dfetch error? bne.b calc_ea_err # yes add.l %d2,%d0 # <ea> += index add.l %d4,%d0 # <ea> += od bra.b done_eapre_indexed: add.l %d2,%d3 # preindexing mov.l %d3,%a0 bsr.l _dmem_read_long tst.l %d1 # ifetch error? bne.b calc_ea_err # yes add.l %d4,%d0 # ea += od bra.b done_eaaii_bd: add.l %d2,%d3 # ea = (base + bd) + index mov.l %d3,%d0done_ea: mov.l %d0,%a0 movm.l (%sp)+,&0x003c # restore d2-d5 rts# if dmem_read_long() returns a fail message in d1, the package# must create an access error frame. here, we pass a skeleton fslw# and the failing address to the routine that creates the new frame.# FSLW:# read = true# size = longword# TM = data# software emulation error = truecalc_ea_err: mov.l %d3,%a0 # pass failing address mov.l &0x01010001,%d0 # pass fslw bra.l isp_dacc########################################################################## XDEF **************************************************************** ## _moveperipheral(): routine to emulate movep instruction ## ## XREF **************************************************************** ## _dmem_read_byte() - read byte from memory ## _dmem_write_byte() - write byte to memory ## isp_dacc() - handle data access error exception ## ## INPUT *************************************************************** ## none ## ## OUTPUT ************************************************************** ## If exiting through isp_dacc... ## a0 = failing address ## d0 = FSLW ## else ## none ## ## ALGORITHM *********************************************************** ## Decode the movep instruction words stored at EXC_OPWORD and ## either read or write the required bytes from/to memory. Use the ## _dmem_{read,write}_byte() routines. If one of the memory routines ## returns a failing value, we must pass the failing address and a FSLW ## to the _isp_dacc() routine. ## Since this instruction is used to access peripherals, make sure ## to only access the required bytes. ## ###################################################################################################### movep.(w,l) Dx,(d,Ay) ## movep.(w,l) (d,Ay),Dx ############################ global _moveperipheral_moveperipheral: mov.w EXC_OPWORD(%a6),%d1 # fetch the opcode word mov.b %d1,%d0 and.w &0x7,%d0 # extract Ay from opcode word mov.l (EXC_AREGS,%a6,%d0.w*4),%a0 # fetch ay add.w EXC_EXTWORD(%a6),%a0 # add: an + sgn_ext(disp) btst &0x7,%d1 # (reg 2 mem) or (mem 2 reg) beq.w mem2reg# reg2mem: fetch dx, then write it to memoryreg2mem: mov.w %d1,%d0 rol.w &0x7,%d0 and.w &0x7,%d0 # extract Dx from opcode word mov.l (EXC_DREGS,%a6,%d0.w*4), %d0 # fetch dx btst &0x6,%d1 # word or long operation? beq.b r2mwtrans# a0 = dst addr# d0 = Dxr2mltrans: mov.l %d0,%d2 # store data mov.l %a0,%a2 # store addr rol.l &0x8,%d2 mov.l %d2,%d0 bsr.l _dmem_write_byte # os : write hi tst.l %d1 # dfetch error? bne.w movp_write_err # yes add.w &0x2,%a2 # incr addr mov.l %a2,%a0 rol.l &0x8,%d2 mov.l %d2,%d0 bsr.l _dmem_write_byte # os : write lo tst.l %d1 # dfetch error? bne.w movp_write_err # yes add.w &0x2,%a2 # incr addr mov.l %a2,%a0 rol.l &0x8,%d2 mov.l %d2,%d0 bsr.l _dmem_write_byte # os : write lo tst.l %d1 # dfetch error? bne.w movp_write_err # yes add.w &0x2,%a2 # incr addr mov.l %a2,%a0 rol.l &0x8,%d2 mov.l %d2,%d0 bsr.l _dmem_write_byte # os : write lo tst.l %d1 # dfetch error? bne.w movp_write_err # yes rts# a0 = dst addr# d0 = Dxr2mwtrans: mov.l %d0,%d2 # store data mov.l %a0,%a2 # store addr lsr.w &0x8,%d0 bsr.l _dmem_write_byte # os : write hi tst.l %d1 # dfetch error? bne.w movp_write_err # yes add.w &0x2,%a2 mov.l %a2,%a0 mov.l %d2,%d0 bsr.l _dmem_write_byte # os : write lo tst.l %d1 # dfetch error? bne.w movp_write_err # yes rts# mem2reg: read bytes from memory.# determines the dest register, and then writes the bytes into it.mem2reg: btst &0x6,%d1 # word or long operation? beq.b m2rwtrans# a0 = dst addrm2rltrans: mov.l %a0,%a2 # store addr bsr.l _dmem_read_byte # read first byte tst.l %d1 # dfetch error? bne.w movp_read_err # yes mov.l %d0,%d2 add.w &0x2,%a2 # incr addr by 2 bytes mov.l %a2,%a0 bsr.l _dmem_read_byte # read second byte tst.l %d1 # dfetch error? bne.w movp_read_err # yes lsl.w &0x8,%d2 mov.b %d0,%d2 # append bytes add.w &0x2,%a2 # incr addr by 2 bytes mov.l %a2,%a0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -