Pārlūkot izejas kodu

Support relative addressing in update script; implement CP/DEC/DJNZ.

master
Ben Kurtovic pirms 9 gadiem
vecāks
revīzija
5e9b890285
3 mainītis faili ar 189 papildinājumiem un 10 dzēšanām
  1. +4
    -0
      scripts/update_asm_instructions.py
  2. +120
    -1
      src/assembler/instructions.inc.c
  3. +65
    -9
      src/assembler/instructions.yml

+ 4
- 0
scripts/update_asm_instructions.py Parādīt failu

@@ -246,6 +246,10 @@ class Instruction(object):
ret.append("INST_IMM_U16_B2({0})".format(imm))
break

elif byte == "rel":
index = types.index("immediate")
ret[i] = "INST_IMM({0}).sval - 2".format(index)

else:
msg = "Unsupported return byte: {0}"
raise RuntimeError(msg.format(byte))


+ 120
- 1
src/assembler/instructions.inc.c Parādīt failu

@@ -7,7 +7,7 @@
`make` should trigger a rebuild when it is modified; if not, use:
`python scripts/update_asm_instructions.py`.

@AUTOGEN_DATE Mon May 18 09:04:07 2015 UTC
@AUTOGEN_DATE Tue May 19 06:49:06 2015 UTC
*/

/* @AUTOGEN_INST_BLOCK_START */
@@ -397,6 +397,53 @@ INST_FUNC(ccf)
INST_RETURN(1, 0x3F)
}

INST_FUNC(cp)
{
INST_TAKES_ARGS(
AT_IMMEDIATE|AT_INDEXED|AT_INDIRECT|AT_REGISTER,
AT_NONE,
AT_NONE
)
if (INST_TYPE(0) == AT_REGISTER) {
if (INST_REG(0) == REG_A)
INST_RETURN(1, 0xBF)
if (INST_REG(0) == REG_B)
INST_RETURN(1, 0xB8)
if (INST_REG(0) == REG_C)
INST_RETURN(1, 0xB9)
if (INST_REG(0) == REG_D)
INST_RETURN(1, 0xBA)
if (INST_REG(0) == REG_E)
INST_RETURN(1, 0xBB)
if (INST_REG(0) == REG_H)
INST_RETURN(1, 0xBC)
if (INST_REG(0) == REG_IXH)
INST_RETURN(2, INST_IX_PREFIX, 0xBC)
if (INST_REG(0) == REG_IYH)
INST_RETURN(2, INST_IY_PREFIX, 0xBC)
if (INST_REG(0) == REG_L)
INST_RETURN(1, 0xBD)
if (INST_REG(0) == REG_IXL)
INST_RETURN(2, INST_IX_PREFIX, 0xBD)
if (INST_REG(0) == REG_IYL)
INST_RETURN(2, INST_IY_PREFIX, 0xBD)
INST_ERROR(ARG_VALUE)
}
if (INST_TYPE(0) == AT_INDIRECT &&
(INST_INDIRECT(0).type == AT_REGISTER && INST_INDIRECT(0).addr.reg == REG_HL)) {
INST_RETURN(1, 0xBE)
}
if (INST_TYPE(0) == AT_INDEXED) {
INST_RETURN(3, INST_INDEX_PREFIX(0), 0xBE, INST_INDEX(0).offset)
}
if (INST_TYPE(0) == AT_IMMEDIATE) {
if (INST_IMM(0).mask & IMM_U8)
INST_RETURN(2, 0xFE, INST_IMM(0).uval)
INST_ERROR(ARG_VALUE)
}
INST_ERROR(ARG_TYPE)
}

INST_FUNC(cpd)
{
INST_TAKES_NO_ARGS
@@ -433,12 +480,81 @@ INST_FUNC(daa)
INST_RETURN(1, 0x27)
}

