AltairZ80: M68K: Changes for SIMH.

Build: Compiled with VS 2022, Clang, gcc.
Test: Boot and run CP/M-68K from: https://schorn.ch/cpm/zip/cpm68k.zip
This commit is contained in:
Howard M. Harte 2022-10-08 00:25:04 -07:00
parent ab21cbab7a
commit 1110802bb1
7 changed files with 32 additions and 19 deletions

View file

@ -89,8 +89,8 @@
* If off, all interrupts will be autovectored and all interrupt requests will
* auto-clear when the interrupt is serviced.
*/
#define M68K_EMULATE_INT_ACK OPT_OFF
#define M68K_INT_ACK_CALLBACK(A) your_int_ack_handler_function(A)
#define M68K_EMULATE_INT_ACK OPT_SPECIFY_HANDLER
#define M68K_INT_ACK_CALLBACK(A) m68k_cpu_irq_ack(A)
/* If ON, CPU will call the breakpoint acknowledge callback when it encounters
@ -108,8 +108,8 @@
/* If ON, CPU will call the output reset callback when it encounters a reset
* instruction.
*/
#define M68K_EMULATE_RESET OPT_OFF
#define M68K_RESET_CALLBACK() your_reset_handler_function()
#define M68K_EMULATE_RESET OPT_SPECIFY_HANDLER
#define M68K_RESET_CALLBACK() m68k_cpu_pulse_reset()
/* If ON, CPU will call the callback when it encounters a cmpi.l #v, dn
* instruction.
@ -147,8 +147,8 @@
* want to properly emulate the m68010 or higher. (moves uses function codes
* to read/write data from different address spaces)
*/
#define M68K_EMULATE_FC OPT_OFF
#define M68K_SET_FC_CALLBACK(A) your_set_fc_handler_function(A)
#define M68K_EMULATE_FC OPT_SPECIFY_HANDLER
#define M68K_SET_FC_CALLBACK(A) m68k_cpu_set_fc(A)
/* If ON, CPU will call the pc changed callback when it changes the PC by a
* large value. This allows host programs to be nicer when it comes to
@ -203,6 +203,17 @@
#endif /* M68K_COMPILE_FOR_MAME */
#include "m68ksim.h"
#define m68k_read_memory_8(A) m68k_cpu_read_byte(A)
#define m68k_read_memory_16(A) m68k_cpu_read_word(A)
#define m68k_read_memory_32(A) m68k_cpu_read_long(A)
#define m68k_write_memory_8(A, V) m68k_cpu_write_byte(A, V)
#define m68k_write_memory_16(A, V) m68k_cpu_write_word(A, V)
#define m68k_write_memory_32(A, V) m68k_cpu_write_long(A, V)
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */

View file

@ -69,9 +69,6 @@ extern "C" {
typedef signed char sint8; /* ASG: changed from char to signed char */
typedef signed short sint16;
typedef signed int sint32; /* AWJ: changed from long to int */
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32; /* AWJ: changed from long to int */
/* signed and unsigned int must be at least 32 bits wide */
typedef signed int sint;
@ -154,7 +151,7 @@ typedef uint32 uint64;
#define EXCEPTION_RESET 0
#define EXCEPTION_BUS_ERROR 2 /* This one is not emulated! */
#define EXCEPTION_ADDRESS_ERROR 3 /* This one is partially emulated (doesn't stack a proper frame yet) */
#define EXCEPTION_ILLEGAL_INSTRUCTION 4
#define EXCEPTION_ILLEGAL_INSTRUCTION_M68K 4
#define EXCEPTION_ZERO_DIVIDE 5
#define EXCEPTION_CHK 6
#define EXCEPTION_TRAPV 7
@ -2010,11 +2007,11 @@ static inline void m68ki_exception_illegal(void)
}
#endif /* M68K_EMULATE_ADDRESS_ERROR */
m68ki_stack_frame_0000(REG_PPC, sr, EXCEPTION_ILLEGAL_INSTRUCTION);
m68ki_jump_vector(EXCEPTION_ILLEGAL_INSTRUCTION);
m68ki_stack_frame_0000(REG_PPC, sr, EXCEPTION_ILLEGAL_INSTRUCTION_M68K);
m68ki_jump_vector(EXCEPTION_ILLEGAL_INSTRUCTION_M68K);
/* Use up some clock cycles and undo the instruction's cycles */
USE_CYCLES(CYC_EXCEPTION[EXCEPTION_ILLEGAL_INSTRUCTION] - CYC_INSTRUCTION[REG_IR]);
USE_CYCLES(CYC_EXCEPTION[EXCEPTION_ILLEGAL_INSTRUCTION_M68K] - CYC_INSTRUCTION[REG_IR]);
}
/* Exception for format errror in RTE */

