Skip to content

Commit

Permalink
add non-aligned memory words (#4681)
Browse files Browse the repository at this point in the history
  • Loading branch information
iFrostizz authored Apr 2, 2023
1 parent cbb8294 commit f7a535d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,11 @@ impl Tui {
let w = debug_steps[current_step].stack[stack_len - 1];
match op {
opcode::MLOAD => {
word = Some(w.as_usize() / 32);
word = Some(w.as_usize());
color = Some(Color::Cyan);
}
opcode::MSTORE => {
word = Some(w.as_usize() / 32);
word = Some(w.as_usize());
color = Some(Color::Red);
}
_ => {}
Expand All @@ -889,7 +889,7 @@ impl Tui {
if let Instruction::OpCode(op) = debug_steps[prev_step].instruction {
if op == opcode::MSTORE {
let prev_top = debug_steps[prev_step].stack[stack_len - 1];
word = Some(prev_top.as_usize() / 32);
word = Some(prev_top.as_usize());
color = Some(Color::Green);
}
}
Expand All @@ -906,11 +906,12 @@ impl Tui {
.map(|(i, mem_word)| {
let words: Vec<Span> = mem_word
.iter()
.map(|byte| {
.enumerate()
.map(|(j, byte)| {
Span::styled(
format!("{byte:02x} "),
if let (Some(w), Some(color)) = (word, color) {
if i == w {
if (i == w / 32 && j >= w % 32) || (i == w / 32 + 1 && j < w % 32) {
Style::default().fg(color)
} else if *byte == 0 {
Style::default().add_modifier(Modifier::DIM)
Expand Down

0 comments on commit f7a535d

Please sign in to comment.