From c7b5512ada627ee4a70fad0f6e9cf0276d678a4d Mon Sep 17 00:00:00 2001 From: Erin Date: Sun, 11 Jun 2023 23:24:16 +0200 Subject: [PATCH] fixed label handling --- hbasm/src/lib.rs | 2 +- hbvm/src/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hbasm/src/lib.rs b/hbasm/src/lib.rs index 73546a5..570a166 100644 --- a/hbasm/src/lib.rs +++ b/hbasm/src/lib.rs @@ -128,7 +128,7 @@ pub fn assembly(code: &str, buf: &mut Vec) -> Result<(), Error> { } } Some(Ok(Token::Label(lbl))) => { - self.label_map.insert(lbl, self.buf.len() as u64 + 1); + self.label_map.insert(lbl, self.buf.len() as u64); } Some(Ok(Token::ISep)) => (), Some(Ok(_)) => return Err(ErrorKind::UnexpectedToken), diff --git a/hbvm/src/main.rs b/hbvm/src/main.rs index a311ff0..a136f59 100644 --- a/hbvm/src/main.rs +++ b/hbvm/src/main.rs @@ -6,7 +6,7 @@ use { fn main() -> Result<(), Box> { let mut prog = vec![]; stdin().read_to_end(&mut prog)?; - + if let Err(e) = validate(&prog) { eprintln!("Program validation error: {e:?}"); return Ok(());