memory.asm
来自「linux下的任天堂模拟器代码。供大家参考。」· 汇编 代码 · 共 2,272 行 · 第 1/3 页
ASM
2,272 行
pop ecx xor ebx,ebx ret.noaccess xor al,al xor ebx,ebx retNEWSYM sramaccessbankr16b cmp dword[ramsize],0 je .noaccess mov ebx,[sram] push ecx and ecx,[ramsizeand] mov al,[ebx+ecx] inc ecx and ecx,[ramsizeand] mov ah,[ebx+ecx] pop ecx xor ebx,ebx ret.noaccess xor ax,ax xor ebx,ebx retNEWSYM sramaccessbankw8b cmp dword[ramsize],0 je .noaccess mov ebx,[sram] push ecx and ecx,[ramsizeand] mov [ebx+ecx],al pop ecx mov dword[sramb4save],5*60.noaccess xor ebx,ebx retNEWSYM sramaccessbankw16b cmp dword[ramsize],0 je .noaccess mov ebx,[sram] push ecx and ecx,[ramsizeand] mov [ebx+ecx],al inc ecx and ecx,[ramsizeand] mov [ebx+ecx],ah pop ecx mov dword[sramb4save],5*60.noaccess xor ebx,ebx ret%macro STsramaccess 1 test ecx,8000h jz %1%endmacroNEWSYM stsramr8 STsramaccess memaccessbankr8 push ecx sub bl,60h shl ebx,15 add ecx,ebx mov ebx,[sram] and ecx,[ramsizeand] mov al,[ebx+ecx] pop ecx xor ebx,ebx retNEWSYM stsramr16 STsramaccess memaccessbankr16 push ecx sub bl,60h shl ebx,15 add ecx,ebx mov ebx,[sram] and ecx,[ramsizeand] mov al,[ebx+ecx] inc ecx and ecx,[ramsizeand] mov ah,[ebx+ecx] pop ecx xor ebx,ebx retNEWSYM stsramw8 STsramaccess memaccessbankw8 push ecx sub bl,60h shl ebx,15 add ecx,ebx mov ebx,[sram] and ecx,[ramsizeand] mov [ebx+ecx],al pop ecx mov dword[sramb4save],5*60 xor ebx,ebx retNEWSYM stsramw16 STsramaccess memaccessbankw16 push ecx sub bl,60h shl ebx,15 add ecx,ebx mov ebx,[sram] and ecx,[ramsizeand] mov [ebx+ecx],al inc ecx and ecx,[ramsizeand] mov [ebx+ecx],ah pop ecx mov dword[sramb4save],5*60 xor ebx,ebx retNEWSYM stsramr8b STsramaccess memaccessbankr8 push ecx sub bl,70h shl ebx,15 add ecx,ebx mov ebx,[sram2] and ecx,[ramsizeand] mov al,[ebx+ecx] pop ecx xor ebx,ebx retNEWSYM stsramr16b STsramaccess memaccessbankr16 push ecx sub bl,70h shl ebx,15 add ecx,ebx mov ebx,[sram2] and ecx,[ramsizeand] mov al,[ebx+ecx] inc ecx and ecx,[ramsizeand] mov ah,[ebx+ecx] pop ecx xor ebx,ebx retNEWSYM stsramw8b STsramaccess memaccessbankw8 push ecx sub bl,70h shl ebx,15 add ecx,ebx mov ebx,[sram2] and ecx,[ramsizeand] mov [ebx+ecx],al pop ecx mov dword[sramb4save],5*60 xor ebx,ebx retNEWSYM stsramw16b STsramaccess memaccessbankw16 push ecx sub bl,70h shl ebx,15 add ecx,ebx mov ebx,[sram2] and ecx,[ramsizeand] mov [ebx+ecx],al inc ecx and ecx,[ramsizeand] mov [ebx+ecx],ah pop ecx mov dword[sramb4save],5*60 xor ebx,ebx ret;*******************************************************; WorkRAM/ExpandRAM Access Bank (7Eh);*******************************************************NEWSYM wramaccessbankr8; mov ebx,[wramdata]; mov al,[ebx+ecx]; xor ebx,ebx mov al,[wramdataa+ecx] retNEWSYM wramaccessbankr16; mov ebx,[wramdata]; mov ax,[ebx+ecx]; xor ebx,ebx mov ax,[wramdataa+ecx] retNEWSYM wramaccessbankw8; mov ebx,[wramdata]; mov [ebx+ecx],al; xor ebx,ebx mov [wramdataa+ecx],al retNEWSYM wramaccessbankw16; mov ebx,[wramdata]; mov [ebx+ecx],ax; xor ebx,ebx mov [wramdataa+ecx],ax ret;*******************************************************; ExpandRAM Access Bank (7Fh);*******************************************************NEWSYM eramaccessbankr8; mov ebx,[ram7f]; mov al,[ebx+ecx]; xor ebx,ebx mov al,[ram7fa+ecx] retNEWSYM eramaccessbankr16; mov ebx,[ram7f]; mov ax,[ebx+ecx]; xor ebx,ebx mov ax,[ram7fa+ecx] retNEWSYM eramaccessbankw8; mov ebx,[ram7f]; mov [ebx+ecx],al; xor ebx,ebx mov [ram7fa+ecx],al retNEWSYM eramaccessbankw16; mov ebx,[ram7f]; mov [ebx+ecx],ax; xor ebx,ebx mov [ram7fa+ecx],ax ret;*******************************************************; SA-1 Bank Accesses;*******************************************************NEWSYM regaccessbankr8SA1 test ecx,8000h jz .regacc mov ebx,[snesmmap+ebx*4] 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 regaccessbankr16SA1 test ecx,8000h jz .regacc mov ebx,[snesmmap+ebx*4] 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 regaccessbankw8SA1 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 cmp byte[writeon],0 jne .modrom ret.modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],al xor ebx,ebx 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 regaccessbankw16SA1 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 cmp byte[writeon],0 jne .modrom ret.modrom mov ebx,[snesmmap+ebx*4] mov [ebx+ecx],ax xor ebx,ebx 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 BWCheck2w16NEWSYM SA1RAMaccessbankr8 and ebx,03h shl ebx,16 add ebx,[SA1RAMArea] mov al,[ebx+ecx] xor ebx,ebx retNEWSYM SA1RAMaccessbankr16 and ebx,03h shl ebx,16 add ebx,[SA1RAMArea] mov ax,[ebx+ecx] xor ebx,ebx retNEWSYM SA1RAMaccessbankw8 and ebx,03h shl ebx,16 add ebx,[SA1RAMArea] mov [ebx+ecx],al xor ebx,ebx retNEWSYM SA1RAMaccessbankw16 and ebx,03h shl ebx,16 add ebx,[SA1RAMArea] mov [ebx+ecx],ax xor ebx,ebx retNEWSYM SA1RAMaccessbankr8b test byte[SA1Overflow+1],80h jnz .2bit and ebx,07h shl ebx,15 test ecx,1 jnz .4bitb shr ecx,1 add ebx,[SA1RAMArea] mov al,[ebx+ecx] xor ebx,ebx and al,0Fh ret.4bitb shr ecx,1 add ebx,[SA1RAMArea] mov al,[ebx+ecx] xor ebx,ebx shr al,4 ret.2bit and ebx,0Fh shl ebx,14 add ebx,[SA1RAMArea] test ecx,2 jnz .bit1 test ecx,1 jnz .bit0 shr ecx,2 mov al,[ebx+ecx] and al,3 xor ebx,ebx ret.bit0 shr ecx,2 mov al,[ebx+ecx] shr al,2 and al,3 xor ebx,ebx ret.bit1 test ecx,1 jnz .bit0b shr ecx,2 mov al,[ebx+ecx] shr al,4 and al,3 xor ebx,ebx ret.bit0b shr ecx,2 mov al,[ebx+ecx] shr al,6 xor ebx,ebx retNEWSYM SA1RAMaccessbankr16b test byte[SA1Overflow+1],80h jnz .2bit and ebx,07h shl ebx,15 test ecx,1 jnz .4bitb shr ecx,1 add ebx,[SA1RAMArea] mov al,[ebx+ecx] and al,0Fh mov ah,[ebx+ecx] shr ah,4 xor ebx,ebx ret.4bitb shr ecx,1 add ebx,[SA1RAMArea] mov ah,[ebx+ecx+1] and ah,0Fh mov al,[ebx+ecx] shr al,4 xor ebx,ebx ret.2bit and ebx,0Fh shl ebx,14 add ebx,[SA1RAMArea] test ecx,2 jnz .bit1 test ecx,1 jnz .bit0 shr ecx,2 mov al,[ebx+ecx] and al,3 mov ah,[ebx+ecx] shr ah,2 and ah,3 xor ebx,ebx ret.bit0 shr ecx,2 mov al,[ebx+ecx] shr al,2 and al,2 mov ah,[ebx+ecx] shr ah,4 and ah,3 xor ebx,ebx ret.bit1 test ecx,1 jnz .bit0b shr ecx,2 mov al,[ebx+ecx] shr al,4 and al,3 mov ah,[ebx+ecx] shr ah,6 xor ebx,ebx ret.bit0b shr ecx,2 mov al,[ebx+ecx] shr al,6 mov ah,[ebx+ecx+1] and ah,3 xor ebx,ebx retNEWSYM SA1RAMaccessbankw8b test byte[SA1Overflow+1],80h jnz .2bit and ebx,07h shl ebx,15 test ecx,1 jnz .4bitb shr ecx,1 add ebx,[SA1RAMArea] and al,0Fh and byte[ebx+ecx],0F0h or byte[ebx+ecx],al xor ebx,ebx ret.4bitb shr ecx,1 add ebx,[SA1RAMArea] and al,0Fh shl al,4 and byte[ebx+ecx],0Fh or byte[ebx+ecx],al xor ebx,ebx ret.2bit and ebx,0Fh shl ebx,14 add ebx,[SA1RAMArea] test ecx,2 jnz .bit1 test ecx,1 jnz .bit0 shr ecx,2 and byte[ebx+ecx],0FCh and al,3 or byte[ebx+ecx],al xor ebx,ebx ret.bit0 shr ecx,2 and byte[ebx+ecx],0F3h and al,3 shl al,2 or byte[ebx+ecx],al xor ebx,ebx ret.bit1 test ecx,1 jnz .bit0b shr ecx,2 and byte[ebx+ecx],0CFh and al,3 shl al,4 or byte[ebx+ecx],al xor ebx,ebx ret.bit0b shr ecx,2 and byte[ebx+ecx],03Fh and al,3 shl al,6 or byte[ebx+ecx],al xor ebx,ebx retNEWSYM SA1RAMaccessbankw16b push ecx push ebx call SA1RAMaccessbankw8b pop ebx pop ecx inc ecx mov al,ah call SA1RAMaccessbankw8b retSECTION .text%macro GetBankLog 1 cmp bl,0C0h jb %%illegal cmp bl,0D0h jb %%firstbank cmp bl,0E0h jb %%secondbank cmp bl,0F0h jb %%thirdbank mov %1,[SDD1BankA+3] jmp %%done%%firstbank mov %1,[SDD1BankA] jmp %%done%%secondbank mov %1,[SDD1BankA+1] jmp %%done%%thirdbank mov %1,[SDD1BankA+2] jmp %%done%%illegal mov %1,0Fh%%done%endmacroSECTION .dataNEWSYM LatestBank, dd 0FFFFhSECTION .text; Software decompression versionNEWSYM memaccessbankr8sdd1 cmp byte[AddrNoIncr],0 je near .failed cmp dword[Sdd1Mode],2 je near .decompress mov [Sdd1Bank],ebx mov [Sdd1Addr],ecx mov [Sdd1NewAddr],ecx mov dword[Sdd1Mode],2 push edx push eax push ecx and ecx,0FFFFh xor eax,eax GetBankLog al shl eax, 20 mov edx, [Sdd1Bank] and edx, 0Fh shl edx, 16 add eax, edx add eax, [romdata] add eax, ecx pushad push eax call SDD1_init pop eax popad pop ecx pop eax pop edx.decompress cmp [Sdd1Bank],ebx jne .nomoredec cmp [Sdd1Addr],ecx je .yesdec.nomoredec mov ebx,[snesmmap+ebx*4] mov al,[ebx+ecx] push eax mov eax,memtabler8+0C0h*4 mov ebx,40h.loopb mov dword[eax],memaccessbankr8 add eax,4 dec ebx jnz .loopb pop eax xor ebx,ebx ret.yesdec pushad call SDD1_get_byte mov [.tmpbyte], al popad mov al, [.tmpbyte] ret.failed push ebx call .nomoredec pop ebx jmp memaccessbankr8SECTION .bss.tmpbyte resb 1
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?