Rev 1289 |
Blame |
Compare with Previous |
Last modification |
View Log
| Download
| RSS feed
; ----------------------------------------------------------------------
; ╨а╨░╤Б╨┐╨░╤А╤Б╨╕╤В╤М ╨┤╨░╨╜╨╜╤Л╨╡ ╨╕╨╖ (_param_ip) ╨╕ ╨▓╤Л╨▓╨╡╤Б╤В╨╕ ╨╜╨░ ╤Н╨║╤А╨░╨╜
; ----------------------------------------------------------------------
decode_line:
xor a
ld (_param_cnt), a
ld (_param_segpfx), a
ld ix, _start_ix_data
; ╨з╤В╨╡╨╜╨╕╨╡ ╨╛╨┐╨║╨╛╨┤╨░
.read: call read
call deb_setprefix ; ╨Т╤Л╤З╨╕╤Б╨╗╨╡╨╜╨╕╨╡ ╨┐╤А╨╡╤Д╨╕╨║╤Б╨░
jr z, .read ; ╨Я╨╡╤А╨╡╤З╨╕╤В╨░╤В╤М, ╨╡╤Б╨╗╨╕ ╤Н╤В╨╛ ╨┐╤А╨╡╤Д╨╕╨║╤Б
ld h, 0
ld l, a
ld (ix+0), a ; _param_opcode
and 3 ; ╨г╨▒╤А╨░╤В╤М ╨╗╨╕╤И╨╜╨╕╨╡ ╨▒╨╕╤В╤Л
ld (ix+1), a ; _param_bitdir
; ╨Я╨╛╨╗╤Г╤З╨╡╨╜╨╕╨╡ ╨║╨╛╨┤╨░ ╨╝╨╜╨╡╨╝╨╛╨╜╨╕╨║╨╕
ld de, opcodes_table
add hl, de
ld a, (hl)
and a
jr z, .ntskip
; ╨Т╤Л╨▓╨╡╤Б╤В╨╕ ╨╝╨╜╨╡╨╝╨╛╨╜╨╕╨║╤Г
ld de, name_table
call print_nt
; ╨Я╤А╨╡╤Д╨╕╨║╤Б╤Л LOCK, REPZ, REPNZ; ╨┐╨╡╤А╨╡╤З╨╕╤В╨░╤В╤М
ld a, (_param_opcode)
cp $f0
jr z, .read
cp $f2
jr z, .read
cp $f3
jr z, .read
; ╨а╨░╤Б╤И╨╕╤А╤П╨╡╤В ╨╝╨╜╨╡╨╝╨╛╨╜╨╕╨║╤Г ╨┤╨╛ 7 ╤Б╨╕╨╝╨▓╨╛╨╗╨╛╨▓
call spacexpand
; ╨Я╨╛╨╗╤Г╤З╨╡╨╜╨╕╨╡ ID ╨╜╨╛╨╝╨╡╤А ╤Д╤Г╨╜╨║╤Ж╨╕╨╕ ╨╛╨┐╨╡╤А╨░╨╜╨┤╨░
.ntskip: ld hl, (_param_opcode)
ld h, 0
ld de, operand_table
add hl, de
ld a, (hl)
and a
ret z
; hl = 2*operand_proc[ opcode ]
ld l, a
ld h, 0
ld de, operand_proc
add hl, hl
add hl, de
ld a, (hl)
inc hl
ld h, (hl)
ld l, a
ld a, (ix)
jp (hl)
; ----------------------------------------------------------------------
; ╨Ф╨╡╨║╨╛╨┤╨╕╤А╨╛╨▓╨░╨╜╨╕╨╡ ╨╕╨╜╤Б╤В╤А╤Г╨║╤Ж╨╕╨╕
; ----------------------------------------------------------------------
; ╨Я╨╡╤З╨░╤В╤М PUSH,POP,INC,DEC r16
show_405f: and 7
set 0, (ix+1) ; ╨г╤Б╤В╨░╨╜╨╛╨▓╨╕╤В 16 ╨▒╨╕╤В
call print_register
ret
; ╨Я╨╡╤З╨░╤В╤М ╨╕╨╜╤Б╤В╤А╤Г╨║╤Ж╨╕╨╕ ╨Р╨Ы╨г ╤Б Immediate8/16
show_aluim: xor a
call print_register ; al/ax
ld a, ','
call print_char
call read ; 8/16 bit
ld c, a
bit 0, (ix+1) ; _param_bitdir[0]
jr nz, .p16bit
call print_uint8
ret
.p16bit: call read
ld b, a
call print_uint16
ret
; ╨Ю╤В╨╜╨╛╤Б╨╕╤В╨╡╨╗╤М╨╜╤Л╨╣ ╨┤╨╗╤П ╨┐╨╡╤А╨╡╤Е╨╛╨┤╨╛╨▓ (8 ╨▒╨╕╤В)
show_rel8: call read
call signextend
ld hl, (_param_ip)
add hl, bc
ld b, h
ld c, l
call print_uint16
ret
; PUSH/POP seg
show_pushpopseg:
and 00011000b
rrca
rrca
rrca
ld de, name_seg+2
call print_nt
ret
; 80h, 82h ╨У╤А╤Г╨┐╨┐╨╛╨▓╨░╤П ╨╛╨┐╨╡╤А╨░╤Ж╨╕╤П
show_grp80: call show_modrm_alu
jp show_i8
; 81h <GRP> r16, i16
show_grp81: call show_modrm_alu
jp show_i16
; 83h <GRP> r16, i8
show_grp83: call show_modrm_alu
jp show_i8sgn
; ╨Ч╨░╨│╤А╤Г╨╖╨╕╤В╤М ╨╕ ╨┐╨╛╨║╨░╨╖╨░╤В╤М ╨Р╨Ы╨г-╤З╨░╤Б╤В╤М
show_modrm_alu:
call load_modrm
ld a, (_param_reg)
ld de, name_table+2
call print_nt ; ╨Ь╨╜╨╡╨╝╨╛╨╜╨╕╨║╨░ ╨▓ modrm_reg
call spacexpand
call print_part_rm ; ╨Я╨╕╤И╨╡╤В╤Б╤П modrm_rm
ld a, ','
call print_char
ret
; MOV r8, i8
show_mov8: and 7
ld de, name_r8
call print_nt
ld a, ','
call print_char ; r8
jp show_i8
; MOV r16, i16
show_mov16: and 7
ld de, name_r16
call print_nt ; r16,
ld a, ','
call print_char
jp show_i16
; XCHG ax, r16
show_xchgw: xor a
ld de, name_r16
call print_nt ; ax,
ld a, ','
call print_char
ld a, (ix)
and 7
call print_nt ; r16
ret
; r16, rm BOUND
show_r16rm: set 0,(ix+1) ; 16-╨▒╨╕╤В
set 1,(ix+1) ; dir=1
call show_modrm
ret
; rm, r16 ARPL
show_rmr16: set 0,(ix+1) ; 16-╨▒╨╕╤В
res 1,(ix+1) ; dir=0
call show_modrm
ret
; i8 sign extend
show_i8sgn: call read
call signextend
call print_uint16
ret
; i8
show_i8: call read
call print_uint8
ret
; i16
show_i16: call readword
call print_uint16
ret
; imul r16,rm,i16
show_imulrm16:
call show_r16rm
ld a, ','
call print_char
jp show_i16
; imul r16,rm,i8
show_imulrm8:
call show_r16rm
ld a, ','
call print_char
jp show_i8sgn
; call|jmp far
show_segoff16:
call readword
push bc
call readword
call print_uint16
ld a, ':'
call print_char
pop bc
call print_uint16
ret
; ╨Ю╤В╨╜╨╛╤Б╨╕╤В╨╡╨╗╤М╨╜╤Л╨╣ 16 ╨▒╨╕╤В╨╜╤Л╨╣
show_rel16: call readword
ld hl, (_param_ip)
add hl, bc
ld b, h
ld c, l
call print_uint16
ret
; enter i16, i8
show_enter: call show_i16
ld a, ','
call print_char
jp show_i8
; mov al, [m16]
; -------------------------------------------
show_alm8: ld de, name_r8 ; mov al, [hhhh]
.m16: xor a
call print_nt
ld a, ','
call print_char
jp show_m16
show_m8al: ld de, name_r8 ; mov [hhhh], al
.m16: call show_m16
ld a, ','
call print_char
xor a
call print_nt
ret
show_axm16: ld de, name_r16 ; mov ax, [hhhh]
jr show_alm8.m16
show_m16ax: ld de, name_r16 ; mov [hhhh], ax
jp show_m8al.m16
show_m16: ld a, '['
call print_char
call show_i16
ld a, ']'
call print_char
ret
; -------------------------------------------
; mov rm, sreg
show_rmsreg:set 0, (ix+1)
call load_modrm
call print_part_rm
ld a, ','
call print_char
ld a, (_param_reg)
ld de, name_seg+2
call print_nt
ret
; mov sreg, rm
show_segrm: set 0, (ix+1)
call load_modrm
ld a, (_param_reg)
ld de, name_seg+2
call print_nt
ld a, ','
call print_char
call print_part_rm
ret
; pop rm16
show_rm16: call load_modrm
call print_part_rm
ret
; rm8, i8
show_rmi8: call show_rmxx
jp show_i8
show_rmi16: call show_rmxx
jp show_i16
show_rmxx: call load_modrm
call print_part_rm
ld a, ','
call print_char
ret
; acc,i8
show_acimm: xor a
call print_register
ld a, ','
call print_char
jp show_i8
; acc, dx
show_acdx: xor a
call print_register
ld a, ','
call print_char
xor a
ld de, name_r16+2*2
call print_nt
ret
; imm, acc
show_immac: call read
call print_uint8
ld a, ','
call print_char
xor a
call print_register
ret
; dx, acc
show_dxac: xor a
ld de, name_r16+2*2
call print_nt
ld a, ','
call print_char
xor a
call print_register
ret
; C0h-C1h
show_grpc0: call show_grpsh
jp show_i8
; D0h-D1h
show_grpd0: call show_grpsh
ld a, '1'
call print_char
ret
; D2h-D3h
show_grpd2: call show_grpsh
xor a
ld de, name_r8+2*1
call print_nt
ret
; ╨Ь╨╜╨╡╨╝╨╛╨╜╨╕╨║╨░ ╨│╤А╤Г╨┐╨┐╤Л ╤Б╨┤╨▓╨╕╨│╨╛╨▓
show_grpsh: call load_modrm
ld a, (_param_reg)
ld de, name_shift
call print_nt
call spacexpand
call print_part_rm
ld a, ','
call print_char
ret
; F6h <modrm>
show_grpf6: call load_modrm
ld a, (_param_reg)
push af
ld de, name_f6
call print_nt
call spacexpand
call print_part_rm
pop af
cp 2
ret nc
ld a, ','
call print_char
bit 0, (ix+1)
jp nz, show_i16
jp show_i8
; FEh <modrm>
show_grpfe: call load_modrm
ld a, (_param_reg)
cp 2
jr c, .ok
ld a, 1 ; DEC
.ok: ld de, name_f7 ; INC
and a
jr z, .prt
inc de ; DEC
inc de
.prt: xor a
call print_nt
call spacexpand
call print_part_rm
ret
; FFh <modrm>
show_grpff: call load_modrm
ld a, (_param_reg)
ld de, name_f7
push af
call print_nt
call spacexpand
pop af
call print_part_rm
ret
; ╨Ч╨░╨┤╨░╨╜ A, ╨┐╨╛╨║╨░╨╖╨░╤В╤М ╨╝╨╜╨╡╨╝╨╛╨╜╨╕╨║╤Г ╨╕╨╖ `name_table_ext`
show_0fmnem:
ld de, name_table_ext
call print_nt
call spacexpand
ret
; D8-DFh ESC/FPU: ╨Т╤Б╨╡ ESC-╨║╨╛╨┤╤Л ╨╖╨░╨│╤А╤Г╨╢╨░╤О╤В modrm
show_fpu: call load_modrm
ret
; ╨а╨░╤Б╤И╨╕╤А╨╡╨╜╨╜╤Л╨╣ ╨╛╨┐╨║╨╛╨┤
show_0fextend:
call read
ld (_param_opcode), a
ld h, 0
ld l, a
ld de, opcodes_0f_table
add hl, hl
add hl, de
ld a, (hl)
inc hl
ld h, (hl)
ld l, a
or h
ret z ; ╨Ш╨╜╤Б╤В╤А╤Г╨║╤Ж╨╕╤П ╨╜╨╡ ╤А╨╡╨░╨╗╨╕╨╖╨╛╨▓╨░╨╜╨░
jp (hl)
; 80h-8Fh J<ccc> near i16
ie80h: ld a, (_param_opcode)
and 15
add 37 ; ╨Ч╨┤╨╡╤Б╤М ╨╝╨╜╨╡╨╝╨╛╨╜╨╕╨║╨╕ j<cccc>
ld de, name_table
call print_nt
call spacexpand
jp show_rel16
; RDTSC
ie31: xor a
jp show_0fmnem
; MOV<z|s>X r8/16, rm
ieb6: ld a, 1 ; movzx
jr ieb67
iebe: ld a, 2 ; movsx
ieb67: call show_0fmnem
call load_modrm
ld a, (ix+1)
push af
set 0, (ix+1)
call print_part_reg
ld a, ','
call print_char
pop af
ld (ix+1),a
call print_part_rm
ret
; 40-4F CMOV<ccc>
ie40: ld a, 3
ld de, name_table_ext
call print_nt
ld a, (_param_opcode)
and 15
ld de, name_cmovccc
.show16: call print_nt
call spacexpand
set 0, (ix+1)
call show_modrm
ret
; IMUL r16, rm16
ieaf: ld a, 24
ld de, name_table
jr ie40.show16
; ----------------------------------------------------------------------
; ╨Я╨╡╤А╨╡╨╝╨╡╨╜╨╜╤Л╨╡
; ----------------------------------------------------------------------
video_cursor: defw 0
; IX parameters
_start_ix_data:
; ╨Я╨╛╤А╤П╨┤╨╛╨║ ╨╜╨╡ ╨╝╨╡╨╜╤П╤В╤М (!)
_param_opcode: defb 0 ; +0
_param_bitdir: defb 0 ; +1 ╨С╨╕╤В╨╜╨╛╤Б╤В╤М=0 / ╨Э╨░╨┐╤А╨░╨▓╨╗╨╡╨╜╨╕╨╡=1
_param_cnt: defb 0 ; +2
_param_segpfx: defb 0 ; +3
_param_mod: defb 0 ; +4
_param_reg: defb 0 ; +5
_param_r_m: defb 0 ; +6