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.

bitmapDisplay(hObject)
function bitmapDisplay(hObject)
%BITMAPDISPLAY displays low 128 bytes of memory as 32x32 bitmap
%   BITMAPDISPLAY(HOBJECT) takes any object in the guie and updates the
%   bitmap display.

%   Copyright 2008 University of Sussex and David Young

handles = guidata(hObject);
arr = memBytes2arr(handles.machine.memory(129:256));
% Not clear why the next step is spectacularly slow. Does not seem to make
% any difference whether the image is indexed or RGB, or what the axis
% settings are, or whether Cdata is updated or the image replaced with a
% new object, or whether the renderer is painter's or z-buffer.
set(handles.bitmapDisplay.image, 'CData', arr);
end


function arr = memBytes2arr(mem)
% Convert bytes to 2-D array for display
arr = zeros(32, 32, 'uint8');
for bit = 1:8
    arr(9-bit:8:end) = bitand(mem, 1);
    mem = bitshift(mem, -1);
end
arr = arr';         % along rows
end
    


Contact us