CS 26
Oct. 3, 1996)
State the addressing mode used and determine the effective address, for memory references, for each of the following.
#63
Immediate. No effective address.
var
Direct. EA = 2000.
(r5)
Indirect. EA = 1000.
12(r6)
Indexed. EA = 1015.
+(r6)
(Pre)Autoincrement. EA = 1004.
Recall that indexed addressing specifies the effective address as the sum of a register and a constant. Indirect addressing is achieved by using a constant value of 0. Direct addressing is achieved by using a register whose value is 0 (note that the range of the constant value might not be the entire memory space).
.text subr: lb $t0, 0($a0) while: beqz $t0, ewhile bne $t0, $a1, next move $v0, $a0 jr $31 next: add $a0, $a0, 1 lb $t0, 0($a0) b while ewhile: li $v0, 0 jr $31Hints:
It's C's strchr() which searches for a character, c, in a string, s, returning a pointer to the first occurrence of c in s. If c is not be be found in s, the function returns the NULL pointer.
if (a <= b && a <= c) min = a; else if (b <= c) min = b; else min = c;a, b, and c are integers stored in memory and the underlying architecture is load/store.
lw $t0, a($0) lw $t1, b($0) lw $t2, c($0) bgt $t0, $t1, elseif bgt $t0, $t2, elseif sw $t0, min($0) b endif elseif: bgt $t1, $t2, else sw $t1, min($0) b endif else: sw $t2, min($0) endif:
This refers to which function is ``responsible'' for saving registers (in an activation record) on a function call --- the caller or callee. For caller-save, the calling function must save any registers which are in-use at the time of the call and restore them after the call. For callee-save, the called function must save any registers which it will use during the call and restore them before returning.
Through registers and on the stack execution stack.
An activation record is an organized mechanism for keeping information related to subroutine calls. Such information includes the return address, storage for local variables, storage for saved registers, parameters, and activation linkage information.
The methodology is useful because it provides for recursion.