mirror of
https://github.com/rkujawa/rk65c02.git
synced 2024-12-23 07:30:31 +00:00
Add test case for assembling functions.
This commit is contained in:
parent
9eff6d535b
commit
09a92740e9
@ -5,7 +5,7 @@ VASM=vasm6502_std
|
||||
VASMFLAGS=-Fbin -c02
|
||||
UTILS=utils.o
|
||||
|
||||
TESTS=test_bus test_emulation test_stepping
|
||||
TESTS=test_bus test_emulation test_stepping test_assemble
|
||||
TESTROMS:=$(addsuffix .rom,$(basename $(wildcard *.s)))
|
||||
|
||||
all : $(TESTS) $(TESTROMS)
|
||||
@ -19,6 +19,9 @@ test_bus : test_bus.o $(UTILS) $(RK6502LIB)
|
||||
test_emulation : test_emulation.o $(UTILS) $(RK6502LIB)
|
||||
$(CC) -o $@ $(LDFLAGS) $< $(UTILS) $(RK6502LIB)
|
||||
|
||||
test_assemble : test_assemble.o $(UTILS) $(RK6502LIB)
|
||||
$(CC) -o $@ $(LDFLAGS) $< $(UTILS) $(RK6502LIB)
|
||||
|
||||
%.rom : %.s
|
||||
$(VASM) $(VASMFLAGS) -o $@ $<
|
||||
|
||||
|
49
test/test_assemble.c
Normal file
49
test/test_assemble.c
Normal file
@ -0,0 +1,49 @@
|
||||
#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());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user