MCPcopy Create free account
hub / github.com/eigenform/perfect / pad_cc_until

Method pad_cc_until

perfect/src/asm.rs:214–233  ·  view source on GitHub ↗

Pad with 0xCC until the requested address. Returns the number of emitted bytes.

(&mut self, addr: usize)

Source from the content-addressed store, hash-verified

212 /// Pad with 0xCC until the requested address.
213 /// Returns the number of emitted bytes.
214 pub fn pad_cc_until(&mut self, addr: usize) -> usize {
215 if self.cur_addr() == addr {
216 return 0;
217 }
218 assert!(addr > self.cur_addr(),
219 "Requested pad target {:016x} must be > {:016x}",
220 addr, self.cur_addr(),
221 );
222 assert!(addr <= self.max_addr(),
223 "Requested {:016x} must be <= max addr {:016x}",
224 addr, self.max_addr(),
225 );
226 let mut count = 0;
227 let num_padding = addr - self.cur_addr();
228 for _ in 0..num_padding {
229 dynasm!(self ; .bytes &[0xcc]);
230 count += 1;
231 }
232 count
233 }
234
235 /// Pad with 1-byte NOP until the requested address.
236 /// Returns the number of emitted bytes.

Callers

nothing calls this directly

Calls 1

cur_addrMethod · 0.80

Tested by

no test coverage detected