Merge pull request #200 from davidgiven/dtrg-cpm

Various CP/M fixes
This commit is contained in:
David Given 2019-06-18 00:13:58 +02:00 committed by GitHub
commit 9d0f03822c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 33 additions and 30 deletions

View file

@ -14,6 +14,8 @@
#error Unsupported EM_PSIZE #error Unsupported EM_PSIZE
#endif #endif
#define MASK ((1<<SHIFT)-1)
extern FILE* input_unit; extern FILE* input_unit;
extern FILE* output_unit; extern FILE* output_unit;

View file

@ -173,6 +173,8 @@ void patch_addresses(uintptr_t** p)
while (*p) while (*p)
{ {
uintptr_t* q = *p++; uintptr_t* q = *p++;
if (*q & MASK)
abort();
*q >>= SHIFT; *q >>= SHIFT;
} }
} }

View file

@ -7,7 +7,8 @@
#define in_ap(y) /* nothing */ #define in_ap(y) /* nothing */
#define newilb(x) fprintf(codefile,"%s:\n",x) #define newilb(x) fprintf(codefile,"%s:\n",x)
#define newdlb(x) fprintf(codefile,"%s:\n",x) #define newdlb(x) fprintf(codefile,".align 2\n%s:\n",x)
#define newplb(x) fprintf(codefile,".align 2\n%s:\n", x)
#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y) #define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y)
#define newlbss(l,x) fprintf(codefile,".comm %s,%u\n",l,x); #define newlbss(l,x) fprintf(codefile,".comm %s,%u\n",l,x);

View file

@ -1089,6 +1089,7 @@ with hl_or_de
gen dcx %1 yields %1 gen dcx %1 yields %1
pat del pat del
kills dereg, hlreg
uses hlreg={const2,$1} uses hlreg={const2,$1}
gen gen
dad lb dad lb

View file

@ -21,6 +21,7 @@ You must specify the appropriate word size, then REMOVE tables.c
#define newilb(x) fprintf(codefile,"%s:\n",x) #define newilb(x) fprintf(codefile,"%s:\n",x)
#define newdlb(x) fprintf(codefile,"%s:\n",x) #define newdlb(x) fprintf(codefile,"%s:\n",x)
#define newplb(x) fprintf(codefile,".align 4\n%s:\n",x)
#define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y) #define dlbdlb(x,y) fprintf(codefile,"%s = %s\n",x,y)
#define newlbss(l,x) fprintf(codefile,".comm %s,%ld\n",l,x); #define newlbss(l,x) fprintf(codefile,".comm %s,%ld\n",l,x);

View file

@ -10,10 +10,10 @@
.sect .data .sect .data
.sect .bss .sect .bss
MAX_ARGV = 8 MAX_ARGV = 10
.sect .bss .sect .bss
STACKSIZE = 2*1024 STACKSIZE = 512
.comm stack, STACKSIZE .comm stack, STACKSIZE
.sect .text .sect .text
@ -140,6 +140,7 @@ __exit:
saved_sp = . + 1 saved_sp = . + 1
lxi sp, 0 ! patched on startup lxi sp, 0 ! patched on startup
ret ret
.align 2
! Emergency exit routine. ! Emergency exit routine.
@ -181,7 +182,8 @@ _cpm_cmdline = 0x0081
! Used to store the argv array. ! Used to store the argv array.
argc: .space 1 ! number of args .sect .bss
argc: .space 2 ! number of args
argv0: .space 2 ! always points at progname argv0: .space 2 ! always points at progname
argv: .space 2*MAX_ARGV ! argv array (must be after argv0) argv: .space 2*MAX_ARGV ! argv array (must be after argv0)
envp: .space 2 ! envp array (always empty, must be after argv) envp: .space 2 ! envp array (always empty, must be after argv)
@ -195,7 +197,7 @@ envp: .space 2 ! envp array (always empty, must be after argv)
.comm .retadr, 2 ! used to save return address .comm .retadr, 2 ! used to save return address
.comm .retadr1, 2 ! reserve .comm .retadr1, 2 ! reserve
.comm .bcreg, 2 .comm .bcreg, 2
.comm .areg, 1 .comm .areg, 2
.comm .tmp1, 2 .comm .tmp1, 2
.comm .fra, 8 ! 8 bytes function return area .comm .fra, 8 ! 8 bytes function return area
block1: .space 4 ! used by 32 bits divide and block1: .space 4 ! used by 32 bits divide and

View file

@ -12,9 +12,9 @@
void _sys_write_tty(char c) void _sys_write_tty(char c)
{ {
cpm_conout(c);
if (c == '\n') if (c == '\n')
cpm_conout(c); cpm_conout('\r');
cpm_conout(c);
} }
ssize_t write(int fd, void* buffer, size_t count) ssize_t write(int fd, void* buffer, size_t count)

View file

@ -4,6 +4,9 @@ plat_testsuite {
name = "tests", name = "tests",
plat = "cpm", plat = "cpm",
method = "plat/cpm/emu+emu", method = "plat/cpm/emu+emu",
skipsets = {"floats"}, skipsets = {
"b", -- B is broken on i80
"floats" -- floats aren't supported
},
tests = { "./*.c" }, tests = { "./*.c" },
} }

View file

@ -1,4 +1,5 @@
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <cpm.h> #include <cpm.h>
#include "test.h" #include "test.h"

View file

@ -44,19 +44,6 @@ begtext:
jmp (__m_a_i_n) jmp (__m_a_i_n)
#if 0
mov eax, (esp) ! eax = argc
lea ebx, 4(esp) ! ebx = argv
lea ecx, (esp)(eax*4)
add ecx, 12 ! environ
push ecx ! environ
push ebx ! argc
push eax ! argv
push eax ! dummy, representing the return argument
xor ebp, ebp
#endif
! This provides an emergency exit routine used by EM. ! This provides an emergency exit routine used by EM.
.define EXIT .define EXIT

View file

@ -3,19 +3,19 @@
# $Revision$ # $Revision$
var w=2 var w=2
var wa=1 var wa=2
var p=2 var p=2
var pa=1 var pa=2
var s=2 var s=2
var sa=1 var sa=2
var l=4 var l=4
var la=1 var la=2
var f=4 var f=4
var fa=1 var fa=2
var d=8 var d=8
var da=1 var da=2
var x=8 var x=8
var xa=1 var xa=2
var ARCH=i86 var ARCH=i86
var PLATFORM=pc86 var PLATFORM=pc86
var PLATFORMDIR={EM}/share/ack/{PLATFORM} var PLATFORMDIR={EM}/share/ack/{PLATFORM}

View file

@ -4,8 +4,6 @@
/* /*
* Uses _rck_ for range checks. Catches the EM trap if a value is out * Uses _rck_ for range checks. Catches the EM trap if a value is out
* of range, and continues with the next instruction after _rck_. * of range, and continues with the next instruction after _rck_.
*
* Some back ends, like i80, ignore _rck_, so this test fails.
*/ */
testnr testnr
@ -19,6 +17,11 @@ caught
exp $_m_a_i_n exp $_m_a_i_n
pro $_m_a_i_n,0 pro $_m_a_i_n,0
/* These architecture ignore _rck_. */
#if defined i80
cal $finished
#endif
lim ; load ignore mask lim ; load ignore mask
loc 2 loc 2
and EM_WSIZE ; check bit 1 << ERANGE and EM_WSIZE ; check bit 1 << ERANGE