Adapted for use of ACK VAX assembler
This commit is contained in:
parent
7babff444a
commit
0ce4d37e54
3 changed files with 34 additions and 85 deletions
|
@ -42,7 +42,7 @@ con_mult(sz)
|
|||
{
|
||||
if (sz != 4)
|
||||
fatal("bad icon/ucon size");
|
||||
fprintf(codefile,".long\t%s\n",str);
|
||||
fprintf(codefile,".data4\t%s\n",str);
|
||||
}
|
||||
|
||||
mes(mesno)
|
||||
|
@ -51,40 +51,15 @@ mes(mesno)
|
|||
while (getarg(any_ptyp) != sp_cend );
|
||||
}
|
||||
|
||||
con_float()
|
||||
{
|
||||
/*
|
||||
* Insert a dot at the right position, if it is not present,
|
||||
* to make the floating point constant acceptable to the assembler.
|
||||
*/
|
||||
register char *c;
|
||||
extern char *index();
|
||||
|
||||
if (argval != 4 && argval != 8)
|
||||
fatal("bad fcon size");
|
||||
if (argval == 8)
|
||||
fprintf(codefile,".double\t0d");
|
||||
else fprintf(codefile,".float\t0f");
|
||||
|
||||
if (index(str,'.') != (char *) 0) {
|
||||
fprintf(codefile,"%s\n",str);
|
||||
|
||||
/*
|
||||
* There must be a dot after the `e' or - if the `e' is not present -
|
||||
* at the end.
|
||||
*/
|
||||
} else if ((c = index(str,'e')) != (char *) 0) {
|
||||
*c++ = '\0';
|
||||
fprintf(codefile,"%s.e%s\n",str,c--);
|
||||
*c = 'e';
|
||||
} else fprintf(codefile,"%s.\n",str);
|
||||
}
|
||||
#define PDPFLOAT
|
||||
#define CODE_GENERATOR
|
||||
#include <con_float>
|
||||
|
||||
#ifndef REGVARS
|
||||
prolog(nlocals)
|
||||
full nlocals;
|
||||
{
|
||||
fprintf(codefile,".word 00\n");
|
||||
fprintf(codefile,".data2 00\n");
|
||||
if (nlocals == 0)
|
||||
return;
|
||||
if (nlocals == 4)
|
||||
|
@ -98,10 +73,10 @@ prolog(nlocals)
|
|||
#endif not REGVARS
|
||||
|
||||
char *segname[] = {
|
||||
".text", /* SEGTXT */
|
||||
".data", /* SEGCON */
|
||||
".data", /* SEGROM */
|
||||
".data" /* SEGBSS */
|
||||
".sect .text", /* SEGTXT */
|
||||
".sect .data", /* SEGCON */
|
||||
".sect .rom", /* SEGROM */
|
||||
".sect .bss" /* SEGBSS */
|
||||
};
|
||||
|
||||
#ifdef REGVARS
|
||||
|
@ -149,7 +124,7 @@ regsave(str, off, size)
|
|||
p_reg->sr_off = off;
|
||||
(p_reg++)->sr_size = size;
|
||||
fprintf(codefile,
|
||||
"\t# Local %ld, size %d, to register %s\n",
|
||||
"\t! Local %ld, size %d, to register %s\n",
|
||||
off, size, str
|
||||
);
|
||||
}
|
||||
|
@ -182,7 +157,7 @@ f_regsave()
|
|||
/*
|
||||
* Now generate code to save registers.
|
||||
*/
|
||||
fprintf(codefile, ".word 0%o\n", mask);
|
||||
fprintf(codefile, ".data2 0%o\n", mask);
|
||||
/*
|
||||
* Emit code to initialize parameters in registers.
|
||||
*/
|
||||
|
|
|
@ -3,27 +3,29 @@
|
|||
* See the copyright notice in the ACK home directory, in the file "Copyright".
|
||||
*/
|
||||
/* $Header$ */
|
||||
#define ex_ap(x) fprintf(codefile,".globl\t%s\n",x)
|
||||
#define ex_ap(x) fprintf(codefile,".extern\t%s\n",x)
|
||||
#define in_ap(x) /* nothing */
|
||||
|
||||
#define newilb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define newdlb(x) fprintf(codefile,"%s:\n",x)
|
||||
#define newplb(x) fprintf(codefile,".align 1\n%s:\n",x)
|
||||
#define dlbdlb(s1,s2) fprintf(codefile,".data\n%s:\n",s1)
|
||||
#define newlbss(l,x) fprintf(codefile,".lcomm\t%s,%d\n",l,x);
|
||||
#define dlbdlb(s1,s2) fprintf(codefile,"%s = %s\n",s1, s2)
|
||||
#define newlbss(l,x) fprintf(codefile,".comm\t%s,%ld\n",l,x);
|
||||
|
||||
#define cst_fmt "%ld"
|
||||
#define off_fmt "%ld"
|
||||
#define ilb_fmt "L%xL%x"
|
||||
#define dlb_fmt "_%d"
|
||||
#define ilb_fmt "I%x_%x"
|
||||
#define dlb_fmt "I_%d"
|
||||
#define hol_fmt "hol%d"
|
||||
|
||||
#define fmt_id(fr,to) sprintf(to,"_%s",fr)
|
||||
|
||||
#define hol_off "%ld+hol%d"
|
||||
|
||||
#define con_cst(w) fprintf(codefile,".long\t%ld\n",w)
|
||||
#define con_ilb(x) fprintf(codefile,".long\t%s\n",x)
|
||||
#define con_dlb(x) fprintf(codefile,".long\t%s\n",x)
|
||||
#define con_cst(w) fprintf(codefile,".data4\t%ld\n",w)
|
||||
#define con_ilb(x) fprintf(codefile,".data4\t%s\n",x)
|
||||
#define con_dlb(x) fprintf(codefile,".data4\t%s\n",x)
|
||||
|
||||
#define BSS_INIT 0
|
||||
|
||||
#define modhead ".sect .text\n.sect .rom\n.sect .data\n.sect .bss\n"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#define DORCK /* define if you want RCK */
|
||||
#define FLOAT4 /* define if you want better 4-byte FP arithmetic */
|
||||
#define FLOAT8 /* define if you want better 8-byte FP arithmetic */
|
||||
#define ASBUG_AVOID /* define if you want to avoid a bug in the BSD 4.1 VAX
|
||||
/* #define ASBUG_AVOID /* define if you want to avoid a bug in the BSD 4.1 VAX
|
||||
assembler, that sometimes generates "*1" for
|
||||
(r1). This is avoided by generating 0(r1), which is
|
||||
optimized by the assembler to (r1).
|
||||
|
@ -87,8 +87,6 @@ CONST1 = {INT num;} 4 cost=(4,3) "$%[num]"
|
|||
CONST2 = {INT num;} 4 cost=(4,3) "$%[num]"
|
||||
CONST4 = {INT num;} 4 cost=(4,3) "$%[num]"
|
||||
CONST8 = {STRING ind;} 8 cost=(8,6) "$%[ind]"
|
||||
FCONST4 = {INT num;} 4 cost=(4,3) "$0f%[num].0"
|
||||
FCONST8 = {INT num;} 8 cost=(8,6) "$0f%[num].0"
|
||||
LOCAL1 = {REGISTER reg; INT num,size;} 4 cost=(2,6) "%[num](%[reg])"
|
||||
LOCAL2 = {REGISTER reg; INT num,size;} 4 cost=(2,6) "%[num](%[reg])"
|
||||
LOCAL4 = {REGISTER reg; INT num,size;} 4 cost=(2,6) "%[num](%[reg])"
|
||||
|
@ -196,7 +194,7 @@ source2 = Xsource2
|
|||
+ reginc2 + regdec2
|
||||
#endif REGVARS
|
||||
Xsource4 = REG + regdef4 + displ4 + displdef4 + LocaLBase +
|
||||
EXTERNAL4 + reldef4 + CONST + DOUBLE + LOCAL4 + FCONST4 + ind4
|
||||
EXTERNAL4 + reldef4 + CONST + DOUBLE + LOCAL4 + ind4
|
||||
source4 = Xsource4
|
||||
#ifdef REGVARS
|
||||
+ RREG + reginc4 + regdec4
|
||||
|
@ -205,7 +203,7 @@ dups4 = CONST + regdef1 + displ1 + LOCAL1 +
|
|||
REG + regdef2 + displ2 + LOCAL2 +
|
||||
RREG + regdef4 + displ4 + LOCAL4 + DOUBLE
|
||||
Xsource8 = QREG + regdef8 + displ8 + displdef8 +
|
||||
EXTERNAL8 + reldef8 + CONST8 + LOCAL8 + FCONST8
|
||||
EXTERNAL8 + reldef8 + CONST8 + LOCAL8
|
||||
+ extind8 + displind8 + extdefind8 + displdefind8
|
||||
source8 = Xsource8
|
||||
#ifdef REGVARS
|
||||
|
@ -1652,7 +1650,9 @@ ngf !defined($1) | source1or2or4 |
|
|||
fif $1==4 | source4 source4 |
|
||||
allocate(%[1],%[2],REG,REG)
|
||||
"mulf3\t%[1],%[2],%[a]"
|
||||
"emodf\t%[a],$$0,$$0f1.0,-(sp),%[b]"
|
||||
/* the assembler does not do immediate floating point */
|
||||
"cvtlf $$1,%[b]"
|
||||
"emodf\t%[a],$$0,%[b],-(sp),%[b]"
|
||||
/*
|
||||
* Don't trust the integer part.
|
||||
* Overflow could occur.
|
||||
|
@ -1662,7 +1662,8 @@ fif $1==4 | source4 source4 |
|
|||
fif $1==8 | source8 source8 |
|
||||
allocate(%[1],%[2],QREG,QREG)
|
||||
"muld3\t%[1],%[2],%[a]"
|
||||
"emodd\t%[a],$$0,$$0f1.0,-(sp),%[b]"
|
||||
"cvtld $$1,%[b]"
|
||||
"emodd\t%[a],$$0,%[b],-(sp),%[b]"
|
||||
"tstl\t(sp)+"
|
||||
"subd2\t%[b],%[a]" | %[b] %[a] | |
|
||||
fif !defined($1) | source1or2or4 |
|
||||
|
@ -1670,18 +1671,11 @@ fif !defined($1) | source1or2or4 |
|
|||
move(%[1],R0)
|
||||
"jsb\t.fif"
|
||||
erase(R0) | | |
|
||||
fef $1==4 | sreg4 |
|
||||
allocate(REG)
|
||||
"extzv\t$$7,$$8,%[1],%[a]"
|
||||
"subl2\t$$128,%[a]"
|
||||
"insv\t$$128,$$7,$$8,%[1]"
|
||||
erase(%[1]) | %[1] %[a] | |
|
||||
fef $1==8 | sreg8 |
|
||||
allocate(REG)
|
||||
"extzv\t$$7,$$8,%[1],%[a]"
|
||||
"subl2\t$$128,%[a]"
|
||||
"insv\t$$128,$$7,$$8,%[1]"
|
||||
erase(%[1]) | %[1] %[a] | |
|
||||
fef defined($1) | |
|
||||
remove(ALL)
|
||||
move({CONST4, $1}, R0)
|
||||
"jsb\t.fef"
|
||||
erase(R0) | | |
|
||||
fef !defined($1) | source1or2or4 |
|
||||
remove(ALL)
|
||||
move(%[1],R0)
|
||||
|
@ -2054,9 +2048,6 @@ zrl zrl $1==$2-4 | | | | zrl $2 zrl $1 |
|
|||
zre | | remove(externals)
|
||||
"clrl\t$1"
|
||||
setcc({EXTERNAL4,$1}) | | |
|
||||
/* Avoid a bug in the VAX assembler, that handles $0f0.0 wrong.
|
||||
So, do NOT create {FCONST[4|8], 0}!
|
||||
*/
|
||||
zrf $1==4 | | allocate(REG)
|
||||
"clrl\t%[a]" | %[a] | |
|
||||
zrf $1==8 | | allocate(QREG)
|
||||
|
@ -2249,8 +2240,6 @@ loc loc cif stl $1==4 && $2==4 && $4>=0
|
|||
loc loc cif ste $1==4 && $2==4 | source4 |
|
||||
remove(externals)
|
||||
"cvtlf\t%[1],$4" | | |
|
||||
loc loc loc cif $1!=0 && $2==4 && $3==4 | | | {FCONST4, $1} | |
|
||||
/* $1 != 0: kludge to avoid bug in VAX assembler */
|
||||
#endif FLOAT4
|
||||
loc loc cif $1==4 && $2==4 | source4 |
|
||||
allocate(%[1],REG)
|
||||
|
@ -2279,11 +2268,6 @@ loc loc cif sdl $1==4 && $2==8 && $4>=0
|
|||
loc loc cif sde $1==4 && $2==8 | source4 |
|
||||
remove(externals)
|
||||
"cvtld\t%[1],$4" | | |
|
||||
loc loc loc cif $1!=0 && $2==4 && $3==8 | | | {FCONST8,$1} | |
|
||||
/* $1!=0: kludge to avoid known bug in Vax assembler, that
|
||||
* doesn't handle 0f0.0 (and other numbers that have the 0x4000 bit off
|
||||
* in the exponent) right.
|
||||
*/
|
||||
#endif FLOAT8
|
||||
loc loc cif $1==4 && $2==8 | source4 |
|
||||
allocate(%[1],QREG)
|
||||
|
@ -4570,14 +4554,6 @@ MOVES:
|
|||
setcc(%[2]), (2,4)+%[2])
|
||||
(CONST8 %[ind]=="0",source8, "clrq\t%[2]"
|
||||
setcc(%[2]), (2,4)+%[2])
|
||||
(FCONST4 %[num]==0,source4, "clrl\t%[2]"
|
||||
setcc(%[2]), (2,4)+%[2])
|
||||
(FCONST4,source4, "movf\t%[1],%[2]"
|
||||
setcc(%[2]), (3,4)+%[1]+%[2])
|
||||
(FCONST8 %[num]==0,source8, "clrq\t%[2]"
|
||||
setcc(%[2]), (2,4)+%[2])
|
||||
(FCONST8,source8, "movd\t%[1],%[2]"
|
||||
setcc(%[2]), (3,4)+%[1]+%[2])
|
||||
#ifdef REGVARS
|
||||
/* Tokens with side effects should not be remembered. */
|
||||
(reginc1+regdec1,reg4, "movzbl\t%[1],%[2]"
|
||||
|
@ -4640,10 +4616,6 @@ STACKS:
|
|||
(source1,, "movzbl\t%[1],-(sp)", (3,7) + %[1])
|
||||
(CONST sfit(%[num],16),,
|
||||
"cvtwl\t%[1],-(sp)", (3,7) + %[1])
|
||||
(FCONST4,, "pushl\t%[1]", (2,7) + %[1])
|
||||
(FCONST8 %[num]==0,,
|
||||
"clrq\t-(sp)", (2,10))
|
||||
(FCONST8,, "movd\t%[1],-(sp)", (3,10) + %[1])
|
||||
(source2,, "movzwl\t%[1],-(sp)", (3,7) + %[1])
|
||||
(source4,, "pushl\t%[1]"
|
||||
setcc(%[1]), (2,7) + %[1])
|
||||
|
|
Loading…
Reference in a new issue