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...
.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)
.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 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;
At any time, you may type 'help' for a list of yard commands or options. Basically, they are the following;
Typing 'help command' provides a description of the use and actions of these options.