Code covered by the BSD License  

Highlights from
Extended Brookshear Machine emulator and assembler

image thumbnail
from Extended Brookshear Machine emulator and assembler by David Young
Emulator and assembler for a simple computer, a teaching aid for computer science courses.

decodeInstr(b1, b2)
function [op, r, s, t] = decodeInstr(b1, b2)
%DECODEINSTR decodes a BM instruction
%   [OP, R, S, T] = DECODEINSTR(B1, B2) decodes an instruction from 2 bytes
%   to 4 nibbles

%   Copyright 2008 University of Sussex and David Young

op = bitshift(b1, -4);
r = bitand(b1, hex2dec('f'));
s = bitshift(b2, -4);
t = bitand(b2, hex2dec('f'));

end

Contact us at files@mathworks.com