Преглед на файлове

Support instructions with args and no args; implement RET.

master
Ben Kurtovic преди 9 години
родител
ревизия
071cad0563
променени са 4 файла, в които са добавени 70 реда и са изтрити 6 реда
  1. +13
    -0
      scripts/update_asm_instructions.py
  2. +0
    -2
      src/assembler/instructions.c
  3. +34
    -1
      src/assembler/instructions.inc.c
  4. +23
    -3
      src/assembler/instructions.yml

+ 13
- 0
scripts/update_asm_instructions.py Целия файл

@@ -266,6 +266,16 @@ class Instruction(object):


return ret return ret


def _handle_null_case(self, case):
"""
Return code to handle an instruction case that takes no arguments.
"""
return [
TAB + "if (INST_NARGS == 0) {",
self._handle_return(case["return"], 2),
TAB + "}"
]

def _handle_pseudo_case(self, pseudo, case): def _handle_pseudo_case(self, pseudo, case):
""" """
Return code to handle an instruction pseudo-case. Return code to handle an instruction pseudo-case.
@@ -294,6 +304,9 @@ class Instruction(object):
Return code to handle an instruction case. Return code to handle an instruction case.
""" """
ctype = case["type"] ctype = case["type"]
if not ctype:
return self._handle_null_case(case)

for pseudo in self.PSEUDO_TYPES: for pseudo in self.PSEUDO_TYPES:
if pseudo in ctype: if pseudo in ctype:
return self._handle_pseudo_case(pseudo, case) return self._handle_pseudo_case(pseudo, case)


+ 0
- 2
src/assembler/instructions.c Целия файл

@@ -65,8 +65,6 @@ static ASMErrorDesc parse_inst_##mnemonic( \
INST_ERROR(TOO_MANY_ARGS) INST_ERROR(TOO_MANY_ARGS)


#define INST_TAKES_ARGS(a0, a1, a2) \ #define INST_TAKES_ARGS(a0, a1, a2) \
if (!ap_info.arg) \
INST_ERROR(TOO_FEW_ARGS) \
ASMInstArg args[3]; \ ASMInstArg args[3]; \
size_t nargs; \ size_t nargs; \
ASMArgType masks[] = {a0, a1, a2}; \ ASMArgType masks[] = {a0, a1, a2}; \


+ 34
- 1
src/assembler/instructions.inc.c Целия файл

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


@AUTOGEN_DATE Wed May 20 06:40:09 2015 UTC
@AUTOGEN_DATE Wed May 20 06:53:00 2015 UTC
*/ */


/* @AUTOGEN_INST_BLOCK_START */ /* @AUTOGEN_INST_BLOCK_START */
@@ -1652,6 +1652,38 @@ INST_FUNC(res)
INST_ERROR(ARG_TYPE) INST_ERROR(ARG_TYPE)
} }


INST_FUNC(ret)
{
INST_TAKES_ARGS(
AT_CONDITION|AT_OPTIONAL,
AT_NONE,
AT_NONE
)
if (INST_NARGS == 0) {
INST_RETURN(1, 0xC9)
}
if (INST_NARGS == 1 && INST_TYPE(0) == AT_CONDITION) {
if (INST_COND(0) == COND_NZ)
INST_RETURN(1, 0xC0)
if (INST_COND(0) == COND_Z)
INST_RETURN(1, 0xC8)
if (INST_COND(0) == COND_NC)
INST_RETURN(1, 0xD0)
if (INST_COND(0) == COND_C)
INST_RETURN(1, 0xD8)
if (INST_COND(0) == COND_PO)
INST_RETURN(1, 0xE0)
if (INST_COND(0) == COND_PE)
INST_RETURN(1, 0xE8)
if (INST_COND(0) == COND_P)
INST_RETURN(1, 0xF0)
if (INST_COND(0) == COND_M)
INST_RETURN(1, 0xF8)
INST_ERROR(ARG_VALUE)
}
INST_ERROR(ARG_TYPE)
}

INST_FUNC(reti) INST_FUNC(reti)
{ {
INST_TAKES_NO_ARGS INST_TAKES_NO_ARGS
@@ -2032,6 +2064,7 @@ static ASMInstParser lookup_parser(uint32_t key)
HANDLE(pop) HANDLE(pop)
HANDLE(push) HANDLE(push)
HANDLE(res) HANDLE(res)
HANDLE(ret)
HANDLE(reti) HANDLE(reti)
HANDLE(retn) HANDLE(retn)
HANDLE(rla) HANDLE(rla)


+ 23
- 3
src/assembler/instructions.yml Целия файл

@@ -1110,9 +1110,29 @@ res:
- cond: [bit.7, _, l] - cond: [bit.7, _, l]
return: [0xCB, 0xBD] return: [0xCB, 0xBD]


# ret:
# args: yes
# return: TODO
ret:
args: yes
cases:
- type: []
return: [0xC9]
- type: [condition]
cases:
- cond: [nz]
return: [0xC0]
- cond: [z]
return: [0xC8]
- cond: [nc]
return: [0xD0]
- cond: [c]
return: [0xD8]
- cond: [po]
return: [0xE0]
- cond: [pe]
return: [0xE8]
- cond: [p]
return: [0xF0]
- cond: [m]
return: [0xF8]


reti: reti:
args: no args: no


Зареждане…
Отказ
Запис