mirror of
https://github.com/rkujawa/rk65c02.git
synced 2025-03-02 07:31:32 +00:00
Try to support assembling multi byte instructions.
This commit is contained in:
parent
09a92740e9
commit
77ce27e4fc
@ -111,6 +111,7 @@ instruction_print(instruction_t *i)
|
||||
bool
|
||||
assemble_single_implied(uint8_t **buf, uint8_t *bsize, const char *mnemonic)
|
||||
{
|
||||
/* XXX: does brk needs special handling? */
|
||||
return assemble_single(buf, bsize, mnemonic, IMPLIED, 0, 0);
|
||||
}
|
||||
|
||||
@ -140,16 +141,21 @@ assemble_single(uint8_t **buf, uint8_t *bsize, const char *mnemonic, addressing_
|
||||
return false;
|
||||
}
|
||||
|
||||
*bsize = id.size;
|
||||
*buf = malloc(id.size);
|
||||
if(*buf == NULL) {
|
||||
fprintf(stderr, "Error allocating assembly buffer\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* fill the buffer */
|
||||
memset(*buf, 0, id.size);
|
||||
*bsize = id.size;
|
||||
|
||||
*buf[0] = opcode;
|
||||
/* XXX */
|
||||
if (id.size > 1)
|
||||
*buf[1] = op1;
|
||||
if (id.size > 2)
|
||||
*buf[2] = op2;
|
||||
|
||||
return found;
|
||||
}
|
||||
|
@ -31,6 +31,13 @@ ATF_TC_BODY(asm_single, tc)
|
||||
free(asmbuf);
|
||||
caddr += bsize;
|
||||
|
||||
ATF_REQUIRE(assemble_single(&asmbuf, &bsize, "lda", IMMEDIATE, 0xAA, 0));
|
||||
ATF_CHECK(asmbuf[0] == 0xA9); /* check if lda really */
|
||||
ATF_CHECK(asmbuf[1] == 0xAA); /* check the operand */
|
||||
ATF_REQUIRE(bus_load_buf(&b, caddr, asmbuf, bsize));
|
||||
free(asmbuf);
|
||||
caddr += bsize;
|
||||
|
||||
ATF_REQUIRE(assemble_single_implied(&asmbuf, &bsize, "stp"));
|
||||
ATF_CHECK(asmbuf[0] == 0xDB); /* check if stp really */
|
||||
ATF_REQUIRE(bus_load_buf(&b, caddr, asmbuf, bsize));
|
||||
|
Loading…
x
Reference in New Issue
Block a user