From ff9f76ea13cd50a264e5d997f27976f774a8618e Mon Sep 17 00:00:00 2001 From: crc Date: Mon, 2 Mar 2020 21:49:51 +0000 Subject: [PATCH] add instruction values in invalid instruction reporting FossilOrigin-Name: 542a1fd386688404e0e562f3bb3bcbbff8825b06ad669a236848a1c8ba6f6b09 --- vm/nga-c-native-x86/image.c | 2 +- vm/nga-c-native-x86/x86/ata.retro | 32 +++++++++++++++++-------------- vm/nga-c/retro-unix.c | 10 +++++++++- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/vm/nga-c-native-x86/image.c b/vm/nga-c-native-x86/image.c index 962f874..48cee02 100644 --- a/vm/nga-c-native-x86/image.c +++ b/vm/nga-c-native-x86/image.c @@ -55,7 +55,7 @@ CELL ngaImage[] = { 1793,13583,13573,13671,202004,0,10,1,10,2,10,3,10,4,10,5,10, 111,110,0,971,412,144,105,0,982,105,144,100,0,987,406,144,114,0,992,335, 144,101,114,114,58,110,111,116,102,111,117,110,100,0,0,0,0,0,0,0, 0,0,0,0,0,0,125,125,0,45,104,111,111,107,0,111,117,110,100,0, - 100,0,72,0,83,0,95,78,79,84,95,70,79,85,78,68,0,125,126,0, + 100,0,72,0,83,0,45,45,45,45,0,70,79,85,78,68,0,125,126,0, 72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/vm/nga-c-native-x86/x86/ata.retro b/vm/nga-c-native-x86/x86/ata.retro index aa2456d..1ab230d 100644 --- a/vm/nga-c-native-x86/x86/ata.retro +++ b/vm/nga-c-native-x86/x86/ata.retro @@ -1,5 +1,7 @@ # ATA (Hard Disk) Driver +This implements a basic PIO mode ATA driver. + The code here works (at least under qemu), but is *very* dangerous to use. It will allow you to read or write a sector to/from a dedicated `ata:Sector` buffer. No checks @@ -15,22 +17,24 @@ are made to validate the sector number. Using these (esp. # Constants ~~~ -0x20 'ata:READ const -0x30 'ata:WRITE const +0x20 'ata:READ const +0x30 'ata:WRITE const 0xE7 'ata:FLUSH-CACHE const -0x1F0 'ata:PRIMARY const -0x1F0 'ata:DATA const -0x1F1 'ata:ERROR const -0x1F1 'ata:FEATURES const -0x1F2 'ata:SECTOR-COUNT const -0x1F3 'ata:SECTOR-NUMBER const -0x1F4 'ata:CYLINDER-LOW const -0x1F5 'ata:CYLINDER-HIGH const -0x1F6 'ata:DRIVE const -0x1F6 'ata:HEAD const -0x1F7 'ata:STATUS const -0x1F7 'ata:COMMAND const +(port (name (access_modes +(---- (----------------------- (------------ +0x1F0 'ata:PRIMARY const +0x1F0 'ata:DATA const (rw +0x1F1 'ata:ERROR const (r +0x1F1 'ata:FEATURES const (w +0x1F2 'ata:SECTOR-COUNT const (rw +0x1F3 'ata:SECTOR-NUMBER const (rw +0x1F4 'ata:CYLINDER-LOW const (rw +0x1F5 'ata:CYLINDER-HIGH const (rw +0x1F6 'ata:DRIVE const (rw +0x1F6 'ata:HEAD const (rw +0x1F7 'ata:STATUS const (r +0x1F7 'ata:COMMAND const (w 0x3F6 'ata:PRIMARY-DCR-AS const ~~~ diff --git a/vm/nga-c/retro-unix.c b/vm/nga-c/retro-unix.c index 9085fb4..011f0a8 100644 --- a/vm/nga-c/retro-unix.c +++ b/vm/nga-c/retro-unix.c @@ -297,7 +297,7 @@ void io_image_query() { ---------------------------------------------------------------------*/ void rre_execute(CELL cell, int silent) { - CELL a, b, token; + CELL a, b, i, token; CELL opcode; silence_input = silent; rp = 1; @@ -317,6 +317,14 @@ void rre_execute(CELL cell, int silent) { } else { printf("\nERROR (nga/rre_execute): Invalid instruction!\n"); printf("At %lld, opcode %lld\n", (long long)ip, (long long)opcode); + printf("Instructions: "); + a = opcode; + for (i = 0; i < 4; i++) { + b = a & 0xFF; + printf("%d ", b); + a = a >> 8; + } + printf("\n"); exit(1); } #ifndef NOCHECKS