Add Bool and Char addressing modes
All checks were successful
per-push tests / build (push) Successful in 1m45s
per-push tests / test-frontend (push) Successful in 2m5s
per-push tests / test-utility (push) Successful in 2m12s
per-push tests / timed-decomposer-parse (push) Successful in 1m8s
per-push tests / test-backend (push) Successful in 1m17s
All checks were successful
per-push tests / build (push) Successful in 1m45s
per-push tests / test-frontend (push) Successful in 2m5s
per-push tests / test-utility (push) Successful in 2m12s
per-push tests / timed-decomposer-parse (push) Successful in 1m8s
per-push tests / test-backend (push) Successful in 1m17s
This commit adds addressing modes for boolean and character data. The Address enum is extended, along with its TryFrom<u8> implementation and its operand_size function. The access macro is extended to handle the new modes. The CONST instruction can now create Char and Bool data. The instructions.toml has information on the new addressing modes. Unit tests have been added to test new CONST logic. fixes: #41 Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
parent
4fb7e78c2a
commit
e310b901c3
3 changed files with 76 additions and 25 deletions
|
|
@ -26,14 +26,16 @@ use core::mem::transmute;
|
|||
#[repr(u8)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Address {
|
||||
Stack = 0xf0, // immutable access only
|
||||
Instr = 0xf1, // immutable access only
|
||||
Expr = 0xf2, // mutable access allowed
|
||||
Oper1 = 0xf3, // mutable access allowed
|
||||
Oper2 = 0xf4, // mutable access allowed
|
||||
Oper3 = 0xf5, // mutable access allowed
|
||||
Oper4 = 0xf6, // mutable access allowed
|
||||
Numer = 0xf8, // immutable access only
|
||||
Stack = 0xf0, // immutable access only
|
||||
Instr = 0xf1, // immutable access only
|
||||
Expr = 0xf2, // mutable access allowed
|
||||
Oper1 = 0xf3, // mutable access allowed
|
||||
Oper2 = 0xf4, // mutable access allowed
|
||||
Oper3 = 0xf5, // mutable access allowed
|
||||
Oper4 = 0xf6, // mutable access allowed
|
||||
Numer = 0xf8, // immutable access only
|
||||
Bool = 0xf9, // immutable access only
|
||||
Char = 0xfa, // immutable access only
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
|
@ -55,14 +57,16 @@ impl TryFrom<u8> for Address {
|
|||
type Error = &'static str;
|
||||
fn try_from(val: u8) -> Result<Self, Self::Error> {
|
||||
match val {
|
||||
_ if val == Address::Stack as u8 => Ok(Address::Stack),
|
||||
_ if val == Address::Instr as u8 => Ok(Address::Instr),
|
||||
_ if val == Address::Expr as u8 => Ok(Address::Expr),
|
||||
_ if val == Address::Oper1 as u8 => Ok(Address::Oper1),
|
||||
_ if val == Address::Oper2 as u8 => Ok(Address::Oper2),
|
||||
_ if val == Address::Oper3 as u8 => Ok(Address::Oper3),
|
||||
_ if val == Address::Oper4 as u8 => Ok(Address::Oper4),
|
||||
_ if val == Address::Numer as u8 => Ok(Address::Numer),
|
||||
_ if val == Address::Stack as u8 => Ok(Address::Stack),
|
||||
_ if val == Address::Instr as u8 => Ok(Address::Instr),
|
||||
_ if val == Address::Expr as u8 => Ok(Address::Expr),
|
||||
_ if val == Address::Oper1 as u8 => Ok(Address::Oper1),
|
||||
_ if val == Address::Oper2 as u8 => Ok(Address::Oper2),
|
||||
_ if val == Address::Oper3 as u8 => Ok(Address::Oper3),
|
||||
_ if val == Address::Oper4 as u8 => Ok(Address::Oper4),
|
||||
_ if val == Address::Numer as u8 => Ok(Address::Numer),
|
||||
_ if val == Address::Bool as u8 => Ok(Address::Bool),
|
||||
_ if val == Address::Char as u8 => Ok(Address::Char),
|
||||
_ => Err("illegal addressing mode")
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +78,8 @@ impl Address {
|
|||
Address::Stack => (usize::BITS / 8) as u8,
|
||||
Address::Instr => (usize::BITS / 8) as u8,
|
||||
Address::Numer => (usize::BITS / 8) as u8,
|
||||
Address::Bool => 1,
|
||||
Address::Char => 1,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue