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

📄 spc700.asm

📁 linux下的任天堂模拟器代码。供大家参考。
💻 ASM
📖 第 1 页 / 共 4 页
字号:
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    retNEWSYM Op6Bb    ReadByte2    stc    spcRORstuff    WriteByte    retNEWSYM 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    retNEWSYM Op3Bb    ReadByte2    stc    spcROLstuff    WriteByte    retNEWSYM 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    retNEWSYM Op7Bb    ReadByte2    stc    spcRORstuff    WriteByte    retNEWSYM 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    retNEWSYM Op2Cb    ReadByte2    stc    spcROLstuff    WriteByte    retNEWSYM 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    retNEWSYM Op6Cb    ReadByte2    stc    spcRORstuff    WriteByte    retNEWSYM 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    retNEWSYM 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    retNEWSYM 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    retNEWSYM Op7Cb    stc    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;************************************************; INC/DEC instructions (Verified);************************************************NEWSYM Op8B     ;  DEC dp   -- (dp)           N......Z.    mov bl,[ebp]    add ebx,[spcRamDP]    inc ebp    ReadByte2    dec al    mov [spcNZ], al    WriteByte    retNEWSYM OpAB     ; INC dp    ++ (dp)           N......Z.    mov bl,[ebp]    add ebx,[spcRamDP]    inc ebp    ReadByte2    inc al    mov [spcNZ], al    WriteByte    retNEWSYM Op9B     ;  DEC dp+X -- (dp+X)         N......Z.    mov bl,[ebp]    add bl,[spcX]    add ebx,[spcRamDP]    inc ebp    ReadByte2    dec al    mov [spcNZ], al    WriteByte    retNEWSYM OpBB     ; INC dp+X  ++ (dp+X)         N......Z.    mov bl,[ebp]    add bl,[spcX]    add ebx,[spcRamDP]    inc ebp    ReadByte2    inc al    mov [spcNZ], al    WriteByte    retNEWSYM Op8C     ; DEC labs  -- (abs)          N......Z.    mov bx,[ebp]    add ebx,SPCRAM    add ebp,2    ReadByte2    dec al    mov [spcNZ], al    WriteByte    retNEWSYM OpAC     ; INC labs  ++ (abs)          N......Z.    mov bx,[ebp]    add ebx,SPCRAM    add ebp,2    ReadByte2    inc al    mov [spcNZ], al    WriteByte    retNEWSYM Op9C     ; DEC A  -- A            N......Z.    dec byte[spcA]    mov al,[spcA]    mov [spcNZ],al    retNEWSYM OpBC     ; INC A  ++ A            N......Z.    inc byte[spcA]    mov al,[spcA]    mov [spcNZ],al    retNEWSYM OpDC     ; DEC Y  -- Y            N......Z.    dec byte[spcY]    mov al,[spcY]    mov [spcNZ],al    retNEWSYM OpFC     ; INC Y  ++ Y            N......Z.    inc byte[spcY]    mov al,[spcY]    mov [spcNZ],al    retNEWSYM Op1D     ; DEC X     -- X            N......Z.    dec byte[spcX]    mov al,[spcX]    mov [spcNZ],al    retNEWSYM Op3D     ; INC X     ++ X            N......Z.    inc byte[spcX]    mov al,[spcX]    mov [spcNZ],al    ret;************************************************; PUSH/POP instructions (Verified);************************************************NEWSYM Op0D     ; PUSH PSW     push PSW to stack     .........    mov eax,[spcS]    mov bl,[spcP]    and bl,01111101b    test byte[spcNZ],80h    jnz .NegSet    cmp byte[spcNZ],0    je .ZeroSet    dec byte[spcS]    mov [SPCRAM+eax],bl    ret.NegSet    or bl,80h    dec byte[spcS]    mov [SPCRAM+eax],bl    ret.ZeroSet    or bl,02h    dec byte[spcS]    mov [SPCRAM+eax],bl    retNEWSYM Op2D     ; PUSH A     push A to stack       .........    mov eax,[spcS]    mov bl,[spcA]    dec byte[spcS]    mov [SPCRAM+eax],bl    retNEWSYM Op4D     ; PUSH X     push X to stack       .........    mov eax,[spcS]    mov bl,[spcX]    dec byte[spcS]    mov [SPCRAM+eax],bl    retNEWSYM Op6D     ; PUSH Y    push Y to stack       .........    mov eax,[spcS]    mov bl,[spcY]    dec byte[spcS]    mov [SPCRAM+eax],bl    retNEWSYM Op8E     ; POP PSW   pop PSW from stack     (Restored)    inc byte[spcS]    mov eax,[spcS]    mov byte[spcNZ],0    mov bl,[SPCRAM+eax]    mov [spcP],bl    test byte[spcP],2    jnz .ZeroYes    mov byte[spcNZ],1    test byte[spcP],80h    jz .NoNeg    or byte[spcNZ],80h.NoNeg.ZeroYes    mov dword[spcRamDP],SPCRAM    test byte[spcP],32    jnz .setpage1    ret.setpage1    add dword[spcRamDP],100h    retNEWSYM OpAE     ; POP A     pop A from stack      .........    inc byte[spcS]    mov eax,[spcS]    mov bl,[SPCRAM+eax]    mov [spcA],bl    retNEWSYM OpCE     ; POP X     pop X from stack      .........    inc byte[spcS]    mov eax,[spcS]    mov bl,[SPCRAM+eax]    mov [spcX],bl    retNEWSYM OpEE     ; POP Y     pop Y from stack      .........    inc byte[spcS]    mov eax,[spcS]    mov bl,[SPCRAM+eax]    mov [spcY],bl    ret;************************************************; Test & set bits Instructions (Verified?);************************************************NEWSYM Op0E     ; TSET1 labs   test and set bits with A   N......Z.    mov bx,[ebp]    add ebx,SPCRAM    add ebp,2    ReadByte2    mov ah,al    and ah,[spcA]    mov [spcNZ],ah    or al,[spcA]    WriteByte    retNEWSYM Op4E     ; TCLR1     test and clear bits with A N......Z.    mov bx,[ebp]    add ebx,[spcRamDP]    add ebp,2    ReadByte2    mov ah,al    and ah,[spcA]    mov [spcNZ],ah    mov ah,[spcA]    not ah    and al,ah    WriteByte    ret;************************************************; Compare/Decrement & Branch Instructions (Verified);************************************************NEWSYM Op2E     ; CBNE dp,rel  compare A with (dp) then BNE   ...    mov bl,[ebp]    add ebx,[spcRamDP]    ReadByte2    cmp byte[spcA], al    jne .Jump    add ebp,2    ret.Jump    movsx ebx,byte[ebp+1]    add ebp,ebx    add ebp,2    retNEWSYM OpDE     ; CBNE dp+X,rel   compare A with (dp+X) then BNE ...    mov bl,[ebp]    add bl,[spcX]    add ebx,[spcRamDP]    ReadByte2    cmp byte[spcA], al    jne .Jump    add ebp,2    ret.Jump    movsx ebx,byte[ebp+1]    add ebp,ebx    add ebp,2    retNEWSYM Op6E     ; DBNZ   decrement memory (dp) then JNZ ...    mov bl,[ebp]    add ebx,[spcRamDP]    ReadByte2    dec al    jnz .Jump    add ebp,2    WriteByte    ret.JumpNEWSYM Op6Eb    push ebx    movsx ebx,byte[ebp+1]    add ebp,ebx    add ebp,2    pop ebx    WriteByte    retNEWSYM OpFE     ; DBNZ Y,rel   decrement Y then JNZ         ...    dec byte[spcY]    jnz .Jump    inc ebp    ret.Jump    movsx ebx,byte[ebp]    add ebp,ebx    inc ebp    ret;************************************************; Jump/Subroutine Instructions;************************************************NEWSYM Op0F     ; BRK     software interrupt     ...1.0..    inc dword[spc700read]    dec ebp    retNEWSYM Op1F     ; JMP (labs+X)    PC <- (abs+X+1)(abs+X)       ...    mov bx,[ebp]    add bx,[spcX]    xor eax,eax    add ebp,2    mov ax,[SPCRAM+ebx]    mov ebp,SPCRAM    add ebp,eax    retNEWSYM Op3F     ; CALL labs    subroutine call        ........    ; calculate PC    mov ecx,ebp    add ecx,2    sub ecx,SPCRAM    mov eax,[spcS]    mov [SPCRAM+eax],ch    dec byte[spcS]    mov eax,[spcS]    mov [SPCRAM+eax],cl    dec byte[spcS]    ; set new PC    mov cx,[ebp]    add ecx,SPCRAM    mov ebp,ecx    xor ecx,ecx    retNEWSYM Op4F     ; PCALL upage  upage call           ........    ; calculate PC    mov ecx,ebp    inc ecx    sub ecx,SPCRAM    mov eax,[spcS]    mov [SPCRAM+eax],ch    dec byte[spcS]    mov eax,[spcS]    mov [SPCRAM+eax],cl    dec byte[spcS]    ; set new PC    xor ecx,ecx    mov cl,[ebp]    add ecx,SPCRAM    add ecx,0ff00h    mov ebp,ecx    xor ecx,ecx    ret; I'm not sure about this one and JMP labs+X...NEWSYM Op5F     ; JMP labs     jump to new location         ...    mov bx,[ebp]    add ebp,2    mov ebp,SPCRAM    add ebp,ebx    retNEWSYM Op6F     ; ret        ret from subroutine   ........    xor ecx,ecx    inc byte[spcS]    mov eax,[spcS]    mov cl,[SPCRAM+eax]    inc byte[spcS]    mov eax,[spcS]    mov ch,[SPCRAM+eax]    add ecx,SPCRAM    mov ebp,ecx    xor ecx,ecx    retNEWSYM Op7F     ; ret1       return from interrupt   (Restored)    dec ebp    ret    xor ecx,ecx    inc byte[spcS]    mov eax,[spcS]    mov cl,[SPCRAM+eax]    mov [spcP],cl    test byte[spcP],80h    jz .NoNeg    or byte[spcNZ],80h.NoNeg    test byte[spcP],2    jz .NoZero    mov byte[spcNZ],0    jmp .YesZero.NoZero    or byte[spcNZ],1.YesZero    inc byte[spcS]    mov eax,[spcS]    mov cl,[SPCRAM+eax]    inc byte[spcS]    mov eax,[spcS]    mov ch,[SPCRAM+eax]    add ecx,SPCRAM    mov ebp,ecx    ; set direct page    mov dword[spcRamDP],SPCRAM    test byte[spcP],32    jz .nodp    add dword[spcRamDP],100h.nodp    xor ecx,ecx    ret;************************************************; Divide/Multiply Instructions;************************************************NEWSYM Op9E     ; DIV YA,X     Q:A B:Y <- YA / X     NV..H..Z.   push edx   mov ah,[spcY]   mov al,[spcA]   xor bh,bh   xor dx,dx   mov bl,[spcX]   cmp bl,0   je NoDiv   div bx   mov [spcA],al   mov [spcY],dl   cmp ah,0   jne Over   and byte[spcP],191-16   pop edx   mov [spcNZ],al   retNEWSYM NoDiv   mov byte[spcA],0ffh   mov byte[spcY],0ffh   or byte[spcP],16   and byte[spcP],255-64   pop edx   retNEWSYM Over   or byte[spcP],64   and byte[spcP],255-16   pop edx   mov [spcNZ],al   retNEWSYM OpCF     ; MUL YA     YA(16 bits) <- Y * A    N......Z.    mov al,[spcA]    mov bl,[spcY]    mul bl    mov [spcA],al    mov [spcY],ah    ; ??? (Is the n flag set on YA or A?)    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;************************************************; Decimal Operations;************************************************NEWSYM OpBE     ; DAS A     decimal adjust for sub  N......ZC    ; copy al flags into AH    xor ah,ah    test byte[spcNZ],80h    jz .noneg    or ah,10000000b.noneg    test byte[spcP],01h    jz .nocarry    or ah,00000001b.nocarry    test byte[spcNZ],0FFh    jnz .nozero    or ah,01000000b.nozero    test byte[spcP],08h    jz .nohcarry    or ah,00010000b.nohcarry    mov al,[spcA]    sahf    das    mov [spcA],al    SPCSetFlagnzcNEWSYM OpDF     ; DAA A      decimal adjust for add  N......ZC    ; copy al flags into AH    xor ah,ah    test byte[spcNZ],80h    jz .noneg    or ah,10000000b.noneg    test byte[spcP],01h    jz .nocarry    or ah,00000001b.nocarry    test byte[spcNZ],0FFh    jnz .nozero    or ah,01000000b.nozero    test byte[spcP],08h    jz .nohcarry    or ah,00010000b.nohcarry    mov al,[spcA]    sahf    daa    mov [spcA],al    SPCSetFlagnzcNEWSYM Invalidopcode ; Invalid Opcode    dec ebp    ret

⌨️ 快捷键说明

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