2018-12-27 17:39:36 +01:00
pub fn addi ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " addi " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = regs [ first ] + second ;
return regs ;
}
pub fn addr ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " addr " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = regs [ first ] + regs [ second ] ;
return regs ;
}
pub fn muli ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " muli " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = regs [ first ] * second ;
return regs ;
}
pub fn mulr ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " rst: " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = regs [ first ] * regs [ second ] ;
return regs ;
}
pub fn bori ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " bori " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = regs [ first ] | second ;
return regs ;
}
pub fn borr ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " borr " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = regs [ first ] | regs [ second ] ;
return regs ;
}
pub fn seti ( first : usize , _second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " seti " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = first ;
return regs ;
}
pub fn setr ( first : usize , _second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " setr " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = regs [ first ] ;
return regs ;
}
pub fn gtir ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " gtir " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = if first > regs [ second ] { 1 } else { 0 } ;
return regs ;
}
pub fn gtri ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " gtri " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = if regs [ first ] > second { 1 } else { 0 } ;
return regs ;
}
pub fn gtrr ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " gtrr " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = if regs [ first ] > regs [ second ] { 1 } else { 0 } ;
return regs ;
}
pub fn eqir ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " eqir " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = if first = = regs [ second ] { 1 } else { 0 } ;
return regs ;
}
pub fn eqri ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " eqri " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = if regs [ first ] = = second { 1 } else { 0 } ;
return regs ;
}
pub fn eqrr ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " eqrr " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = if regs [ first ] = = regs [ second ] { 1 } else { 0 } ;
return regs ;
}
pub fn bani ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " bani " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = regs [ first ] & second ;
return regs ;
}
pub fn banr ( first : usize , second : usize , address : usize , registers : & [ usize ; 4 ] ) -> [ usize ; 4 ] {
2019-01-12 15:08:56 +01:00
println! ( " banr " ) ;
2018-12-27 17:39:36 +01:00
let mut regs = registers . clone ( ) ;
regs [ address ] = first & regs [ second ] ;
return regs ;
}