Browse Source

implement INS/OUTS

tags/0.1.1
asie 1 year ago
parent
commit
b71c9c5a9a
2 changed files with 88 additions and 0 deletions
  1. 44
    0
      emu_core.lua
  2. 44
    0
      emu_core_pre.lua

+ 44
- 0
emu_core.lua View File

@@ -1248,7 +1248,7 @@ if cpu_arch == "8086" then
end
else
-- 80186+ opcodes
-- TODO: IMUL(69/6B), BOUND

-- PUSHA
opcode_map[0x60] = function(opcode)
@@ -1306,6 +1306,49 @@ opcode_map[0xC9] = function(opcode)
CPU_REGS[6] = cpu_pop16()
end

opcode_map[0xA4] = function(opcode)
local addrSrc = ((CPU_SEGMENTS[(CPU_SEGMOD or (SEG_DS))+1]<<4) + (CPU_REGS[7]))
local addrDst = ((CPU_SEGMENTS[(SEG_ES)+1]<<4)+(CPU_REGS[8]))
RAM[addrDst] = RAM[addrSrc]
cpu_incdec_dir(7, 1)
cpu_incdec_dir(8, 1)
end
opcode_map[0xA5] = function(opcode)
local addrSrc = ((CPU_SEGMENTS[(CPU_SEGMOD or (SEG_DS))+1]<<4) + (CPU_REGS[7]))
local addrDst = ((CPU_SEGMENTS[(SEG_ES)+1]<<4)+(CPU_REGS[8]))
RAM:w16(addrDst, RAM:r16(addrSrc))
cpu_incdec_dir(7, 2)
cpu_incdec_dir(8, 2)
end

-- INS Ib
opcode_map[0x6C] = function(opcode)
local addrDst = ((CPU_SEGMENTS[(SEG_ES)+1]<<4)+(CPU_REGS[8]))
RAM[addrDst] = cpu_in(CPU_REGS[3]) & 0xFF
cpu_incdec_dir(8, 1)
end

-- INS Iw
opcode_map[0x6D] = function(opcode)
local addrDst = ((CPU_SEGMENTS[(SEG_ES)+1]<<4)+(CPU_REGS[8]))
RAM:w16(addrDst, cpu_in(CPU_REGS[3]) & 0xFFFF)
cpu_incdec_dir(8, 2)
end

-- OUTS Ib
opcode_map[0x6E] = function(opcode)
local addrSrc = ((CPU_SEGMENTS[(CPU_SEGMOD or (SEG_DS))+1]<<4) + (CPU_REGS[7]))
cpu_out(CPU_REGS[3], RAM[addrSrc])
cpu_incdec_dir(7, 1)
end

-- OUTS Iw
opcode_map[0x6F] = function(opcode)
local addrSrc = ((CPU_SEGMENTS[(CPU_SEGMOD or (SEG_DS))+1]<<4) + (CPU_REGS[7]))
cpu_out(CPU_REGS[3], RAM:r16(addrSrc))
cpu_incdec_dir(7, 2)
end

end -- (80186+ opcodes)

local grp1_table = {

+ 44
- 0
emu_core_pre.lua View File

@@ -1241,7 +1241,7 @@ if cpu_arch == "8086" then
end
else
-- 80186+ opcodes
-- TODO: IMUL(69/6B), BOUND

-- PUSHA
opcode_map[0x60] = function(opcode)
@@ -1299,6 +1299,49 @@ opcode_map[0xC9] = function(opcode)
CPU_REGS[6] = cpu_pop16()
end

opcode_map[0xA4] = function(opcode)
local addrSrc = segmd(SEG_DS, CPU_REGS[7])
local addrDst = seg(SEG_ES, CPU_REGS[8])
RAM[addrDst] = RAM[addrSrc]
cpu_incdec_dir(7, 1)
cpu_incdec_dir(8, 1)
end
opcode_map[0xA5] = function(opcode)
local addrSrc = segmd(SEG_DS, CPU_REGS[7])
local addrDst = seg(SEG_ES, CPU_REGS[8])
RAM:w16(addrDst, RAM:r16(addrSrc))
cpu_incdec_dir(7, 2)
cpu_incdec_dir(8, 2)
end

-- INS Ib
opcode_map[0x6C] = function(opcode)
local addrDst = seg(SEG_ES, CPU_REGS[8])
RAM[addrDst] = cpu_in(CPU_REGS[3]) & 0xFF
cpu_incdec_dir(8, 1)
end

-- INS Iw
opcode_map[0x6D] = function(opcode)
local addrDst = seg(SEG_ES, CPU_REGS[8])
RAM:w16(addrDst, cpu_in(CPU_REGS[3]) & 0xFFFF)
cpu_incdec_dir(8, 2)
end

-- OUTS Ib
opcode_map[0x6E] = function(opcode)
local addrSrc = segmd(SEG_DS, CPU_REGS[7])
cpu_out(CPU_REGS[3], RAM[addrSrc])
cpu_incdec_dir(7, 1)
end

-- OUTS Iw
opcode_map[0x6F] = function(opcode)
local addrSrc = segmd(SEG_DS, CPU_REGS[7])
cpu_out(CPU_REGS[3], RAM:r16(addrSrc))
cpu_incdec_dir(7, 2)
end

end -- (80186+ opcodes)

local grp1_table = {

Loading…
Cancel
Save