⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spc700.asm

📁 十七种模拟器源代码 非常有用的作课程设计不可缺少的
💻 ASM
📖 第 1 页 / 共 5 页
字号:
      add ebx,[spcRamDP]
      inc ebp
      inc ebx
      ReadByte2
      mov ah,al
      dec ebx
NEWSYM Op1AB
      ReadByte2
      dec ax
      test ax,8000h
      jnz .YesNeg
      cmp ax,0000h
      je .YesZero
      mov byte [spcNZ],1
      jmp .SkipFlag
.YesNeg
      mov byte [spcNZ],80h
      jmp .SkipFlag
.YesZero
      mov byte [spcNZ],0
.SkipFlag
      push ebx
      WriteByte
      pop ebx
NEWSYM Op1Ab
      inc ebx
      mov al,ah
      WriteByte
      ret

NEWSYM Op3A       ; INCW dp   Increment dp memory pair  N......Z.
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      inc ebx
      ReadByte2
      mov ah,al
      dec ebx
NEWSYM Op3AB
      ReadByte2
      inc ax
      test ax,8000h
      jnz .YesNeg
      cmp ax,0000h
      je .YesZero
      mov byte [spcNZ],1
      jmp .SkipFlag
.YesNeg
      mov byte [spcNZ],80h
      jmp .SkipFlag
.YesZero
      mov byte [spcNZ],0
.SkipFlag
      push ebx
      WriteByte
      pop ebx
NEWSYM Op3Ab
      inc ebx
      mov al,ah
      WriteByte
      ret

; looks like there is the Carry flag checked in op5a..

NEWSYM Op5A       ; CMPW YA,dp   YA - (dp+1)(dp)        N......ZC
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      inc ebx
      ReadByte2
      mov ah,al
      dec ebx
NEWSYM Op5AB
      ReadByte
      mov bl,[spcA]
      mov bh,[spcY]
      cmp bx,ax
      cmc
      SPCSetFlagnzc

NEWSYM Op7A       ; ADDW YA,dp   YA  <- YA + (dp+1)(dp)   NV..H..ZC
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      inc ebx
      ReadByte2
      mov ah,al
      dec ebx
NEWSYM Op7AB
      ReadByte
      mov bl,[spcA]
      mov bh,[spcY]
      add bx,ax
      mov [spcA],bl
      mov [spcY],bh
      SPCSetFlagnvhzc

NEWSYM Op9A       ; SUBW YA,dp   YA  <- YA - (dp+1)(dp)   NV..H..ZC
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      inc ebx
      ReadByte2
      mov ah,al
      dec ebx
NEWSYM Op9AB
      ReadByte
      mov bl,[spcA]
      mov bh,[spcY]
      sub bx,ax
      cmc
      mov [spcA],bl
      mov [spcY],bh
      SPCSetFlagnvhzc

NEWSYM OpBA       ; MOVW YA,dp   YA  - (dp+1)(dp)       N......Z.
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      inc ebx
      ReadByte2
      mov ah,al
      dec ebx
NEWSYM OpBAb
      ReadByte
      mov [spcA],al
      mov [spcY],ah
      test ax,8000h
      jnz .YesNeg
      cmp ax,0000h
      je .YesZero
      mov byte [spcNZ],1
      ret
.YesNeg
      mov byte [spcNZ],80h
      ret
.YesZero
      mov byte [spcNZ],0
      ret

NEWSYM OpDA       ; MOVW dp,YA   (dp+1)(dp) - YA         .........
      mov bl,[ebp]
      mov al,[spcA]
      add ebx,[spcRamDP]
      inc ebp
      push ebx
      WriteByte
      pop ebx
      inc ebx
      mov al,[spcY]
NEWSYM OpDAb
      WriteByte
      ret

;************************************************
; mem.bit instructions (Verified)
;************************************************

%macro spcaddrmembit 0
      mov bx,[ebp]

      mov cl,bh
      add ebp,2
      shr cl,5
      and bx,1FFFh

;      mov cl,bl
;      add ebp,2
;      shr bx,3
;      and cl,00000111b

      add ebx,spcRam
      ReadByte
      shr al,cl
      and al,01h
%endmacro

NEWSYM Op0A       ; OR1 C,mem.bit   C <- C OR  (mem.bit)      ........C
      spcaddrmembit
      or [spcP],al
      ret

