"int" is 16 bit on an ESP32
This commit is contained in:
parent
43b2e2ca93
commit
4bdc5272b2
10 changed files with 34 additions and 33 deletions
|
@ -119,10 +119,10 @@ void console_esp32::panel_update_thread()
|
|||
pixels.setPixelColor(b, full_addr & (1 << b) ? led_color : 0);
|
||||
|
||||
for(uint8_t b=0; b<16; b++)
|
||||
pixels.setPixelColor(b + 22, current_PSW & (1 << b) ? magenta : 0);
|
||||
pixels.setPixelColor(b + 22, current_PSW & (1l << b) ? magenta : 0);
|
||||
|
||||
for(uint8_t b=0; b<16; b++)
|
||||
pixels.setPixelColor(b + 38, current_instr & (1 << b) ? red : 0);
|
||||
pixels.setPixelColor(b + 38, current_instr & (1l << b) ? red : 0);
|
||||
|
||||
pixels.setPixelColor(54, running_flag ? white : 0);
|
||||
|
||||
|
|
22
bus.cpp
22
bus.cpp
|
@ -25,7 +25,7 @@ constexpr const int di_ena_mask[4] = { 4, 2, 0, 1 };
|
|||
|
||||
bus::bus()
|
||||
{
|
||||
m = new memory(n_pages * 8192);
|
||||
m = new memory(n_pages * 8192l);
|
||||
|
||||
memset(pages, 0x00, sizeof pages);
|
||||
|
||||
|
@ -372,7 +372,7 @@ uint16_t bus::read(const uint16_t addr_in, const word_mode_t word_mode, const rm
|
|||
}
|
||||
|
||||
// LO size register field must be all 1s, so subtract 1
|
||||
constexpr uint32_t system_size = n_pages * 8192 / 64 - 1;
|
||||
constexpr uint32_t system_size = n_pages * 8192l / 64 - 1;
|
||||
|
||||
if (a == ADDR_SYSSIZE + 2) { // system size HI
|
||||
uint16_t temp = system_size >> 16;
|
||||
|
@ -416,12 +416,12 @@ uint16_t bus::read(const uint16_t addr_in, const word_mode_t word_mode, const rm
|
|||
return temp;
|
||||
}
|
||||
|
||||
void bus::setMMR0(const uint16_t value)
|
||||
void bus::setMMR0(uint16_t value)
|
||||
{
|
||||
value &= ~(3 << 10); // bit 10 & 11 always read as 0
|
||||
|
||||
if (value & 1)
|
||||
value &= ~(7 << 13); // reset error bits
|
||||
value &= ~(7l << 13); // reset error bits
|
||||
|
||||
if (MMR0 & 0160000) {
|
||||
if ((value & 1) == 0)
|
||||
|
@ -543,13 +543,13 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
|
|||
pages[run_mode][d][apf].pdr |= 1 << 7;
|
||||
|
||||
if ((MMR0 & 0160000) == 0) {
|
||||
MMR0 &= ~((1 << 15) | (1 << 14) | (1 << 13) | (1 << 12) | (3 << 5) | (7 << 1));
|
||||
MMR0 &= ~((1l << 15) | (1 << 14) | (1 << 13) | (1 << 12) | (3 << 5) | (7 << 1));
|
||||
|
||||
if (is_write && access_control != 6)
|
||||
MMR0 |= 1 << 13; // read-only
|
||||
//
|
||||
if (access_control == 0 || access_control == 4)
|
||||
MMR0 |= 1 << 15; // not resident
|
||||
MMR0 |= 1l << 15; // not resident
|
||||
else
|
||||
MMR0 |= 1 << 13; // read-only
|
||||
|
||||
|
@ -570,13 +570,13 @@ uint32_t bus::calculate_physical_address(const int run_mode, const uint16_t a, c
|
|||
}
|
||||
}
|
||||
|
||||
if (m_offset >= n_pages * 8192 && !is_io) {
|
||||
DOLOG(debug, !peek_only, "bus::calculate_physical_address %o >= %o", m_offset, n_pages * 8192);
|
||||
if (m_offset >= n_pages * 8192l && !is_io) {
|
||||
DOLOG(debug, !peek_only, "bus::calculate_physical_address %o >= %o", m_offset, n_pages * 8192l);
|
||||
DOLOG(debug, true, "TRAP(04) (throw 6) on address %06o", a);
|
||||
|
||||
if ((MMR0 & 0160000) == 0) {
|
||||
MMR0 &= 017777;
|
||||
MMR0 |= 1 << 15; // non-resident
|
||||
MMR0 |= 1l << 15; // non-resident
|
||||
|
||||
MMR0 &= ~14; // add current page
|
||||
MMR0 |= apf << 1;
|
||||
|
@ -981,7 +981,7 @@ void bus::writePhysical(const uint32_t a, const uint16_t value)
|
|||
{
|
||||
DOLOG(debug, true, "physicalWRITE %06o to %o", value, a);
|
||||
|
||||
if (a >= n_pages * 8192) {
|
||||
if (a >= n_pages * 8192l) {
|
||||
DOLOG(debug, true, "physicalWRITE to %o: trap 004", a);
|
||||
c->trap(004);
|
||||
throw 12;
|
||||
|
@ -993,7 +993,7 @@ void bus::writePhysical(const uint32_t a, const uint16_t value)
|
|||
|
||||
uint16_t bus::readPhysical(const uint32_t a)
|
||||
{
|
||||
if (a >= n_pages * 8192) {
|
||||
if (a >= n_pages * 8192l) {
|
||||
DOLOG(debug, true, "physicalREAD from %o: trap 004", a);
|
||||
c->trap(004);
|
||||
throw 13;
|
||||
|
|
2
bus.h
2
bus.h
|
@ -159,7 +159,7 @@ public:
|
|||
void setMMR0(const uint16_t value);
|
||||
void setMMR0Bit(const int bit);
|
||||
void clearMMR0Bit(const int bit);
|
||||
void setMMR2(const uint16_t value);
|
||||
void setMMR2(uint16_t value);
|
||||
|
||||
void check_odd_addressing(const uint16_t a, const int run_mode, const d_i_space_t space, const bool is_write);
|
||||
void trap_odd(const uint16_t a);
|
||||
|
|
4
cpu.cpp
4
cpu.cpp
|
@ -578,7 +578,7 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr)
|
|||
return true;
|
||||
}
|
||||
|
||||
int32_t R0R1 = (getRegister(reg) << 16) | getRegister(reg | 1);
|
||||
int32_t R0R1 = (uint32_t(getRegister(reg)) << 16) | getRegister(reg | 1);
|
||||
|
||||
int32_t quot = R0R1 / divider;
|
||||
uint16_t rem = R0R1 % divider;
|
||||
|
@ -657,7 +657,7 @@ bool cpu::additional_double_operand_instructions(const uint16_t instr)
|
|||
}
|
||||
|
||||
case 3: { // ASHC
|
||||
uint32_t R0R1 = (getRegister(reg) << 16) | getRegister(reg | 1);
|
||||
uint32_t R0R1 = (uint32_t(getRegister(reg)) << 16) | getRegister(reg | 1);
|
||||
|
||||
auto g_dst = getGAM(dst_mode, dst_reg, wm_word, rm_cur);
|
||||
uint16_t shift = g_dst.value.value() & 077;
|
||||
|
|
|
@ -27,7 +27,7 @@ void recall_configuration(console *const c);
|
|||
#endif
|
||||
|
||||
// returns size of instruction (in bytes)
|
||||
int disassemble(cpu *const c, console *const cnsl, const int pc, const bool instruction_only)
|
||||
int disassemble(cpu *const c, console *const cnsl, const uint16_t pc, const bool instruction_only)
|
||||
{
|
||||
auto data = c->disassemble(pc);
|
||||
|
||||
|
@ -220,7 +220,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
|||
continue;
|
||||
}
|
||||
else if (parts[0] == "disassemble" || parts[0] == "d") {
|
||||
int pc = kv.find("pc") != kv.end() ? std::stoi(kv.find("pc")->second, nullptr, 8) : c->getPC();
|
||||
uint16_t pc = kv.find("pc") != kv.end() ? std::stoi(kv.find("pc")->second, nullptr, 8) : c->getPC();
|
||||
int n = kv.find("n") != kv.end() ? std::stoi(kv.find("n") ->second, nullptr, 10) : 1;
|
||||
|
||||
cnsl->put_string_lf(format("Disassemble %d instructions starting at %o", n, pc));
|
||||
|
@ -312,7 +312,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
|||
if (parts.size() < 3)
|
||||
cnsl->put_string_lf("parameter missing");
|
||||
else {
|
||||
int addr = std::stoi(parts[2], nullptr, 8);
|
||||
uint16_t addr = std::stoi(parts[2], nullptr, 8);
|
||||
int val = -1;
|
||||
|
||||
int n = parts.size() == 4 ? atoi(parts[3].c_str()) : 1;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define NTOHLL(x) ((1==ntohl(1)) ? (x) : (((uint64_t)ntohl((x) & 0xFFFFFFFFUL)) << 32) | ntohl((uint32_t)((x) >> 32)))
|
||||
|
||||
|
||||
disk_backend_nbd::disk_backend_nbd(const std::string & host, const int port) :
|
||||
disk_backend_nbd::disk_backend_nbd(const std::string & host, const unsigned port) :
|
||||
host(host),
|
||||
port(port)
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ bool disk_backend_nbd::connect(const bool retry)
|
|||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
char port_str[8] { 0 };
|
||||
snprintf(port_str, sizeof port_str, "%d", port);
|
||||
snprintf(port_str, sizeof port_str, "%u", port);
|
||||
|
||||
int rc = getaddrinfo(host.c_str(), port_str, &hints, &res);
|
||||
|
||||
|
|
|
@ -11,13 +11,13 @@ class disk_backend_nbd : public disk_backend
|
|||
{
|
||||
private:
|
||||
const std::string host;
|
||||
const int port { 0 };
|
||||
const unsigned port { 0 };
|
||||
int fd { -1 };
|
||||
|
||||
bool connect(const bool retry);
|
||||
|
||||
public:
|
||||
disk_backend_nbd(const std::string & host, const int port);
|
||||
disk_backend_nbd(const std::string & host, const unsigned port);
|
||||
virtual ~disk_backend_nbd();
|
||||
|
||||
bool begin() override;
|
||||
|
|
9
memory.h
9
memory.h
|
@ -3,13 +3,14 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
|
||||
class memory
|
||||
{
|
||||
private:
|
||||
const uint32_t size;
|
||||
uint8_t *m { nullptr };
|
||||
const uint32_t size { 0 };
|
||||
uint8_t *m { nullptr };
|
||||
|
||||
public:
|
||||
memory(const uint32_t size);
|
||||
|
@ -18,8 +19,8 @@ public:
|
|||
void reset();
|
||||
|
||||
uint16_t readByte(const uint32_t a) const { return m[a]; }
|
||||
void writeByte(const uint32_t a, const uint16_t v) { m[a] = v; }
|
||||
void writeByte(const uint32_t a, const uint16_t v) { assert(a < size); m[a] = v; }
|
||||
|
||||
uint16_t readWord(const uint32_t a) const { return m[a] | (m[a + 1] << 8); }
|
||||
void writeWord(const uint32_t a, const uint16_t v) { m[a] = v; m[a + 1] = v >> 8; }
|
||||
void writeWord(const uint32_t a, const uint16_t v) { assert(a < size - 1); m[a] = v; m[a + 1] = v >> 8; }
|
||||
};
|
||||
|
|
10
rk05.cpp
10
rk05.cpp
|
@ -111,11 +111,11 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
|
|||
uint8_t surface = (temp >> 4) & 1;
|
||||
int track = (temp >> 4) & 511;
|
||||
uint16_t cylinder = (temp >> 5) & 255;
|
||||
uint8_t device = temp >> 13;
|
||||
uint16_t device = temp >> 13;
|
||||
|
||||
const int diskoff = track * 12 + sector;
|
||||
const uint32_t diskoff = track * 12 + sector;
|
||||
|
||||
const int diskoffb = diskoff * 512; // RK05 is high density
|
||||
const uint32_t diskoffb = diskoff * 512l; // RK05 is high density
|
||||
const uint16_t memoff = registers[(RK05_BA - RK05_BASE) / 2];
|
||||
|
||||
registers[(RK05_CS - RK05_BASE) / 2] &= ~(1 << 13); // reset search complete
|
||||
|
@ -164,7 +164,7 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
|
|||
|
||||
uint8_t xfer_buffer[512];
|
||||
|
||||
int temp_diskoffb = diskoffb;
|
||||
uint32_t temp_diskoffb = diskoffb;
|
||||
|
||||
uint32_t temp = reclen;
|
||||
uint32_t p = memoff;
|
||||
|
@ -224,7 +224,7 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
|
|||
|
||||
// bit 6, invoke interrupt when done vector address 220, see http://www.pdp-11.nl/peripherals/disk/rk05-info.html
|
||||
if (v & 64) {
|
||||
registers[(RK05_DS - RK05_BASE) / 2] &= ~(7 << 13); // store id of the device that caused the interrupt
|
||||
registers[(RK05_DS - RK05_BASE) / 2] &= ~(7l << 13); // store id of the device that caused the interrupt
|
||||
registers[(RK05_DS - RK05_BASE) / 2] |= device << 13;
|
||||
|
||||
b->getCpu()->queue_interrupt(5, 0220);
|
||||
|
|
2
rl02.cpp
2
rl02.cpp
|
@ -124,7 +124,7 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
|
|||
|
||||
uint32_t memory_address = registers[(RL02_BAR - RL02_BASE) / 2];
|
||||
|
||||
uint32_t count = (65536 - registers[(RL02_MPR - RL02_BASE) / 2]) * 2;
|
||||
uint32_t count = (65536l - registers[(RL02_MPR - RL02_BASE) / 2]) * 2;
|
||||
|
||||
DOLOG(debug, true, "RL02 read %d bytes (dec) from %d (dec) to %06o (oct)", count, disk_offset, memory_address);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue