Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 15 additions & 15 deletions examples/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use aluvm::{aluasm, Prog, Vm};
fn main() {
let code = aluasm! {
clr r1024[5] ;
put 5,a16[8] ;
putif 0xaf67937b5498dc,r256[1] ;
putif 13,a8[1] ;
put a16[8],5 ;
putif r256[1],0xaf67937b5498dc ;
putif a8[1],13 ;
swp a8[1],a8[2] ;
swp f256[8],f256[7] ;
dup a256[1],a256[7] ;
Expand All @@ -40,24 +40,24 @@ fn main() {
ifz r2048[17] ;
inv st0 ;
st.s a8[1] ;
put 13,a32[12] ;
put 66,a32[13] ;
put a32[12],13 ;
put a32[13],66 ;
add.uc a32[12],a32[13] ;
add.sw a32[12],a32[13] ;
sub.sc a32[13],a32[12] ;
mul.uw a32[12],a32[13] ;
div.cu a32[12],a32[13] ;
put 2.13,f32[12] ;
put 5.18,f32[13] ;
put f32[12],2.13 ;
put f32[13],5.18 ;
add.z f32[12],f32[13] ;
sub.n f32[13],f32[12] ;
mul.c f32[12],f32[13] ;
div.f f32[12],f32[13] ;
rem a64[8],a8[2] ;
rem a8[2],a64[8] ;
inc a16[3] ;
add 5,a16[4] ;
add a16[4],5 ;
dec a16[8] ;
sub 82,a16[4] ;
sub a16[4],82 ;
neg a64[15] ;
abs f128[11] ;
and a32[5],a32[6],a32[5] ;
Expand All @@ -69,14 +69,14 @@ fn main() {
scr r256[24],a16[22] ;
scl r256[24],a16[22] ;
rev a512[28] ;
ripemd s16[9],r160[7] ;
sha2 s16[19],r256[2] ;
secpgen r256[1],r512[1] ;
ripemd r160[7],s16[9] ;
sha2 r256[2],s16[19] ;
secpgen r512[1],r256[1] ;
dup r512[1],r512[22] ;
spy a512[1],r512[22] ;
secpmul r256[1],r512[1],r512[2] ;
secpadd r512[22],r512[1] ;
secpneg r512[1],r512[3] ;
secpadd r512[1],r512[22] ;
secpneg r512[3],r512[1] ;
ifz a16[8] ;
jif 190 ;
call 56 @ alu07EnUZgFtu28sWqqH3womkTopXCkgAGsCLvLnYvNcPLRt ;
Expand Down
8 changes: 6 additions & 2 deletions src/data/byte_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,20 @@ impl ByteStr {
#[inline]
pub fn is_empty(&self) -> bool { self.len == 0 }

/// Adjusts the length of the string if necessary
/// Adjusts the length of the string
#[inline]
pub fn adjust_len(&mut self, new_len: u16) { self.len = new_len }

/// Extends the length of the string if necessary
#[inline]
pub fn extend_len(&mut self, new_len: u16) { self.len = new_len.max(self.len) }

/// Fills range within a string with the provided byte value, increasing string length if
/// necessary
pub fn fill(&mut self, range: Range<u16>, val: u8) {
let start = range.start;
let end = range.end;
self.adjust_len(end);
self.extend_len(end);
self.bytes[start as usize..end as usize].fill(val);
}

Expand Down
Loading