mirror of
https://github.com/rkujawa/rk65c02.git
synced 2025-01-03 18:30:00 +00:00
Add test cases for 16-bit ADC and SBC.
This commit is contained in:
parent
1f8db85688
commit
a72a2c0872
@ -1036,9 +1036,54 @@ ATF_TC_BODY(emul_sbc, tc)
|
||||
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(emul_adc_16bit);
|
||||
ATF_TC_BODY(emul_adc_16bit, tc)
|
||||
{
|
||||
rk65c02emu_t e;
|
||||
bus_t b;
|
||||
|
||||
b = bus_init();
|
||||
e = rk65c02_init(&b);
|
||||
|
||||
bus_write_1(&b, 0x62, 0x55);
|
||||
bus_write_1(&b, 0x63, 0xAA);
|
||||
bus_write_1(&b, 0x64, 0xAA);
|
||||
bus_write_1(&b, 0x65, 0x55);
|
||||
|
||||
ATF_REQUIRE(rom_start(&e, "test_emulation_adc_16bit.rom", tc));
|
||||
|
||||
ATF_CHECK(bus_read_1(&b, 0x66) == 0xFF);
|
||||
ATF_CHECK(bus_read_1(&b, 0x67) == 0xFF);
|
||||
rk65c02_dump_regs(&e);
|
||||
|
||||
}
|
||||
|
||||
ATF_TC_WITHOUT_HEAD(emul_sbc_16bit);
|
||||
ATF_TC_BODY(emul_sbc_16bit, tc)
|
||||
{
|
||||
rk65c02emu_t e;
|
||||
bus_t b;
|
||||
|
||||
b = bus_init();
|
||||
e = rk65c02_init(&b);
|
||||
|
||||
bus_write_1(&b, 0x62, 0xFF);
|
||||
bus_write_1(&b, 0x63, 0xFF);
|
||||
bus_write_1(&b, 0x64, 0xAA);
|
||||
bus_write_1(&b, 0x65, 0x55);
|
||||
ATF_REQUIRE(rom_start(&e, "test_emulation_sbc_16bit.rom", tc));
|
||||
|
||||
printf("%x %x\n", bus_read_1(&b, 0x66), bus_read_1(&b, 0x67)) ;
|
||||
ATF_CHECK(bus_read_1(&b, 0x66) == 0x55);
|
||||
ATF_CHECK(bus_read_1(&b, 0x67) == 0xAA);
|
||||
rk65c02_dump_regs(&e);
|
||||
|
||||
}
|
||||
|
||||
ATF_TP_ADD_TCS(tp)
|
||||
{
|
||||
ATF_TP_ADD_TC(tp, emul_and);
|
||||
ATF_TP_ADD_TC(tp, emul_adc_16bit);
|
||||
ATF_TP_ADD_TC(tp, emul_bit);
|
||||
ATF_TP_ADD_TC(tp, emul_branch);
|
||||
ATF_TP_ADD_TC(tp, emul_cmp);
|
||||
@ -1063,6 +1108,7 @@ ATF_TP_ADD_TCS(tp)
|
||||
ATF_TP_ADD_TC(tp, emul_txa_tya_tax_tay);
|
||||
ATF_TP_ADD_TC(tp, emul_sta);
|
||||
ATF_TP_ADD_TC(tp, emul_sbc);
|
||||
ATF_TP_ADD_TC(tp, emul_sbc_16bit);
|
||||
|
||||
ATF_TP_ADD_TC(tp, emul_sign_overflow);
|
||||
|
||||
|
21
test/test_emulation_adc_16bit.s
Normal file
21
test/test_emulation_adc_16bit.s
Normal file
@ -0,0 +1,21 @@
|
||||
; 16-bit addition simple example by FMan/Tropyx
|
||||
; modified by rkujawa
|
||||
|
||||
.org 0xC000
|
||||
.set num1lo, 0x62
|
||||
.set num1hi, 0x63
|
||||
.set num2lo, 0x64
|
||||
.set num2hi, 0x65
|
||||
.set reslo, 0x66
|
||||
.set reshi, 0x67
|
||||
|
||||
; adds numbers 1 and 2, writes result to separate location
|
||||
|
||||
add: clc ; clear carry
|
||||
lda num1lo
|
||||
adc num2lo
|
||||
sta reslo ; store sum of LSBs
|
||||
lda num1hi
|
||||
adc num2hi ; add the MSBs using carry from
|
||||
sta reshi ; the previous calculation
|
||||
stp
|
21
test/test_emulation_sbc_16bit.s
Normal file
21
test/test_emulation_sbc_16bit.s
Normal file
@ -0,0 +1,21 @@
|
||||
; 16-bit subtraction simple example by FMan/Tropyx
|
||||
; modified by rkujawa
|
||||
|
||||
.org 0xC000
|
||||
.set num1lo, 0x62
|
||||
.set num1hi, 0x63
|
||||
.set num2lo, 0x64
|
||||
.set num2hi, 0x65
|
||||
.set reslo, 0x66
|
||||
.set reshi, 0x67
|
||||
|
||||
; subtracts number 2 from number 1 and writes result out
|
||||
|
||||
sub: sec ; set carry for borrow purpose
|
||||
lda num1lo
|
||||
sbc num2lo ; perform subtraction on the LSBs
|
||||
sta reslo
|
||||
lda num1hi ; do the same for the MSBs, with carry
|
||||
sbc num2hi ; set according to the previous result
|
||||
sta reshi
|
||||
stp
|
Loading…
Reference in New Issue
Block a user