EE 2504: Introduction to Computer Engineering
MANOSIM and MANOASM User's Guide
Version 2.20
by
Roger Chen and Dong S. Ha
January 1, 1990
(User's Guide Revised August 20, 1996)
(Revised for Univ. at Albany March 21, 2001)
Table of Contents
Introduction
MANOSIM is a simulator program designed to simulate all the functions of
the computer in Chapters 5 and 6 of Computer System Architecture
by M. Morris Mano. The simulator is written in "C" and is currently available
for IBM based machines. MANOSIM can simulate all functions of the "Mano
Machine" including input-output functions and interrupts. The simulator
is completely interactive and is designed to be used by persons with little
experience in using computers.
MANOASM is an assembler program that will input programs written
in the assembly language for the Mano Basic Machine, which is described
in Chapter 6 of Computer System Architecture by M. Morris Mano.
It will output a file that can be input to MANOSIM. Instructions
for MANOASM are given below . You
can use MANOSIM and MANOASM independently of one another.
The names of the executables supplied here mano2 and
manoasm differ from the names MANOSIM and
MANOASM documented below. Please make the
appropriate substitutions. Please report variations from the behavior
documented below to sdc@cs.albany.edu
so I can improve this page.
The concepts for the software package and this manual are derived from
the original MANOSIM written by J. Pelissier, August 1983.
Starting MANOSIM
To use the software, you must first obtain your own copies of MANOASM and/or
MANOSIM. They are available as (uncompressed) MSDOS executables:
-
Download the files manoasm.exe and
mano2.exe and save them in the directory where
you will use the assembler and simulator.
Your instructor may announce other ways to obtain MANOSIM. Once you have
manosim.exe, you are ready to run the program. Simply execute MANOSIM at
the DOS prompt. You will see the following start-up message.
MANOSIM Version 2.20
(w)1989 Roger Chen
System Reset
*
MANOSIM is now ready to accept your commands. All commands may be typed
in upper or lower case letters.
MANOSIM Commands
All interaction between MANOSIM and the user is accomplished through a
set of commands. Each command consists of a name, such as "TRACE", and
may be followed by several parameters.
The parameters consist of keywords, such as "ON" or "OFF", expressions,
text, and file names. Numbers in expressions may be entered in either decimal
or hex. To enter a number in hex, the number must be preceded by a '$'
character.
Expressions can be simple mathematical expressions, and even labels.
As an example, the numerical convert command "CV" will accept an expression
"expr" that can contain a combination of numbers and labels, and use the
arithmetic operators "+" and "-".
Examples:
| * CV 5+4+$100 |
adds decimal 5 and 4 to hex $100 |
| * CV $FF2 |
converts hex $FF2 |
| * CV START |
displays value of label START (if present) |
| * CV START + $20 |
|
| * CV (START-END)+1 |
YES! Parentheses are okay |
Evaluation always occurs from right to left, so, for example the following
expressions produce different results.
| * CV (10-5)+2 |
Evaluates to 7 |
| * CV 10-5+2 |
Evaluates to -(5+2)+10, or 3 |
Types of parameters used for commands are as follows.
| "number" |
A numerical expression (as in above examples) |
| "addr-val" |
An expression that refers to a Mano machine memory address and that
does not exceed $FFF |
| "text" |
Any text strings (quotes are not necessary) |
| "filename" |
DOS file name that can include path and extension |
| ON, OFF, M, PC, AC, E,
IEN |
Specific MANOSIM keywords |
MANOSIM Command List
Below is a list of commands that MANOSIM recognizes. Parameters listed
in [ ] are optional. Many commands have abbreviated forms.
BREAKPOINT (Abbreviations: "BPT", "B")
-
Syntax:
-
BREAKPOINT [number] addr-val
-
BPT [number] ON
-
BPT [number] OFF
-
BPT
The BREAKPOINT command instructs the simulator to stop execution of a program
immediately before executing the instruction located at the specified address.
The simulator will always execute at least one instruction. Therefore,
if execution begins at a breakpoint, the simulator will ignore the breakpoint
for the instruction cycle. Program execution may be continued by entering
the "GO" command.
There are a total of six unique breakpoints. "number" specifies which
breakpoint, and if omitted, breakpoint 1 is assumed. The "ON" and "OFF"
keywords turn a certain breakpoint on and off, respectively.
Examples:
| BPT START+5 |
Sets breakpoint 1 to label START plus 5 words and enables it |
| BPT 3 $100 |
Enables and set break 3 to $100 |
| BPT 5 OFF |
Disables breakpoint 5 |
| BPT |
Displays all breakpoints and value |
COMMENT (Abbreviation: "C")
-
Syntax:
-
COMMENT text
The COMMENT command is used for documentation purposes. Any text following
"COMMENT" will be ignored by the simulator.
CONVERT (Abbreviation: "CV")
-
Syntax:
-
CONVERT number
The CONVERT command will convert a numerical expression (hex or decimal
constant or label, or combination of constants and/or labels using math
operators "+" and "-") to decimal unsigned, decimal signed two's complement,
and hexadecimal form. The value of the expression and any constants must
be between $0000 and $FFFF, inclusive, if entered in hex or between -32768
and 65535, inclusive, if entered in decimal.
DISASSEMBLE (Abbreviation: "DIS")
-
Syntax:
-
DISASSEMBLE addr-val1 [addr-val2]
The DISASSEMBLE command causes the section of memory between addr-val1
and addr-val2, inclusive, to be disassembled. The disassembled listing
will include the address, contents, and mnemonic. The address of the operand
and the indirect indicator will also be printed, if applicable. Labels
from source code are not included in the disassembly.
Illegal opcodes will produce "???" as the mnemonic.
The disassembler has no way of distinguishing areas of memory containing
programs from those containing data or garbage. Consequently, the disassembler
will attempt to disassemble any section of memory that it is told to do
so. If a program is not present at that section of memory, the disassembler
will produce meaningless results.
Pressing the escape (ESC) key while MANOSIM is disassembling will halt
the disassembly and MANOSIM will prompt you for a new command. Pressing
the SPACE key during a disassembly will pause and un-pause the listing.
DISPLAY (Abbreviation: "D")
-
Syntax:
-
DISPLAY addr-val1 [addr-val2]
This command will cause the section of memory between addr-val1 and addr-val2
to be displayed. Data is displayed in hexadecimal form.
ERASE
-
Syntax:
-
ERASE filename
The ERASE command will cause a file to be removed from the floppy disk.
Care should be taken to ensure that a file is not erased by mistake. Once
a file is erased, it requires a special software utility to get it back.
The full file name must be specified as if you were using the DOS "DEL"
command. An error is displayed if the file does not exist.
FILES
-
Syntax:
-
FILES filename
The FILES command causes the file names contained on the floppy disk to
be displayed. Because of the way DOS handles a FILES request, the file
names will not appear in the log output. "filename" must be a DOS file
specification. It may contain wildcards "*" or "?".
GO (Abbreviation: "G")
-
Syntax:
-
GO [addr-val1] [addr-val2]
This command instructs the simulator to begin executing a program in memory.
Entering "GO" without parameters starts at the address currently stored
in the program counter. If [addr-val1] is specified, the program counter
is set to [addr-val1] and then execution is begun. Specifying a second
address will set an unused breakpoint to [addr-val2] and enable that breakpoint.
If all breakpoints are in use, it will re-assign breakpoint 1 to [addr-val2].
The computer will execute commands between [addr-val1] and [addr-val2],
considering the program will reach [addr-val2]. While the computer is executing
a program, all input/output interaction will be through the computer screen
and keyboard, as if it were acting as a terminal to the host computer.
Input to the "host" is buffered until read by "INP" instructions. Output
from "OUT" occurs immediately.
INITIALIZE (Abbreviation: "INI")
-
Syntax:
-
INITIALIZE
If you use the "HXC" assembly language directive instead of "HEX" and the
"DCC" directive instead of "DEC", you can automatically initialize those
memory locations in MANOSIM using the INITIALIZE command. INITIALIZE resets
the memory values defined by "HXC" or "DCC" to their original (assembled)
values. This is useful if the program modifies values (e.g. counters or
pointers) stored in memory during execution that need to be reset to run
the program again.
IOCYC (Abbreviation: "IOC")
-
Syntax:
-
IOCYC number
The IOCYC command allows the user to specify how many instruction cycles
are required to complete each input or output request of the Mano Machine.
See MANOSIM Input-Output section for a detailed
explanation.
LOAD (Abbreviation: "L")
-
Syntax:
-
LOAD filename[.OBJ]
The LOAD command reads the contents of an object file into memory. The
name of the object file is specified in "filename".
LOG
-
Syntax:
-
LOG ON filename
-
LOG OFF
The "LOG ON" command creates a log file. This will cause all information
displayed on the screen to be placed in the log file specified by "filename".
Note that no file extension is implied. If desired, an extension must be
included in "filename". After ending the simulator session, this file may
be printed or used with another application. If the specified file already
exists, all new information will be appended at the end of the file. This
allows the user to include only particular parts of the MANOSIM session
in the log file.
"LOG OFF" instructs the simulator to stop echoing information to the
log file.
Note that when the log command is on, the disk will occasionally start
and stop. This is normal.
QUIT
-
Syntax:
-
QUIT
This command is used to exit the simulator. Memory contents and all changes
will be lost unless the SAVE command has been used.
RESET
-
Syntax:
-
RESET
This command resets all the simulator options to their default values.
These are summarized in the following table. The log option and memory
contents are not affected by this command.
| Parameter |
Default Value |
| IEN |
0 |
| Accumulator |
0 |
| STEPS |
infinite |
| Breakpoints |
clear |
| Input Buffer |
clear |
| E |
0 |
| Program Counter |
0 |
| TRACE |
OFF |
| IOCYC |
5 |
SAVE
-
Syntax:
-
SAVE addr-val1 addr-val2 filename[.OBJ]
This command creates an object file containing the contents of memory between
addr-val1 and addr-val2, inclusive. The name of the object file is specified
by "filename".
If the specified file already exists, the old file will be replaced
by the new one.
SET (Abbreviation: "S")
-
Syntax Option 1:
-
SET PC [constant]
-
SET AC [constant]
-
SET E [constant]
-
SET IEN [constant]
This first version of the command allows the user to examine and optionally
change the value of the PC, AC, E or IEN registers. If "constant" is specified,
the register will be set to that value. The constant may be in decimal
or hex.
-
Syntax Option 2:
-
SET M addr-val
This second version of the command allows the user to examine and optionally
set individual bytes of memory. Upon receiving the SET command, the simulator
will display the address specified by "addr-val" and the contents of memory
at that address. If the user simply types the return (ENTER) key, the next
sequential memory location will be displayed. If the user enters a number,
that value will be set at the current memory location before the next location
is displayed. A preceding "$" character is required for hex values.
To exit this command, enter a "/" character.
SOURCE
-
Syntax:
-
SOURCE filename[.TXT]
This command reads and assembles a source code file like MANOASM. The only
advantage is that labels used in the program will be accessible while using
the simulator. In this way, more than one program can be loaded at a time,
provided:
-
they do not occupy the same space in memory, and
-
they do not use labels with the same name.
Subsequent programs can use the labels from previously loaded programs,
thus the concept of program module linking can be achieved.
STEPS (Abbreviation: "ST")
-
Syntax:
-
STEPS number
This command specifies the maximum number of instructions the simulator
should execute before stopping. This will allow the user some recovery
from infinite loops and branches outside the program area.
After execution has stopped, it may be continued again simply by entering
the "GO" command.
Setting STEPS to 1 will allow the user to single step through a program.
Setting STEPS to 0 will set an infinite number of steps. The default for
STEPS is infinity.
TIMESTAMP (Abbreviation: "TS")
-
Syntax:
-
TIMESTAMP
This command causes the simulator to display the current time and date
(as set on your computer).
TRACE (Abbreviation: "T")
-
Syntax:
-
TRACE ON
-
TRACE OFF
This command causes the simulator to trace the execution of a program.
The simulator will display the instruction, operand, and processor status
immediately after each instruction is executed. When TRACE is OFF, the
simulator will execute a program without printing any information regarding
its execution. Note that programs execute considerably faster when the
trace option is off.
MANOSIM Input-Output
MANOSIM will very nearly simulate the action of a low-speed data terminal
as an input-output (I/O) device. The simulation is described below.
Input
Input characters are sequentially retrieved from the input buffer and placed
in the INPR register. When a character is placed in the INPR register,
the FGI flag is set. When a character is removed from the INPR register
by an INP instruction, the FGI flag is reset (cleared), but the INPR register
is unaffected. Once an INP instruction is executed, the simulator waits
the number of machine cycles specified by the "IOCYC" command before another
character is retrieved from the input buffer and placed in INPR, thus setting
the FGI flag. If an attempt is made to execute an INP instruction while
the FGI flag is reset, the current contents of INPR will be moved, causing
duplication of characters read. This action is consistent with the action
of most serial interfaces.
Output
When an OUT instruction is executed, data is moved to the OUTR register
and the FGO flag is reset (cleared). This data is then echoed to the simulator
display. The simulator will then wait the number of instruction cycles
specified by the "IOCYC" command before setting the FGO flag again. If
an OUT instruction is executed while the FGO flag is reset, the OUT information
will be lost. OUT instructions that occur while TRACE is ON will work concurrently
with the trace display, so some lines of the trace will be shifted over
one column.
MANOASM Assembler
MANOASM is a two-pass assembler for converting MANO source code (as described
in Chapter 6 of Computer Systems Architecture) into object code
for use in the MANOSIM simulator. All of the conventions and rules of proper
syntax outlined in the book apply here.
Executing MANOASM
To invoke the assembler and assemble a single file, use the following at
the DOS prompt:
MANOASM sourcefile[.TXT] [-L[listfile[.LST]]]
[-Oobjectfile[.OBJ]]
"sourcefile" is the name of the source code file created by a text editor
(such as EDLIN in DOS or the Windows Notepad). If the -L option is specified,
MANOASM will produce an listing file for the assembled program, including
a label chart. If a name is not specified after the -L option, the listing
file name will default to the "sourcefile" root and the extension ".LST".
The -O option is used only if you want the object file to be named something
other than the root of the "sourcefile" with extension ".OBJ".
Example: A> MANOASM PROJ_3 -L
This will assemble the file "PROJ_3.TXT" and produce the object file
named "PROJ_3.OBJ" and the list file "PROJ_3.LST".
HXC and DCC Directives
"HXC" and "DCC" are two extra pseudo-ops and act exactly like "HEX" and
"DEC", respectively, except that the associated memory location can be
reset to its initial value using the INITIALIZE (INI) command in MANOSIM.
MANOASM Error Messages
-
"Bad opcode spec or unknown opcode"
-
An opcode unknown to the assembler was given, or a label was specified
without a comma.
-
"Memory overflow"
-
Program went past the bounds of memory, FFF hex.
-
"Bad label (too long)"
-
Label was too long or contained an unrecognizable ASCII character.
-
"Operand field error (too long)"
-
Operand specification was too long (math expression too complex), or slash
character not encountered before comment(s).
-
"Numeric overflow"
-
Math expression produced numerical over or underflow
-
"Bad operand or missing value"
-
Operand contains insufficient or unrecognizable information.
-
"Bad address spec (overflow)"
-
Address field contains value outside of memory bounds (FFF hex).
-
"Too many '(' parens"
-
Not enough close-parentheses were specified in an expression.
-
"Bad expression, value expected"
-
A non-numerical or unknown label was encountered in a math expression,
or operand field contains misspelled label.
-
"Bad expression, math operation expected"
-
A "+" or "-" was expected in a math expression, or an illegal ASCII character
was used to specify a label.
MANOSIM Example Run
A> MANOSIM
*.C
* C FIRST WE WILL ENTER THE OP-CODES FROM TABLE 6-14
* C
* SET M $100
:100: (0000) $7400
:101: (0000) $2113
:102: (0000) $7080
:103: (0000) $3113
:104: (0000) $7002
:105: (0000) $4107
:106: (0000) $410B
:107: (0000) $2112
:108: (0000) $1114
:109: (0000) $3114
:10A: (0000) $7400
:10B: (0000) $2112
:10C: (0000) $7004
:10D: (0000) $3112
:10E: (0000) $6111
:10F: (0000) $4100
:110: (0000) $7001
:111: (0000) $FFF8
:112: (0000) $000F
:113: (0000) $000B
:114: (0000) 0
:115: (0000) /
* C
* C NOW, WE WILL CHECK TO SEE IF THE PROGRAM IS THE SAME AS THE BOOK
* C
* DIS $100 $114
100: 7400 CLE
101: 2113 LDA 113
102: 7080 CIR
103: 3113 STA 113
104: 7002 SZE
105: 4107 BUN 107
106: 410B BUN 10B
107: 2112 LDA 112
108: 1114 ADD 114
109: 3114 STA 114
10A: 7400 CLE
10B: 2112 LDA 112
10C: 7004 SZA
10D: 3112 STA 112
10E: 6111 ISZ 111
10F: 4100 BUN 100
110: 7001 HLT
111: FFF8 ???
112: 000F AND 00F
113: 000B AND 00B
114: 0000 AND 000
* C
* C OOPS! ADDRESS $10C SHOULD HAVE BEEN SOMETHING ELSE!
* C
* S M $10C
:10C: (7004) $7040
:10D: (3112) /
* C
* C WE WILL SAVE THE PROGRAM TO DISK, SO WE DON'T HAVE TO ENTER IN
* C ALL THOSE CODES AGAIN.
* C
* SAVE $100 $114 MYPROG
* C
* C NOW, WE WILL SET UP THE EMULATOR TO BEGIN AT START OF THE PROGRAM,
* C AND "WATCH" THE FIRST FEW INSTRUCTIONS.
* C
* RESET
*** System Reset ***
* SET PC $100
PC = 100
* TRACE ON
TRACE = ON
* STEPS 10
* C
* C WE WILL ALSO SAVE THE OUTPUT TO A LOG FILE, TO BE PRINTED LATER
* C
* LOG JOURNAL.TXT
* GO
+PC--Cont--Instruction+ +Mem-Ind+ E--AC--I-INPR-O-OUTR-IEN
100: 7400 CLE 0 0000 0 01 0 01 0
101: 2113 LDA 113 000B 0 000B 0 01 0 01 0
102: 7080 CIR 1 0005 0 01 0 01 0
103: 3113 STA 113 000B 1 0005 0 01 0 01 0
104: 7002 SZE 1 0005 0 01 0 01 0
105: 4107 BUN 107 2112 1 0005 0 01 1 01 0
107: 2112 LDA 112 000F 1 000F 0 01 1 01 0
108: 1114 ADD 114 0000 0 000F 0 01 1 01 0
109: 3114 STA 114 0000 0 000F 0 01 1 01 0
10A: 7400 CLE 0 000F 0 01 1 01 0
--> Execution stopped after 10 steps, due to reaching STEPS
* C
* C NOTICE THAT THE PROCESSOR STATUS INFORMATION ON THE RIGHT DEPICTS
* C THE STATUS IMMEDIATELY AFTER THE INSTRUCTION IS EXECUTED.
* C
* LOG OFF
* C
* C EVERYTHING LOOKS OKAY, SO WE WILL LET IT RUN UNTIL IT STOPS
* C
* TRACE OFF
TRACE = OFF
* ST 0
* GO
--> Execution
stopped after 90 steps, due to HLT at 110
* C
* C THE PROCESSOR STOPPED BECAUSE OF THE HLT INSTRUCTION. THIS IS
* C NORMAL. WHAT IS THE RESULT? WHAT IS IN THE AC REGISTER?
* C
* DISPLAY $100 $120
100: 7400 2113 7080 3113 7002 4107 410B 2112
108: 1114 3114 7400 2112 7040 3112 6111 4100
110: 7001 0000 0F00 0000 00A5 0000 0000 0000
118: 0000 0000 0000 0000 0000 0000 0000 0000
* SET AC
AC = 0F00
* C
* C THE ANSWER IS $00A5, WHICH IS CORRECT. NOTE THAT IF WE RUN THE PROGRAM
* C AGAIN, THE PROGRAM WILL NOT WORK PROPERLY BECAUSE THE CONTENTS OF
* C "CTR", "X", AND "Y" HAVE BEEN MODIFIED. WE MUST EITHER RE-EDIT THESE
* C VALUES, OR RE-LOAD THE PROGRAM. HERE, WE WILL DO BOTH.
* C
* LOAD MYPROG
* SET M $112
:112: (000F) 117
:113: (000B) 82
:114: (0000) /
* C
* C NOTE THAT THESE ARE IN THEIR DECIMAL FORM. WE WILL NOW RUN THE PROGRAM
* C AGAIN WITH THESE NEW VALUES.
* C
* GO $100
--> Execution stopped after 100 steps, due to HLT at 110
* DISPLAY $114
114: 257A
* C
* C WHAT IS THIS VALUE IN DECIMAL?
* C
* CV $257A DEC = 9594 (9594), HEX = $257A
* C
* C WOW! IT WORKS!
* C
Comments to: midkiff@vt.edu
Last updated: August 20, 1996
http://fiddle.ee.vt.edu/courses/ee2504/mano_man.html
© 1990, Roger Chen and Dong
S. Ha (minor revisions August, 1996 by Scott
F. Midkiff)