Skip to content

Commit

Permalink
isa: asm fix RegAR macro
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Apr 22, 2024
1 parent 3c4d6c2 commit 4058c09
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/isa/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ impl InstructionSet for BytesOp {
let offset = regs.a16[*offset as u8 as usize].filter(|e| *e < s_len)?;
let end = offset
.checked_add(dst.layout().bytes())
.filter(|e| *e < s_len)
.filter(|e| *e <= s_len)
.unwrap_or_else(|| {
regs.st0 = false;
s_len
Expand Down
60 changes: 57 additions & 3 deletions src/isa/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ macro_rules! aluasm_isa {
MergeFlag, MoveOp, PutOp, RoundingFlag, Secp256k1Op, SignFlag, NoneEqFlag
};
use ::aluvm::reg::{
Reg16, Reg32, Reg8, RegA, RegA2, RegBlockAFR, RegBlockAR, RegF, RegR, RegS,
Reg16, Reg32, Reg8, RegA, RegA2, RegAR, RegBlockAFR, RegBlockAR, RegF, RegR, RegS,
NumericRegister,
};
use ::aluvm::library::LibSite;
Expand Down Expand Up @@ -220,15 +220,15 @@ macro_rules! instr {
(extr s16[$idx:literal], $reg:ident[$reg_idx:literal], a16[$offset_idx:literal]) => {
Instr::Bytes(BytesOp::Extr(
RegS::from($idx),
$crate::_reg_ty!(Reg, $reg),
$crate::_reg_tyar!($reg),
$crate::_reg_idx16!($reg_idx),
$crate::_reg_idx16!($offset_idx),
))
};
(inj s16[$idx:literal], $reg:ident[$reg_idx:literal], a16[$offset_idx:literal]) => {
Instr::Bytes(BytesOp::Inj(
RegS::from($idx),
$crate::_reg_ty!(Reg, $reg),
$crate::_reg_tyar!($reg),
$crate::_reg_idx16!($reg_idx),
$crate::_reg_idx16!($offset_idx),
))
Expand Down Expand Up @@ -1355,6 +1355,60 @@ macro_rules! _reg_tyr {
};
}

#[doc(hidden)]
#[macro_export]
macro_rules! _reg_tyar {
(a8) => {
RegAR::A(RegA::A8)
};
(a16) => {
RegAR::A(RegA::A16)
};
(a32) => {
RegAR::A(RegA::A32)
};
(a64) => {
RegAR::A(RegA::A64)
};
(a128) => {
RegAR::A(RegA::A128)
};
(a256) => {
RegAR::A(RegA::A256)
};
(a512) => {
RegAR::A(RegA::A512)
};
(a1024) => {
RegAR::A(RegA::A1024)
};

(r128) => {
RegAR::R(RegR::R128)
};
(r160) => {
RegAR::R(RegR::R160)
};
(r256) => {
RegAR::R(RegR::R256)
};
(r512) => {
RegAR::R(RegR::R512)
};
(r1024) => {
RegAR::R(RegR::R1024)
};
(r2048) => {
RegAR::R(RegR::R2048)
};
(r4096) => {
RegAR::R(RegR::R4096)
};
(r8192) => {
RegAR::R(RegR::R8192)
};
}

#[doc(hidden)]
#[macro_export]
macro_rules! _reg_idx {
Expand Down

0 comments on commit 4058c09

Please sign in to comment.