NEWSYM Op2A       ; OR1 C,/mem.bit  C <- C OR  !(mem.bit)     ........C
      spcaddrmembit
      xor al,01h
      or [spcP],al
      ret

NEWSYM Op4A       ; AND1 C,mem.bit  C <- C AND (mem.bit)      ........C
      mov bx,[ebp]

      mov cl,bh
      add ebp,2
      shr cl,5
      and bx,1FFFh

;      mov cl,bl
;      add ebp,2
;      shr bx,3
;      and cl,00000111b

      add ebx,spcRam
      ReadByte
      shr al,cl
      or al,0FEh
      and [spcP],al
      ret

NEWSYM Op6A       ; AND1 C,/mem.bit C <- C AND !(mem.bit)     ........C
      mov bx,[ebp]

      mov cl,bh
      add ebp,2
      shr cl,5
      and bx,1FFFh

;      mov cl,bl
;      add ebp,2
;      shr bx,3
;      and cl,00000111b

      add ebx,spcRam
      ReadByte
      shr al,cl
      or al,0FEh
      xor al,01h
      and [spcP],al
      ret

NEWSYM Op8A       ; EOR1 C,mem.bit  C <- C EOR (mem.bit)      ........C
      spcaddrmembit
      xor [spcP],al
      ret

NEWSYM OpAA       ; MOV1 C,mem.bit  C <- (mem.bit)
      spcaddrmembit
      and byte[spcP],0FEh
      or [spcP],al
      ret

NEWSYM OpCA       ; MOV1 mem.bit,C  C -> (mem.bit)            .........
      mov bx,[ebp]
      mov al,[spcP]

      mov cl,bh
      mov ah,01h
      shr cl,5
      and bx,1FFFh

;      mov cl,bl
;      mov ah,01h
;      and cl,00000111b
;      shr bx,3

      shl ah,cl
      and al,01h
      add ebp,2
      shl al,cl
      add ebx,spcRam
      ; al = carry flag positioned in correct location, ah = 1 positioned
      mov cl,al
      xor ah,0FFh
      ReadByte2
      and al,ah
      or al,cl
      WriteByte
      ret

NEWSYM OpEA       ; NOT1 mem.bit    complement (mem.bit)      .........
      mov bx,[ebp]

      mov cl,bh
      mov ah,01h
      shr cl,5
      and bx,1FFFh

;      mov cl,bl
;      mov ah,01h
;      and cl,00000111b
;      shr bx,3

      shl ah,cl
      add ebp,2
      add ebx,spcRam
      ReadByte2
      xor al,ah
      WriteByte
      ret

;************************************************
; Shift Instructions (Verified)
;************************************************

NEWSYM Op0B       ; ASL dp    C << (dp)   <<0       N......ZC
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      ReadByte2
      shl al,1
      SPCSetFlagnzcnoret
      WriteByte
      ret

NEWSYM Op4B       ; LSR dp    0 >> (dp)   <<C       N......ZC
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      ReadByte2
      shr al,1
      SPCSetFlagnzcnoret
      WriteByte
      ret

NEWSYM Op1B       ; ASL dp+X  C << (dp+X) <<0       N......ZC
      mov bl,[ebp]
      add bl,[spcX]
      inc ebp
      add ebx,[spcRamDP]
      ReadByte2
      shl al,1
      SPCSetFlagnzcnoret
      WriteByte
      ret

NEWSYM Op5B       ; LSR dp+X  0 >> (dp+X) <<C       N......ZC
      mov bl,[ebp]
      add bl,[spcX]
      inc ebp
      add ebx,[spcRamDP]
      ReadByte2
      shr al,1
      SPCSetFlagnzcnoret
      WriteByte
      ret

NEWSYM Op0C       ; ASL labs  C << (abs)  <<0       N......ZC
      mov bx,[ebp]
      add ebx,spcRam
      add ebp,2
      ReadByte2
      shl al,1
      SPCSetFlagnzcnoret
      WriteByte
      ret

NEWSYM Op4C       ; LSR labs  0 >> (abs)  <<C       N......ZC
      mov bx,[ebp]
      add ebx,spcRam
      add ebp,2
      ReadByte2
      shr al,1
      SPCSetFlagnzcnoret
      WriteByte
      ret

NEWSYM Op1C       ; ASL A  C << A      <<0       N......ZC
      shl byte [spcA],1
      SPCSetFlagnzc