INST_FUNC(dec)
{
INST_TAKES_ARGS(
AT_INDEXED|AT_INDIRECT|AT_REGISTER,
AT_NONE,
AT_NONE
)
if (INST_TYPE(0) == AT_REGISTER) {
if (INST_REG(0) == REG_A)
INST_RETURN(1, 0x3D)
if (INST_REG(0) == REG_B)
INST_RETURN(1, 0x05)
if (INST_REG(0) == REG_C)
INST_RETURN(1, 0x0D)
if (INST_REG(0) == REG_D)
INST_RETURN(1, 0x15)
if (INST_REG(0) == REG_E)
INST_RETURN(1, 0x1D)
if (INST_REG(0) == REG_H)
INST_RETURN(1, 0x25)
if (INST_REG(0) == REG_IXH)
INST_RETURN(2, INST_IX_PREFIX, 0x25)
if (INST_REG(0) == REG_IYH)
INST_RETURN(2, INST_IY_PREFIX, 0x25)
if (INST_REG(0) == REG_L)
INST_RETURN(1, 0x2D)
if (INST_REG(0) == REG_IXL)
INST_RETURN(2, INST_IX_PREFIX, 0x2D)
if (INST_REG(0) == REG_IYL)
INST_RETURN(2, INST_IY_PREFIX, 0x2D)
if (INST_REG(0) == REG_BC)
INST_RETURN(1, 0x0B)
if (INST_REG(0) == REG_DE)
INST_RETURN(1, 0x1B)
if (INST_REG(0) == REG_HL)
INST_RETURN(1, 0x2B)
if (INST_REG(0) == REG_IX)
INST_RETURN(2, INST_IX_PREFIX, 0x2B)
if (INST_REG(0) == REG_IY)
INST_RETURN(2, INST_IY_PREFIX, 0x2B)
if (INST_REG(0) == REG_SP)
INST_RETURN(1, 0x3B)
INST_ERROR(ARG_VALUE)
}
if (INST_TYPE(0) == AT_INDIRECT &&
(INST_INDIRECT(0).type == AT_REGISTER && INST_INDIRECT(0).addr.reg == REG_HL)) {
INST_RETURN(1, 0x35)
}
if (INST_TYPE(0) == AT_INDEXED) {
INST_RETURN(3, INST_INDEX_PREFIX(0), 0x35, INST_INDEX(0).offset)
}
INST_ERROR(ARG_TYPE)
}

INST_FUNC(di)
{
INST_TAKES_NO_ARGS
INST_RETURN(1, 0xF3)
}

INST_FUNC(djnz)
{
INST_TAKES_ARGS(
AT_IMMEDIATE,
AT_NONE,
AT_NONE
)
if (INST_TYPE(0) == AT_IMMEDIATE) {
if (INST_IMM(0).mask & IMM_REL)
INST_RETURN(2, 0x10, INST_IMM(0).sval - 2)
INST_ERROR(ARG_VALUE)
}
INST_ERROR(ARG_TYPE)
}

INST_FUNC(ei)
{
INST_TAKES_NO_ARGS
@@ -1042,13 +1158,16 @@ static ASMInstParser lookup_parser(uint32_t key)
HANDLE(bit)
HANDLE(call)
HANDLE(ccf)
HANDLE(cp)
HANDLE(cpd)
HANDLE(cpdr)
HANDLE(cpi)
HANDLE(cpir)
HANDLE(cpl)
HANDLE(daa)
HANDLE(dec)
HANDLE(di)
HANDLE(djnz)
HANDLE(ei)
HANDLE(exx)
HANDLE(halt)


+ 65
- 9
src/assembler/instructions.yml Parādīt failu

@@ -276,9 +276,33 @@ ccf:
args: no
return: [0x3F]

# cp:
# args: yes
# return: TODO
cp:
args: yes
cases:
- type: [register]
cases:
- cond: [a]
return: [0xBF]
- cond: [b]
return: [0xB8]
- cond: [c]
return: [0xB9]
- cond: [d]
return: [0xBA]
- cond: [e]
return: [0xBB]
- cond: [h|ih]
return: [0xBC]
- cond: [l|il]
return: [0xBD]
- type: [indirect_hl_or_indexed]
cases:
- cond: [_]
return: [0xBE]
- type: [immediate]
cases:
- cond: [u8]
return: [0xFE, u8]

cpd:
args: no
@@ -304,17 +328,49 @@ daa:
args: no
return: [0x27]

# dec:
# args: yes
# return: TODO
dec:
args: yes
cases:
- type: [register]
cases:
- cond: [a]
return: [0x3D]
- cond: [b]
return: [0x05]
- cond: [c]
return: [0x0D]
- cond: [d]
return: [0x15]
- cond: [e]
return: [0x1D]
- cond: [h|ih]
return: [0x25]
- cond: [l|il]
return: [0x2D]
- cond: [bc]
return: [0x0B]
- cond: [de]
return: [0x1B]
- cond: [hl|i]
return: [0x2B]
- cond: [sp]
return: [0x3B]
- type: [indirect_hl_or_indexed]
cases:
- cond: [_]
return: [0x35]

di:
args: no
return: [0xF3]

# djnz:
# args: yes
# return: TODO
djnz:
args: yes
cases:
- type: [immediate]
cases:
- cond: [rel]
return: [0x10, rel]

ei:
args: no


Notiek ielāde…
Atcelt
Saglabāt