1 |
48 |
robfinch |
// ============================================================================
|
2 |
|
|
// __
|
3 |
|
|
// \\__/ o\ (C) 2012-2018 Robert Finch, Waterloo
|
4 |
|
|
// \ __ / All rights reserved.
|
5 |
|
|
// \/_// robfinch<remove>@finitron.ca
|
6 |
|
|
// ||
|
7 |
|
|
//
|
8 |
|
|
// CC64 - 'C' derived language compiler
|
9 |
|
|
// - 64 bit CPU
|
10 |
|
|
//
|
11 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
12 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
13 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
14 |
|
|
// (at your option) any later version.
|
15 |
|
|
//
|
16 |
|
|
// This source file is distributed in the hope that it will be useful,
|
17 |
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
|
|
// GNU General Public License for more details.
|
20 |
|
|
//
|
21 |
|
|
// You should have received a copy of the GNU General Public License
|
22 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
23 |
|
|
//
|
24 |
|
|
// ============================================================================
|
25 |
|
|
//
|
26 |
|
|
#include "stdafx.h"
|
27 |
|
|
|
28 |
|
|
void put_mask(int mask);
|
29 |
|
|
void align(int n);
|
30 |
|
|
void roseg();
|
31 |
|
|
bool renamed = false;
|
32 |
|
|
int64_t genst_cumulative;
|
33 |
|
|
|
34 |
|
|
/* variable initialization */
|
35 |
|
|
|
36 |
|
|
enum e_gt { nogen, bytegen, chargen, halfgen, wordgen, longgen };
|
37 |
|
|
//enum e_sg { noseg, codeseg, dataseg, bssseg, idataseg };
|
38 |
|
|
|
39 |
|
|
int gentype = nogen;
|
40 |
|
|
int curseg = noseg;
|
41 |
|
|
int outcol = 0;
|
42 |
|
|
|
43 |
|
|
// Please keep table in alphabetical order.
|
44 |
|
|
// Instruction.cpp has the number of table elements hard-coded in it.
|
45 |
|
|
//
|
46 |
|
|
Instruction opl[] =
|
47 |
|
|
{
|
48 |
|
|
{ ";", op_rem },
|
49 |
|
|
{ "abs", op_abs,2,1,false,am_reg,am_reg,0,0 },
|
50 |
|
|
{ "add",op_add,1,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
51 |
|
|
{ "addu", op_addu,1,1 },
|
52 |
|
|
{ "and",op_and,1,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
53 |
|
|
{ "asl", op_asl,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
54 |
|
|
{ "asr",op_asr,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
55 |
|
|
{ "bbc", op_bbc,3,0,false,am_reg,am_ui6,0,0 },
|
56 |
|
|
{ "bbs", op_bbs,3,0,false,am_reg,am_ui6,0,0 },
|
57 |
|
|
{ "bchk", op_bchk,3,0 },
|
58 |
|
|
{ "beq", op_beq,3,0,false,am_reg,am_reg|am_imm,0,0 },
|
59 |
|
|
{ "beqi", op_beqi,3,0,false,am_reg,am_imm,0,0 },
|
60 |
|
|
{ "bex", op_bex,0,0,false,0,0,0,0 },
|
61 |
|
|
{ "bfext", op_bfext,2,1,false,am_reg },
|
62 |
|
|
{ "bfextu", op_bfextu,2,1,false,am_reg, },
|
63 |
|
|
{ "bfins", op_bfins,2,1,false,am_reg },
|
64 |
|
|
{ "bge", op_bge,3,0,false,am_reg,am_reg,0,0 },
|
65 |
|
|
{ "bgeu", op_bgeu,3,0,false,am_reg,am_reg,0,0 },
|
66 |
|
|
{ "bgt", op_bgt,3,0,false,am_reg,am_reg,0,0 },
|
67 |
|
|
{ "bgtu", op_bgtu,3,0,false,am_reg,am_reg,0,0 },
|
68 |
|
|
{ "bhi",op_bhi,2,0, false, am_reg, am_reg,0,0 },
|
69 |
|
|
{ "bhs",op_bhs,2,0, false, am_reg, am_reg,0,0 },
|
70 |
|
|
{ "ble", op_ble, 3,0,false,am_reg,am_reg,0,0 },
|
71 |
|
|
{ "bleu", op_bleu,3,0,false,am_reg,am_reg,0,0 },
|
72 |
|
|
{ "blo",op_blo,2,0,false,am_reg,am_reg,0,0 },
|
73 |
|
|
{ "bls",op_bls,2,0,false,am_reg,am_reg,0,0 },
|
74 |
|
|
{ "blt", op_blt,3,0,false,am_reg,am_reg,0,0 },
|
75 |
|
|
{ "bltu", op_bltu,3,0,false,am_reg,am_reg,0,0 },
|
76 |
|
|
{ "bmi", op_bmi,2,0,false,am_reg,am_reg,0,0 },
|
77 |
|
|
{ "bne", op_bne,3,0,false,am_reg,am_reg,0,0 },
|
78 |
|
|
{ "bor", op_bor,3,0 },
|
79 |
|
|
{ "br",op_br,3,0,false,0,0,0,0 },
|
80 |
|
|
{ "bra",op_bra,3,0,false,0,0,0,0 },
|
81 |
|
|
{ "brk", op_brk,1,0 },
|
82 |
|
|
{ "bsr", op_bsr },
|
83 |
|
|
{ "bun", op_bun,2,0 },
|
84 |
|
|
{ "cache",op_cache,1,0 },
|
85 |
|
|
{ "call", op_call,4,1,false,0,0,0,0 },
|
86 |
|
|
{ "chk", op_chk,1,0 },
|
87 |
|
|
{ "cmovenz", op_cmovenz,1,1,false,am_reg,am_reg,am_reg,am_reg },
|
88 |
|
|
{ "cmp",op_cmp,1,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
89 |
|
|
{ "cmpu",op_cmpu,1,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
90 |
|
|
{ "com", op_com,2,1,false,am_reg,am_reg,0,0 },
|
91 |
|
|
{ "csrrw", op_csrrw,1,1,false,am_reg },
|
92 |
|
|
{ "dc",op_dc },
|
93 |
|
|
{ "dec", op_dec,4,0,true,am_i5 },
|
94 |
|
|
{ "div", op_div,68,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
95 |
|
|
{ "divu",op_divu,68,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
96 |
|
|
{ "dw", op_dw },
|
97 |
|
|
{ "eor",op_eor,1,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
98 |
|
|
{ "eq",op_eq },
|
99 |
|
|
{ "ext",op_ext },
|
100 |
|
|
{ "fadd", op_fadd, 6, 1, false, am_fpreg, am_fpreg, am_fpreg, 0 },
|
101 |
|
|
{ "fadd", op_fdadd,6,1,false,am_fpreg,am_fpreg,am_fpreg,0 },
|
102 |
|
|
{ "fadd.s", op_fsadd,6,1,false,am_fpreg,am_fpreg,am_fpreg,0 },
|
103 |
|
|
{ "fbeq", op_fbeq,3,0,false,am_fpreg,am_fpreg,0,0 },
|
104 |
|
|
{ "fbge", op_fbge,3,0,false,am_fpreg,am_fpreg,0,0 },
|
105 |
|
|
{ "fbgt", op_fbgt,3,0,false,am_fpreg,am_fpreg,0,0 },
|
106 |
|
|
{ "fble", op_fble,3,0,false,am_fpreg,am_fpreg,0,0 },
|
107 |
|
|
{ "fblt", op_fblt,3,0,false,am_fpreg,am_fpreg,0,0 },
|
108 |
|
|
{ "fbne", op_fbne,3,0,false,am_fpreg,am_fpreg,0,0 },
|
109 |
|
|
{ "fbor", op_fbor,3,0,false,am_fpreg,am_fpreg,0,0 },
|
110 |
|
|
{ "fbun", op_fbun,3,0,false,am_fpreg,am_fpreg,0,0 },
|
111 |
|
|
{ "fcmp", op_fcmp, 1,1,false,am_reg,am_fpreg,am_fpreg,0 },
|
112 |
|
|
{ "fcvtdq", op_fcvtdq,2,1,false,am_fpreg,am_fpreg,0,0 },
|
113 |
|
|
{ "fcvtsq", op_fcvtsq,2,1,false,am_fpreg,am_fpreg,0,0 },
|
114 |
|
|
{ "fcvttq", op_fcvttq,2,1,false,am_fpreg,am_fpreg,0,0 },
|
115 |
|
|
{ "fdiv", op_fdiv, 160, 1, false, am_fpreg, am_fpreg, am_fpreg, 0 },
|
116 |
|
|
{ "fdiv.s", op_fsdiv,80,1,false },
|
117 |
|
|
{ "fi2d", op_i2d,2,1,false },
|
118 |
|
|
{ "fix2flt", op_fix2flt },
|
119 |
|
|
{ "flt2fix",op_flt2fix },
|
120 |
|
|
{ "fmov", op_fmov,1,1 },
|
121 |
|
|
{ "fmov.d", op_fdmov,1,1 },
|
122 |
|
|
{ "fmul", op_fdmul,10,1,false,am_fpreg,am_fpreg,am_fpreg,0 },
|
123 |
|
|
{ "fmul", op_fmul, 10, 1, false, am_fpreg, am_fpreg, am_fpreg, 0 },
|
124 |
|
|
{ "fmul.s", op_fsmul,10,1,false },
|
125 |
|
|
{ "fneg", op_fneg,2,1,false,am_fpreg,am_fpreg,0,0 },
|
126 |
|
|
{ "fs2d", op_fs2d,2,1,false,am_fpreg,am_fpreg,0,0 },
|
127 |
|
|
{ "fslt", op_fslt, 1, 1, false, am_reg, am_fpreg, am_fpreg, 0 },
|
128 |
|
|
{ "fsub", op_fdsub,6,1,false,am_fpreg,am_fpreg,am_fpreg,0 },
|
129 |
|
|
{ "fsub", op_fsub, 6, 1, false, am_fpreg, am_fpreg, am_fpreg, 0 },
|
130 |
|
|
{ "fsub.s", op_fssub,6,1,false },
|
131 |
|
|
{ "ftadd", op_ftadd },
|
132 |
|
|
{ "ftdiv", op_ftdiv },
|
133 |
|
|
{ "ftmul", op_ftmul },
|
134 |
|
|
{ "ftoi", op_ftoi, 2, 1, false, am_reg, am_fpreg, 0, 0 },
|
135 |
|
|
{ "ftsub", op_ftsub },
|
136 |
|
|
{ "ge",op_ge },
|
137 |
|
|
{ "geu", op_geu },
|
138 |
|
|
{ "gt",op_gt },
|
139 |
|
|
{ "gtu",op_gtu },
|
140 |
|
|
{ "hint", op_hint,0 },
|
141 |
|
|
{ "hint2",op_hint2,0 },
|
142 |
|
|
{ "ibne", op_ibne,3,1 ,false,am_reg,am_reg,0,0 },
|
143 |
|
|
{ "inc", op_inc,4,0,true,am_i5,am_mem,0,0 },
|
144 |
|
|
{ "iret", op_iret,2,0,false,0,0,0,0 },
|
145 |
|
|
{ "itof", op_itof, 2, 1, false, am_fpreg, am_reg, 0, 0 },
|
146 |
|
|
{ "jal", op_jal,1,1,false },
|
147 |
|
|
{ "jmp",op_jmp,1,0,false,am_mem,0,0,0 },
|
148 |
|
|
{ "lb", op_lb,4,1,true,am_reg,am_mem,0,0 },
|
149 |
|
|
{ "lbu", op_lbu,4,1,true,am_reg,am_mem,0,0 },
|
150 |
|
|
{ "lc", op_lc,4,1,true,am_reg,am_mem,0,0 },
|
151 |
|
|
{ "lcu", op_lcu,4,1,true,am_reg,am_mem,0,0 },
|
152 |
|
|
{ "ldi",op_ldi,1,1,false,am_reg,am_imm,0,0 },
|
153 |
|
|
{ "le",op_le },
|
154 |
|
|
{ "lea",op_lea,1,1,false,am_reg,am_mem,0,0 },
|
155 |
|
|
{ "leu",op_leu },
|
156 |
|
|
{ "lf", op_lf, 4, 1, true, am_fpreg, am_mem, 0, 0 },
|
157 |
|
|
{ "lfd", op_lfd,4,1,true, am_fpreg, am_mem,0,0 },
|
158 |
|
|
{ "lft", op_lft,4,1,true, am_fpreg, am_mem,0,0 },
|
159 |
|
|
{ "lh", op_lh,4,1,true,am_reg,am_mem,0,0 },
|
160 |
|
|
{ "lhu", op_lhu,4,1,true,am_reg,am_mem,0,0 },
|
161 |
|
|
{ "link",op_link,4,1,true },
|
162 |
|
|
{ "lm", op_lm },
|
163 |
|
|
{ "loop", op_loop,1,0 },
|
164 |
|
|
{ "lsr", op_lsr,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
165 |
|
|
{ "lt",op_lt },
|
166 |
|
|
{ "ltu", op_ltu },
|
167 |
|
|
{ "lv", op_lv,256,1 },
|
168 |
|
|
{ "lvbu", op_lvbu,4,1,true ,am_reg,am_mem,0,0 },
|
169 |
|
|
{ "lvcu", op_lvcu,4,1,true ,am_reg,am_mem,0,0 },
|
170 |
|
|
{ "lvhu", op_lvhu,4,1,true ,am_reg,am_mem,0,0 },
|
171 |
|
|
{ "lw", op_lw,4,1,true,am_reg,am_mem,0,0 },
|
172 |
|
|
{ "lwr", op_lwr,4,1,true,am_reg,am_mem,0,0 },
|
173 |
|
|
{ "lws", op_lws,4,1,true },
|
174 |
|
|
{ "mffp",op_mffp },
|
175 |
|
|
{ "mod", op_mod,68,1, false,am_reg,am_reg,am_reg|am_imm,0 },
|
176 |
|
|
{ "modu", op_modu,68,1,false,am_reg,am_reg,am_reg,0 },
|
177 |
|
|
{ "mov", op_mov,1,1,false,am_reg|am_fpreg,am_reg|am_fpreg,0,0 },
|
178 |
|
|
{ "move",op_move,1,1,false,am_reg | am_fpreg,am_reg | am_fpreg,0,0 },
|
179 |
|
|
{ "movs", op_movs },
|
180 |
|
|
{ "mtfp", op_mtfp },
|
181 |
|
|
{ "mul",op_mul,18,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
182 |
|
|
{ "mulu",op_mulu,10,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
183 |
|
|
{ "nand",op_nand,1,1,false,am_reg,am_reg,am_reg,0 },
|
184 |
|
|
{ "ne",op_ne },
|
185 |
|
|
{ "neg",op_neg, 1, 1, false,am_reg,am_reg,0,0 },
|
186 |
|
|
{ "nop", op_nop,0,0,false },
|
187 |
|
|
{ "nor",op_nor,1,1,false,am_reg,am_reg,am_reg,0 },
|
188 |
|
|
{ "not", op_not,2,1,false,am_reg,am_reg,0,0 },
|
189 |
|
|
{ "not",op_not,2,1, false,am_reg, am_reg,0,0 },
|
190 |
|
|
{ "nr", op_nr },
|
191 |
|
|
{ "or",op_or,1,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
192 |
|
|
{ "pea", op_pea },
|
193 |
|
|
{ "pea",op_pea },
|
194 |
|
|
{ "phi", op_phi },
|
195 |
|
|
{ "pop", op_pop,4,2,true,am_reg,am_reg,0,0 },
|
196 |
|
|
{ "popf", op_popf,4,2,true,am_fpreg,am_reg,0,0 },
|
197 |
|
|
{ "push",op_push,4,1,true,am_reg,0,0,0 },
|
198 |
|
|
{ "pushf",op_pushf,4,0,true,am_fpreg,0,0,0 },
|
199 |
|
|
{ "redor", op_redor,2,1,false,am_reg,am_reg,am_reg,0 },
|
200 |
|
|
{ "ret", op_ret,1,0,am_imm,0,0,0 },
|
201 |
|
|
{ "rol", op_rol,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
202 |
|
|
{ "ror", op_ror,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
203 |
|
|
{ "rtd", op_rtd },
|
204 |
|
|
{ "rte", op_rte,2,0 },
|
205 |
|
|
{ "rti", op_rti,2,0 },
|
206 |
|
|
{ "sb",op_sb,4,0,true,am_reg,am_mem,0,0 },
|
207 |
|
|
{ "sc",op_sc,4,0,true,am_reg,am_mem,0,0 },
|
208 |
|
|
{ "sei", op_sei,1,0,false,am_reg,0,0,0 },
|
209 |
|
|
{ "seq", op_seq,1,1,false,am_reg,am_reg,am_reg|am_i26,0 },
|
210 |
|
|
{ "setwb", op_setwb, 1, 0 },
|
211 |
|
|
{ "sf", op_sf, 4, 0, true, am_fpreg, am_mem, 0, 0 },
|
212 |
|
|
{ "sfd", op_sfd,4,0,true, am_fpreg, am_mem,0,0 },
|
213 |
|
|
{ "sft", op_sft,4,0,true, am_fpreg, am_mem,0,0 },
|
214 |
|
|
{ "sge",op_sge,1,1,false,am_reg,am_reg,am_reg | am_i26,0 },
|
215 |
|
|
{ "sgeu",op_sgeu,1,1,false,am_reg,am_reg,am_reg | am_i26,0 },
|
216 |
|
|
{ "sgt",op_sgt,1,1,false,am_reg,am_reg,am_reg | am_i26,0 },
|
217 |
|
|
{ "sgtu",op_sgtu,1,1,false,am_reg,am_reg,am_reg | am_i26,0 },
|
218 |
|
|
{ "sh",op_sh,4,0,true,am_reg,am_mem,0,0 },
|
219 |
|
|
{ "shl", op_shl,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
220 |
|
|
{ "shlu", op_shlu,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
221 |
|
|
{ "shr", op_shr,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
222 |
|
|
{ "shru", op_shru,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
223 |
|
|
{ "sle",op_sle,1,1,false,am_reg,am_reg,am_reg | am_i26,0 },
|
224 |
|
|
{ "sleu",op_sleu,1,1,false,am_reg,am_reg,am_reg | am_i26,0 },
|
225 |
|
|
{ "sll", op_sll,2,1,false,am_reg,am_reg,am_reg,0 },
|
226 |
|
|
{ "slt", op_slt,1,1,false,am_reg,am_reg,am_reg,0 },
|
227 |
|
|
{ "sltu", op_sltu,1,1,false,am_reg,am_reg,am_reg,0 },
|
228 |
|
|
{ "sm",op_sm },
|
229 |
|
|
{ "sne",op_sne,1,1,false,am_reg,am_reg,am_reg|am_i26,0 },
|
230 |
|
|
{ "spt", op_spt,4,0,true ,am_reg,am_mem,0,0 },
|
231 |
|
|
{ "sptr", op_sptr,4,0,true,am_reg,am_mem,0,0 },
|
232 |
|
|
{ "sra", op_sra,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
233 |
|
|
{ "srl", op_srl,2,1,false,am_reg,am_reg,am_reg|am_ui6,0 },
|
234 |
|
|
{ "sti", op_sti,1,0 },
|
235 |
|
|
{ "stop", op_stop },
|
236 |
|
|
{ "sub",op_sub,1,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
237 |
|
|
{ "subu", op_subu,1,1 },
|
238 |
|
|
{ "sv", op_sv,256,0 },
|
239 |
|
|
{ "sw", op_sw,4,0,true,am_reg,am_mem,0,0 },
|
240 |
|
|
{ "swap",op_swap,1,1,false },
|
241 |
|
|
{ "swc", op_swc,4,0,true, am_reg, am_mem,0,0 },
|
242 |
|
|
{ "swp", op_swp, 8, false },
|
243 |
|
|
{ "sws", op_sws,4,0 },
|
244 |
|
|
{ "sxb",op_sxb,1,1,false,am_reg,am_reg,0,0 },
|
245 |
|
|
{ "sxc",op_sxc,1,1,false,am_reg,am_reg,0,0 },
|
246 |
|
|
{ "sxh",op_sxh,1,1,false,am_reg,am_reg,0,0 },
|
247 |
|
|
{ "tgt", op_calltgt,1 },
|
248 |
|
|
{ "tst",op_tst,1,1 },
|
249 |
|
|
{ "unlink",op_unlk,4,1,true },
|
250 |
|
|
{ "vadd", op_vadd,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
251 |
|
|
{ "vadds", op_vadds,10 },
|
252 |
|
|
{ "vdiv", op_vdiv,100,1,false, am_vreg,am_vreg,am_vreg,0 },
|
253 |
|
|
{ "vdivs", op_vdivs,100 },
|
254 |
|
|
{ "veins",op_veins,10 },
|
255 |
|
|
{ "vex", op_vex,10 },
|
256 |
|
|
{ "vmul", op_vmul,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
257 |
|
|
{ "vmuls", op_vmuls,10 },
|
258 |
|
|
{ "vseq", op_vseq,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
259 |
|
|
{ "vsge", op_vsge,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
260 |
|
|
{ "vsgt", op_vsgt,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
261 |
|
|
{ "vsle", op_vsle,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
262 |
|
|
{ "vslt", op_vslt,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
263 |
|
|
{ "vsne", op_vsne,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
264 |
|
|
{ "vsub", op_vsub,10,1,false, am_vreg,am_vreg,am_vreg,0 },
|
265 |
|
|
{ "vsubs", op_vsubs,10 },
|
266 |
|
|
{ "xnor",op_xnor,1,1,false,am_reg,am_reg,am_reg,0 },
|
267 |
|
|
{ "xor",op_xor,1,1,false,am_reg,am_reg,am_reg|am_imm,0 },
|
268 |
|
|
{ "zxb",op_zxb,1,1,false,am_reg,am_reg,0,0 },
|
269 |
|
|
{ "zxc",op_zxc,1,1,false,am_reg,am_reg,0,0 },
|
270 |
|
|
{ "zxh",op_zxh,1,1,false,am_reg,am_reg,0,0 },
|
271 |
|
|
{ "",op_empty },
|
272 |
|
|
{ "",op_asm,300 },
|
273 |
|
|
{ "", op_fnname },
|
274 |
|
|
{0,0,0,0,false,0,0,0,0}
|
275 |
|
|
};
|
276 |
|
|
|
277 |
|
|
Instruction *GetInsn(int op)
|
278 |
|
|
{
|
279 |
|
|
return (Instruction::Get(op));
|
280 |
|
|
}
|
281 |
|
|
|
282 |
|
|
/*
|
283 |
|
|
static char *segstr(int op)
|
284 |
|
|
{
|
285 |
|
|
static char buf[20];
|
286 |
|
|
|
287 |
|
|
switch(op & 0xff00) {
|
288 |
|
|
case op_cs:
|
289 |
|
|
return "cs";
|
290 |
|
|
case op_ss:
|
291 |
|
|
return "ss";
|
292 |
|
|
case op_ds:
|
293 |
|
|
return "ds";
|
294 |
|
|
case op_bs:
|
295 |
|
|
return "bs";
|
296 |
|
|
case op_ts:
|
297 |
|
|
return "ts";
|
298 |
|
|
default:
|
299 |
|
|
sprintf(buf, "seg%d", op >> 8);
|
300 |
|
|
return buf;
|
301 |
|
|
}
|
302 |
|
|
}
|
303 |
|
|
*/
|
304 |
|
|
|
305 |
|
|
// Output a friendly register moniker
|
306 |
|
|
|
307 |
|
|
char *RegMoniker(int regno)
|
308 |
|
|
{
|
309 |
|
|
static char buf[4][20];
|
310 |
|
|
static int n;
|
311 |
|
|
|
312 |
|
|
n = (n + 1) & 3;
|
313 |
|
|
if (regno==30)
|
314 |
|
|
sprintf_s(&buf[n][0], 20, "$fp");
|
315 |
|
|
else if (regno==27)
|
316 |
|
|
sprintf_s(&buf[n][0], 20, "$gp");
|
317 |
|
|
else if (regno==28)
|
318 |
|
|
sprintf_s(&buf[n][0], 20, "$xlr");
|
319 |
|
|
else if (regno==regPC)
|
320 |
|
|
sprintf_s(&buf[n][0], 20, "$pc");
|
321 |
|
|
else if (regno==31)
|
322 |
|
|
sprintf_s(&buf[n][0], 20, "$sp");
|
323 |
|
|
else if (regno==29)
|
324 |
|
|
sprintf_s(&buf[n][0], 20, "$lr");
|
325 |
|
|
else if (regno>=1 && regno<=2)
|
326 |
|
|
sprintf_s(&buf[n][0], 20, "$v%d", regno-1);
|
327 |
|
|
else if (regno >= 18 && regno <= 24)
|
328 |
|
|
sprintf_s(&buf[n][0], 20, "$a%d", regno-regFirstArg);
|
329 |
|
|
else if (regno >= 3 && regno <= 10)
|
330 |
|
|
sprintf_s(&buf[n][0], 20, "$t%d", regno-regFirstTemp);
|
331 |
|
|
else if (regno >= 11 && regno <= 17)
|
332 |
|
|
sprintf_s(&buf[n][0], 20, "$r%d", regno);
|
333 |
|
|
else {
|
334 |
|
|
if (regno == 3533)
|
335 |
|
|
printf("hi");
|
336 |
|
|
sprintf_s(&buf[n][0], 20, "$r%d", regno);
|
337 |
|
|
}
|
338 |
|
|
return &buf[n][0];
|
339 |
|
|
}
|
340 |
|
|
|
341 |
|
|
char *RegMoniker2(int regno)
|
342 |
|
|
{
|
343 |
|
|
static char buf[4][20];
|
344 |
|
|
static int n;
|
345 |
|
|
|
346 |
|
|
n = (n + 1) & 3;
|
347 |
|
|
if (regno == regFP)
|
348 |
|
|
sprintf_s(&buf[n][0], 20, "$fp");
|
349 |
|
|
else if (regno == regGP)
|
350 |
|
|
sprintf_s(&buf[n][0], 20, "$gp");
|
351 |
|
|
else if (regno == regXLR)
|
352 |
|
|
sprintf_s(&buf[n][0], 20, "$xlr");
|
353 |
|
|
else if (regno == regPC)
|
354 |
|
|
sprintf_s(&buf[n][0], 20, "$pc");
|
355 |
|
|
else if (regno == regSP)
|
356 |
|
|
sprintf_s(&buf[n][0], 20, "$sp");
|
357 |
|
|
else if (regno == regLR)
|
358 |
|
|
sprintf_s(&buf[n][0], 20, "$lr");
|
359 |
|
|
else if (regno >= 1 && regno <= 2)
|
360 |
|
|
sprintf_s(&buf[n][0], 20, "$v%d", regno - 1);
|
361 |
|
|
else if (regno >= regFirstArg && regno <= regLastArg)
|
362 |
|
|
sprintf_s(&buf[n][0], 20, "$a%d", regno - regFirstArg);
|
363 |
|
|
else if (regno >= regFirstTemp && regno <= regLastTemp)
|
364 |
|
|
sprintf_s(&buf[n][0], 20, "$t%d", regno - regFirstTemp);
|
365 |
|
|
else if (regno >= regFirstRegvar && regno <= regLastRegvar)
|
366 |
|
|
sprintf_s(&buf[n][0], 20, "$r%d", regno);
|
367 |
|
|
else
|
368 |
|
|
sprintf_s(&buf[n][0], 20, "$r%d", regno);
|
369 |
|
|
return &buf[n][0];
|
370 |
|
|
}
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
/*
|
374 |
|
|
* generate a register mask for restore and save.
|
375 |
|
|
*/
|
376 |
|
|
void put_mask(int mask)
|
377 |
|
|
{
|
378 |
|
|
int nn;
|
379 |
|
|
int first = 1;
|
380 |
|
|
|
381 |
|
|
for (nn = 0; nn < 32; nn++) {
|
382 |
|
|
if (mask & (1<<nn)) {
|
383 |
|
|
if (!first)
|
384 |
|
|
ofs.printf("/");
|
385 |
|
|
ofs.printf("r%d",nn);
|
386 |
|
|
first = 0;
|
387 |
|
|
}
|
388 |
|
|
}
|
389 |
|
|
// fprintf(output,"#0x%04x",mask);
|
390 |
|
|
|
391 |
|
|
}
|
392 |
|
|
|
393 |
|
|
/*
|
394 |
|
|
* generate a register name from a tempref number.
|
395 |
|
|
*/
|
396 |
|
|
void putreg(int r)
|
397 |
|
|
{
|
398 |
|
|
ofs.printf("r%d", r);
|
399 |
|
|
}
|
400 |
|
|
|
401 |
|
|
/*
|
402 |
|
|
* generate a named label.
|
403 |
|
|
*/
|
404 |
|
|
void gen_strlab(char *s)
|
405 |
|
|
{ ofs.printf("%s:\n",s);
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
/*
|
409 |
|
|
* output a compiler generated label.
|
410 |
|
|
*/
|
411 |
|
|
char *gen_label(int lab, char *nm, char *ns, char d)
|
412 |
|
|
{
|
413 |
|
|
static char buf[500];
|
414 |
|
|
|
415 |
|
|
if (nm == NULL)
|
416 |
|
|
sprintf_s(buf, sizeof(buf), "%.400s_%d:\n", ns, lab);
|
417 |
|
|
else if (strlen(nm) == 0)
|
418 |
|
|
sprintf_s(buf, sizeof(buf), "%.400s_%d:\n", ns, lab);
|
419 |
|
|
else
|
420 |
|
|
sprintf_s(buf, sizeof(buf), "%.400s_%d: ; %s\n", ns, lab, nm);
|
421 |
|
|
return (buf);
|
422 |
|
|
}
|
423 |
|
|
char *put_labels(char *buf)
|
424 |
|
|
{
|
425 |
|
|
ofs.printf("%s", buf);
|
426 |
|
|
return (buf);
|
427 |
|
|
}
|
428 |
|
|
|
429 |
|
|
char *put_label(int lab, char *nm, char *ns, char d)
|
430 |
|
|
{
|
431 |
|
|
static char buf[500];
|
432 |
|
|
|
433 |
|
|
sprintf_s(buf, sizeof(buf), "%.400s_%d", ns, lab);
|
434 |
|
|
if (nm==NULL)
|
435 |
|
|
ofs.printf("%s:\n",buf);
|
436 |
|
|
else if (strlen(nm)==0)
|
437 |
|
|
ofs.printf("%s:\n",buf);
|
438 |
|
|
else
|
439 |
|
|
ofs.printf("%s: ; %s\n",buf,nm);
|
440 |
|
|
return buf;
|
441 |
|
|
}
|
442 |
|
|
|
443 |
|
|
|
444 |
|
|
void GenerateByte(int64_t val)
|
445 |
|
|
{
|
446 |
|
|
if( gentype == bytegen && outcol < 60) {
|
447 |
|
|
ofs.printf(",%d",(int)val & 0x00ff);
|
448 |
|
|
outcol += 4;
|
449 |
|
|
}
|
450 |
|
|
else {
|
451 |
|
|
nl();
|
452 |
|
|
ofs.printf("\tdb\t%d",(int)val & 0x00ff);
|
453 |
|
|
gentype = bytegen;
|
454 |
|
|
outcol = 19;
|
455 |
|
|
}
|
456 |
|
|
genst_cumulative += 1;
|
457 |
|
|
}
|
458 |
|
|
|
459 |
|
|
void GenerateChar(int64_t val)
|
460 |
|
|
{
|
461 |
|
|
if( gentype == chargen && outcol < 60) {
|
462 |
|
|
ofs.printf(",%d",(int)val & 0xffff);
|
463 |
|
|
outcol += 6;
|
464 |
|
|
}
|
465 |
|
|
else {
|
466 |
|
|
nl();
|
467 |
|
|
ofs.printf("\tdc\t%d",(int)val & 0xffff);
|
468 |
|
|
gentype = chargen;
|
469 |
|
|
outcol = 21;
|
470 |
|
|
}
|
471 |
|
|
genst_cumulative += 2;
|
472 |
|
|
}
|
473 |
|
|
|
474 |
|
|
void genhalf(int64_t val)
|
475 |
|
|
{
|
476 |
|
|
if( gentype == halfgen && outcol < 60) {
|
477 |
|
|
ofs.printf(",%ld",(long)(val & 0xffffffff));
|
478 |
|
|
outcol += 10;
|
479 |
|
|
}
|
480 |
|
|
else {
|
481 |
|
|
nl();
|
482 |
|
|
ofs.printf("\tdh\t%ld",(long)(val & 0xffffffff));
|
483 |
|
|
gentype = halfgen;
|
484 |
|
|
outcol = 25;
|
485 |
|
|
}
|
486 |
|
|
genst_cumulative += 4;
|
487 |
|
|
}
|
488 |
|
|
|
489 |
|
|
void GenerateWord(int64_t val)
|
490 |
|
|
{
|
491 |
|
|
if( gentype == wordgen && outcol < 58) {
|
492 |
|
|
ofs.printf(",%lld",val);
|
493 |
|
|
outcol += 18;
|
494 |
|
|
}
|
495 |
|
|
else {
|
496 |
|
|
nl();
|
497 |
|
|
ofs.printf("\tdw\t%lld",val);
|
498 |
|
|
gentype = wordgen;
|
499 |
|
|
outcol = 33;
|
500 |
|
|
}
|
501 |
|
|
genst_cumulative += 8;
|
502 |
|
|
}
|
503 |
|
|
|
504 |
|
|
void GenerateLong(int64_t val)
|
505 |
|
|
{
|
506 |
|
|
if( gentype == longgen && outcol < 56) {
|
507 |
|
|
ofs.printf(",%lld",val);
|
508 |
|
|
outcol += 10;
|
509 |
|
|
}
|
510 |
|
|
else {
|
511 |
|
|
nl();
|
512 |
|
|
ofs.printf("\tdw\t%lld",val);
|
513 |
|
|
gentype = longgen;
|
514 |
|
|
outcol = 25;
|
515 |
|
|
}
|
516 |
|
|
genst_cumulative += 8;
|
517 |
|
|
}
|
518 |
|
|
|
519 |
|
|
void GenerateFloat(Float128 *val)
|
520 |
|
|
{
|
521 |
|
|
if (val==nullptr)
|
522 |
|
|
return;
|
523 |
|
|
ofs.printf("\r\n\talign 8\r\n");
|
524 |
|
|
ofs.printf("\tdh\t%s",val->ToString(64));
|
525 |
|
|
gentype = longgen;
|
526 |
|
|
outcol = 65;
|
527 |
|
|
genst_cumulative += 8;
|
528 |
|
|
}
|
529 |
|
|
|
530 |
|
|
void GenerateQuad(Float128 *val)
|
531 |
|
|
{
|
532 |
|
|
if (val==nullptr)
|
533 |
|
|
return;
|
534 |
|
|
ofs.printf("\r\n\talign 8\r\n");
|
535 |
|
|
ofs.printf("\tdh\t%s",val->ToString(128));
|
536 |
|
|
gentype = longgen;
|
537 |
|
|
outcol = 65;
|
538 |
|
|
genst_cumulative += 16;
|
539 |
|
|
}
|
540 |
|
|
|
541 |
|
|
void GenerateReference(SYM *sp,int64_t offset)
|
542 |
|
|
{
|
543 |
|
|
char sign;
|
544 |
|
|
if( offset < 0) {
|
545 |
|
|
sign = '-';
|
546 |
|
|
offset = -offset;
|
547 |
|
|
}
|
548 |
|
|
else
|
549 |
|
|
sign = '+';
|
550 |
|
|
if( gentype == longgen && outcol < 55 - (int)sp->name->length()) {
|
551 |
|
|
if( sp->storage_class == sc_static) {
|
552 |
|
|
ofs.printf(",");
|
553 |
|
|
ofs.printf(GetNamespace());
|
554 |
|
|
ofs.printf("_%lld", sp->value.i);
|
555 |
|
|
ofs.putch(sign);
|
556 |
|
|
ofs.printf("%lld", offset);
|
557 |
|
|
// fprintf(output,",%s_%ld%c%d",GetNamespace(),sp->value.i,sign,offset);
|
558 |
|
|
}
|
559 |
|
|
else if( sp->storage_class == sc_thread) {
|
560 |
|
|
ofs.printf(",");
|
561 |
|
|
ofs.printf(GetNamespace());
|
562 |
|
|
ofs.printf("_%lld", sp->value.i);
|
563 |
|
|
ofs.putch(sign);
|
564 |
|
|
ofs.printf("%lld", offset);
|
565 |
|
|
// fprintf(output,",%s_%ld%c%d",GetNamespace(),sp->value.i,sign,offset);
|
566 |
|
|
}
|
567 |
|
|
else {
|
568 |
|
|
if (offset==0) {
|
569 |
|
|
ofs.printf(",%s",(char *)sp->name->c_str());
|
570 |
|
|
}
|
571 |
|
|
else {
|
572 |
|
|
ofs.printf(",%s",(char *)sp->name->c_str());
|
573 |
|
|
ofs.putch(sign);
|
574 |
|
|
ofs.printf("%lld",offset);
|
575 |
|
|
}
|
576 |
|
|
}
|
577 |
|
|
outcol += (11 + sp->name->length());
|
578 |
|
|
}
|
579 |
|
|
else {
|
580 |
|
|
nl();
|
581 |
|
|
if(sp->storage_class == sc_static) {
|
582 |
|
|
ofs.printf("\tdw\t%s",GetNamespace());
|
583 |
|
|
ofs.printf("_%lld",sp->value.i);
|
584 |
|
|
ofs.putch(sign);
|
585 |
|
|
ofs.printf("%lld",offset);
|
586 |
|
|
// fprintf(output,"\tdw\t%s_%ld%c%d",GetNamespace(),sp->value.i,sign,offset);
|
587 |
|
|
}
|
588 |
|
|
else if(sp->storage_class == sc_thread) {
|
589 |
|
|
// fprintf(output,"\tdw\t%s_%ld%c%d",GetNamespace(),sp->value.i,sign,offset);
|
590 |
|
|
ofs.printf("\tdw\t%s",GetNamespace());
|
591 |
|
|
ofs.printf("_%lld",sp->value.i);
|
592 |
|
|
ofs.putch(sign);
|
593 |
|
|
ofs.printf("%lld",offset);
|
594 |
|
|
}
|
595 |
|
|
else {
|
596 |
|
|
if (offset==0) {
|
597 |
|
|
ofs.printf("\tdw\t%s",(char *)sp->name->c_str());
|
598 |
|
|
}
|
599 |
|
|
else {
|
600 |
|
|
ofs.printf("\tdw\t%s",(char *)sp->name->c_str());
|
601 |
|
|
ofs.putch(sign);
|
602 |
|
|
ofs.printf("%lld", offset);
|
603 |
|
|
// fprintf(output,"\tdw\t%s%c%d",sp->name,sign,offset);
|
604 |
|
|
}
|
605 |
|
|
}
|
606 |
|
|
outcol = 26 + sp->name->length();
|
607 |
|
|
gentype = longgen;
|
608 |
|
|
}
|
609 |
|
|
}
|
610 |
|
|
|
611 |
|
|
void genstorageskip(int nbytes)
|
612 |
|
|
{
|
613 |
|
|
char buf[200];
|
614 |
|
|
int64_t nn;
|
615 |
|
|
|
616 |
|
|
nl();
|
617 |
|
|
nn = (nbytes + 7) >> 3;
|
618 |
|
|
if (nn) {
|
619 |
|
|
sprintf_s(buf, sizeof(buf), "\talign\t8\r\n\tdw\t0x%I64X\r\n", nn | 0xFFF0200000000000LL);
|
620 |
|
|
ofs.printf("%s", buf);
|
621 |
|
|
}
|
622 |
|
|
}
|
623 |
|
|
|
624 |
|
|
void genstorage(int64_t nbytes)
|
625 |
|
|
{
|
626 |
|
|
nl();
|
627 |
|
|
if (nbytes) {
|
628 |
|
|
ofs.printf("\tfill.b\t%lld,0x00\n", nbytes);
|
629 |
|
|
}
|
630 |
|
|
genst_cumulative += nbytes;
|
631 |
|
|
}
|
632 |
|
|
|
633 |
|
|
void GenerateLabelReference(int n)
|
634 |
|
|
{
|
635 |
|
|
if( gentype == longgen && outcol < 58) {
|
636 |
|
|
ofs.printf(",%s_%d",GetNamespace(),n);
|
637 |
|
|
outcol += 6;
|
638 |
|
|
}
|
639 |
|
|
else {
|
640 |
|
|
nl();
|
641 |
|
|
ofs.printf("\tdw\t%s_%d",GetNamespace(),n);
|
642 |
|
|
outcol = 22;
|
643 |
|
|
gentype = longgen;
|
644 |
|
|
}
|
645 |
|
|
}
|
646 |
|
|
|
647 |
|
|
/*
|
648 |
|
|
* make s a string literal and return it's label number.
|
649 |
|
|
*/
|
650 |
|
|
int stringlit(char *s)
|
651 |
|
|
{
|
652 |
|
|
struct slit *lp;
|
653 |
|
|
|
654 |
|
|
lp = (struct slit *)allocx(sizeof(struct slit));
|
655 |
|
|
lp->label = nextlabel++;
|
656 |
|
|
lp->str = my_strdup(s);
|
657 |
|
|
lp->nmspace = my_strdup(GetNamespace());
|
658 |
|
|
lp->next = strtab;
|
659 |
|
|
strtab = lp;
|
660 |
|
|
return lp->label;
|
661 |
|
|
}
|
662 |
|
|
|
663 |
|
|
int caselit(struct scase *cases, int64_t num)
|
664 |
|
|
{
|
665 |
|
|
struct clit *lp;
|
666 |
|
|
|
667 |
|
|
lp = (struct clit *)allocx(sizeof(struct clit));
|
668 |
|
|
lp->label = nextlabel++;
|
669 |
|
|
lp->nmspace = my_strdup(GetNamespace());
|
670 |
|
|
lp->cases = (struct scase *)allocx(sizeof(struct scase)*(int)num);
|
671 |
|
|
lp->num = (int)num;
|
672 |
|
|
memcpy(lp->cases, cases, (int)num * sizeof(struct scase));
|
673 |
|
|
lp->next = casetab;
|
674 |
|
|
casetab = lp;
|
675 |
|
|
return lp->label;
|
676 |
|
|
}
|
677 |
|
|
|
678 |
|
|
int quadlit(Float128 *f128)
|
679 |
|
|
{
|
680 |
|
|
Float128 *lp;
|
681 |
|
|
lp = quadtab;
|
682 |
|
|
// First search for the same literal constant and it's label if found.
|
683 |
|
|
while(lp) {
|
684 |
|
|
if (Float128::IsEqual(lp,Float128::Zero())) {
|
685 |
|
|
if (Float128::IsEqualNZ(lp,f128))
|
686 |
|
|
return lp->label;
|
687 |
|
|
}
|
688 |
|
|
else if (Float128::IsEqual(lp,f128))
|
689 |
|
|
return lp->label;
|
690 |
|
|
lp = lp->next;
|
691 |
|
|
}
|
692 |
|
|
lp = (Float128 *)allocx(sizeof(Float128));
|
693 |
|
|
lp->label = nextlabel++;
|
694 |
|
|
Float128::Assign(lp,f128);
|
695 |
|
|
lp->nmspace = my_strdup(GetNamespace());
|
696 |
|
|
lp->next = quadtab;
|
697 |
|
|
quadtab = lp;
|
698 |
|
|
return (lp->label);
|
699 |
|
|
}
|
700 |
|
|
|
701 |
|
|
|
702 |
|
|
char *strip_crlf(char *p)
|
703 |
|
|
{
|
704 |
|
|
static char buf[2000];
|
705 |
|
|
int nn;
|
706 |
|
|
|
707 |
|
|
for (nn = 0; *p && nn < 1998; p++) {
|
708 |
|
|
if (*p != '\r' && *p!='\n') {
|
709 |
|
|
buf[nn] = *p;
|
710 |
|
|
nn++;
|
711 |
|
|
}
|
712 |
|
|
}
|
713 |
|
|
buf[nn] = '\0';
|
714 |
|
|
return buf;
|
715 |
|
|
}
|
716 |
|
|
|
717 |
|
|
int64_t GetStrtabLen()
|
718 |
|
|
{
|
719 |
|
|
struct slit *p;
|
720 |
|
|
int64_t len;
|
721 |
|
|
char *cp;
|
722 |
|
|
|
723 |
|
|
len = 0;
|
724 |
|
|
for (p = strtab; p; p = p->next) {
|
725 |
|
|
cp = p->str;
|
726 |
|
|
while (*cp) {
|
727 |
|
|
len++;
|
728 |
|
|
cp++;
|
729 |
|
|
}
|
730 |
|
|
len++; // for null char
|
731 |
|
|
}
|
732 |
|
|
len += 7;
|
733 |
|
|
len >>= 3;
|
734 |
|
|
return (len);
|
735 |
|
|
}
|
736 |
|
|
|
737 |
|
|
int64_t GetQuadtabLen()
|
738 |
|
|
{
|
739 |
|
|
Float128 *p;
|
740 |
|
|
int64_t len;
|
741 |
|
|
|
742 |
|
|
len = 0;
|
743 |
|
|
for (p = quadtab; p; p = p->next) {
|
744 |
|
|
len++;
|
745 |
|
|
}
|
746 |
|
|
return (len);
|
747 |
|
|
}
|
748 |
|
|
|
749 |
|
|
// Dump the literal pools.
|
750 |
|
|
|
751 |
|
|
void dumplits()
|
752 |
|
|
{
|
753 |
|
|
char *cp;
|
754 |
|
|
int64_t nn;
|
755 |
|
|
|
756 |
|
|
dfs.printf("<Dumplits>\n");
|
757 |
|
|
roseg();
|
758 |
|
|
if (casetab) {
|
759 |
|
|
nl();
|
760 |
|
|
align(8);
|
761 |
|
|
nl();
|
762 |
|
|
}
|
763 |
|
|
while(casetab != nullptr) {
|
764 |
|
|
nl();
|
765 |
|
|
put_label(casetab->label,"",casetab->nmspace,'D');
|
766 |
|
|
for (nn = 0; nn < casetab->num; nn++)
|
767 |
|
|
GenerateLabelReference(casetab->cases[nn].label);
|
768 |
|
|
casetab = casetab->next;
|
769 |
|
|
}
|
770 |
|
|
if (quadtab) {
|
771 |
|
|
nl();
|
772 |
|
|
align(8);
|
773 |
|
|
nl();
|
774 |
|
|
}
|
775 |
|
|
|
776 |
|
|
// Dumping to ro segment - no need for GC skip
|
777 |
|
|
/*
|
778 |
|
|
nn = GetQuadtabLen();
|
779 |
|
|
if (nn) {
|
780 |
|
|
sprintf_s(buf, sizeof(buf), "\tdw\t$%I64X ; GC_skip\n", nn | 0xFFF0200000000000LL);
|
781 |
|
|
ofs.printf("%s", buf);
|
782 |
|
|
}
|
783 |
|
|
*/
|
784 |
|
|
while(quadtab != nullptr) {
|
785 |
|
|
nl();
|
786 |
|
|
put_label(quadtab->label,"",quadtab->nmspace,'D');
|
787 |
|
|
ofs.printf("\tdh\t");
|
788 |
|
|
quadtab->Pack(64);
|
789 |
|
|
ofs.printf("%s",quadtab->ToString(64));
|
790 |
|
|
outcol += 35;
|
791 |
|
|
quadtab = quadtab->next;
|
792 |
|
|
}
|
793 |
|
|
if (strtab) {
|
794 |
|
|
nl();
|
795 |
|
|
align(8);
|
796 |
|
|
nl();
|
797 |
|
|
}
|
798 |
|
|
|
799 |
|
|
//nn = GetStrtabLen();
|
800 |
|
|
//if (nn) {
|
801 |
|
|
// sprintf_s(buf, sizeof(buf), "\tdw\t$%I64X ; GC_skip\n", nn | 0xFFF0200000000000LL);
|
802 |
|
|
// ofs.printf("%s", buf);
|
803 |
|
|
//}
|
804 |
|
|
while( strtab != NULL) {
|
805 |
|
|
dfs.printf(".");
|
806 |
|
|
nl();
|
807 |
|
|
put_label(strtab->label,strip_crlf(strtab->str),strtab->nmspace,'D');
|
808 |
|
|
cp = strtab->str;
|
809 |
|
|
while(*cp)
|
810 |
|
|
GenerateChar(*cp++);
|
811 |
|
|
GenerateChar(0);
|
812 |
|
|
strtab = strtab->next;
|
813 |
|
|
}
|
814 |
|
|
nl();
|
815 |
|
|
dfs.printf("</Dumplits>\n");
|
816 |
|
|
}
|
817 |
|
|
|
818 |
|
|
void nl()
|
819 |
|
|
{
|
820 |
|
|
if(outcol > 0) {
|
821 |
|
|
ofs.printf("\n");
|
822 |
|
|
outcol = 0;
|
823 |
|
|
gentype = nogen;
|
824 |
|
|
}
|
825 |
|
|
}
|
826 |
|
|
|
827 |
|
|
void align(int n)
|
828 |
|
|
{
|
829 |
|
|
ofs.printf("\talign\t%d\n",n);
|
830 |
|
|
}
|
831 |
|
|
|
832 |
|
|
void cseg()
|
833 |
|
|
{
|
834 |
|
|
if( curseg != codeseg) {
|
835 |
|
|
nl();
|
836 |
|
|
ofs.printf("\tcode\n");
|
837 |
|
|
ofs.printf("\talign\t16\n");
|
838 |
|
|
curseg = codeseg;
|
839 |
|
|
}
|
840 |
|
|
}
|
841 |
|
|
|
842 |
|
|
void dseg()
|
843 |
|
|
{
|
844 |
|
|
nl();
|
845 |
|
|
if( curseg != dataseg) {
|
846 |
|
|
ofs.printf("\tdata\n");
|
847 |
|
|
curseg = dataseg;
|
848 |
|
|
}
|
849 |
|
|
ofs.printf("\talign\t8\n");
|
850 |
|
|
}
|
851 |
|
|
|
852 |
|
|
void tseg()
|
853 |
|
|
{
|
854 |
|
|
if( curseg != tlsseg) {
|
855 |
|
|
nl();
|
856 |
|
|
ofs.printf("\ttls\n");
|
857 |
|
|
ofs.printf("\talign\t8\n");
|
858 |
|
|
curseg = tlsseg;
|
859 |
|
|
}
|
860 |
|
|
}
|
861 |
|
|
|
862 |
|
|
void roseg()
|
863 |
|
|
{
|
864 |
|
|
if( curseg != rodataseg) {
|
865 |
|
|
nl();
|
866 |
|
|
ofs.printf("\trodata\n");
|
867 |
|
|
ofs.printf("\talign\t16\n");
|
868 |
|
|
curseg = rodataseg;
|
869 |
|
|
}
|
870 |
|
|
}
|
871 |
|
|
|
872 |
|
|
void seg(int sg, int algn)
|
873 |
|
|
{
|
874 |
|
|
nl();
|
875 |
|
|
if( curseg != sg) {
|
876 |
|
|
switch(sg) {
|
877 |
|
|
case bssseg:
|
878 |
|
|
ofs.printf("\tbss\n");
|
879 |
|
|
break;
|
880 |
|
|
case dataseg:
|
881 |
|
|
ofs.printf("\tdata\n");
|
882 |
|
|
break;
|
883 |
|
|
case tlsseg:
|
884 |
|
|
ofs.printf("\ttls\n");
|
885 |
|
|
break;
|
886 |
|
|
case idataseg:
|
887 |
|
|
ofs.printf("\tidata\n");
|
888 |
|
|
break;
|
889 |
|
|
case codeseg:
|
890 |
|
|
ofs.printf("\tcode\n");
|
891 |
|
|
break;
|
892 |
|
|
case rodataseg:
|
893 |
|
|
ofs.printf("\trodata\n");
|
894 |
|
|
break;
|
895 |
|
|
}
|
896 |
|
|
curseg = sg;
|
897 |
|
|
}
|
898 |
|
|
ofs.printf("\talign\t%d\n", algn);
|
899 |
|
|
}
|