From 7d1f636239dd88eecd5b542d465a0466a4d86389 Mon Sep 17 00:00:00 2001 From: Ry Date: Sun, 18 Sep 2022 16:34:14 -0700 Subject: [PATCH] Add `rfp` register support --- src/fox32.pest | 2 +- src/main.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fox32.pest b/src/fox32.pest index 124ed92..f7073f8 100644 --- a/src/fox32.pest +++ b/src/fox32.pest @@ -158,4 +158,4 @@ body_str_chars = { } register = ${ "r" ~ register_num } -register_num = @{ ASCII_DIGIT+ | "sp" | "esp" } +register_num = @{ ASCII_DIGIT+ | "sp" | "esp" | "fp" } diff --git a/src/main.rs b/src/main.rs index eadd173..5034838 100644 --- a/src/main.rs +++ b/src/main.rs @@ -814,8 +814,9 @@ fn parse_operand(mut pair: pest::iterators::Pair, is_pointer: bool) -> Ast let register_num_pair = operand_value_pair.into_inner().next().unwrap(); let register_num = if register_num_pair.as_str() == "sp" { 32 } else if register_num_pair.as_str() == "esp" { 33 } + else if register_num_pair.as_str() == "fp" { 34 } else { register_num_pair.as_str().parse::().unwrap() }; - if register_num > 33 { panic!("register number out of range"); } + if register_num > 34 { panic!("register number out of range"); } if is_pointer { AstNode::RegisterPointer(register_num) } else {