📄 asmz80.asm
字号:
jmp next
sbc_a_h:
sahf
sbb al,dh
lahf
mov byte ptr [_nFlag],1
jmp next
sbc_a_l:
sahf
sbb al,dl
lahf
mov byte ptr [_nFlag],1
jmp next
sbc_a_xhl:
call get_hl
sahf
sbb al,byte ptr [memVal]
lahf
mov byte ptr [_nFlag],1
jmp next
sbc_a_a:
sahf
sbb al,al
lahf
mov byte ptr [_nFlag],1
jmp next
sbc_a_byte:
call get_opbyte
sahf
sbb al,byte ptr [memVal]
lahf
mov byte ptr [_nFlag],1
jmp next
scf:
and ah,0efh
or ah,1
mov byte ptr [_nFlag],0
jmp next
set_0_b:
bts bx,8
jmp next
set_0_c:
bts bx,0
jmp next
set_0_d:
bts cx,8
jmp next
set_0_e:
bts cx,0
jmp next
set_0_h:
bts dx,8
jmp next
set_0_l:
bts dx,0
jmp next
set_0_xhl:
call get_hl
bts [memVal],0
call put_hl
jmp next
set_0_a:
bts ax,0
jmp next
set_1_b:
bts bx,9
jmp next
set_1_c:
bts bx,1
jmp next
set_1_d:
bts cx,9
jmp next
set_1_e:
bts cx,1
jmp next
set_1_h:
bts dx,9
jmp next
set_1_l:
bts dx,1
jmp next
set_1_xhl:
call get_hl
bts [memVal],1
call put_hl
jmp next
set_1_a:
bts ax,1
jmp next
set_2_b:
bts bx,10
jmp next
set_2_c:
bts bx,2
jmp next
set_2_d:
bts cx,10
jmp next
set_2_e:
bts cx,2
jmp next
set_2_h:
bts dx,10
jmp next
set_2_l:
bts dx,2
jmp next
set_2_xhl:
call get_hl
bts [memVal],2
call put_hl
jmp next
set_2_a:
bts ax,2
jmp next
set_3_b:
bts bx,11
jmp next
set_3_c:
bts bx,3
jmp next
set_3_d:
bts cx,11
jmp next
set_3_e:
bts cx,3
jmp next
set_3_h:
bts dx,11
jmp next
set_3_l:
bts dx,3
jmp next
set_3_xhl:
call get_hl
bts [memVal],3
call put_hl
jmp next
set_3_a:
bts ax,3
jmp next
set_4_b:
bts bx,12
jmp next
set_4_c:
bts bx,4
jmp next
set_4_d:
bts cx,12
jmp next
set_4_e:
bts cx,4
jmp next
set_4_h:
bts dx,12
jmp next
set_4_l:
bts dx,4
jmp next
set_4_xhl:
call get_hl
bts [memVal],4
call put_hl
jmp next
set_4_a:
bts ax,4
jmp next
set_5_b:
bts bx,13
jmp next
set_5_c:
bts bx,5
jmp next
set_5_d:
bts cx,13
jmp next
set_5_e:
bts cx,5
jmp next
set_5_h:
bts dx,13
jmp next
set_5_l:
bts dx,5
jmp next
set_5_xhl:
call get_hl
bts [memVal],5
call put_hl
jmp next
set_5_a:
bts ax,5
jmp next
set_6_b:
bts bx,14
jmp next
set_6_c:
bts bx,6
jmp next
set_6_d:
bts cx,14
jmp next
set_6_e:
bts cx,6
jmp next
set_6_h:
bts dx,14
jmp next
set_6_l:
bts dx,6
jmp next
set_6_xhl:
call get_hl
bts [memVal],6
call put_hl
jmp next
set_6_a:
bts ax,6
jmp next
set_7_b:
bts bx,15
jmp next
set_7_c:
bts bx,7
jmp next
set_7_d:
bts cx,15
jmp next
set_7_e:
bts cx,7
jmp next
set_7_h:
bts dx,15
jmp next
set_7_l:
bts dx,7
jmp next
set_7_xhl:
call get_hl
bts [memVal],7
call put_hl
jmp next
set_7_a:
bts ax,7
jmp next
sla_b:
shl bh,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sla_c:
shl bl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sla_d:
shl ch,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sla_e:
shl cl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sla_h:
shl dh,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sla_l:
shl dl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sla_xhl:
call get_hl
shl byte ptr [memVal],1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
call put_hl
jmp next
sla_a:
shl al,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sra_b:
sar bh,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sra_c:
sar bl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sra_d:
sar ch,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sra_e:
sar cl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sra_h:
sar dh,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sra_l:
sar dl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
sra_xhl:
call get_hl
sar byte ptr [memVal],1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
call put_hl
jmp next
sra_a:
sar al,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
srl_b:
shr bh,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
srl_c:
shr bl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
srl_d:
shr ch,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
srl_e:
shr cl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
srl_h:
shr dh,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
srl_l:
shr dl,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
srl_xhl:
call get_hl
shr byte ptr [memVal],1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
call put_hl
jmp next
srl_a:
shr al,1
lahf
and ah,0efh
mov byte ptr [_nFlag],0
jmp next
stop:
call get_opbyte
test byte ptr [_hiRam+4dh],1
jz next
xor byte ptr [_hiRam+4dh],80h
and byte ptr [_hiRam+4dh],80h
test byte ptr [_hiRam+4dh],80h
jz stop_SlowMode
mov byte ptr [_clkMult],2
jmp next
stop_SlowMode:
mov byte ptr [_clkMult],1
jmp next
sub_a_b:
sub al,bh
lahf
mov byte ptr [_nFlag],1
jmp next
sub_a_c:
sub al,bl
lahf
mov byte ptr [_nFlag],1
jmp next
sub_a_d:
sub al,ch
lahf
mov byte ptr [_nFlag],1
jmp next
sub_a_e:
sub al,cl
lahf
mov byte ptr [_nFlag],1
jmp next
sub_a_h:
sub al,dh
lahf
mov byte ptr [_nFlag],1
jmp next
sub_a_l:
sub al,dl
lahf
mov byte ptr [_nFlag],1
jmp next
sub_a_xhl:
call get_hl
sub al,byte ptr [memVal]
lahf
mov byte ptr [_nFlag],1
jmp next
sub_a_a:
sub al,al
lahf
mov byte ptr [_nFlag],1
jmp next
sub_byte:
call get_opbyte
sub al,byte ptr [memVal]
lahf
mov byte ptr [_nFlag],1
jmp next
swap_b:
rol bh,4
cmp bh,0
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
swap_c:
rol bl,4
cmp bl,0
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
swap_d:
rol ch,4
cmp ch,0
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
swap_e:
rol cl,4
cmp cl,0
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
swap_h:
rol dh,4
cmp dh,0
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
swap_l:
rol dl,4
cmp dl,0
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
swap_xhl:
call get_hl
rol byte ptr [memVal],4
cmp byte ptr [memVal],0
lahf
and ah,40h
mov byte ptr [_nFlag],0
call put_hl
jmp next
swap_a:
rol al,4
cmp al,0
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_a_b:
xor al,bh
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_a_c:
xor al,bl
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_a_d:
xor al,ch
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_a_e:
xor al,cl
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_a_h:
xor al,dh
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_a_l:
xor al,dl
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_a_xhl:
call get_hl
xor al,byte ptr [memVal]
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_a_a:
xor al,al
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
xor_byte:
call get_opbyte
xor al,byte ptr [memVal]
lahf
and ah,40h
mov byte ptr [_nFlag],0
jmp next
cb_cycle_table:
db 8,8,8,8,8,8,16,8
db 8,8,8,8,8,8,16,8
db 8,8,8,8,8,8,16,8
db 8,8,8,8,8,8,16,8
db 8,8,8,8,8,8,16,8
db 8,8,8,8,8,8,16,8
db 8,8,8,8,8,8,16,8
db 8,8,8,8,8,8,16,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
db 8,8,8,8,8,8,12,8
cb_table:
dd rlc_b,rlc_c,rlc_d,rlc_e,rlc_h,rlc_l,rlc_xhl,rlc_a
dd rrc_b,rrc_c,rrc_d,rrc_e,rrc_h,rrc_l,rrc_xhl,rrc_a
dd rl_b,rl_c,rl_d,rl_e,rl_h,rl_l,rl_xhl,rl_a
dd rr_b,rr_c,rr_d,rr_e,rr_h,rr_l,rr_xhl,rr_a
dd sla_b,sla_c,sla_d,sla_e,sla_h,sla_l,sla_xhl,sla_a
dd sra_b,sra_c,sra_d,sra_e,sra_h,sra_l,sra_xhl,sra_a
dd swap_b,swap_c,swap_d,swap_e,swap_h,swap_l,swap_xhl,swap_a
dd srl_b,srl_c,srl_d,srl_e,srl_h,srl_l,srl_xhl,srl_a
dd bit_0_b,bit_0_c,bit_0_d,bit_0_e,bit_0_h,bit_0_l,bit_0_xhl,bit_0_a
dd bit_1_b,bit_1_c,bit_1_d,bit_1_e,bit_1_h,bit_1_l,bit_1_xhl,bit_1_a
dd bit_2_b,bit_2_c,bit_2_d,bit_2_e,bit_2_h,bit_2_l,bit_2_xhl,bit_2_a
dd bit_3_b,bit_3_c,bit_3_d,bit_3_e,bit_3_h,bit_3_l,bit_3_xhl,bit_3_a
dd bit_4_b,bit_4_c,bit_4_d,bit_4_e,bit_4_h,bit_4_l,bit_4_xhl,bit_4_a
dd bit_5_b,bit_5_c,bit_5_d,bit_5_e,bit_5_h,bit_5_l,bit_5_xhl,bit_5_a
dd bit_6_b,bit_6_c,bit_6_d,bit_6_e,bit_6_h,bit_6_l,bit_6_xhl,bit_6_a
dd bit_7_b,bit_7_c,bit_7_d,bit_7_e,bit_7_h,bit_7_l,bit_7_xhl,bit_7_a
dd res_0_b,res_0_c,res_0_d,res_0_e,res_0_h,res_0_l,res_0_xhl,res_0_a
dd res_1_b,res_1_c,res_1_d,res_1_e,res_1_h,res_1_l,res_1_xhl,res_1_a
dd res_2_b,res_2_c,res_2_d,res_2_e,res_2_h,res_2_l,res_2_xhl,res_2_a
dd res_3_b,res_3_c,res_3_d,res_3_e,res_3_h,res_3_l,res_3_xhl,res_3_a
dd res_4_b,res_4_c,res_4_d,res_4_e,res_4_h,res_4_l,res_4_xhl,res_4_a
dd res_5_b,res_5_c,res_5_d,res_5_e,res_5_h,res_5_l,res_5_xhl,res_5_a
dd res_6_b,res_6_c,res_6_d,res_6_e,res_6_h,res_6_l,res_6_xhl,res_6_a
dd res_7_b,res_7_c,res_7_d,res_7_e,res_7_h,res_7_l,res_7_xhl,res_7_a
dd set_0_b,set_0_c,set_0_d,set_0_e,set_0_h,set_0_l,set_0_xhl,set_0_a
dd set_1_b,set_1_c,set_1_d,set_1_e,set_1_h,set_1_l,set_1_xhl,set_1_a
dd set_2_b,set_2_c,set_2_d,set_2_e,set_2_h,set_2_l,set_2_xhl,set_2_a
dd set_3_b,set_3_c,set_3_d,set_3_e,set_3_h,set_3_l,set_3_xhl,set_3_a
dd set_4_b,set_4_c,set_4_d,set_4_e,set_4_h,set_4_l,set_4_xhl,set_4_a
dd set_5_b,set_5_c,set_5_d,set_5_e,set_5_h,set_5_l,set_5_xhl,set_5_a
dd set_6_b,set_6_c,set_6_d,set_6_e,set_6_h,set_6_l,set_6_xhl,set_6_a
dd set_7_b,set_7_c,set_7_d,set_7_e,set_7_h,set_7_l,set_7_xhl,set_7_a
cb_prefix:
call get_opbyte
xor esi,esi
movzx si,byte ptr [memVal]
movzx bp,byte ptr [offset cb_cycle_table+esi]
sub [clkLeft],bp
sub word ptr [_minTime],bp
jmp [offset cb_table+esi*4]
invalid:
jmp next
cycle_table:
db 4,12,8,8,4,4,8,4
db 4,12,8,8,4,4,8,4
db 8,12,8,8,4,4,8,4
db 8,12,8,8,4,4,8,4
db 8,12,8,8,4,4,8,4
db 8,12,8,8,4,4,8,4
db 8,12,8,8,12,12,12,4
db 8,12,8,8,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 8,8,8,8,8,8,4,8
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 4,4,4,4,4,4,8,4
db 16,12,16,16,24,16,8,16
db 16,16,16,0,24,24,8,16
db 16,10,16,16,24,16,8,16
db 16,16,16,16,24,24,8,16
db 12,12,8,12,12,16,8,16
db 16,4,16,12,12,12,8,16
db 12,12,8,4,12,16,8,16
db 12,8,16,4,12,12,8,16
op_table:
dd nop,ld_bc_word,ld_xbc_a,inc_bc,inc_b,dec_b,ld_b_byte,rlca
dd ld_xword_sp,add_hl_bc,ld_a_xbc,dec_bc,inc_c,dec_c,ld_c_byte,rrca
dd stop,ld_de_word,ld_xde_a,inc_de,inc_d,dec_d,ld_d_byte,rla
dd jr_disp,add_hl_de,ld_a_xde,dec_de,inc_e,dec_e,ld_e_byte,rra
dd jr_nz_disp,ld_hl_word,ldi_xhl_a,inc_hl,inc_h,dec_h,ld_h_byte,daa
dd jr_z_disp,add_hl_hl,ldi_a_xhl,dec_hl,inc_l,dec_l,ld_l_byte,cpl
dd jr_nc_disp,ld_sp_word,ldd_xhl_a,inc_sp,inc_xhl,dec_xhl,ld_xhl_byte,scf
dd jr_c_disp,add_hl_sp,ldd_a_xhl,dec_sp,inc_a,dec_a,ld_a_byte,ccf
dd ld_b_b,ld_b_c,ld_b_d,ld_b_e,ld_b_h,ld_b_l,ld_b_xhl,ld_b_a
dd ld_c_b,ld_c_c,ld_c_d,ld_c_e,ld_c_h,ld_c_l,ld_c_xhl,ld_c_a
dd ld_d_b,ld_d_c,ld_d_d,ld_d_e,ld_d_h,ld_d_l,ld_d_xhl,ld_d_a
dd ld_e_b,ld_e_c,ld_e_d,ld_e_e,ld_e_h,ld_e_l,ld_e_xhl,ld_e_a
dd ld_h_b,ld_h_c,ld_h_d,ld_h_e,ld_h_h,ld_h_l,ld_h_xhl,ld_h_a
dd ld_l_b,ld_l_c,ld_l_d,ld_l_e,ld_l_h,ld_l_l,ld_l_xhl,ld_l_a
dd ld_xhl_b,ld_xhl_c,ld_xhl_d,ld_xhl_e,ld_xhl_h,ld_xhl_l,halt,ld_xhl_a
dd ld_a_b,ld_a_c,ld_a_d,ld_a_e,ld_a_h,ld_a_l,ld_a_xhl,ld_a_a
dd add_a_b,add_a_c,add_a_d,add_a_e,add_a_h,add_a_l,add_a_xhl,add_a_a
dd adc_a_b,adc_a_c,adc_a_d,adc_a_e,adc_a_h,adc_a_l,adc_a_xhl,adc_a_a
dd sub_a_b,sub_a_c,sub_a_d,sub_a_e,sub_a_h,sub_a_l,sub_a_xhl,sub_a_a
dd sbc_a_b,sbc_a_c,sbc_a_d,sbc_a_e,sbc_a_h,sbc_a_l,sbc_a_xhl,sbc_a_a
dd and_a_b,and_a_c,and_a_d,and_a_e,and_a_h,and_a_l,and_a_xhl,and_a_a
dd xor_a_b,xor_a_c,xor_a_d,xor_a_e,xor_a_h,xor_a_l,xor_a_xhl,xor_a_a
dd or_a_b,or_a_c,or_a_d,or_a_e,or_a_h,or_a_l,or_a_xhl,or_a_a
dd cp_a_b,cp_a_c,cp_a_d,cp_a_e,cp_a_h,cp_a_l,cp_a_xhl,cp_a_a
dd ret_nz,pop_bc,jp_nz_word,jp_word,call_nz_word,push_bc,add_a_byte,rst_00
dd ret_z,ret,jp_z_word,cb_prefix,call_z_word,call_word,adc_a_byte,rst_08
dd ret_nc,pop_de,jp_nc_word,invalid,call_nc_word,push_de,sub_byte,rst_10
dd ret_c,reti,jp_c_word,invalid,call_c_word,invalid,sbc_a_byte,rst_18
dd ldh_xbyte_a,pop_hl,ldh_xc_a,invalid,invalid,push_hl,and_byte,rst_20
dd add_sp_disp,jp_hl,ld_xword_a,invalid,invalid,invalid,xor_byte,rst_28
dd ldh_a_xbyte,pop_af,ldh_a_xc,di_,invalid,push_af,or_byte,rst_30
dd ld_hl_spdisp,ld_sp_hl,ld_a_xword,ei,invalid,invalid,cp_byte,rst_38
@AsmZ80_Execute proc near
cmp [_run],0
jz execret
push eax
mov [clkLeft],ax
pusha
mov al,byte ptr [_regAF+1]
mov ah,byte ptr [_regAF]
mov bx,[_regBC]
mov cx,[_regDE]
mov dx,[_regHL]
mov di,[_regSP]
pusha
jmp execloop
execloop2:
cmp word ptr [_gdmaClk],0
jnz inGDMA
mov si,[_regPC]
mov [_oldPC],si
call get_opbyte
xor esi,esi
movzx si,byte ptr [memVal]
movzx bp,byte ptr [offset cycle_table+esi]
sub [clkLeft],bp
sub [_minTime],bp
jmp [offset op_table+esi*4]
inGDMA:
mov bp,4
sub word ptr [clkLeft],bp
sub word ptr [_minTime],bp
sub word ptr [_gdmaClk],bp
jnc next
mov word ptr [_gdmaClk],0
next:
cmp word ptr [_minTime],0
jg execloop2
jmp afterexecloop
execloop:
cmp [_debugCheckEnable],0
jz ecNoDebug
mov [_minTime],1
jmp ecNotNeg2
ecNoDebug:
mov [_minTime],16
mov bp,[clkLeft]
cmp bp,[_minTime]
jg ecGo
mov [_minTime],bp
ecGo:
cmp word ptr [_dmaClk],0
je ecNoDmaClk
mov bp,word ptr [_dmaClk]
cmp bp,[_minTime]
jg ecNoDmaClk
mov [_minTime],bp
ecNoDmaClk:
mov bp,[divClk]
cmp bp,[_minTime]
jg ecNoDivClk
mov [_minTime],bp
ecNoDivClk:
cmp word ptr [_timerClkCount],0
je ecNoTimerClk
mov bp,[timerClk]
cmp bp,[_minTime]
jg ecNo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -