Pristine Ack-5.5
[Ack-5.5.git] / mach / sun3 / ce / mach.c
1 #define CODE_EXPANDER
2 #include "mach.h"
3 #include <back.h>
4 #include <system.h>
5
6
7 #ifdef DEBUG
8 arg_error( s, arg)
9 char *s;
10 int arg;
11 {
12         fprint( STDERR, "arg_error %s %d\n", s, arg);
13 }
14 #endif
15
16
17 /*
18 do_open( filename)
19 char *filename;
20 {
21         if ( filename == (char *)0 || !sys_open( filename, OP_WRITE, &codefile))
22                 return( 0);
23
24         fprint( codefile, ".sect .text; .sect .rom; .sect .data; .sect .bss\n");
25         return( 1);
26 }
27 */
28
29 #include <con_float>
30
31 __instr_code(code, reg, off)
32 {
33   if (off <= 32767 & off >= -32768) {
34         text2(code|0x28|reg);
35         text2(off);
36         return;
37   }
38   text2(code|0x30|reg);
39   text2(0x0170);
40   text4(off);
41 }
42
43 __move_X(code, reg, off)
44 {
45   if (off <= 32767 & off >= -32768) {
46         text2(code|(reg<<9)|0x140);
47         text2(off);
48         return;
49   }
50   text2(code|(reg<<9)|0x180);
51   text2(0x0170);
52   text4(off);
53 }
54
55 __moveXX(code, srcreg, srcoff, dstreg, dstoff)
56 {
57   if (srcoff <= 32767 && srcoff >= -32768) {
58         __move_X(code|0x28|srcreg, dstreg, dstoff);
59         return;
60   }
61   if (dstoff <= 32767 && dstoff >= -32768) {
62         __instr_code(code|0x140|(dstreg<<9), srcreg, srcoff);
63         return;
64   }
65   text2(code|(dstreg<<9)|srcreg|0x180|0x30);
66   text2(0x0170);
67   text4(srcoff);
68   text2(0x0170);
69   text4(dstoff);
70 }