Skip to content

Commit 49b6fc3

Browse files
committed
And fix kRexPrefix too
1 parent 492a813 commit 49b6fc3

10 files changed

+30
-10
lines changed

compiling-binary.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,9 @@ Indirect Ind(Register reg, int8_t disp) {
232232
return (Indirect){.reg = reg, .disp = disp};
233233
}
234234

235-
static const byte kRexPrefix = 0x48;
235+
enum {
236+
kRexPrefix = 0x48,
237+
};
236238

237239
void Emit_mov_reg_imm32(Buffer *buf, Register dst, int32_t src) {
238240
Buffer_write8(buf, kRexPrefix);

compiling-elf.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,9 @@ Indirect Ind(Register reg, word disp) {
322322
// http://www.c-jump.com/CIS77/CPU/x86/lecture.html
323323
// https://wiki.osdev.org/X86-64_Instruction_Encoding
324324

325-
const byte kRexPrefix = 0x48;
325+
enum {
326+
kRexPrefix = 0x48,
327+
};
326328

327329
typedef enum {
328330
Scale1 = 0,

compiling-heap.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ Indirect Ind(Register reg, int8_t disp) {
274274
return (Indirect){.reg = reg, .disp = disp};
275275
}
276276

277-
const byte kRexPrefix = 0x48;
277+
enum {
278+
kRexPrefix = 0x48,
279+
};
278280

279281
void Emit_mov_reg_imm32(Buffer *buf, Register dst, int32_t src) {
280282
Buffer_write8(buf, kRexPrefix);

compiling-if.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,9 @@ Indirect Ind(Register reg, int8_t disp) {
256256
return (Indirect){.reg = reg, .disp = disp};
257257
}
258258

259-
static const byte kRexPrefix = 0x48;
259+
enum {
260+
kRexPrefix = 0x48,
261+
};
260262

261263
void Emit_mov_reg_imm32(Buffer *buf, Register dst, int32_t src) {
262264
Buffer_write8(buf, kRexPrefix);

compiling-immediates.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ typedef enum {
177177
kRdi,
178178
} Register;
179179

180-
static const byte kRexPrefix = 0x48;
180+
enum {
181+
kRexPrefix = 0x48,
182+
};
181183

182184
void Emit_mov_reg_imm32(Buffer *buf, Register dst, int32_t src) {
183185
Buffer_write8(buf, kRexPrefix);

compiling-integers.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ typedef enum {
141141
kRdi,
142142
} Register;
143143

144-
static const byte kRexPrefix = 0x48;
144+
enum {
145+
kRexPrefix = 0x48,
146+
};
145147

146148
void Emit_mov_reg_imm32(Buffer *buf, Register dst, int32_t src) {
147149
Buffer_write8(buf, kRexPrefix);

compiling-let.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ Indirect Ind(Register reg, int8_t disp) {
248248
return (Indirect){.reg = reg, .disp = disp};
249249
}
250250

251-
static const byte kRexPrefix = 0x48;
251+
enum {
252+
kRexPrefix = 0x48,
253+
};
252254

253255
void Emit_mov_reg_imm32(Buffer *buf, Register dst, int32_t src) {
254256
Buffer_write8(buf, kRexPrefix);

compiling-procedures.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,9 @@ Indirect Ind(Register reg, word disp) {
276276
// http://www.c-jump.com/CIS77/CPU/x86/lecture.html
277277
// https://wiki.osdev.org/X86-64_Instruction_Encoding
278278

279-
const byte kRexPrefix = 0x48;
279+
enum {
280+
kRexPrefix = 0x48,
281+
};
280282

281283
typedef enum {
282284
Scale1 = 0,

compiling-reader.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ Indirect Ind(Register reg, int8_t disp) {
235235
return (Indirect){.reg = reg, .disp = disp};
236236
}
237237

238-
static const byte kRexPrefix = 0x48;
238+
enum {
239+
kRexPrefix = 0x48,
240+
};
239241

240242
void Emit_mov_reg_imm32(Buffer *buf, Register dst, int32_t src) {
241243
Buffer_write8(buf, kRexPrefix);

compiling-unary.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ typedef enum {
214214
// TODO(max): Add more
215215
} Condition;
216216

217-
static const byte kRexPrefix = 0x48;
217+
enum {
218+
kRexPrefix = 0x48,
219+
};
218220

219221
void Emit_mov_reg_imm32(Buffer *buf, Register dst, int32_t src) {
220222
Buffer_write8(buf, kRexPrefix);

0 commit comments

Comments
 (0)