File:  [Isaki's NoNo m68k/m88k emulator] / nono / m680x0 / testop.cpp
Revision 1.1.1.3 (vendor branch): download - view: text, annotated - select for diffs
Wed Apr 29 17:04:34 2026 UTC (2 months, 3 weeks ago) by root
Branches: MAIN, Isaki
CVS tags: v019, v018, v017, v016, v015, v014, v013, v012, v011, v010, v009, v008, v007, v006, v005, v004, HEAD
nono 0.1.0

//
// nono
// Copyright (C) 2020 nono project
// Licensed under nono-license.txt
//

#include "m68030core.h"
#include "bus.h"

#define OP_PROTO(name)	extern void __CONCAT(op_,name)(m68kcpu *cpu)

#include "m68030ops.h"

uint8 mem[32];
uint32 pc;

void
set_8(uint32 addr, uint32 data)
{
	mem[HLB(addr)] = data;
}

void
set_16(uint32 addr, uint32 data)
{
	*(uint16 *)&mem[HLW(addr)] = data;
}

void
set_32(uint32 addr, uint32 data)
{
	*(uint32 *)&mem[addr] = data;
}

uint32
vm_phys_read_8(uint32 addr)
{
	return mem[HLB(addr)];
}

uint32
vm_phys_read_16(uint32 addr)
{
	return *(uint16 *)&mem[HLW(addr)];
}

uint32
vm_phys_read_32(uint32 addr)
{
	return *(uint32 *)&mem[addr];
}

void
vm_phys_write_8(uint32 addr, uint32 data)
{
}

void
vm_phys_write_16(uint32 addr, uint32 data)
{
}

void
vm_phys_write_32(uint32 addr, uint32 data)
{
}

// バイトデータ
uint8 data_8[] = {
	0x00,
	0x01,
	0x55,
	0x7f,
	0x80,
	0xaa,
	0xff,
};
// ワードデータ
uint16 data_16[] = {
	0x0000,
	0x0001,
	0x007f,
	0x0080,
	0x00ff,
	0x5555,
	0x7fff,
	0x8000,
	0xaaaa,
	0xfffe,
	0xffff,
};
// ロングデータ
uint32 data_32[] = {
	0x00000000,
	0x00000001,
	0x0000007f,
	0x00000080,
	0x000000ff,
	0x00007fff,
	0x00008000,
	0x0000ffff,
	0x55555555,
	0x7fffffff,
	0x80000000,
	0xaaaaaaaa,
	0xffffffff,
};

//
//
//

m68kcpu *cpu;

void
Init()
{
	cpu->prev = cpu->reg;
	RegA(0) = 0x10;
	RegPC = 0;
}

#define Test(expr)	do {	\
	if (!(expr))	\
		printf(#expr " failed at %d\n", __LINE__);	\
} while (0)


//
//
//
void
test_ori_b()
{
	// ORI.B #<data>,D0
	int x = 0;
	for (int i = 0; i < countof(data_8); i++) {
		for (int j = 0; j < countof(data_32); i++) {
			set_16(0, data_8[i]);
			RegD(0) = data_32[j];
			Init();
			op_ori_b(cpu);
			Test(RegD(0) == (data_32[j] | (data_32[i] & 0xff)));
			Test(ccr.IsX() == cpu->prev.ccr.IsX());
			Test(ccr.IsN() == (((data_32[j] | data_32[i]) & 0x80) != 0));
			Test(ccr.IsZ() == (((data_32[j] | data_32[i]) & 0xff) == 0));
			Test(ccr.IsV() == 0);
			Test(ccr.IsC() == 0);
		}
	}
}

int
main(int ac, char *av[])
{
	cpu = (m68kcpu *)malloc(sizeof(*cpu));
	memset(&cpu, 0, sizeof(cpu));

	test_ori_b();

	return 0;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.