|
|
c m s c 311
s u m m e r 2 0 0 2 |
p2 -d 0x0400 -t 0x0800 -f primary.file -s < primary.inputThis is essentially the code in run.sh.
Reg[ 10 ] = -1 0xFFFFFFFF Reg[ 11 ] = 12 0x0000000C Reg[ 12 ] = 7 0x00000007
The original (incorrect) program, then prints the contents of the register, which contains an address. That's incorrect (based on the comment---which is why you should always comment every line of assembly). Instead, it should treat the register content as an address, and find the contents of the memory address.
This is called register addressing, where you load something from memory based on an address in a register. jr uses register addressing.
In order to print a byte value in memory, two more interrupts are required. Fortunately, they are similar to the ones listed below.
reg stores an address of a byte in memory. Print the byte in unsigned base 10 (thus values will print between 0 and 255) located at that address.
reg stores an address of a byte in memory. Print the byte in unsigned hex (thus values will print between 0x00 and 0xFF) located at that address.
swi exit
Quit execution of the program.
Print the contents at memory address stored in register, reg, (written as, e.g. $r10) as an signed int. Assume that the address stored in reg is word-aligned. (Can print error message if not).
Print the contents at memory address, stored in register reg, as unsigned hex. Assume that it's word-aligned memory. (Can print error message if not). addr can be base 10 or hex.
Print the contents at memory address, stored in register reg, as a char. The address does not have to be word-aligned. This time, print out the character. So, if the register contains "\n", actually print out the newline character.
Print the contents at memory address, stored in register reg, as a string. reg appears as something like $r10. This should print character by character, until you reach a null character (which should not be printed), at which point you stop.
If it exists, then you print out all the information from before during a load, i.e. [ label = val, type = byte, num bytes = 1, start addr = 100A ], etc.
If the switch does NOT exist, then just print.
Program [<filename>] successfully loaded.
display prog-info
This will print the [ label = val, type = byte, num bytes = 1, start addr = 100A ], etc. for the program that is currently loaded.
These instructions should be rewritten using one or more valid MIPS instructions. When you load the instruction, they should be rewritten to the new instructions. Add a comment to those instructions indicating the original instruction.
Key issues in rewriting instructions. mov can be implemented by using addi or ori. movi is tough, becuaes you can also use addi or ori, but you need to check how big immed is. If it's more than 16 bits, you need to use two commands (such as lui and ori together.)
|
See the class syllabus for policies concerning email Last Modified: Mon Jul 1 23:26:44 EDT 2002 |
|
|
|
|
|