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.

writetext(text, file)
function writetext(text, file)
%WRITETEXT writes text to a file
%   WRITETEXT(TEXT, FILE) takes a string TEXT and a string FILE. A file
%   named FILE is opened and the text string is written to it; the file is
%   then closed.

%   Copyright 2008 University of Sussex and David Young

[fid, message] = fopen(file, 'wt');
if fid < 0
    throw(MException('bmachine:savemem:open', message));
end
if ~isequal(fwrite(fid, text, 'char'), length(text))
    throw(MException('bmachine:savemem:write', 'Could not complete write'));
end
fclose(fid);
end

Contact us at files@mathworks.com