Skip to content

Commit

Permalink
Alignment with HITECH AGN453 commit 266f7b4eff194f2de7c13c7e47ba0423b…
Browse files Browse the repository at this point in the history
…cf78a6b
  • Loading branch information
tsupplis committed Feb 9, 2022
1 parent bde6f5e commit ec1ceb4
Show file tree
Hide file tree
Showing 19 changed files with 104 additions and 64 deletions.
1 change: 1 addition & 0 deletions abort.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

static char mess[] = "Fatal error - program aborted\r\n$";

void
abort()
{
bdos(CPMWCOB, mess);
Expand Down
4 changes: 2 additions & 2 deletions atan.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ double
atan(f)
double f;
{
static const double coeff_a[] =
static /* const */ double coeff_a[] =
{
33.058618473989548,
58.655751569001961,
Expand All @@ -17,7 +17,7 @@ double f;
0.19523741936234277,
-.0024346033004411264
};
static const double coeff_b[] =
static /* const */ double coeff_b[] =
{
33.058618473992416,
69.675291059524653,
Expand Down
3 changes: 2 additions & 1 deletion atol.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ register char * s;
if(*s == '-') {
sign++;
s++;
}
} else if(*s == '+')
s++;
while(isdigit(*s))
a = a*10L + (*s++ - '0');
if(sign)
Expand Down
2 changes: 1 addition & 1 deletion brelop.as
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; byte relational operation - returns flags correctly for
; comparision of words in a and c
; comparision of words in a and b

psect text
global brelop
Expand Down
2 changes: 1 addition & 1 deletion evalpoly.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
double
eval_poly(x, d, n)
double x;
const double * d;
/* const */ double * d;
int n;
{
int i;
Expand Down
2 changes: 1 addition & 1 deletion exp.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ double x;
int exp;
char sign;

const static double coeff[] =
/* const */ static double coeff[] =
{
1.0000000000e+00,
6.9314718056e-01,
Expand Down
4 changes: 2 additions & 2 deletions filbuf.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* _filbuf for Zios stdio
* _filbuf for HI-TECH C stdio
*/

extern int read(int, void *, int);
Expand Down Expand Up @@ -28,5 +28,5 @@ register FILE * f;
}
f->_ptr = f->_base;
f->_cnt--;
return((unsigned)*f->_ptr++);
return((unsigned char)*f->_ptr++);
}
26 changes: 10 additions & 16 deletions frelop.as
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,21 @@ frelop:
ld a,h ;get the sign of the LHS
or 1 ;ensure zero flag is reset, set sign flag
pop bc ;unjunk stack
jp 1f ;return with sign of LHS
jr 1f ;return with sign of LHS
2:
ld a,h ;test for differing exponents
sub d ;compare with the other
jr z,2f ;the same, go for mantissas
xor h ;complement sign flag if operands -ve
or 1 ;reset zero flag
pop bc ;unjunk stack
jp 1f ;and return
2:
or a
ld a,d ;preserve sign flag
res 7,d ;clear sign flag
res 7,h ;and the other
and 80h ;mask out sign flag
sbc hl,de ;set the flags
pop hl ;low word of 1st into hl again
jr nz,1f ;go return if not zero
jr nz,togs ;go fixup sign flag if different
sbc hl,bc ;now set flags on basis of low word
jr z,1f ;if zero, all ok
ld a,2 ;make non-zero
rra ;rotate carry into sign
or a ;set minus flag
rlca ;put carry flag back

togs:
rr h ;rotate carry into sign
xor h ;toggle sign if necessary
or 1 ;reset zero flag
1:
exx ;get return address
jp (hl) ;and return with stack clean
2 changes: 1 addition & 1 deletion getw.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ register FILE * stream;

if((lo = getc(stream)) == EOF || (hi = getc(stream)) == EOF)
return EOF;
return (hi << 8) + (lo & 0xFF);
return (hi << 8) | (lo & 0xFF);
}
11 changes: 7 additions & 4 deletions idiv.as
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ lmod:

ldiv:
xor a
ex af,af'
push af
ex de,hl
jr dv1

Expand All @@ -30,14 +30,17 @@ adiv:
ld a,h
xor d ;set sign flag for quotient
ld a,h ;get sign of dividend
ex af,af'
push af
call negif
ex de,hl
call negif
dv1: ld b,1
ld a,h
or l
ret z
jr nz,dv8
pop af
ret

dv8: push hl
add hl,hl
jr c,dv2
Expand Down Expand Up @@ -76,7 +79,7 @@ dv3: ex (sp),hl
djnz dv4
pop de
ex de,hl
ex af,af'
pop af
call m,negat
ex de,hl
or a ;test remainder sign bit
Expand Down
2 changes: 1 addition & 1 deletion log.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ double x;
{
int exp;

static const double coeff[] =
static /* const */ double coeff[] =
{
0.0000000000, /* a0 */
0.9999964239, /* a1 */
Expand Down
43 changes: 24 additions & 19 deletions longjmp.as
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,50 @@
global _longjmp, _setjmp

_setjmp:
pop bc ;return address
ex (sp),iy
pop de
push iy
pop bc
push de
ex (sp),iy ;jmp_buf ptr to IY
pop de ;old IY to DE
ld hl,0
add hl,sp
ld (iy+0),l
ld (iy+0),l ;save SP in jmp_buf
ld (iy+1),h
push ix
pop hl
ld (iy+2),l
ld (iy+2),l ;save IX (frame ptr) in jmp_buf
ld (iy+3),h
ld (iy+4),c
ld (iy+4),c ;return address to jmp_buf
ld (iy+5),b
ld (iy+6),e
ld (iy+6),e ;save IY in jmp_buf
ld (iy+7),d
push bc
ld hl,0 ;setjmp returns 0
push de ;restore iy
push de ;restore IY
pop iy
push bc ;return address -> BC
ret

_longjmp:
pop bc ;return address - junk now
pop iy ;argument
pop de ;and return value
ld l,(iy+0)
push de
pop iy ;jmp_buf ptr to IY
ld e,c ;return val to DE
ld d,b
ld l,(iy+0) ;restore SP from jmp_buf
ld h,(iy+1)
ld sp,hl ;stack pointer
ld l,(iy+2)
ld sp,hl
ld l,(iy+2) ;restore IX (frame ptr) from jmp_buf
ld h,(iy+3)
push hl
pop ix
ld l,(iy+4)
ld l,(iy+4) ;return address
ld h,(iy+5)
ld c,(iy+6)
push hl
ld c,(iy+6) ;restore IY from jmp_buf
ld b,(iy+7)
push bc
pop iy
push hl
ex de,hl ;get arg into hl
ld a,l
or h
ret nz ;not allowed to return 0
inc l
ret
4 changes: 3 additions & 1 deletion lrelop.as
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ lrelop:
xor d
jp p,2f ;the same, so ok
ld a,h ;get the sign of the LHS
or 1 ;ensure zero flag is reset, set sign flag
or 2 ;ensure zero flag is reset, set sign flag
ld a,d ;get RHS
rla ;rotate hi bit into carry - Z and S unchanged
pop hl ;unjunk stack
jp 1f ;return with sign of LHS
2:
Expand Down
49 changes: 41 additions & 8 deletions ltof.as
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
global fpnorm

lbtof:
ld e,a
ld d,0
ld l,a
ld h,0
litof:
ex de,hl ;put arg in de
ld l,0 ;zero top byte
Expand All @@ -17,10 +17,10 @@ b3tof:
jp fpnorm

abtof:
ld e,a
ld l,a
rla
sbc a,a
ld d,a
ld h,a

aitof:
bit 7,h ;negative?
Expand All @@ -37,10 +37,43 @@ lltof:
ld a,h ;anything in top byte?
or a
jr z,b3tof ;no, just do 3 bytes
ld e,d ;shift down 8 bits
ld d,l
ld l,h
ld h,64+24+8 ;the 8 compensates for the shift
ld c,0
; Do it the hard way
slop:
ld a,h
cp 1 ;last shift coming up?
jr z,slop2
srl h
rr l
rr d
rr e
inc c
jr slop
slop2:
inc e
jr nz,slop3
inc d
jr nz,slop3
inc l
jr nz,slop3
inc h
slop3:
srl h
rr l
rr d
rr e
ld a,h
or a
jr z,slop4
srl h
rr l
rr d
rr e
inc c
slop4:
ld a,c
add a,64+25
ld h,a
jp fpnorm ;and normalize it

altof:
Expand Down
2 changes: 1 addition & 1 deletion rand.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ unsigned x;

rand()
{
return(((randx = randx*1103515245 + 12345)>>16) & 077777);
return(((randx = randx*1103515245L + 12345)>>16) & 077777);
}
4 changes: 2 additions & 2 deletions sin.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ double
sin(f)
double f;
{
const static double coeff_a[] =
/* const */ static double coeff_a[] =
{
207823.68416961012,
-76586.415638846949,
7064.1360814006881,
-237.85932457812158,
2.8078274176220686
};
const static double coeff_b[] =
/* const */ static double coeff_b[] =
{
132304.66650864931,
5651.6867953169177,
Expand Down
2 changes: 1 addition & 1 deletion strftime.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ static void strfmt(char *str, char *fmt, ...)
while (ilen)
{
ival %= pow[ilen--];
*str++ = '0' + ival / pow[ilen];
*str++ = (char)('0' + ival / pow[ilen]);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions test.sub
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ c -v -r testargs.c
c -v -r testfsiz.c
c -v -r testview.c
c -v -r testsub.c
c -v -r -A testrel.c
c -ftestovrx.sym -v -r testovr.c -lovr
c -y -r -v testovr2.c testovrx.sym
c -y -r -v testovr1.c testovrx.sym
Expand Down
4 changes: 2 additions & 2 deletions ungetc.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include <stdio.h>

/*
* ungetc for Zios
* ungetc for HI-TECH C
*/

ungetc(c, stream)
int c;
register FILE * stream;
{
if(c == EOF || !(stream->_flag & _IOREAD) ||
if(c == EOF || !(stream->_flag & _IOREAD) || stream->_flag & _IODIRN ||
stream->_base == (char *)NULL || stream->_cnt == BUFSIZ)
return(EOF);
if(stream->_ptr == stream->_base)
Expand Down

0 comments on commit ec1ceb4

Please sign in to comment.