1
0
mirror of https://github.com/rkujawa/rk65c02.git synced 2024-12-12 10:30:23 +00:00
rk65c02/test/test_assemble.c
2017-02-02 14:46:10 +01:00

50 lines
942 B
C

#include <atf-c.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "bus.h"
#include "rk65c02.h"
#include "instruction.h"
#include "utils.h"
ATF_TC_WITHOUT_HEAD(asm_single);
ATF_TC_BODY(asm_single, tc)
{
rk65c02emu_t e;
bus_t b;
uint8_t *asmbuf;
uint8_t bsize;
uint16_t caddr;
b = bus_init();
e = rk65c02_init(&b);
caddr = ROM_LOAD_ADDR;
e.regs.PC = ROM_LOAD_ADDR;
ATF_REQUIRE(assemble_single_implied(&asmbuf, &bsize, "nop"));
ATF_CHECK(asmbuf[0] == 0xEA); /* check if nop really */
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));
free(asmbuf);
caddr += bsize;
rk65c02_start(&e);
}
ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, asm_single);
return (atf_no_error());
}