8000 Fix incorrect range check for PC offset values by dxrcy · Pull Request #33 · rozukke/lace · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix incorrect range check for PC offset values #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/air.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl AsmLine {
let (offset, _) = label_pos.overflowing_sub(self.line);
let offset = (offset as i16) - 1;
// Must fit in specified offset bits
if offset.abs() > 2i16.pow(bits - 1) - 1 {
if offset.abs() > 2i16.pow(bits - 1) - if offset > 0 { 1 } else { 0 } {
bail!(
severity = Severity::Error,
r#"Difference between label and label reference is too large: at line {}, referencing line {}
Expand Down Expand Up @@ -436,7 +436,7 @@ mod test {
};
assert!(asm.emit().is_err());
let asm = AsmLine {
line: 256,
line: 257,
stmt: AirStmt::Branch {
flag: Flag::Nzp,
dest_label: Label::Ref(1),
Expand Down
Loading
0