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.

readtext(filename)
function text = readtext(filename)
%READTEXT reads a file's text into a string
%   TEXT = READTEXT(FILENAME) returns the contents of the text file with
%   name FILENAME as a long string.

%   Copyright 2008 University of Sussex and David Young

fid = fopen(filename, 'rt');
if fid == -1
    throw(MException('bmachine:readtext', ['Unable to open file ' filename]));
end
text = (fread(fid, '*char'))';
fclose(fid);
end

Contact us