瀏覽代碼

Implement CALL; bugfix for condition 'Z'.

master
Ben Kurtovic 9 年之前
父節點
當前提交
4bc8339ba1
共有 4 個檔案被更改,包括 63 行新增6 行删除
  1. +1
    -1
      src/assembler/inst_args.h
  2. +36
    -1
      src/assembler/instructions.inc.c
  3. +25
    -3
      src/assembler/instructions.yml
  4. +1
    -1
      src/assembler/parse_util.c

+ 1
- 1
src/assembler/inst_args.h 查看文件

@@ -57,7 +57,7 @@ typedef struct {
} ASMArgIndexed;

typedef enum {
COND_NZ, COND_N, COND_NC, COND_C, COND_PO, COND_PE, COND_P, COND_M
COND_NZ, COND_Z, COND_NC, COND_C, COND_PO, COND_PE, COND_P, COND_M
} ASMArgCondition;

typedef struct {


+ 36
- 1
src/assembler/instructions.inc.c 查看文件

@@ -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 08:43:46 2015 UTC
@AUTOGEN_DATE Mon May 18 08:55:31 2015 UTC
*/

/* @AUTOGEN_INST_BLOCK_START */
@@ -357,6 +357,40 @@ INST_FUNC(bit)
INST_ERROR(ARG_TYPE)
}

INST_FUNC(call)
{
INST_TAKES_ARGS(
AT_CONDITION|AT_IMMEDIATE,
AT_IMMEDIATE|AT_OPTIONAL,
AT_NONE
)
if (INST_NARGS == 1 && INST_TYPE(0) == AT_IMMEDIATE) {
if (INST_IMM(0).mask & IMM_U16)
INST_RETURN(3, 0xCD, INST_IMM_U16_B1(INST_IMM(0)), INST_IMM_U16_B2(INST_IMM(0)))
INST_ERROR(ARG_VALUE)
}
if (INST_NARGS == 2 && INST_TYPE(0) == AT_CONDITION && INST_TYPE(1) == AT_IMMEDIATE) {
if (INST_COND(0) == COND_NZ && INST_IMM(1).mask & IMM_U16)
INST_RETURN(3, 0xC4, INST_IMM_U16_B1(INST_IMM(1)), INST_IMM_U16_B2(INST_IMM(1)))
if (INST_COND(0) == COND_Z && INST_IMM(1).mask & IMM_U16)
INST_RETURN(3, 0xCC, INST_IMM_U16_B1(INST_IMM(1)), INST_IMM_U16_B2(INST_IMM(1)))
if (INST_COND(0) == COND_NC && INST_IMM(1).mask & IMM_U16)
INST_RETURN(3, 0xD4, INST_IMM_U16_B1(INST_IMM(1)), INST_IMM_U16_B2(INST_IMM(1)))
if (INST_COND(0) == COND_C && INST_IMM(1).mask & IMM_U16)
INST_RETURN(3, 0xDC, INST_IMM_U16_B1(INST_IMM(1)), INST_IMM_U16_B2(INST_IMM(1)))
if (INST_COND(0) == COND_PO && INST_IMM(1).mask & IMM_U16)
INST_RETURN(3, 0xE4, INST_IMM_U16_B1(INST_IMM(1)), INST_IMM_U16_B2(INST_IMM(1)))
if (INST_COND(0) == COND_PE && INST_IMM(1).mask & IMM_U16)
INST_RETURN(3, 0xEC, INST_IMM_U16_B1(INST_IMM(1)), INST_IMM_U16_B2(INST_IMM(1)))
if (INST_COND(0) == COND_P && INST_IMM(1).mask & IMM_U16)
INST_RETURN(3, 0xF4, INST_IMM_U16_B1(INST_IMM(1)), INST_IMM_U16_B2(INST_IMM(1)))
if (INST_COND(0) == COND_M && INST_IMM(1).mask & IMM_U16)
INST_RETURN(3, 0xFC, INST_IMM_U16_B1(INST_IMM(1)), INST_IMM_U16_B2(INST_IMM(1)))
INST_ERROR(ARG_VALUE)
}
INST_ERROR(ARG_TYPE)
}

INST_FUNC(ccf)
{
INST_TAKES_NO_ARGS
@@ -1006,6 +1040,7 @@ static ASMInstParser lookup_parser(uint32_t key)
HANDLE(add)
HANDLE(and)
HANDLE(bit)
HANDLE(call)
HANDLE(ccf)
HANDLE(cpd)
HANDLE(cpdr)


+ 25
- 3
src/assembler/instructions.yml 查看文件

@@ -246,9 +246,31 @@ bit:
- cond: [bit.7, _]
return: [0xCB, 0x7E]

# call:
# args: yes
# return: TODO
call:
args: yes
cases:
- type: [immediate]
cases:
- cond: [u16]
return: [0xCD, u16]
- type: [condition, immediate]
cases:
- cond: [nz, u16]
return: [0xC4, u16]
- cond: [z, u16]
return: [0xCC, u16]
- cond: [nc, u16]
return: [0xD4, u16]
- cond: [c, u16]
return: [0xDC, u16]
- cond: [po, u16]
return: [0xE4, u16]
- cond: [pe, u16]
return: [0xEC, u16]
- cond: [p, u16]
return: [0xF4, u16]
- cond: [m, u16]
return: [0xFC, u16]

ccf:
args: no


+ 1
- 1
src/assembler/parse_util.c 查看文件

@@ -302,7 +302,7 @@ bool argparse_condition(ASMArgCondition *result, ASMArgParseInfo ai)
switch (ai.size) {
case 1:
switch (buf[0]) {
case 'n': return (*result = COND_N), true;
case 'z': return (*result = COND_Z), true;
case 'c': return (*result = COND_C), true;
case 'p': return (*result = COND_P), true;
case 'm': return (*result = COND_M), true;


Loading…
取消
儲存