//////////////////////////////////////////////////////////////////// // // sum: return the sum of the elements in this object // int sum() const;
//////////////////////////////////////////////////////////////////// // // operator== determine if this object and v contain the same values // bool operator== (const intVector &v) const;
//////////////////////////////////////////////////////////////////// // // operator +: concatenate this object and v into a new intVector // that is returned intVector operator+ (const intVector &v) const;
int s, t, n; //assume these get initialized
switch(n){
case 0:
t = 1;
case 1:
s = 1;
break;
case 2:
s = 2;
t = 2;
break;
default:
s = 3;
t = 3;
}
| Instruction | Description |
|---|---|
| LOAD R1 X | Load the variable X from memory into the register R1 |
| LDI R1 C | Load the constant C (given in the instruction) into register R1 |
| STORE R1 X | Store the value in register R1 into the memory location for variable X |
| ADD R1 R2 R3 | Add the contents of register R2 and R3 and store the result in register R1. R1 = R2 + R3 |
| SUB R1 R2 R3 | Subtract the contents of R3 from R2 and store the result in R1. R1 = R2 - R3 |
| JMP L | Jump to the instruction with label L |
| JE L | Jump to the instruction with label L if the result of the last ALU operation was 0. |
| JNE L | Jump to the instruction with label L if the result of the last ALU operation was lesss than or equal to 0. |
HINT: you might consider putting this code in a C program and assembling it to see what it does on our machines.