Any information would be appreciated - thanks in advance.
David Brown
Varian Instruments
2700 Mitchell DR
Walnut Creek Ca 94598
(415) 939-2400 x288
...decvax!sytek!zehntel!varian!david
The stack frame is the same on PDP-11 System III as on V7, as is cret.
However,
jsr r0,csav
is generated instead of the V7
jsr r5,csv
in order to solve a problem with interrupting csv (the new one is also
slightly faster). Support for both is in the System III library, and
both old-compiled and new-compiled object modules can be mixed in one
executable image.
/**** uldiv.c, by John Woods, October 9, 1982 ****/
unsigned long uldiv(a,b) unsigned long a,b; {
return((unsigned long)((double)a / (double)b));
}
unsigned long auldiv(a,b) unsigned long *a,b; {
return(*a = ((unsigned long)((double)*a / (double)b)));
}
unsigned long ulmul(a,b) unsigned long a,b; {
return((unsigned long)((double)a * (double)b));
}
unsigned long aulmul(a,b) unsigned long *a,b; {
return(*a = ((unsigned long)((double)*a * (double)b)));
}
/****************/
The following is a massaged assembly language version which avoids some of the
overhead of C procedure discipline: (It was compiled -S by PCC and -O'd by me).
/**** uldiv.s, by John Woods, October 9, 1982 ****/
.text
.globl uldiv
uldiv:
/ line 2, file "uldiv.c"
setl
movif 2.(sp),fr0
cfcc
bpl 1f
addf $050200,fr0
1:
movif 6.(sp),fr1
cfcc
bpl 1f
addf $050200,fr1
1:
divf fr1,fr0
movfi fr0,-(sp)
seti
mov (sp)+,r0
mov (sp)+,r1
rts pc
.globl fltused
.globl auldiv
auldiv:
/ line 5, file "uldiv.c"
mov 2.(sp),r1
mov (r1)+,r0
mov (r1),r1
mov r1,-(sp)
mov r0,-(sp)
setl
movif (sp)+,fr0
cfcc
bpl 1f
addf $050200,fr0
1:
movif 4.(sp),fr1
cfcc
bpl 1f
addf $050200,fr1
1:
divf fr1,fr0
movfi fr0,-(sp)
seti
mov (sp)+,r0
mov (sp)+,r1
mov 2.(sp),r2
mov r0,(r2)+
mov r1,(r2)
rts pc
.globl fltused
.globl ulmul
ulmul:
/ line 8, file "uldiv.c"
setl
movif 2.(sp),fr0
seti
cfcc
bpl 1f
addf $050200,fr0
1:
setl
movif 6.(sp),fr1
cfcc
bpl 1f
addf $050200,fr1
1:
mulf fr1,fr0
movfi fr0,-(sp)
seti
mov (sp)+,r0
mov (sp)+,r1
rts pc
.globl fltused
.globl aulmul
aulmul:
/ line 11, file "uldiv.c"
mov 2.(sp),r1
mov (r1)+,r0
mov (r1),r1
mov r1,-(sp)
mov r0,-(sp)
setl
movif (sp)+,fr0
cfcc
bpl 1f
addf $050200,fr0
1:
setl
movif 4.(sp),fr1
cfcc
bpl 1f
addf $050200,fr1
1:
mulf fr1,fr0
movfi fr0,-(sp)
seti
mov (sp)+,r0
mov (sp)+,r1
mov 2.(sp),r2
mov r0,(r2)+
mov r1,(r2)
rts pc
.globl fltused
.data
/*
* Check for bug in PDP-11 long division routines
*/
long int i, j, k;
main ()
{
i = 020000000000;
j = 1;
k = i / j;
printf ("%lo %lo %lo\n", i, j, k);
}