Skip to content

Commit 17d17a8

Browse files
committed
Latest
1 parent fc29a87 commit 17d17a8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2926
-2281
lines changed

workspace/assembler/src/mk2/ByteEmitter.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ pub(crate) struct ByteEmitter
1212

1313
impl ByteEmitter
1414
{
15+
#[inline(always)]
16+
pub(crate) fn emit_u8_if_not_zero(&mut self, byte: u8)
17+
{
18+
if byte != 0x00
19+
{
20+
self.byte_emitter.emit_u8(byte)
21+
}
22+
}
23+
1524
#[inline(always)]
1625
pub(crate) fn emit_u8(&mut self, emit: u8)
1726
{
@@ -26,7 +35,7 @@ impl ByteEmitter
2635
{
2736
const Size: usize = 2;
2837
debug_assert!(self.instruction_pointer + Size <= self.end_instruction_pointer, "Not enough space to emit an u16");
29-
unsafe { *(self.instruction_pointer as *mut u16) } = emit;
38+
unsafe { *(self.instruction_pointer as *mut u16) } = emit.to_le();
3039
self.instruction_pointer += Size;
3140
}
3241

@@ -35,7 +44,7 @@ impl ByteEmitter
3544
{
3645
const Size: usize = 4;
3746
debug_assert!(self.instruction_pointer + Size <= self.end_instruction_pointer, "Not enough space to emit an u32");
38-
unsafe { *(self.instruction_pointer as *mut u32) } = emit;
47+
unsafe { *(self.instruction_pointer as *mut u32) } = emit.to_le();
3948
self.instruction_pointer += Size;
4049
}
4150

@@ -44,7 +53,7 @@ impl ByteEmitter
4453
{
4554
const Size: usize = 8;
4655
debug_assert!(self.instruction_pointer + Size <= self.end_instruction_pointer, "Not enough space to emit an u64");
47-
unsafe { *(self.instruction_pointer as *mut u64) } = emit;
56+
unsafe { *(self.instruction_pointer as *mut u64) } = emit.to_le();
4857
self.instruction_pointer += Size;
4958
}
5059
}

workspace/assembler/src/mk2/Displacement.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ impl Displacement for u16
2222
#[inline(always)]
2323
fn write(self, byte_emitter: &mut ByteEmitter)
2424
{
25-
byte_emitter.emit_u16(self.to_le())
25+
byte_emitter.emit_u16(self)
2626
}
2727
}
2828

@@ -31,7 +31,7 @@ impl Displacement for u32
3131
#[inline(always)]
3232
fn write(self, byte_emitter: &mut ByteEmitter)
3333
{
34-
byte_emitter.emit_u32(self.to_le())
34+
byte_emitter.emit_u32(self)
3535
}
3636
}
3737

@@ -40,6 +40,6 @@ impl Displacement for u64
4040
#[inline(always)]
4141
fn write(self, byte_emitter: &mut ByteEmitter)
4242
{
43-
byte_emitter.emit_u64(self.to_le())
43+
byte_emitter.emit_u64(self)
4444
}
4545
}

0 commit comments

Comments
 (0)