Code covered by the BSD License
-
Extended Brookshear Machine A...
-
Extended Brookshear Machine E...
-
bm(varargin)
BM GUI for Brookshear Machine emulator
-
assembler(file)
ASSEMBLER is an assembler for the extended Brookshear machine
-
bitmapDisplay(hObject)
BITMAPDISPLAY displays low 128 bytes of memory as 32x32 bitmap
-
bits2strings(a, i, type)
BITS2STRINGS returns strings for displaying memory contents
-
bmachine
BMACHINE starts the emulator and assembler GUI
-
dble2f8(d)
DBLE2F8 converts from double to Brookshear's 1-byte floating point
-
dble2int8(d)
DBLE2INT8 converts double to 1-byte signed integer
-
decodeInstr(b1, b2)
DECODEINSTR decodes a BM instruction
-
f82dble(f)
F82DBLE converts Brookshear 1-byte float to double
-
instr2string(type, b1, b2)
INSTR2STRING returns string representation of instruction
-
instr2string_ass(b1, b2)
INSTR2STRING_ASS returns string representation of instruction
-
instr2string_desc(b1, b2)
INSTR2STRING_DESC returns string representation of instruction
-
int82dble(i)
INT82DBLE converts 1-byte signed integer to double
-
loadmem(machine, text)
LOADMEM loads instructions from text into memory
-
memstrings(machine, rows, ins...
MEMSTRINGS returns strings describing contents of memory as instructions
-
newbm
NEWBM creates a new Brookshear machine
-
nibbles2byte(x, y)
NIBBLES2BYTE converts two nibbles to a byte
-
oddaddr(pc, a)
ODDADDR checks whether an address is at an odd offset from the pc
-
readtext(filename)
READTEXT reads a file's text into a string
-
regstrings(machine)
REGSTRINGS returns strings representing the current state of the registers
-
resetReg(machine)
RESETREG resets registers
-
saveDisplay(hObject)
SAVEDISPLAY saves the current display in a file
-
savemem(machine, file, instty...
SAVEMEM saves the current state of memory in a text file
-
showhelp(name)
SHOWHELP displays a help file
-
showinstructions
SHOWINSTRUCTIONS displays a list of BM instructions
-
step(machine)
STEP carries out one execution step on a BM
-
string2val(type, inp)
STRING2VAL returns value from text entry in display
-
writetext(text, file)
WRITETEXT writes text to a file
-
Contents.m
-
Contents.m
-
todo.m
-
View all files
from
Extended Brookshear Machine emulator and assembler
by David Young
Emulator and assembler for a simple computer, a teaching aid for computer science courses.
|
| memstrings(machine, rows, insttype)
|
function c = memstrings(machine, rows, insttype)
%MEMSTRINGS returns strings describing contents of memory as instructions
% C = MEMSTRINGS(MACHINE, ROWS, INSTTYPE) produces a cell array of
% strings representing the current state of the memory of the BM MACHINE
% between the rows given by the elements of ROWS. Memory is indexed from
% 1 to 256 - i.e. rows are 1 greater than the corresponding BM addresses.
% INSTTYPE controls whether the text is assembly language or descriptive.
%
% With no arguments returns header strings.
%
% If MACHINE is empty, return result for a machine whose memory has been
% cleared.
%
% See also: BITS2STRINGS, INSTR2STRING
% Copyright 2008 University of Sussex and David Young
if nargin == 0
b = bits2strings;
c = {b{:} 'Instruction'};
return
end
if isempty(machine)
machine = newbm;
end
m = machine.memory;
pc = machine.pc;
r0 = rows(1);
r1 = rows(2);
c = cell(r1-r0+1, length(bits2strings)+1);
j = 0;
for i = r0:r1
j = j+1;
c(j, 1:end-1) = bits2strings(i-1, m(i));
if oddaddr(pc, i) && i < length(m) % even offsets from pc only
c{j, end} = instr2string(insttype, m(i), m(i+1));
else
c{j, end} = '';
end
end
end
|
|
Contact us at files@mathworks.com