Support Software I. The Rasm risc assembler



Download 15.53 Kb.
Date07.08.2017
Size15.53 Kb.
#28113
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 mneu­monics 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 (R0)data,R16 ;load R16 from data

start: ADD R15,#1,R15 ;increment R15

...

JMP UNC,start ;jump back to start



data: .DL 100
Assembler Directives. The following directives are provided to simplify RISC programming;
a) .ORG ;specifies the beginning memory address for instructions/data that follow;

.ORG 200 ;instructions/data that follow are placed at loc 200


b) .Dx ;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 ;defines the end of the assembly. 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:

.ORG 200 ;add a list of 30 small integers from memory

ADD R0,#0,R11 ;initialize sum

ADD R0,#30,R17 ;init count and begin loop

again: LDBS (R17)data,R18 ; get a value...

ADD R18,R11,R11 ; sum it...

ADD R17,#-1,R17,C ; decrement count...

JMP GEQ,again(R0) ; and loop back...

CALL R10,#154(R0) ;write result (OS call to WriteInt)

HALT


.ORG 400 ;begin data segment

data: .DB 5

.DB 9 ; etc. for 30 values

~

~



.END 200 ;first instruction is at loc 200.
Execution. $ rasm source object (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 architec­tures -- 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 das­sem (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 regis­ters 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 cont

goto help

list print

quit set


step stop

status run



rerun
Typing 'help command' provides a description of the use and actions of these options.

Download 15.53 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page