memory.asm
来自「linux下的任天堂模拟器代码。供大家参考。」· 汇编 代码 · 共 2,272 行 · 第 1/3 页
ASM
2,272 行
ret; --- 8 BIT READ STUFF ---NEWSYM membank0r8ram ; 0000-1FFF mov al,[wramdataa+ebx+ecx] retNEWSYM membank0r8reg ; 2000-48FF add ecx,ebx call dword near [regptra+ecx*4-8000h] xor ebx,ebx retNEWSYM membank0r8inv ; 4800-5FFF add ecx,ebx mov al,ch retNEWSYM membank0r8chip ; 6000-7FFF add ecx,ebx cmp byte[SFXEnable],1 je .sfxram cmp byte[SA1Enable],1 je .sa1ram xor al,al cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read8b.nodsp1 ret.sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov al,[ebx+ecx] xor ebx,ebx pop ecx ret.sa1ram BWCheck mov ebx,[CurBWPtr] mov al,[ebx+ecx] xor ebx,ebx ret BWCheck2r8NEWSYM membank0r8rom ; 8000-FFFF add ebx,[snesmmap] mov al,[ebx+ecx] xor ebx,ebx retNEWSYM membank0r8romram ; 0000-1FFF add cx,bx test cx,8000h jnz .rom mov al,[wramdataa+ecx] ret.rom mov ebx,[snesmmap] mov al,[ebx+ecx] xor ebx,ebx ret; --- 16 BIT READ STUFF ---NEWSYM membank0r16ram ; 0000-1EFF mov ax,[wramdataa+ebx+ecx] retNEWSYM membank0r16ramh ; 1F00-1FFF add ecx,ebx cmp ecx,1FFFh je .over mov ax,[wramdataa+ecx] ret.over mov al,[wramdataa+ecx] mov ah,al ;open bus retNEWSYM membank0r16reg ; 2000-48FF add ecx,ebx call dword near [regptra+ecx*4-8000h] inc ecx mov ah,al call dword near [regptra+ecx*4-8000h] mov bl,al dec ecx mov al,ah mov ah,bl xor ebx,ebx retNEWSYM membank0r16inv ; 4800-5FFF add ecx,ebx mov al,ch mov ah,ch mov ax,8080h retNEWSYM membank0r16chip ; 6000-FFFF add ecx,ebx cmp byte[SFXEnable],1 je .sfxram cmp byte[SA1Enable],1 je .sa1ram xor ax,ax cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read16b.nodsp1 ret.sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov ax,[ebx+ecx] xor ebx,ebx pop ecx ret.sa1ram BWCheck mov ebx,[CurBWPtr] mov ax,[ebx+ecx] xor ebx,ebx ret BWCheck2r16NEWSYM membank0r16rom ; 8000-FFFF add ebx,[snesmmap] mov ax,[ebx+ecx] xor ebx,ebx retNEWSYM membank0r16romram ; 0000-1FFF add cx,bx test cx,8000h jnz .rom mov ax,[wramdataa+ecx] ret.rom mov ebx,[snesmmap] mov ax,[ebx+ecx] xor ebx,ebx ret; --- 8 BIT WRITE STUFF ---NEWSYM membank0w8ram ; 0000-1FFF mov [wramdataa+ebx+ecx],al retNEWSYM membank0w8reg ; 2000-48FF add ecx,ebx call dword near [regptwa+ecx*4-8000h] xor ebx,ebx retNEWSYM membank0w8inv ; 4800-5FFF retNEWSYM membank0w8chip ; 6000-FFFF add ecx,ebx cmp byte[SFXEnable],1 je .sfxram cmp byte[SA1Enable],1 je .sa1ram cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write8b.nodsp1 ret.sfxram push ecx sub cx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],al xor ebx,ebx pop ecx ret.sa1ram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],al xor ebx,ebx ret BWCheck2w8NEWSYM membank0w8rom ; 8000-FFFF retNEWSYM membank0w8romram ; 0000-1FFF add cx,bx test cx,8000h jnz .rom mov [wramdataa+ecx],al ret.rom ret; --- 16 BIT WRITE STUFF ---NEWSYM membank0w16ram ; 0000-1EFF mov [wramdataa+ebx+ecx],ax retNEWSYM membank0w16ramh ; 1F00-1FFF add ecx,ebx cmp ecx,1FFFh je .over mov [wramdataa+ecx],ax ret.over mov [wramdataa+ecx],al retNEWSYM membank0w16reg ; 2000-48FF add ecx,ebx call dword near [regptwa+ecx*4-8000h] inc ecx mov al,ah call dword near [regptwa+ecx*4-8000h] dec ecx xor ebx,ebx retNEWSYM membank0w16inv ; 4800-5FFF retNEWSYM membank0w16chip ; 6000-FFFF add ecx,ebxNEWSYM membank0w16rom ; 8000-FFFF cmp byte[SFXEnable],1 je .sfxram cmp byte[SA1Enable],1 je .sa1ram cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write16b.nodsp1 ret.sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],ax xor ebx,ebx pop ecx ret.sa1ram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],ax xor ebx,ebx ret BWCheck2w16NEWSYM membank0w16romram ; 0000-1FFF add cx,bx test cx,8000h jnz .rom mov [wramdataa+ecx],ax ret.rom retNEWSYM membank0r8 and ecx,0FFFFh cmp byte[SA1Enable],1 je near membank0r8SA1 cmp ecx,2000h jae .regs mov al,[wramdataa+ecx] ret.regs test ecx,8000h jz .regacc mov ebx,[snesmmap] mov al,[ebx+ecx] xor ebx,ebx ret.regacc cmp ecx,48FFh ja .invaccess; mov ebx,ecx; shl ebx,2; add ebx,[regptr]; call dword near [ebx] call dword near [regptra+ecx*4-8000h] xor ebx,ebx ret.invaccess cmp ecx,6000h jae .dsp1 mov al,ch ret.dsp1 cmp byte[SFXEnable],1 je .sfxram xor al,al cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read8b.nodsp1 ret.sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov al,[ebx+ecx] xor ebx,ebx pop ecx retNEWSYM membank0r16 and ecx,0FFFFh cmp byte[SA1Enable],1 je near membank0r16SA1 cmp ecx,2000h jae .regs mov ax,[wramdataa+ecx] ret.regs test ecx,8000h jz .regacc mov ebx,[snesmmap] mov ax,[ebx+ecx] xor ebx,ebx ret.regacc cmp ecx,48FFh ja .invaccess; mov ebx,ecx; shl ebx,2; add ebx,[regptr]; call dword near [ebx] call dword near [regptra+ecx*4-8000h] inc ecx mov ah,al; mov ebx,ecx; shl ebx,2; add ebx,[regptr]; call dword near [ebx] call dword near [regptra+ecx*4-8000h] mov bl,al dec ecx mov al,ah mov ah,bl xor ebx,ebx ret.invaccess cmp ecx,6000h jae .dsp1 xor ax,ax ret.dsp1 cmp byte[SFXEnable],1 je .sfxram xor ax,ax cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Read16b.nodsp1 ret.sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov ax,[ebx+ecx] xor ebx,ebx pop ecx retNEWSYM membank0w8 and ecx,0FFFFh cmp byte[SA1Enable],1 je near membank0w8SA1 cmp ecx,2000h jae .regs mov [wramdataa+ecx],al ret.romacc cmp byte[writeon],0 jne .modrom ret.modrom mov ebx,[snesmmap] mov [ebx+ecx],al xor ebx,ebx ret.regs test ecx,8000h jnz .romacc cmp ecx,48FFh ja .invaccess; mov ebx,ecx; shl ebx,2; add ebx,[regptw]; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] xor ebx,ebx ret.invaccess cmp ecx,6000h jae .dsp1 ret.dsp1 cmp byte[SFXEnable],1 je .sfxram cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write8b.nodsp1 ret.sfxram push ecx sub cx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],al xor ebx,ebx pop ecx retNEWSYM membank0w16 and ecx,0FFFFh cmp byte[SA1Enable],1 je near membank0w16SA1 cmp ecx,2000h jae .regs mov [wramdataa+ecx],ax ret.romacc cmp byte[writeon],0 jne .modrom ret.modrom mov ebx,[snesmmap] mov [ebx+ecx],ax xor ebx,ebx ret.regs test ecx,8000h jnz .romacc cmp ecx,48FFh ja .invaccess; mov ebx,ecx; shl ebx,2; add ebx,[regptw]; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] inc ecx mov al,ah; mov ebx,ecx; shl ebx,2; add ebx,[regptw]; call dword near [ebx] call dword near [regptwa+ecx*4-8000h] dec ecx xor ebx,ebx ret.invaccess cmp ecx,6000h jae .dsp1 ret.dsp1 cmp byte[SFXEnable],1 je .sfxram cmp byte[DSP1Type],2 jne .nodsp1 call DSP1Write16b.nodsp1 ret.sfxram push ecx sub ecx,6000h and ecx,1fffh mov ebx,[sfxramdata] mov [ebx+ecx],ax xor ebx,ebx pop ecx retNEWSYM membank0r8SA1 test ecx,8000h jz .regacc mov ebx,[snesmmap] mov al,[ebx+ecx] xor ebx,ebx ret.regacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov al,[wramdataa+ecx] ret.nowram cmp ecx,800h jae .invaccess mov al,[IRAM+ecx] ret.regs cmp ecx,48FFh ja .invaccess call dword near [regptra+ecx*4-8000h] xor ebx,ebx ret.invaccess cmp ecx,6000h jae .bwram xor al,al ret.bwram BWCheck mov ebx,[CurBWPtr] mov al,[ebx+ecx] xor ebx,ebx ret BWCheck2r8NEWSYM membank0r16SA1 test ecx,8000h jz .regacc mov ebx,[snesmmap] mov ax,[ebx+ecx] xor ebx,ebx ret.regacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov ax,[wramdataa+ecx] ret.nowram cmp ecx,800h jae .invaccess mov ax,[IRAM+ecx] ret.regs cmp ecx,48FFh ja .invaccess call dword near [regptra+ecx*4-8000h] inc ecx mov ah,al call dword near [regptra+ecx*4-8000h] mov bl,al dec ecx mov al,ah mov ah,bl xor ebx,ebx ret.invaccess cmp ecx,6000h jae .bwram xor ax,ax ret.bwram BWCheck mov ebx,[CurBWPtr] mov ax,[ebx+ecx] xor ebx,ebx ret BWCheck2r16NEWSYM membank0w8SA1 test ecx,8000h jnz .romacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov [wramdataa+ecx],al ret.nowram cmp ecx,800h jae .invaccess mov [IRAM+ecx],al ret.romacc ret.regs cmp ecx,48FFh ja .invaccess call dword near [regptwa+ecx*4-8000h] xor ebx,ebx ret.invaccess cmp ecx,6000h jae .bwram ret.bwram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],al xor ebx,ebx ret BWCheck2w8NEWSYM membank0w16SA1 test ecx,8000h jnz .romacc cmp ecx,2000h jae .regs cmp byte[SA1Status],0 jne .nowram mov [wramdataa+ecx],ax ret.nowram cmp ecx,800h jae .invaccess mov [IRAM+ecx],ax ret.romacc ret.regs cmp cx,48FFh ja .invaccess call dword near [regptwa+ecx*4-8000h] inc ecx mov al,ah call dword near [regptwa+ecx*4-8000h] dec ecx xor ebx,ebx ret.invaccess cmp ecx,6000h jae .bwram ret.bwram BWCheck mov ebx,[CurBWPtr] mov [ebx+ecx],ax xor ebx,ebx ret BWCheck2w16;*******************************************************; ROM Only Access Banks (40 - 6F) / (C0 - FF);*******************************************************NEWSYM memaccessbankr8 mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] xor ebx,ebx retNEWSYM memaccessbankr16 mov ebx,[snesmmap+ebx*4] mov ax,[ebx+ecx] xor ebx,ebx retNEWSYM memaccessbankw8 cmp byte[writeon],0 jne .modrom ret.modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],al xor ebx,ebx retNEWSYM memaccessbankw16 cmp byte[writeon],0 jne .modrom ret.modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],ax xor ebx,ebx ret;*******************************************************; SRAM Access Bank (70h);*******************************************************%macro SRAMAccess 1 cmp dword[curromspace],0x200000 ja .large cmp dword[ramsize],0x8000 ja .large jmp .notlarge.large test ecx,8000h jnz %1.notlarge%endmacroNEWSYM sramaccessbankr8 SRAMAccess memaccessbankr8 push ecx and bl,7Fh sub bl,70h shl ebx,15 add ecx,ebx call sramaccessbankr8b pop ecx retNEWSYM sramaccessbankr16 SRAMAccess memaccessbankr16 push ecx and bl,7Fh sub bl,70h shl ebx,15 add ecx,ebx call sramaccessbankr16b pop ecx retNEWSYM sramaccessbankw8 SRAMAccess memaccessbankw8 push ecx and bl,7Fh sub bl,70h shl ebx,15 add ecx,ebx call sramaccessbankw8b pop ecx retNEWSYM sramaccessbankw16 SRAMAccess memaccessbankw16 push ecx and bl,7Fh sub bl,70h shl ebx,15 add ecx,ebx call sramaccessbankw16b pop ecx retNEWSYM sramaccessbankr8s push ecx sub bl,78h shl ebx,15 add ecx,ebx call sramaccessbankr8b pop ecx retNEWSYM sramaccessbankr16s push ecx sub bl,78h shl ebx,15 add ecx,ebx call sramaccessbankr16b pop ecx retNEWSYM sramaccessbankw8s push ecx sub bl,78h shl ebx,15 add ecx,ebx call sramaccessbankw8b pop ecx retNEWSYM sramaccessbankw16s push ecx sub bl,78h shl ebx,15 add ecx,ebx call sramaccessbankw16b pop ecx retNEWSYM sramaccessbankr8b cmp dword[ramsize],0 je .noaccess push ecx and ecx,[ramsizeand] mov ebx,[sram] mov al,[ebx+ecx]
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?