ESP32 poc
This commit is contained in:
parent
5258ea3661
commit
30a69ce0a5
30 changed files with 426 additions and 75 deletions
|
@ -21,7 +21,7 @@ add_executable(
|
||||||
utils.cpp
|
utils.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
|
||||||
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
|
|
1
ESP32/bus.cpp
Symbolic link
1
ESP32/bus.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../bus.cpp
|
1
ESP32/bus.h
Symbolic link
1
ESP32/bus.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../bus.h
|
1
ESP32/cpu.cpp
Symbolic link
1
ESP32/cpu.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../cpu.cpp
|
1
ESP32/cpu.h
Symbolic link
1
ESP32/cpu.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../cpu.h
|
1
ESP32/error.cpp
Symbolic link
1
ESP32/error.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../error.cpp
|
1
ESP32/error.h
Symbolic link
1
ESP32/error.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../error.h
|
1
ESP32/gen.h
Symbolic link
1
ESP32/gen.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../gen.h
|
235
ESP32/main.ino
Normal file
235
ESP32/main.ino
Normal file
|
@ -0,0 +1,235 @@
|
||||||
|
// (C) 2018-2022 by Folkert van Heusden
|
||||||
|
// Released under Apache License v2.0
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "memory.h"
|
||||||
|
#include "cpu.h"
|
||||||
|
#include "tty.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "error.h"
|
||||||
|
|
||||||
|
bus *b = new bus();
|
||||||
|
cpu *c = new cpu(b);
|
||||||
|
tty *tty_ = nullptr;
|
||||||
|
|
||||||
|
void loadbin(bus *const b, uint16_t base)
|
||||||
|
{
|
||||||
|
constexpr unsigned char ___tester_bin[] = {
|
||||||
|
0x01, 0x00, 0x8a, 0x07, 0x00, 0x02, 0xc6, 0x15, 0x00, 0x02, 0x77, 0x00,
|
||||||
|
0xb6, 0x05, 0xc0, 0x15, 0xcf, 0x03, 0xf7, 0x09, 0xe0, 0x05, 0xc1, 0x15,
|
||||||
|
0x5d, 0x6b, 0x01, 0x8d, 0xa1, 0x00, 0xa2, 0x00, 0xa4, 0x00, 0xa8, 0x00,
|
||||||
|
0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0x00, 0xc2, 0x8b, 0x01, 0x02, 0x87, 0x00,
|
||||||
|
0x80, 0x10, 0xf7, 0x09, 0xde, 0x05, 0xc0, 0x15, 0xa0, 0x03, 0xf7, 0x09,
|
||||||
|
0xb8, 0x05, 0x87, 0x00, 0xa1, 0x00, 0xa2, 0x00, 0xa4, 0x00, 0xa8, 0x00,
|
||||||
|
0x87, 0x00, 0xf7, 0x09, 0xf2, 0xff, 0xc1, 0x15, 0x00, 0x80, 0xc1, 0x8b,
|
||||||
|
0x04, 0x03, 0xc2, 0x15, 0x01, 0x00, 0x77, 0x00, 0x2e, 0x01, 0xf7, 0x09,
|
||||||
|
0xde, 0xff, 0xc1, 0x15, 0x80, 0x00, 0xc1, 0x8b, 0x04, 0x02, 0xc2, 0x15,
|
||||||
|
0x02, 0x00, 0x77, 0x00, 0x1a, 0x01, 0xf7, 0x09, 0xca, 0xff, 0xc1, 0x15,
|
||||||
|
0x7f, 0x00, 0x81, 0x8a, 0x04, 0x85, 0xc2, 0x15, 0x03, 0x00, 0x77, 0x00,
|
||||||
|
0x06, 0x01, 0xf7, 0x09, 0xb6, 0xff, 0xc1, 0x15, 0x80, 0xff, 0xc1, 0x8a,
|
||||||
|
0x04, 0x85, 0xc2, 0x15, 0x04, 0x00, 0x77, 0x00, 0xf2, 0x00, 0xf7, 0x09,
|
||||||
|
0xa2, 0xff, 0xc1, 0x15, 0x7f, 0x00, 0x81, 0x8a, 0x04, 0x81, 0xc2, 0x15,
|
||||||
|
0x05, 0x00, 0x77, 0x00, 0xde, 0x00, 0xf7, 0x09, 0x8e, 0xff, 0xc1, 0x15,
|
||||||
|
0x80, 0x00, 0xc1, 0x8a, 0x04, 0x80, 0xc2, 0x15, 0x06, 0x00, 0x77, 0x00,
|
||||||
|
0xca, 0x00, 0xf7, 0x09, 0x7a, 0xff, 0xc1, 0x15, 0x80, 0x00, 0xc1, 0x8c,
|
||||||
|
0x04, 0x87, 0xc2, 0x15, 0x07, 0x00, 0x77, 0x00, 0xb6, 0x00, 0xf7, 0x09,
|
||||||
|
0x66, 0xff, 0xc1, 0x15, 0x40, 0x00, 0xc1, 0x8c, 0x04, 0x86, 0xc2, 0x15,
|
||||||
|
0x08, 0x00, 0x77, 0x00, 0xa2, 0x00, 0xf7, 0x09, 0x52, 0xff, 0xc1, 0x15,
|
||||||
|
0x00, 0x00, 0xc1, 0x0b, 0x04, 0x03, 0xc2, 0x15, 0x09, 0x00, 0x77, 0x00,
|
||||||
|
0x8e, 0x00, 0xf7, 0x09, 0x3e, 0xff, 0xc1, 0x15, 0x00, 0x80, 0xc1, 0x0b,
|
||||||
|
0x04, 0x02, 0xc2, 0x15, 0x0a, 0x00, 0x77, 0x00, 0x7a, 0x00, 0xf7, 0x09,
|
||||||
|
0x2a, 0xff, 0xc1, 0x15, 0xff, 0x7f, 0x81, 0x0a, 0x04, 0x85, 0xc2, 0x15,
|
||||||
|
0x0b, 0x00, 0x77, 0x00, 0x66, 0x00, 0xf7, 0x09, 0x16, 0xff, 0xc1, 0x15,
|
||||||
|
0x00, 0x80, 0xc1, 0x0a, 0x04, 0x85, 0xc2, 0x15, 0x0c, 0x00, 0x77, 0x00,
|
||||||
|
0x52, 0x00, 0xf7, 0x09, 0x02, 0xff, 0xc1, 0x15, 0xff, 0x7f, 0x81, 0x0a,
|
||||||
|
0x04, 0x81, 0xc2, 0x15, 0x0d, 0x00, 0x77, 0x00, 0x3e, 0x00, 0xf7, 0x09,
|
||||||
|
0xee, 0xfe, 0xc1, 0x15, 0x00, 0x80, 0xc1, 0x0a, 0x04, 0x80, 0xc2, 0x15,
|
||||||
|
0x0e, 0x00, 0x77, 0x00, 0x2a, 0x00, 0xf7, 0x09, 0xda, 0xfe, 0xc1, 0x15,
|
||||||
|
0x00, 0x80, 0xc1, 0x0c, 0x04, 0x87, 0xc2, 0x15, 0x0f, 0x00, 0x77, 0x00,
|
||||||
|
0x16, 0x00, 0xf7, 0x09, 0xc6, 0xfe, 0xc1, 0x15, 0x00, 0x40, 0xc1, 0x0c,
|
||||||
|
0x04, 0x86, 0xc2, 0x15, 0x10, 0x00, 0x77, 0x00, 0x02, 0x00, 0x87, 0x00,
|
||||||
|
0xf7, 0x09, 0xb0, 0xfe, 0x80, 0x10, 0xf7, 0x09, 0x7e, 0x04, 0xc0, 0x8d,
|
||||||
|
0xf7, 0x09, 0x78, 0x04, 0xc0, 0x15, 0xbc, 0x03, 0xf7, 0x09, 0x52, 0x04,
|
||||||
|
0x87, 0x00, 0x4d, 0x46, 0x50, 0x53, 0x20, 0x2f, 0x20, 0x4d, 0x54, 0x50,
|
||||||
|
0x53, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46,
|
||||||
|
0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00, 0x50, 0x53, 0x57, 0x20, 0x74, 0x72,
|
||||||
|
0x69, 0x67, 0x67, 0x65, 0x72, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x0d, 0x0a,
|
||||||
|
0x00, 0x50, 0x53, 0x57, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69, 0x6e,
|
||||||
|
0x67, 0x20, 0x74, 0x65, 0x73, 0x74, 0x0d, 0x0a, 0x00, 0x00, 0xc0, 0x15,
|
||||||
|
0xb4, 0x04, 0xf7, 0x09, 0x04, 0x04, 0xc0, 0x15, 0x01, 0x80, 0xc1, 0x15,
|
||||||
|
0x01, 0x01, 0xc0, 0x65, 0xeb, 0x03, 0x40, 0x0b, 0xc2, 0x8d, 0xc2, 0x45,
|
||||||
|
0xf0, 0xff, 0x80, 0x60, 0xc1, 0x0a, 0xc1, 0x0b, 0xf6, 0x02, 0xc0, 0x25,
|
||||||
|
0xf0, 0x72, 0x12, 0x02, 0xc0, 0x15, 0x01, 0x80, 0xc1, 0x15, 0x01, 0x01,
|
||||||
|
0xc0, 0x65, 0x0d, 0x00, 0x40, 0x8b, 0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff,
|
||||||
|
0x80, 0x60, 0xc1, 0x0a, 0xc1, 0x0b, 0xf6, 0x02, 0xc0, 0x25, 0x0e, 0x90,
|
||||||
|
0x01, 0x02, 0x87, 0x00, 0xc0, 0x15, 0x3c, 0x04, 0xf7, 0x09, 0xb6, 0x03,
|
||||||
|
0x87, 0x00, 0x41, 0x44, 0x43, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69,
|
||||||
|
0x6e, 0x67, 0x20, 0x46, 0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00, 0xc0, 0x15,
|
||||||
|
0x01, 0x80, 0xc1, 0x15, 0x01, 0x01, 0xc0, 0xe5, 0xeb, 0x03, 0x80, 0x0b,
|
||||||
|
0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff, 0x80, 0xe0, 0xc1, 0x0a, 0xc1, 0x0b,
|
||||||
|
0xf6, 0x02, 0xc0, 0x25, 0x0a, 0x8d, 0x12, 0x02, 0xc0, 0x15, 0x01, 0x80,
|
||||||
|
0xc1, 0x15, 0x01, 0x01, 0xc0, 0xe5, 0x0d, 0x00, 0x80, 0x8b, 0xc2, 0x8d,
|
||||||
|
0xc2, 0x45, 0xf0, 0xff, 0x80, 0xe0, 0xc1, 0x0a, 0xc1, 0x0b, 0xf6, 0x02,
|
||||||
|
0xc0, 0x25, 0xec, 0x6f, 0x01, 0x02, 0x87, 0x00, 0xc0, 0x15, 0xa0, 0x04,
|
||||||
|
0xf7, 0x09, 0x52, 0x03, 0x87, 0x00, 0x53, 0x42, 0x43, 0x20, 0x68, 0x61,
|
||||||
|
0x6e, 0x64, 0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x41, 0x49, 0x4c, 0x0d,
|
||||||
|
0x0a, 0x00, 0x41, 0x44, 0x43, 0x2f, 0x53, 0x42, 0x43, 0x20, 0x74, 0x65,
|
||||||
|
0x73, 0x74, 0x0d, 0x0a, 0x00, 0x00, 0xc0, 0x15, 0x3d, 0x06, 0xf7, 0x09,
|
||||||
|
0x24, 0x03, 0xc0, 0x15, 0x55, 0xaa, 0xc0, 0x25, 0x55, 0xaa, 0x04, 0x03,
|
||||||
|
0xc0, 0x15, 0x01, 0x00, 0x77, 0x00, 0x36, 0x01, 0xc0, 0x95, 0xf0, 0x00,
|
||||||
|
0xc0, 0x25, 0xf0, 0xff, 0x04, 0x03, 0xc0, 0x15, 0x02, 0x00, 0x77, 0x00,
|
||||||
|
0x24, 0x01, 0xc0, 0x95, 0x7f, 0x00, 0xc0, 0x25, 0x7f, 0x00, 0x04, 0x03,
|
||||||
|
0xc0, 0x15, 0x03, 0x00, 0x77, 0x00, 0x12, 0x01, 0xc0, 0x15, 0x52, 0x06,
|
||||||
|
0x01, 0x12, 0xc1, 0x25, 0xd2, 0x04, 0x04, 0x03, 0xc0, 0x15, 0x04, 0x00,
|
||||||
|
0x77, 0x00, 0xfe, 0x00, 0xc0, 0x15, 0x52, 0x06, 0x01, 0x92, 0xc1, 0x25,
|
||||||
|
0xd2, 0xff, 0x04, 0x03, 0xc0, 0x15, 0x05, 0x00, 0x77, 0x00, 0xea, 0x00,
|
||||||
|
0xc0, 0x15, 0x52, 0x06, 0x01, 0x92, 0xc1, 0x25, 0xd2, 0x04, 0x04, 0x02,
|
||||||
|
0xc0, 0x15, 0x06, 0x00, 0x77, 0x00, 0xd6, 0x00, 0xc0, 0x15, 0x52, 0x06,
|
||||||
|
0x01, 0x14, 0xc1, 0x25, 0xd2, 0x04, 0x04, 0x03, 0xc0, 0x15, 0x07, 0x00,
|
||||||
|
0x77, 0x00, 0xc2, 0x00, 0xc2, 0x15, 0x54, 0x06, 0x02, 0x20, 0x04, 0x03,
|
||||||
|
0xc0, 0x15, 0x08, 0x00, 0x77, 0x00, 0xb2, 0x00, 0xc0, 0x15, 0x52, 0x06,
|
||||||
|
0x01, 0x94, 0xc1, 0xa5, 0xd2, 0x00, 0x04, 0x03, 0xc0, 0x15, 0x09, 0x00,
|
||||||
|
0x77, 0x00, 0x9e, 0x00, 0xc0, 0x15, 0x52, 0x06, 0x00, 0x14, 0xc0, 0x25,
|
||||||
|
0xd2, 0x04, 0x04, 0x03, 0xc0, 0x15, 0x0a, 0x00, 0x77, 0x00, 0x8a, 0x00,
|
||||||
|
0xc0, 0x1d, 0xc8, 0x00, 0xc8, 0x25, 0xd2, 0x04, 0x04, 0x03, 0xc0, 0x15,
|
||||||
|
0x0c, 0x00, 0x77, 0x00, 0x78, 0x00, 0x01, 0x16, 0xc2, 0x15, 0x54, 0x06,
|
||||||
|
0x02, 0x20, 0x04, 0x03, 0xc0, 0x15, 0x0d, 0x00, 0x77, 0x00, 0x66, 0x00,
|
||||||
|
0xc0, 0x15, 0x52, 0x06, 0x01, 0x18, 0xc1, 0x25, 0x67, 0x11, 0x04, 0x03,
|
||||||
|
0xc0, 0x15, 0x0e, 0x00, 0x77, 0x00, 0x52, 0x00, 0xc2, 0x15, 0x50, 0x06,
|
||||||
|
0x02, 0x20, 0x04, 0x03, 0xc0, 0x15, 0x0f, 0x00, 0x77, 0x00, 0x42, 0x00,
|
||||||
|
0xc0, 0x15, 0x52, 0x06, 0x01, 0x98, 0xc1, 0xa5, 0x11, 0x00, 0x04, 0x03,
|
||||||
|
0xc0, 0x15, 0x10, 0x00, 0x77, 0x00, 0x2e, 0x00, 0xc0, 0x15, 0x52, 0x06,
|
||||||
|
0x01, 0x1c, 0x02, 0x00, 0xc1, 0x25, 0xe1, 0x10, 0x04, 0x03, 0xc0, 0x15,
|
||||||
|
0x11, 0x00, 0x77, 0x00, 0x18, 0x00, 0xc0, 0x15, 0x56, 0x06, 0x01, 0x1e,
|
||||||
|
0x02, 0x00, 0xc1, 0x25, 0xe1, 0x10, 0x04, 0x03, 0xc0, 0x15, 0x12, 0x00,
|
||||||
|
0x77, 0x00, 0x02, 0x00, 0x87, 0x00, 0xf7, 0x09, 0xf6, 0x01, 0xc0, 0x15,
|
||||||
|
0x22, 0x06, 0xf7, 0x09, 0xd0, 0x01, 0x87, 0x00, 0x61, 0x64, 0x64, 0x72,
|
||||||
|
0x65, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c,
|
||||||
|
0x69, 0x6e, 0x67, 0x20, 0x46, 0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00, 0x61,
|
||||||
|
0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x69, 0x6e, 0x67, 0x20, 0x74, 0x65,
|
||||||
|
0x73, 0x74, 0x73, 0x0d, 0x0a, 0x00, 0x67, 0x11, 0xd2, 0x04, 0xe1, 0x10,
|
||||||
|
0x52, 0x06, 0x54, 0x06, 0xf7, 0x09, 0x66, 0xfe, 0x87, 0x00, 0xc0, 0x15,
|
||||||
|
0xce, 0x06, 0xf7, 0x09, 0x88, 0x01, 0xc0, 0x15, 0x03, 0x00, 0x00, 0x8d,
|
||||||
|
0xc0, 0x15, 0x00, 0x00, 0xc1, 0x8d, 0xc1, 0x45, 0xf0, 0xff, 0xc1, 0x25,
|
||||||
|
0x05, 0x00, 0x04, 0x03, 0xc0, 0x15, 0x01, 0x00, 0x77, 0x00, 0x20, 0x00,
|
||||||
|
0xc0, 0x15, 0x00, 0x00, 0x00, 0x8d, 0xc0, 0x15, 0x00, 0x80, 0xc1, 0x8d,
|
||||||
|
0xc1, 0x45, 0xf0, 0xff, 0xc1, 0xa5, 0x08, 0x00, 0x04, 0x03, 0xc0, 0x15,
|
||||||
|
0x02, 0x00, 0x77, 0x00, 0x02, 0x00, 0x87, 0x00, 0xf7, 0x09, 0x64, 0x01,
|
||||||
|
0x40, 0x10, 0xf7, 0x09, 0x5e, 0x01, 0xc0, 0x15, 0xba, 0x06, 0xf7, 0x09,
|
||||||
|
0x38, 0x01, 0x87, 0x00, 0x4d, 0x4f, 0x56, 0x20, 0x68, 0x61, 0x6e, 0x64,
|
||||||
|
0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00,
|
||||||
|
0x4d, 0x4f, 0x56, 0x20, 0x66, 0x6c, 0x61, 0x67, 0x20, 0x74, 0x65, 0x73,
|
||||||
|
0x74, 0x0d, 0x0a, 0x00, 0xc0, 0x15, 0x50, 0x07, 0xf7, 0x09, 0x0a, 0x01,
|
||||||
|
0xc0, 0x15, 0x0f, 0x00, 0x00, 0x8d, 0xc1, 0x15, 0x00, 0x00, 0xc1, 0x0b,
|
||||||
|
0xc2, 0x8d, 0xc2, 0x45, 0xf0, 0xff, 0xc2, 0x25, 0x04, 0x00, 0x04, 0x03,
|
||||||
|
0xc0, 0x15, 0x01, 0x00, 0x77, 0x00, 0x22, 0x00, 0xc0, 0x15, 0x0f, 0x00,
|
||||||
|
0x00, 0x8d, 0xc1, 0x15, 0x00, 0x80, 0xc1, 0x0b, 0xc2, 0x8d, 0xc2, 0x45,
|
||||||
|
0xf0, 0xff, 0xc2, 0x25, 0x08, 0x00, 0x04, 0x03, 0xc0, 0x15, 0x02, 0x00,
|
||||||
|
0x77, 0x00, 0x02, 0x00, 0x87, 0x00, 0xf7, 0x09, 0xe2, 0x00, 0x80, 0x10,
|
||||||
|
0xf7, 0x09, 0xdc, 0x00, 0xc0, 0x15, 0x3c, 0x07, 0xf7, 0x09, 0xb6, 0x00,
|
||||||
|
0x87, 0x00, 0x54, 0x53, 0x54, 0x20, 0x68, 0x61, 0x6e, 0x64, 0x6c, 0x69,
|
||||||
|
0x6e, 0x67, 0x20, 0x46, 0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00, 0x54, 0x53,
|
||||||
|
0x54, 0x20, 0x74, 0x65, 0x73, 0x74, 0x0d, 0x0a, 0x00, 0x00, 0xc0, 0x15,
|
||||||
|
0xb2, 0x07, 0xf7, 0x09, 0x8c, 0x00, 0xc0, 0x15, 0x08, 0x00, 0x00, 0x8d,
|
||||||
|
0x02, 0x04, 0x77, 0x00, 0x08, 0x00, 0xc0, 0x15, 0x01, 0x00, 0x77, 0x00,
|
||||||
|
0x12, 0x00, 0xc0, 0x15, 0x0a, 0x00, 0x00, 0x8d, 0x04, 0x04, 0xc0, 0x15,
|
||||||
|
0x02, 0x00, 0x77, 0x00, 0x02, 0x00, 0x87, 0x00, 0xf7, 0x09, 0x80, 0x00,
|
||||||
|
0x80, 0x10, 0xf7, 0x09, 0x7a, 0x00, 0xc0, 0x15, 0x9e, 0x07, 0xf7, 0x09,
|
||||||
|
0x54, 0x00, 0x87, 0x00, 0x42, 0x47, 0x45, 0x20, 0x68, 0x61, 0x6e, 0x64,
|
||||||
|
0x6c, 0x69, 0x6e, 0x67, 0x20, 0x46, 0x41, 0x49, 0x4c, 0x0d, 0x0a, 0x00,
|
||||||
|
0x42, 0x47, 0x45, 0x20, 0x74, 0x65, 0x73, 0x74, 0x0d, 0x0a, 0x00, 0x00,
|
||||||
|
0xc0, 0x15, 0x5e, 0x08, 0xf7, 0x09, 0x2a, 0x00, 0xf7, 0x09, 0x3e, 0xfa,
|
||||||
|
0xf7, 0x09, 0x76, 0xfa, 0xf7, 0x09, 0x12, 0xfc, 0xf7, 0x09, 0x7a, 0xfc,
|
||||||
|
0xf7, 0x09, 0x80, 0xfe, 0xf7, 0x09, 0x82, 0xfe, 0xf7, 0x09, 0xfc, 0xfe,
|
||||||
|
0xf7, 0x09, 0x76, 0xff, 0xc0, 0x15, 0x72, 0x08, 0xf7, 0x09, 0x02, 0x00,
|
||||||
|
0x07, 0x89, 0x26, 0x10, 0xe6, 0x8d, 0xc8, 0x8b, 0x08, 0x03, 0x1f, 0x92,
|
||||||
|
0x76, 0xff, 0xdf, 0x8b, 0x74, 0xff, 0xfd, 0x80, 0x80, 0x0a, 0x77, 0x00,
|
||||||
|
0xec, 0xff, 0x16, 0x8d, 0x80, 0x15, 0x87, 0x00, 0xe6, 0x8d, 0x26, 0x10,
|
||||||
|
0x66, 0x10, 0xc1, 0x15, 0x10, 0x00, 0xc0, 0x0c, 0x07, 0x87, 0xdf, 0x8b,
|
||||||
|
0x74, 0xff, 0xfd, 0x80, 0xdf, 0x95, 0x30, 0x00, 0x76, 0xff, 0x07, 0x01,
|
||||||
|
0xdf, 0x8b, 0x74, 0xff, 0xfd, 0x80, 0xdf, 0x95, 0x31, 0x00, 0x76, 0xff,
|
||||||
|
0x00, 0x01, 0xc1, 0x0a, 0xc1, 0x0b, 0xed, 0x02, 0xdf, 0x8b, 0x74, 0xff,
|
||||||
|
0xfd, 0x80, 0xdf, 0x95, 0x20, 0x00, 0x76, 0xff, 0xdf, 0x8b, 0x74, 0xff,
|
||||||
|
0xfd, 0x80, 0xdf, 0x95, 0x20, 0x00, 0x76, 0xff, 0x81, 0x15, 0x80, 0x15,
|
||||||
|
0x16, 0x8d, 0x87, 0x00, 0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x20, 0x72,
|
||||||
|
0x75, 0x6e, 0x6e, 0x69, 0x6e, 0x67, 0x2e, 0x2e, 0x2e, 0x0d, 0x0a, 0x00,
|
||||||
|
0x74, 0x65, 0x73, 0x74, 0x65, 0x72, 0x20, 0x66, 0x69, 0x6e, 0x69, 0x73,
|
||||||
|
0x68, 0x65, 0x64, 0x0d, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xdf, 0x01,
|
||||||
|
0x00, 0x06, 0x00, 0x00, 0x02
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned int ___tester_bin_len = 1937;
|
||||||
|
|
||||||
|
for(int i=0; i<___tester_bin_len; i++)
|
||||||
|
b -> writeByte(base++, ___tester_bin[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
Serial.print(F("Size of int: "));
|
||||||
|
Serial.println(sizeof(int));
|
||||||
|
|
||||||
|
Serial.println(F("Init bus"));
|
||||||
|
b = new bus();
|
||||||
|
|
||||||
|
Serial.println(F("Init CPU"));
|
||||||
|
c = new cpu(b);
|
||||||
|
|
||||||
|
Serial.println(F("Connect CPU to BUS"));
|
||||||
|
b->add_cpu(c);
|
||||||
|
|
||||||
|
c->setEmulateMFPT(true);
|
||||||
|
|
||||||
|
Serial.println(F("Load program"));
|
||||||
|
loadbin(b, 01000);
|
||||||
|
c->setRegister(7, 01000);
|
||||||
|
|
||||||
|
Serial.println(F("Init TTY"));
|
||||||
|
tty_ = new tty(false);
|
||||||
|
Serial.println(F("Connect TTY to bus"));
|
||||||
|
b->add_tty(tty_);
|
||||||
|
|
||||||
|
Serial.println(F("Press <enter> to start"));
|
||||||
|
|
||||||
|
for(;;) {
|
||||||
|
if (Serial.available()) {
|
||||||
|
int c = Serial.read();
|
||||||
|
if (c == 13 || c == 10)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println(F("Emulation go!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
if (c->step()) {
|
||||||
|
c->setRegister(7, 01000);
|
||||||
|
c->resetHalt();
|
||||||
|
}
|
||||||
|
}
|
1
ESP32/memory.cpp
Symbolic link
1
ESP32/memory.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../memory.cpp
|
1
ESP32/memory.h
Symbolic link
1
ESP32/memory.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../memory.h
|
44
ESP32/platformio.ini
Normal file
44
ESP32/platformio.ini
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
[platformio]
|
||||||
|
default_envs = serial32
|
||||||
|
src_dir = .
|
||||||
|
|
||||||
|
[env]
|
||||||
|
framework = arduino
|
||||||
|
lib_ldf_mode = deep+
|
||||||
|
lib_deps =
|
||||||
|
src_filter = +<*> -<.git/> -<.svn/> -<example/> -<examples/> -<test/> -<tests/> -<build> -<player.cpp>
|
||||||
|
|
||||||
|
[env:serial]
|
||||||
|
platform = espressif8266
|
||||||
|
board = d1_mini
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 57600
|
||||||
|
upload_speed = 1000000
|
||||||
|
|
||||||
|
[env:serial_debug]
|
||||||
|
platform = espressif8266
|
||||||
|
board = d1_mini
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 57600
|
||||||
|
upload_speed = 1000000
|
||||||
|
build_flags = -DDEBUG
|
||||||
|
|
||||||
|
[env:serial32]
|
||||||
|
platform = espressif32
|
||||||
|
board = wemos_d1_mini32
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
upload_speed = 1000000
|
||||||
|
lib_deps =
|
||||||
|
build_flags = -std=c++17
|
||||||
|
build_unflags = -std=gnu++11
|
||||||
|
|
||||||
|
[env:serial32_debug]
|
||||||
|
platform = espressif32
|
||||||
|
board = wemos_d1_mini32
|
||||||
|
framework = arduino
|
||||||
|
monitor_speed = 115200
|
||||||
|
upload_speed = 1000000
|
||||||
|
lib_deps =
|
||||||
|
build_flags = -std=c++17 -DDEBUG
|
||||||
|
build_unflags = -std=gnu++11
|
1
ESP32/rk05.cpp
Symbolic link
1
ESP32/rk05.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../rk05.cpp
|
1
ESP32/rk05.h
Symbolic link
1
ESP32/rk05.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../rk05.h
|
1
ESP32/rx02.cpp
Symbolic link
1
ESP32/rx02.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../rx02.cpp
|
1
ESP32/rx02.h
Symbolic link
1
ESP32/rx02.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../rx02.h
|
1
ESP32/tm-11.cpp
Symbolic link
1
ESP32/tm-11.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../tm-11.cpp
|
1
ESP32/tm-11.h
Symbolic link
1
ESP32/tm-11.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../tm-11.h
|
1
ESP32/tty.cpp
Symbolic link
1
ESP32/tty.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../tty.cpp
|
1
ESP32/tty.h
Symbolic link
1
ESP32/tty.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../tty.h
|
1
ESP32/utils.cpp
Symbolic link
1
ESP32/utils.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../utils.cpp
|
1
ESP32/utils.h
Symbolic link
1
ESP32/utils.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../utils.h
|
124
bus.cpp
124
bus.cpp
|
@ -1,5 +1,8 @@
|
||||||
// (C) 2018 by Folkert van Heusden
|
// (C) 2018 by Folkert van Heusden
|
||||||
// Released under Apache License v2.0
|
// Released under Apache License v2.0
|
||||||
|
#if defined(ESP32)
|
||||||
|
#include <Arduino.h>
|
||||||
|
#endif
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -12,9 +15,15 @@
|
||||||
|
|
||||||
bus::bus() : c(nullptr), tm11(nullptr), rk05_(nullptr), rx02_(nullptr), tty_(nullptr)
|
bus::bus() : c(nullptr), tm11(nullptr), rk05_(nullptr), rx02_(nullptr), tty_(nullptr)
|
||||||
{
|
{
|
||||||
m = new memory(16 * 8192);
|
#if defined(ESP32)
|
||||||
|
int n = 8;
|
||||||
|
#else
|
||||||
|
int n = 16;
|
||||||
|
#endif
|
||||||
|
|
||||||
for(int i=0; i<16; i++) {
|
m = new memory(n * 8192);
|
||||||
|
|
||||||
|
for(int i=0; i<n; i++) {
|
||||||
pages[i].par = (i & 7) * 8192 / 64;
|
pages[i].par = (i & 7) * 8192 / 64;
|
||||||
pages[i].pdr = (3 << 1) | (0 << 4) | (0 << 6) | ((8192 / (32 * 2)) << 8);
|
pages[i].pdr = (3 << 1) | (0 << 4) | (0 << 6) | ((8192 / (32 * 2)) << 8);
|
||||||
}
|
}
|
||||||
|
@ -45,62 +54,62 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev)
|
||||||
D(fprintf(stderr, "read%c I/O %o\n", word_mode ? 'b' : ' ', a);)
|
D(fprintf(stderr, "read%c I/O %o\n", word_mode ? 'b' : ' ', a);)
|
||||||
|
|
||||||
if (a == 0177750) { // MAINT
|
if (a == 0177750) { // MAINT
|
||||||
fprintf(stderr, "read MAINT\n");
|
D(fprintf(stderr, "read MAINT\n");)
|
||||||
return 1; // POWER OK
|
return 1; // POWER OK
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177570) { // console switch & display register
|
if (a == 0177570) { // console switch & display register
|
||||||
fprintf(stderr, "read console switch\n");
|
D(fprintf(stderr, "read console switch\n");)
|
||||||
return 128; // educated guess
|
return 128; // educated guess
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0172540) { // KW11P programmable clock
|
if (a == 0172540) { // KW11P programmable clock
|
||||||
fprintf(stderr, "read programmable clock\n");
|
D(fprintf(stderr, "read programmable clock\n");)
|
||||||
return 128;
|
return 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177772) { // PIR
|
if (a == 0177772) { // PIR
|
||||||
fprintf(stderr, "read PIT\n");
|
D(fprintf(stderr, "read PIT\n");)
|
||||||
return PIR;
|
return PIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177546) { // line frequency clock and status register
|
if (a == 0177546) { // line frequency clock and status register
|
||||||
fprintf(stderr, "read line freq clock\n");
|
D(fprintf(stderr, "read line freq clock\n");)
|
||||||
return CSR;
|
return CSR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177514) { // printer, CSR register, LP11
|
if (a == 0177514) { // printer, CSR register, LP11
|
||||||
fprintf(stderr, "read LP11 CSR\n");
|
D(fprintf(stderr, "read LP11 CSR\n");)
|
||||||
return 0x80;
|
return 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177564) { // console tty status register
|
if (a == 0177564) { // console tty status register
|
||||||
fprintf(stderr, "console tty status register\n");
|
D(fprintf(stderr, "console tty status register\n");)
|
||||||
return 0x80;
|
return 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// MMU ///
|
/// MMU ///
|
||||||
if (a >= 0172300 && a < 0172320) {
|
if (a >= 0172300 && a < 0172320) {
|
||||||
uint16_t t = pages[((a & 017) >> 1)].pdr;
|
uint16_t t = pages[((a & 017) >> 1)].pdr;
|
||||||
fprintf(stderr, "read PDR for %d: %o\n", (a & 017) >> 1, t);
|
D(fprintf(stderr, "read PDR for %d: %o\n", (a & 017) >> 1, t);)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0172340 && a < 0172360) {
|
if (a >= 0172340 && a < 0172360) {
|
||||||
uint16_t t = pages[((a & 017) >> 1)].par;
|
uint16_t t = pages[((a & 017) >> 1)].par;
|
||||||
fprintf(stderr, "read PAR for %d: %o\n", (a & 017) >> 1, t);
|
D(fprintf(stderr, "read PAR for %d: %o\n", (a & 017) >> 1, t);)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0177600 && a < 0177620) {
|
if (a >= 0177600 && a < 0177620) {
|
||||||
uint16_t t = pages[((a & 017) >> 1) + 8].pdr;
|
uint16_t t = pages[((a & 017) >> 1) + 8].pdr;
|
||||||
fprintf(stderr, "read PDR for %d: %o\n", ((a & 017) >> 1) + 8, t);
|
D(fprintf(stderr, "read PDR for %d: %o\n", ((a & 017) >> 1) + 8, t);)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0177640 && a < 0177660) {
|
if (a >= 0177640 && a < 0177660) {
|
||||||
uint16_t t = pages[((a & 017) >> 1) + 8].par;
|
uint16_t t = pages[((a & 017) >> 1) + 8].par;
|
||||||
fprintf(stderr, "read PAR for %d: %o\n", ((a & 017) >> 1) + 8, t);
|
D(fprintf(stderr, "read PAR for %d: %o\n", ((a & 017) >> 1) + 8, t);)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,74 +118,74 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev)
|
||||||
((c -> getRegister(7) >> 13) << 1) | // page nr
|
((c -> getRegister(7) >> 13) << 1) | // page nr
|
||||||
0 // MMU enabled
|
0 // MMU enabled
|
||||||
;
|
;
|
||||||
fprintf(stderr, "read MMU SR0 %o\n", t);
|
D(fprintf(stderr, "read MMU SR0 %o\n", t);)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
///////////
|
///////////
|
||||||
|
|
||||||
if (word_mode) {
|
if (word_mode) {
|
||||||
if (a == 0177776) { // PSW
|
if (a == 0177776) { // PSW
|
||||||
fprintf(stderr, "readb PSW LSB\n");
|
D(fprintf(stderr, "readb PSW LSB\n");)
|
||||||
return c -> getPSW() & 255;
|
return c -> getPSW() & 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177777) {
|
if (a == 0177777) {
|
||||||
fprintf(stderr, "readb PSW MSB\n");
|
D(fprintf(stderr, "readb PSW MSB\n");)
|
||||||
return c -> getPSW() >> 8;
|
return c -> getPSW() >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177774) { // stack limit register
|
if (a == 0177774) { // stack limit register
|
||||||
fprintf(stderr, "readb stack limit register\n");
|
D(fprintf(stderr, "readb stack limit register\n");)
|
||||||
return c -> getStackLimitRegister() & 0xff;
|
return c -> getStackLimitRegister() & 0xff;
|
||||||
}
|
}
|
||||||
if (a == 0177775) { // stack limit register
|
if (a == 0177775) { // stack limit register
|
||||||
fprintf(stderr, "readb stack limit register\n");
|
D(fprintf(stderr, "readb stack limit register\n");)
|
||||||
return c -> getStackLimitRegister() >> 8;
|
return c -> getStackLimitRegister() >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
|
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
|
||||||
fprintf(stderr, "readb kernel R%d\n", a - 0177700);
|
D(fprintf(stderr, "readb kernel R%d\n", a - 0177700);)
|
||||||
return c -> getRegister(false, a - 0177700) & 0xff;
|
return c -> getRegister(false, a - 0177700) & 0xff;
|
||||||
}
|
}
|
||||||
if (a >= 0177710 && a <= 0177715) { // user R0-R5
|
if (a >= 0177710 && a <= 0177715) { // user R0-R5
|
||||||
fprintf(stderr, "readb user R%d\n", a - 0177710);
|
D(fprintf(stderr, "readb user R%d\n", a - 0177710);)
|
||||||
return c -> getRegister(true, a - 0177710) & 0xff;
|
return c -> getRegister(true, a - 0177710) & 0xff;
|
||||||
}
|
}
|
||||||
if (a == 0177706) { // kernel SP
|
if (a == 0177706) { // kernel SP
|
||||||
fprintf(stderr, "readb kernel sp\n");
|
D(fprintf(stderr, "readb kernel sp\n");)
|
||||||
return c -> getStackPointer(0) & 0xff;
|
return c -> getStackPointer(0) & 0xff;
|
||||||
}
|
}
|
||||||
if (a == 0177707) { // PC
|
if (a == 0177707) { // PC
|
||||||
fprintf(stderr, "readb pc\n");
|
D(fprintf(stderr, "readb pc\n");)
|
||||||
return c -> getPC() & 0xff;
|
return c -> getPC() & 0xff;
|
||||||
}
|
}
|
||||||
if (a == 0177716) { // supervisor SP
|
if (a == 0177716) { // supervisor SP
|
||||||
fprintf(stderr, "readb supervisor sp\n");
|
D(fprintf(stderr, "readb supervisor sp\n");)
|
||||||
return c -> getStackPointer(1) & 0xff;
|
return c -> getStackPointer(1) & 0xff;
|
||||||
}
|
}
|
||||||
if (a == 0177717) { // user SP
|
if (a == 0177717) { // user SP
|
||||||
fprintf(stderr, "readb user sp\n");
|
D(fprintf(stderr, "readb user sp\n");)
|
||||||
return c -> getStackPointer(3) & 0xff;
|
return c -> getStackPointer(3) & 0xff;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177766) { // cpu error register
|
if (a == 0177766) { // cpu error register
|
||||||
fprintf(stderr, "readb cpuerr\n");
|
D(fprintf(stderr, "readb cpuerr\n");)
|
||||||
return CPUERR & 0xff;
|
return CPUERR & 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (a == 0177576) { // MMR2
|
if (a == 0177576) { // MMR2
|
||||||
fprintf(stderr, "read MMR2\n");
|
D(fprintf(stderr, "read MMR2\n");)
|
||||||
return MMR2;
|
return MMR2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0172516) { // MMR3
|
if (a == 0172516) { // MMR3
|
||||||
fprintf(stderr, "read MMR3\n");
|
D(fprintf(stderr, "read MMR3\n");)
|
||||||
return MMR3;
|
return MMR3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177776) { // PSW
|
if (a == 0177776) { // PSW
|
||||||
fprintf(stderr, "read PSW\n");
|
D(fprintf(stderr, "read PSW\n");)
|
||||||
return c -> getPSW();
|
return c -> getPSW();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,35 +194,34 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
|
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
|
||||||
fprintf(stderr, "read kernel R%d\n", a - 0177700);
|
D(fprintf(stderr, "read kernel R%d\n", a - 0177700);)
|
||||||
return c -> getRegister(false, a - 0177700);
|
return c -> getRegister(false, a - 0177700);
|
||||||
}
|
}
|
||||||
if (a >= 0177710 && a <= 0177715) { // user R0-R5
|
if (a >= 0177710 && a <= 0177715) { // user R0-R5
|
||||||
fprintf(stderr, "read user R%d\n", a - 0177710);
|
D(fprintf(stderr, "read user R%d\n", a - 0177710);)
|
||||||
return c -> getRegister(true, a - 0177710);
|
return c -> getRegister(true, a - 0177710);
|
||||||
}
|
}
|
||||||
if (a == 0177706) { // kernel SP
|
if (a == 0177706) { // kernel SP
|
||||||
fprintf(stderr, "read kernel sp\n");
|
D(fprintf(stderr, "read kernel sp\n");)
|
||||||
return c -> getStackPointer(0);
|
return c -> getStackPointer(0);
|
||||||
}
|
}
|
||||||
if (a == 0177707) { // PC
|
if (a == 0177707) { // PC
|
||||||
fprintf(stderr, "read pc\n");
|
D(fprintf(stderr, "read pc\n");)
|
||||||
return c -> getPC();
|
return c -> getPC();
|
||||||
}
|
}
|
||||||
if (a == 0177716) { // supervisor SP
|
if (a == 0177716) { // supervisor SP
|
||||||
fprintf(stderr, "read supervisor sp\n");
|
D(fprintf(stderr, "read supervisor sp\n");)
|
||||||
return c -> getStackPointer(1);
|
return c -> getStackPointer(1);
|
||||||
}
|
}
|
||||||
if (a == 0177717) { // user SP
|
if (a == 0177717) { // user SP
|
||||||
fprintf(stderr, "read user sp\n");
|
D(fprintf(stderr, "read user sp\n");)
|
||||||
return c -> getStackPointer(3);
|
return c -> getStackPointer(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177766) { // cpu error register
|
if (a == 0177766) { // cpu error register
|
||||||
fprintf(stderr, "read CPUERR\n");
|
D(fprintf(stderr, "read CPUERR\n");)
|
||||||
return CPUERR;
|
return CPUERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tm11 && a >= TM_11_BASE && a < TM_11_END)
|
if (tm11 && a >= TM_11_BASE && a < TM_11_END)
|
||||||
|
@ -240,7 +248,7 @@ uint16_t bus::read(const uint16_t a, const bool word_mode, const bool use_prev)
|
||||||
uint32_t m_offset = pages[apf + is_user * 8].par * 64;
|
uint32_t m_offset = pages[apf + is_user * 8].par * 64;
|
||||||
|
|
||||||
if ((a & 1) && word_mode == 0)
|
if ((a & 1) && word_mode == 0)
|
||||||
fprintf(stderr, "odd addressing\n");
|
D(fprintf(stderr, "odd addressing\n");)
|
||||||
|
|
||||||
D(fprintf(stderr, "READ FROM %o\n", m_offset);)
|
D(fprintf(stderr, "READ FROM %o\n", m_offset);)
|
||||||
if (!word_mode)
|
if (!word_mode)
|
||||||
|
@ -260,7 +268,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
|
||||||
assert(word_mode == 0 || value < 256);
|
assert(word_mode == 0 || value < 256);
|
||||||
|
|
||||||
if (a >= 0160000) {
|
if (a >= 0160000) {
|
||||||
fprintf(stderr, "write%c %o to I/O %o\n", word_mode ? 'b' : ' ', value, a);
|
D(fprintf(stderr, "write%c %o to I/O %o\n", word_mode ? 'b' : ' ', value, a);)
|
||||||
|
|
||||||
if (word_mode) {
|
if (word_mode) {
|
||||||
if (a == 0177776 || a == 0177777) { // PSW
|
if (a == 0177776 || a == 0177777) { // PSW
|
||||||
|
@ -305,57 +313,57 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
|
if (a >= 0177700 && a <= 0177705) { // kernel R0-R5
|
||||||
fprintf(stderr, "write kernel R%d to %o\n", a - 01777700, value);
|
D(fprintf(stderr, "write kernel R%d to %o\n", a - 01777700, value);)
|
||||||
c -> setRegister(false, a - 0177700, value);
|
c -> setRegister(false, a - 0177700, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (a >= 0177710 && a <= 0177715) { // user R0-R5
|
if (a >= 0177710 && a <= 0177715) { // user R0-R5
|
||||||
fprintf(stderr, "write user R%d to %o\n", a - 01777710, value);
|
D(fprintf(stderr, "write user R%d to %o\n", a - 01777710, value);)
|
||||||
c -> setRegister(true, a - 0177710, value);
|
c -> setRegister(true, a - 0177710, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (a == 0177706) { // kernel SP
|
if (a == 0177706) { // kernel SP
|
||||||
fprintf(stderr, "write kernel SP to %o\n", value);
|
D(fprintf(stderr, "write kernel SP to %o\n", value);)
|
||||||
c -> setStackPointer(0, value);
|
c -> setStackPointer(0, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (a == 0177707) { // PC
|
if (a == 0177707) { // PC
|
||||||
fprintf(stderr, "write PC to %o\n", value);
|
D(fprintf(stderr, "write PC to %o\n", value);)
|
||||||
c -> setPC(value);
|
c -> setPC(value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (a == 0177716) { // supervisor SP
|
if (a == 0177716) { // supervisor SP
|
||||||
fprintf(stderr, "write supervisor sp to %o\n", value);
|
D(fprintf(stderr, "write supervisor sp to %o\n", value);)
|
||||||
c -> setStackPointer(1, value);
|
c -> setStackPointer(1, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
if (a == 0177717) { // user SP
|
if (a == 0177717) { // user SP
|
||||||
fprintf(stderr, "write user sp to %o\n", value);
|
D(fprintf(stderr, "write user sp to %o\n", value);)
|
||||||
c -> setStackPointer(3, value);
|
c -> setStackPointer(3, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177766) { // cpu error register
|
if (a == 0177766) { // cpu error register
|
||||||
fprintf(stderr, "write CPUERR %o\n", value);
|
D(fprintf(stderr, "write CPUERR %o\n", value);)
|
||||||
CPUERR = 0;
|
CPUERR = 0;
|
||||||
return CPUERR;
|
return CPUERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0172516) { // MMR3
|
if (a == 0172516) { // MMR3
|
||||||
fprintf(stderr, "write set MMR3 to %o\n", value);
|
D(fprintf(stderr, "write set MMR3 to %o\n", value);)
|
||||||
MMR3 = value;
|
MMR3 = value;
|
||||||
return MMR3;
|
return MMR3;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177772) { // PIR
|
if (a == 0177772) { // PIR
|
||||||
fprintf(stderr, "write set PIR to %o\n", value);
|
D(fprintf(stderr, "write set PIR to %o\n", value);)
|
||||||
PIR = value; // FIXME
|
PIR = value; // FIXME
|
||||||
return PIR;
|
return PIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177546) { // line frequency clock and status register
|
if (a == 0177546) { // line frequency clock and status register
|
||||||
fprintf(stderr, "write set LFC/SR to %o\n", value);
|
D(fprintf(stderr, "write set LFC/SR to %o\n", value);)
|
||||||
CSR = value;
|
CSR = value;
|
||||||
return CSR;
|
return CSR;
|
||||||
}
|
}
|
||||||
|
@ -377,25 +385,25 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
|
||||||
|
|
||||||
/// MMU ///
|
/// MMU ///
|
||||||
if (a >= 0172300 && a < 0172320) {
|
if (a >= 0172300 && a < 0172320) {
|
||||||
fprintf(stderr, "write set PDR for %d to %o\n", (a & 017) >> 1, value);
|
D(fprintf(stderr, "write set PDR for %d to %o\n", (a & 017) >> 1, value);)
|
||||||
pages[((a & 017) >> 1)].pdr = value;
|
pages[((a & 017) >> 1)].pdr = value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0172340 && a < 0172360) {
|
if (a >= 0172340 && a < 0172360) {
|
||||||
fprintf(stderr, "write set PAR for %d to %o\n", (a & 017) >> 1, value);
|
D(fprintf(stderr, "write set PAR for %d to %o\n", (a & 017) >> 1, value);)
|
||||||
pages[((a & 017) >> 1)].par = value;
|
pages[((a & 017) >> 1)].par = value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0117600 && a < 0117620) {
|
if (a >= 0117600 && a < 0117620) {
|
||||||
fprintf(stderr, "write set PDR for %d to %o\n", ((a & 017) >> 1) + 8, value);
|
D(fprintf(stderr, "write set PDR for %d to %o\n", ((a & 017) >> 1) + 8, value);)
|
||||||
pages[((a & 017) >> 1) + 8].pdr = value;
|
pages[((a & 017) >> 1) + 8].pdr = value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a >= 0117640 && a < 0177660) {
|
if (a >= 0117640 && a < 0177660) {
|
||||||
fprintf(stderr, "write set PAR for %d to %o\n", ((a & 017) >> 1) + 8, value);
|
D(fprintf(stderr, "write set PAR for %d to %o\n", ((a & 017) >> 1) + 8, value);)
|
||||||
pages[((a & 017) >> 1) + 8].par = value;
|
pages[((a & 017) >> 1) + 8].par = value;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -413,8 +421,16 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a == 0177566) { // console tty buffer register
|
if (a == 0177566) { // console tty buffer register
|
||||||
fprintf(stderr, "bus::write TTY buffer %c\n", value);
|
D(fprintf(stderr, "bus::write TTY buffer %d / %c\n", value, value);)
|
||||||
|
|
||||||
|
if (value) {
|
||||||
|
#if defined(ESP32)
|
||||||
|
Serial.print(char(value & 127));
|
||||||
|
#else
|
||||||
printf("%c", value & 127);
|
printf("%c", value & 127);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
return 128;
|
return 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -435,7 +451,7 @@ uint16_t bus::write(const uint16_t a, const bool word_mode, uint16_t value, cons
|
||||||
pages[apf].pdr |= 1 << 6; // page has been written to
|
pages[apf].pdr |= 1 << 6; // page has been written to
|
||||||
|
|
||||||
if ((a & 1) && word_mode == 0)
|
if ((a & 1) && word_mode == 0)
|
||||||
fprintf(stderr, "odd addressing\n");
|
D(fprintf(stderr, "odd addressing\n");)
|
||||||
|
|
||||||
D(fprintf(stderr, "WRITE TO: %o\n", m_offset);)
|
D(fprintf(stderr, "WRITE TO: %o\n", m_offset);)
|
||||||
if (word_mode)
|
if (word_mode)
|
||||||
|
|
23
cpu.cpp
23
cpu.cpp
|
@ -194,7 +194,7 @@ uint16_t cpu::getGAM(const uint8_t mode, const uint8_t reg, const bool word_mode
|
||||||
addRegister(7, prev_mode, + 2);
|
addRegister(7, prev_mode, + 2);
|
||||||
temp = b -> read(getRegister(reg, prev_mode) + next_word, word_mode, prev_mode);
|
temp = b -> read(getRegister(reg, prev_mode) + next_word, word_mode, prev_mode);
|
||||||
//fprintf(stderr, "-> %d: %o\n", word_mode, temp);
|
//fprintf(stderr, "-> %d: %o\n", word_mode, temp);
|
||||||
#ifndef NDEBUG
|
#if !defined(NDEBUG) && !defined(ESP32)
|
||||||
if (reg == 7)
|
if (reg == 7)
|
||||||
*text = format("0o%o", getPC() + next_word); // FIXME
|
*text = format("0o%o", getPC() + next_word); // FIXME
|
||||||
else
|
else
|
||||||
|
@ -337,7 +337,7 @@ bool cpu::double_operand_instructions(const uint16_t instr)
|
||||||
const uint8_t src_mode = (src >> 3) & 7;
|
const uint8_t src_mode = (src >> 3) & 7;
|
||||||
const uint8_t src_reg = src & 7;
|
const uint8_t src_reg = src & 7;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#if !defined(NDEBUG) && !defined(ESP32)
|
||||||
std::string debug_a, debug_b;
|
std::string debug_a, debug_b;
|
||||||
std::string *src_gam_text = &debug_a, *dst_gam_text = &debug_b;
|
std::string *src_gam_text = &debug_a, *dst_gam_text = &debug_b;
|
||||||
#endif
|
#endif
|
||||||
|
@ -433,7 +433,7 @@ bool cpu::double_operand_instructions(const uint16_t instr)
|
||||||
if (dst_mode == 0)
|
if (dst_mode == 0)
|
||||||
putGAM(dst_mode, dst_reg, word_mode, result, false, dst_gam_text);
|
putGAM(dst_mode, dst_reg, word_mode, result, false, dst_gam_text);
|
||||||
else {
|
else {
|
||||||
#ifndef NDEBUG
|
#if !defined(NDEBUG) && !defined(ESP32)
|
||||||
dst_gam_text -> assign(format("(%o)", a));
|
dst_gam_text -> assign(format("(%o)", a));
|
||||||
#endif
|
#endif
|
||||||
b -> write(a, word_mode, result);
|
b -> write(a, word_mode, result);
|
||||||
|
@ -479,7 +479,7 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr)
|
||||||
{
|
{
|
||||||
const uint8_t reg = (instr >> 6) & 7;
|
const uint8_t reg = (instr >> 6) & 7;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#if !defined(NDEBUG) && !defined(ESP32)
|
||||||
std::string debug_b;
|
std::string debug_b;
|
||||||
std::string *dst_gam_text = &debug_b;
|
std::string *dst_gam_text = &debug_b;
|
||||||
#endif
|
#endif
|
||||||
|
@ -624,7 +624,7 @@ bool cpu::single_operand_instructions(const uint16_t instr)
|
||||||
int32_t vl = -1;
|
int32_t vl = -1;
|
||||||
uint16_t v = -1;
|
uint16_t v = -1;
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#if !defined(NDEBUG) && !defined(ESP32)
|
||||||
std::string debug_b;
|
std::string debug_b;
|
||||||
std::string *dst_gam_text = &debug_b;
|
std::string *dst_gam_text = &debug_b;
|
||||||
std::string debug_b2;
|
std::string debug_b2;
|
||||||
|
@ -938,7 +938,7 @@ bool cpu::conditional_branch_instructions(const uint16_t instr)
|
||||||
const uint8_t opcode = (instr >> 8) & 255;
|
const uint8_t opcode = (instr >> 8) & 255;
|
||||||
const int8_t offset = instr & 255;
|
const int8_t offset = instr & 255;
|
||||||
bool take = false;
|
bool take = false;
|
||||||
#ifndef NDEBUG
|
#if !defined(NDEBUG) && !defined(ESP32)
|
||||||
std::string name;
|
std::string name;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1102,13 +1102,8 @@ bool cpu::misc_operations(const uint16_t instr)
|
||||||
switch(instr) {
|
switch(instr) {
|
||||||
case 0b0000000000000000: // HALT
|
case 0b0000000000000000: // HALT
|
||||||
D(fprintf(stderr, "HALT\n");)
|
D(fprintf(stderr, "HALT\n");)
|
||||||
haltFlag = true;
|
// pretend HALT is not executed, proceed
|
||||||
{
|
//haltFlag = true;
|
||||||
FILE *fh = fopen("halt.dat", "wb");
|
|
||||||
for(int i=0; i<256; i++)
|
|
||||||
fputc(b -> readByte(getPC() - 2 + i), fh);
|
|
||||||
fclose(fh);
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case 0b0000000000000001: // WAIT
|
case 0b0000000000000001: // WAIT
|
||||||
|
@ -1276,7 +1271,7 @@ bool cpu::step()
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
ok:
|
ok:
|
||||||
#ifndef NDEBUG
|
#if !defined(NDEBUG) && !defined(ESP32)
|
||||||
for(int r=0; r<8; r++)
|
for(int r=0; r<8; r++)
|
||||||
fprintf(stderr, "%06o ", getRegister(r, false));
|
fprintf(stderr, "%06o ", getRegister(r, false));
|
||||||
fprintf(stderr, " | n%dz%dv%dc%d P%dC%d S%d", getPSW_n(), getPSW_z(), getPSW_v(), getPSW_c(), (getPSW() >> 12) & 3, getPSW() >> 14, getBitPSW(11));
|
fprintf(stderr, " | n%dz%dv%dc%d P%dC%d S%d", getPSW_n(), getPSW_z(), getPSW_v(), getPSW_c(), (getPSW() >> 12) & 3, getPSW() >> 14, getBitPSW(11));
|
||||||
|
|
11
error.cpp
11
error.cpp
|
@ -7,23 +7,32 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <regex.h>
|
#include <regex.h>
|
||||||
|
#if defined(ESP32)
|
||||||
|
#include <Arduino.h>
|
||||||
|
#else
|
||||||
#include <ncursesw/ncurses.h>
|
#include <ncursesw/ncurses.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
|
|
||||||
[[ noreturn ]] void error_exit(bool sys_err, const char *format, ...)
|
[[ noreturn ]] void error_exit(bool sys_err, const char *format, ...)
|
||||||
{
|
{
|
||||||
int e = errno;
|
int e = errno;
|
||||||
va_list ap;
|
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
Serial.println(format);
|
||||||
|
#else
|
||||||
(void)endwin();
|
(void)endwin();
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
(void)vfprintf(stderr, format, ap);
|
(void)vfprintf(stderr, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
if (sys_err == TRUE)
|
if (sys_err == TRUE)
|
||||||
fprintf(stderr, "error: %s (%d)\n", strerror(e), e);
|
fprintf(stderr, "error: %s (%d)\n", strerror(e), e);
|
||||||
|
#endif
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
4
gen.h
4
gen.h
|
@ -1,7 +1,11 @@
|
||||||
// (C) 2018-2022 by Folkert van Heusden
|
// (C) 2018-2022 by Folkert van Heusden
|
||||||
// Released under Apache License v2.0
|
// Released under Apache License v2.0
|
||||||
|
#if defined(ESP32)
|
||||||
|
#define D(...) do { } while(0);
|
||||||
|
#else
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#define D(x) do { x } while(0);
|
#define D(x) do { x } while(0);
|
||||||
#else
|
#else
|
||||||
#define D(...) do { } while(0);
|
#define D(...) do { } while(0);
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
7
rk05.cpp
7
rk05.cpp
|
@ -3,9 +3,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "rk05.h"
|
|
||||||
#include "gen.h"
|
|
||||||
#include "bus.h"
|
#include "bus.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "gen.h"
|
||||||
|
#include "rk05.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
const char * const regnames[] = {
|
const char * const regnames[] = {
|
||||||
|
@ -24,6 +25,8 @@ rk05::rk05(const std::string & file, bus *const b) : b(b)
|
||||||
memset(xfer_buffer, 0x00, sizeof xfer_buffer);
|
memset(xfer_buffer, 0x00, sizeof xfer_buffer);
|
||||||
|
|
||||||
fh = fopen(file.c_str(), "rb");
|
fh = fopen(file.c_str(), "rb");
|
||||||
|
if (!fh)
|
||||||
|
error_exit(true, "rk05: cannot open \"%s\"", file.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
rk05::~rk05()
|
rk05::~rk05()
|
||||||
|
|
19
tty.cpp
19
tty.cpp
|
@ -1,7 +1,11 @@
|
||||||
// (C) 2018 by Folkert van Heusden
|
// (C) 2018 by Folkert van Heusden
|
||||||
// // Released under Apache License v2.0
|
// // Released under Apache License v2.0
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#if defined(ESP32)
|
||||||
|
#include <Arduino.h>
|
||||||
|
#else
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
@ -9,9 +13,11 @@
|
||||||
#include "gen.h"
|
#include "gen.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "terminal.h"
|
|
||||||
|
|
||||||
|
#if !defined(ESP32)
|
||||||
|
#include "terminal.h"
|
||||||
extern NEWWIN *w_main;
|
extern NEWWIN *w_main;
|
||||||
|
#endif
|
||||||
|
|
||||||
const char * const regnames[] = {
|
const char * const regnames[] = {
|
||||||
"reader status ",
|
"reader status ",
|
||||||
|
@ -85,14 +91,20 @@ void tty::writeWord(const uint16_t addr, uint16_t v)
|
||||||
D(fprintf(stderr, "PDP11TTY write %o (%s): %o\n", addr, regnames[reg], v);)
|
D(fprintf(stderr, "PDP11TTY write %o (%s): %o\n", addr, regnames[reg], v);)
|
||||||
|
|
||||||
if (v == 0207 && testMode) {
|
if (v == 0207 && testMode) {
|
||||||
fprintf(stderr, "TestMode: TTY 0207 char\n");
|
D(fprintf(stderr, "TestMode: TTY 0207 char\n");)
|
||||||
|
|
||||||
|
#if !defined(ESP32)
|
||||||
exit(0);
|
exit(0);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME
|
// FIXME
|
||||||
if (addr == PDP11TTY_TPB) {
|
if (addr == PDP11TTY_TPB) {
|
||||||
v &= 127;
|
v &= 127;
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
Serial.print(char(v));
|
||||||
|
#else
|
||||||
FILE *tf = fopen("tty.dat", "a+");
|
FILE *tf = fopen("tty.dat", "a+");
|
||||||
if (tf) {
|
if (tf) {
|
||||||
fprintf(tf, "%c", v);
|
fprintf(tf, "%c", v);
|
||||||
|
@ -111,6 +123,7 @@ void tty::writeWord(const uint16_t addr, uint16_t v)
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "punch char: '%c'\n", v);
|
fprintf(stderr, "punch char: '%c'\n", v);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
D(fprintf(stderr, "set register %o to %o\n", addr, v);)
|
D(fprintf(stderr, "set register %o to %o\n", addr, v);)
|
||||||
|
@ -119,10 +132,12 @@ void tty::writeWord(const uint16_t addr, uint16_t v)
|
||||||
|
|
||||||
void tty::sendChar(const char v)
|
void tty::sendChar(const char v)
|
||||||
{
|
{
|
||||||
|
#if !defined(ESP32)
|
||||||
if (c)
|
if (c)
|
||||||
fprintf(stderr, "PDP11TTY: overwriting %d - %c\n", c, c);
|
fprintf(stderr, "PDP11TTY: overwriting %d - %c\n", c, c);
|
||||||
else
|
else
|
||||||
fprintf(stderr, "PDP11TTY: setting character %d - %c\n", v, v);
|
fprintf(stderr, "PDP11TTY: setting character %d - %c\n", v, v);
|
||||||
|
#endif
|
||||||
|
|
||||||
c = v;
|
c = v;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// (C) 2018 by Folkert van Heusden
|
// (C) 2018 by Folkert van Heusden
|
||||||
// Released under Apache License v2.0
|
// Released under Apache License v2.0
|
||||||
|
#if defined(ESP32)
|
||||||
|
#include <Arduino.h>
|
||||||
|
#endif
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -15,6 +18,7 @@ void setBit(uint16_t & v, const int bit, const bool vb)
|
||||||
v |= mask;
|
v |= mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !defined(ESP32)
|
||||||
std::string format(const char *const fmt, ...)
|
std::string format(const char *const fmt, ...)
|
||||||
{
|
{
|
||||||
char *buffer = nullptr;
|
char *buffer = nullptr;
|
||||||
|
@ -29,14 +33,19 @@ std::string format(const char *const fmt, ...)
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned long get_ms()
|
unsigned long get_ms()
|
||||||
{
|
{
|
||||||
|
#if defined(ESP32)
|
||||||
|
return millis();
|
||||||
|
#else
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
|
|
||||||
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
return tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int parity(int v)
|
int parity(int v)
|
||||||
|
|
2
utils.h
2
utils.h
|
@ -8,5 +8,7 @@ int parity(int v);
|
||||||
|
|
||||||
#define sign(a) ( ( (a) < 0 ) ? -1 : ( (a) > 0 ) )
|
#define sign(a) ( ( (a) < 0 ) ? -1 : ( (a) > 0 ) )
|
||||||
|
|
||||||
|
#if !defined(ESP32)
|
||||||
std::string format(const char *const fmt, ...);
|
std::string format(const char *const fmt, ...);
|
||||||
|
#endif
|
||||||
unsigned long get_ms();
|
unsigned long get_ms();
|
||||||
|
|
Loading…
Add table
Reference in a new issue