Вы находитесь на странице: 1из 1

Project 1 CS 3113 Operating Systems September 14, 2009, 12:01 AM

==--- ASSIGNMENT GOAL ---==


Execute programs written in assembly language MYASM, which is meant for a 32 bit machine. This language
manipulates only INTEGERS.

==--- BACKGROUND ---==


You will be given a program that is written in assembly language MYASM (described below). Your program should
read this assembly language, produce object code and execute the object code. This assignment will be expanded in the
future so make sure it is modular.
The MYASM assembly language is for a 32 bit machine. It has 16 32-bit registers (R0 through R15) that can be
used. It allows memory locations (variable names) to be used in some of the instructions and the names of these
memory locations can be at most 5 characters long. Other constraints on the naming rules follow rules of FORTRAN.
We now describe the instruction of MYASM. All executable instructions start in column 7. The operands can be
separated from the instructions by one or more blanks.
The second operand for instructions LOD, ADD, SUB, MUL, DIV, TST, and CMP can be integer literal.

(0) LOD Ri,X Load contents of memory location X into Register Ri.
(1) LOD Ri,’L Load contents of literal L into Register Ri.
(2) STR Ri,X Load contents of Register Ri into memory location X.
(3) ADD Ri,Rj Ri = Ri + Rj;
(4) ADD Ri,’L; Ri = Ri + L;
(5) SUB Ri,Rj Ri = Ri - Rj;
(6) SUB Ri,’L; Ri = Ri – L;
(7) MUL Ri,Rj Ri = Ri * Rj;
(8) MUL Ri,’L; Ri = Ri * L;
(9) DIV Ri,Rj Ri = DIV (Ri,Rj) (Integer Division);Ri+1 = MOD (Ri,Rj)
(10) DIV Ri,’L Ri = DIV (Ri,L) (Integer Division);Ri+1 = MOD (Ri,L)
(11) PRT X Print contents of memory location X.
(12) JMP label Jump to instruction labeled by label in columns 1 through 5.
(13)TST Ri,Rj,label If (Ri=Rj) jump to instruction labeled by label in columns 1 through 5.
otherwise, execute the next instruction.
(14)TST Ri,’L,label; If (Ri=L) jump to instruction labeled by label in columns 1 through 5.
otherwise, execute the next instruction.
(15) CMP Ri,Rj,Rk If (Ri < Rj) then Rk = -1; If (Ri > Rj) then Rk = 1;
If (Ri = Rj) then Rk = 0;
(16) CMP Ri,’L,Rk If (Ri < L) then Rk = -1; If (Ri > L) then Rk = 1;
If (Ri=L) then Rk = 0;
(17) STP STOP the program from executing.
(18) END End of the assembly language program.

Comments can be placed in the program after placing a * (star) character in the first column. The memory variables
used appear after the END statement of the program. For example, if ANS is a memory variable, then the operator label
will be ANS and the operand will be INT indicating that this variable is an integer variable.

==--- DESIGN ==---


Each instruction code occupies one byte (use the number in the shown in the parenthesis for each instruction), registers
occupy four bytes, and operands 4 bytes. You need an array data structure to simulate the 16 registers. You also need a
data structure to keep track of memory location addresses and values. You also need an array data structure to store the
program containing instruction and operand(s). You can assume that the program will not cause overflow or underflow
during execution.

==--- INPUT ==---


The input to your assignment is an assembly language program with unknown number of statements. There will be at
most one instruction per line.

==--- PROCESSING ==---


After the assembly and generation of the memory address for each line of instruction in the program, execute the
program by following the logic of each instruction. You are required to print the address of each line of the program
and the assembled byte code.

You are not allowed to communicate in any form or action about this project with anyone else in the class. Good Luck!

Вам также может понравиться