Add call/ret/push/pop instructions
* Call/ret/push/pop are implemented and appear to be working * Call/ret/push/pop is specified in the 0x2000 block, replacing the mov instruction * Mov instruction is now specified in the 0x3000 block Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -90,6 +90,13 @@ impl<T> MemCursor<T>
|
||||
Ok(Inst::$variant(source))
|
||||
}};
|
||||
}
|
||||
macro_rules! dest {
|
||||
($variant:ident) => {{
|
||||
let spec = (self.next_u8()? & 0xF0) >> 4;
|
||||
let dest = self.next_dest(spec)?;
|
||||
Ok(Inst::$variant(dest))
|
||||
}};
|
||||
}
|
||||
let inst = match op {
|
||||
ADD => dest_source!(Add),
|
||||
SUB => dest_source!(Sub),
|
||||
@@ -110,6 +117,10 @@ impl<T> MemCursor<T>
|
||||
JMP => source!(Jmp),
|
||||
JZ => source!(Jz),
|
||||
JNZ => source!(Jnz),
|
||||
CALL => source!(Call),
|
||||
RET => Ok(Inst::Ret),
|
||||
PUSH => source!(Push),
|
||||
POP => dest!(Pop),
|
||||
MOV => dest_source!(Mov),
|
||||
HALT => Ok(Inst::Halt),
|
||||
NOP => Ok(Inst::Nop),
|
||||
|
||||
Reference in New Issue
Block a user