View file

@ -4,6 +4,7 @@
#ifdef LSB_FIRST
#define LITTLEENDIAN
#else
#undef BIGENDIAN
#define BIGENDIAN
#endif
@ -23,9 +24,6 @@
*----------------------------------------------------------------------------*/
typedef sint8 flag;
typedef sint8 int8;
typedef sint16 int16;
typedef sint32 int32;
typedef sint64 int64;
/*----------------------------------------------------------------------------

View file

@ -451,9 +451,9 @@ static inline void mul64To128( bits64 a, bits64 b, bits64 *z0Ptr, bits64 *z1Ptr
bits32 aHigh, aLow, bHigh, bLow;
bits64 z0, zMiddleA, zMiddleB, z1;
aLow = a;
aLow = (bits32)a;
aHigh = a>>32;
bLow = b;
bLow = (bits32)b;
bHigh = b>>32;
z1 = ( (bits64) aLow ) * bLow;
zMiddleA = ( (bits64) aLow ) * bHigh;
@ -661,7 +661,7 @@ static int8 countLeadingZeros64( bits64 a )
else {
a >>= 32;
}
shiftCount += countLeadingZeros32( a );
shiftCount += countLeadingZeros32( (bits32)a );
return shiftCount;
}

View file

@ -244,6 +244,8 @@ void m68k_clear_memory(void ) {
void m68k_cpu_reset(void) {
WRITE_LONG(m68k_ram, 0, 0x00006000); // SP
WRITE_LONG(m68k_ram, 4, 0x00000200); // PC
m68k_init();
m68k_set_cpu_type(M68K_CPU_TYPE_68000);
m68k_pulse_reset(); // also calls MC6850_reset()
m68k_CPUToView();
}

View file

@ -279,6 +279,10 @@
RelativePath="..\AltairZ80\m68k\m68kops.c"
>
</File>
<File
RelativePath="..\AltairZ80\m68k\softfloat\softfloat.c"
>
</File>
<File
RelativePath="..\AltairZ80\m68ksim.c"
>

View file

@ -1853,6 +1853,7 @@ ALTAIRZ80 = ${ALTAIRZ80D}/altairz80_cpu.c ${ALTAIRZ80D}/altairz80_cpu_nommu.c \
${ALTAIRZ80D}/s100_if3.c ${ALTAIRZ80D}/s100_adcs6.c \
${ALTAIRZ80D}/m68k/m68kcpu.c ${ALTAIRZ80D}/m68k/m68kdasm.c ${ALTAIRZ80D}/m68k/m68kasm.c \
${ALTAIRZ80D}/m68k/m68kopac.c ${ALTAIRZ80D}/m68k/m68kopdm.c \
${ALTAIRZ80D}/m68k/softfloat/softfloat.c \
${ALTAIRZ80D}/m68k/m68kopnz.c ${ALTAIRZ80D}/m68k/m68kops.c ${ALTAIRZ80D}/m68ksim.c
ALTAIRZ80_OPT = -I ${ALTAIRZ80D}