MMN 11 ארגון המחשב 25א
Q1
Q2
- for each of of the following pseudoinstructions, find a minimal sequence of native instructions that will perform the same operation.
- it’s likely that you will need to use
$at
register in some of the pseudoinstructions. - in the next table,
big
is some number that requires 32 bits to represent, andsmall
is some number that requires 16 bits to represent.
Psuedoinstruction | |
---|---|
$t1 = $t2 | move $t1, $t2 |
$t0 = 0 | clear $t0 |
if ($t1 = small) go to L | beq $t1, small, L |
if ($t1 = big) go to L | beq $t1, big, L |
$t1 = small | li $t1, small |
$t2 = big | li $t2, big |
if ($t3 <= $t5) go to L | ble $t3, $t5, L |
if ($t4 > $t6) go to L | bgt $t4, $t6, L |
if ($t5 >= $t3) go to L | bge $t5, $t3, L |
$t0 = $t2 + big | addi $t0, $t2, big |
$t5 = memory[$t2 + big] | lw $t5, big($t2) |
Q3
# text segment:
# start address: 0x00400078
---
0x002f0821 addu $1, $1, $15
0x802b0000 lb $11, 0x00000000($1)
0x000b2021 addu $4, $0, $11 70: move $a0, $t3
0x2402000b addiu $2, $0, 0x0000000b 71: li $v0, 11
0x0000000c syscall 72: syscall
0x20010001 addi $1, $0, 0x00000001 73: subi $t7, $t7, 1
0x01e17822 sub $15, $15, $1
0x15e0fff7 bne $15, $0, 0xfffffff7 74: bne $t7, $zero, reverse
0x2402000a addiu $2, $0, 0x0000000a 80: li $v0, 10
0x0000000c syscall 81: syscall
- (A)
- what can we say about the instruction in line 73 in the source code
subi
?- it’s not a valid instruction
- will the program pass compilation?
- no
- is it possible to perform an effective translation of the MARS translation as it appears in the Basic column?
- using the
addi $t7, $t7, -1
instruction
- using the
- what can we say about the instruction in line 73 in the source code
- (B) can we know what will happen following the
syscall
instruction in line 72? explain!- answer: the program will print the character that its ASCII code is in register
$a0
which is the value of$t3
- answer: the program will print the character that its ASCII code is in register
- (C) can we know what will happen following the syscall instruction in line 81? explain!
- answer: the program will terminate (syscall
10
)
- answer: the program will terminate (syscall
- (D) based on the data in the segment code, what is the address of the label
reverse
? explain!0xfffffff7 = -9
0x00400094
is the address ofbne ...
0x00400094 + 4 + (-9 * 4)
0x00400094 + 4 - 0x24 = 0x00400074
is the address ofreverse
Programming
Q4
- the two programming exercises are supposed to be written separately: each one in separate
.asm/.s
file. - the three files (thisone and the two
.asm/.s
files) are supposed to be zipped zipped and submitted.