Download The Rasm RISC assembler

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Support Software
I. The RASM RISC assembler -- rasm
rasm is a RISC assembler program compatible with the cinter and inter RISC interpreters. The input is a
RISC source and the output is an executable object program. In other words, rasm converts assembler mneumonics into executable numeric codes. The following conventions are supported;
a) The condition-codes flag (C) is always placed at the end of instruction arguments.
b) A semicolon marks the rest of a line as a comment.
c) One instruction per line. Blank lines and lines containing only comments are allowed.
d) Character case for instructions and arguments is not significant.
e) Programs must fit within a maximum of 8188 bytes of memory.
f) 16 bits (signed) are available for Y constants, 13 bits (signed) for S2 constants.
g) While RASM is usually forgiving, spaces (tabs, LF, etc.) should not separate arguments.
h) The maximum number of labels (and label references) is currently 200.
Label Support. RASM supports the use of labels for S2 arguments. Labels are a maximum of 5 letters or
digits with the first character being a letter. Case for labels is significant! Labels for an address must end with a
colon. Label references (arguments of an instruction) are replaced during assembly with the address defined by
the label. Forward references are allowed. For example;
LDL
start: ADD
...
JMP
data: .DL
(R0)data,R16 ;load R16 from data
R15,#1,R15 ;increment R15
UNC,start
100
;jump back to start
Assembler Directives. The following directives are provided to simplify RISC programming;
a) .ORG <n> ;specifies the beginning memory address for instructions/data that follow;
.ORG 200
;instructions/data that follow are placed at loc 200
b) .Dx <n> ;defines constants for memory locations. For options are available;
.DB
5
;stores 5 as the next byte value
.DS
257
;stores 257 as the next short (2 bytes)
.DL
8000 ;stores 8000 as the next long (4 bytes)
.DC
"hello" ;stores the string h-e-l-l-o as the next 5 bytes. DC strings
may not
wrap around to
the next line.
c) .END <n> ;defines the end of the assembly. <n> defines the starting address for program
execution. This directive is required at the end of every source.
The .ORG specifies where the next instructions or data is to be stored
in memory. The .END specifies the starting address of the first
instruction of a program. A program can have any number of .ORG
directives, but only one .END since nothing after that will be
considered. The .ORG and .END numbers do not need to be the same.
When writing a program, you must know what else is residing in memory
so as not to overwrite. Memory addresses below 200 are reserved for
interrupt/trap vectors and the monitor that provides support
functions. If you overwrite the monitor or interrupt/trap addresses,
you take your chances. Sometimes the problem may go undetected for a while...
Example:
again:
data:
.ORG
ADD
ADD
LDBS
ADD
ADD
JMP
CALL
HALT
.ORG
.DB
.DB
~
~
.END
200
R0,#0,R11
R0,#30,R17
(R17)data,R18
R18,R11,R11
R17,#-1,R17,C
GEQ,again(R0)
R10,#154(R0)
;add a list of 30 small integers from memory
;initialize sum
;init count and begin loop
; get a value...
; sum it...
; decrement count...
; and loop back...
;write result (OS call to WriteInt)
400
5
9
; etc. for 30 values
200
;first instruction is at loc 200.
Execution. $ rasm source object
;begin data segment
(no special extensions are assumed)
For teaching purposed, the output object file produced by rasm is in ASCII rather than binary to allow the
object to be printed or displayed.
II. The RISC interpreters -- cinter, inter
cinter is a RISC interpreter compatible with object programs produced with rasm. Use of this interpreter in
place of physical CPU execution allows us to use the same assembly language (RISC) for a variety of architectures -- cinter.c is in ANSI standard C and should be compilable under Unix or Windows. A makefile is
provided for Unix or Linux. To compile under MS C++, a project file would need to be created from the
makefile contents. Currently, the interpreter supports a maximum of 8191 bytes of program memory. The
interpreter is invoked with the following;
$ cinter object
where object is a machine code file produced with rasm. The output goes to standard out.
inter is also a RISC interpreter with the same capabilities as cinter but written in Pascal. The executable
provided is for Intel DOS or Windows systems. This program prompts for a source object file and a debugging
level. Level 0 represents no debug information while higher levels represent increasing verbosity.
III. The RISC disassemblers -- cdassem and dassem
The machine code object files produced under rasm can be "disassembled" back into mneumonics with dassem (Windows) or cdassem (ANSI standard C). The disassembler is invoked with the following;
$ cdassem object
where object is a machine code file produced with rasm. The output goes to standard out. Please keep in mind
that there is no way for the disassembler to differentiate between instructions and data -- it will simply assume
that all machine codes represent instructions and require you to know the difference between code and data.
IV. The RISC debugger -- yard
yard is a machine code debugger compatable with object files produced with rasm. the system is written in
ANSI-standard C and should be compilable under Unix or Windows. A makefile is provided for Unix or Linux.
To compile under MS C++, a project file would need to be created from the makefile contents. The debugger is
invoked with the following;
$ yard object
The debugger allows step-by-step execution of an object program and can display instructions, contents of registers and flags, and any memory locations. The debugger prompt is;
yard>
At any time, you may type 'help' for a list of yard commands or options. Basically, they are the following;
clear
goto
list
quit
step
status
rerun
cont
help
print
set
stop
run
Typing 'help command' provides a description of the use and actions of these options.