NEWSYM Op5C       ; LSR A  0 >> A      <<C       N......ZC
      shr byte [spcA],1
      SPCSetFlagnzc

%macro spcROLstuff 0
      rcl al,1
      jc .setcarryflag
      and byte[spcP],0FEh
      mov [spcNZ],al
      jmp .skipflags
.setcarryflag
      or byte[spcP],01h
      mov [spcNZ],al
.skipflags
%endmacro

%macro spcRORstuff 0
      rcr al,1
      jc .setcarryflag
      and byte[spcP],0FEh
      mov [spcNZ],al
      jmp .skipflags
.setcarryflag
      or byte[spcP],01h
      mov [spcNZ],al
.skipflags
%endmacro

NEWSYM Op2B       ; ROL dp    C << (dp)   <<C       N......ZC
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      test byte [spcP],01h
      jnz near Op2Bb
      ReadByte2
      clc
      spcROLstuff
      WriteByte
      ret
NEWSYM Op2Bb
      ReadByte2
      stc
      spcROLstuff
      WriteByte
      ret

NEWSYM Op6B       ; ROR dp    C >> (dp)   <<C       N......ZC
      mov bl,[ebp]
      add ebx,[spcRamDP]
      inc ebp
      test byte [spcP],01h
      jnz near Op6Bb
      ReadByte2
      clc
      spcRORstuff
      WriteByte
      ret
NEWSYM Op6Bb
      ReadByte2
      stc
      spcRORstuff
      WriteByte
      ret

NEWSYM Op3B       ; ROL dp+X  C << (dp+X) <<C       N......ZC
      mov bl,[ebp]
      add bl,[spcX]
      add ebx,[spcRamDP]
      inc ebp
      test byte [spcP],01h
      jnz near Op3Bb
      ReadByte2
      clc
      spcROLstuff
      WriteByte
      ret
NEWSYM Op3Bb
      ReadByte2
      stc
      spcROLstuff
      WriteByte
      ret

NEWSYM Op7B       ; ROR dp+X  C >> (dp+X) <<C       N......ZC
      mov bl,[ebp]
      add bl,[spcX]
      add ebx,[spcRamDP]
      inc ebp
      test byte [spcP],01h
      jnz near Op7Bb
      ReadByte2
      clc
      spcRORstuff
      WriteByte
      ret
NEWSYM Op7Bb
      ReadByte2
      stc
      spcRORstuff
      WriteByte
      ret

NEWSYM Op2C       ; ROL labs  C << (abs)  <<C       N......ZC
      mov bx,[ebp]
      add ebx,spcRam
      add ebp,2
      test byte [spcP],01h
      jnz near Op2Cb
      ReadByte2
      clc
      spcROLstuff
      WriteByte
      ret
NEWSYM Op2Cb
      ReadByte2
      stc
      spcROLstuff
      WriteByte
      ret

NEWSYM Op6C       ; ROR labs  C >> (abs)  <<C       N......ZC
      mov bx,[ebp]
      add ebx,spcRam
      add ebp,2
      test byte [spcP],01h
      jnz near Op6Cb
      ReadByte2
      clc
      spcRORstuff
      WriteByte
      ret
NEWSYM Op6Cb
      ReadByte2
      stc
      spcRORstuff
      WriteByte
      ret

NEWSYM Op3C       ; ROL A  C << A      <<C       N......ZC
      test byte [spcP],01h
      jnz near Op3Cb
      clc
      rcl byte [spcA],1
      mov al,[spcA]
      jc .setcarryflag
      and byte[spcP],0FEh
      mov [spcNZ],al
      ret
.setcarryflag
      or byte[spcP],01h
      mov [spcNZ],al
      ret
NEWSYM Op3Cb
      stc
      rcl byte [spcA],1
      mov al,[spcA]
      jc .setcarryflag
      and byte[spcP],0FEh
      mov [spcNZ],al
      ret
.setcarryflag
      or byte[spcP],01h
      mov [spcNZ],al
      ret

NEWSYM Op7C       ; ROR A  C >> A      <<C       N......ZC
      test byte [spcP],01h
      jnz near Op7Cb
      clc
      rcr byte [spcA],1
      mov al,[spcA]
      jc .setcarryflag
      and byte[spcP],0FEh
      mov [spcNZ],al
      ret
.setcarryflag
      or byte[spcP],01h
      mov [spcNZ],al
      ret
NEWSYM Op7Cb
      stc

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -