Instructions: Language of the Computer

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What symbol is used for comments in MIPS?

#

$v0-$v1 (numbers/uses?)

2,3 Two value registers in which to return values.

$t8-$t9 (numbers/uses?)

24, 25 More temporaries

$k0-$k1 (numbers/uses?)

26, 27 Reserved for OS Kernal

$gp (number/use?)

28, Global Pointer

$sp (number/use?)

29, Stack Pointer

$fp (number/use?)

30, Frame Pointer

$ra

31, Return Address register to return to the point of origin.

There are how many MIPS registers?

32

How long is a MIPS word?

32 bits or 4 bytes

$a0-$a3 (numbers/uses?)

4,5,6,7 Arguments (think C or java where arguments are passed into method)

$t0-$t7 (numbers/uses?)

8,9,10,11,12,13,14,15 Temporaries

What is the ideal data structure for spilling registers?

A Stack.

Data transfer instruction

A command that moves data between memory and registers.

Instruction Format

A form of representation of an instruction composed of fields of binary numbers.

return address

A link to the calling site that allows a procedure to return to the proper address; in MIPS it is stored in $ra

callee

A procedure that executes a series of stored instructions based on parameters provided by the caller and then returns control to the caller (placed results of any calculation into $v0-$v1) using jr $ra.

Why might a very large number of registers slow down a MIPS computer?

A very large number of registers may increase the clock cycle time simply because it takes electronic signals longer when they must travel farther.

What is the range of addresses for jump and jump and link in MIPS (M=1024K)?

Anywhere within a block of 256M addresses where the PC supplies the upper 4 bits.

Stored-program-concept

The idea that instructions and data of many types can be stored in memory as numbers, leading to the stored-program computer.

Most Significant Bit

The leftmost bit in a MIPS word.

What is a word in MIPS?

The natural unit of access in a computer, usually a group of 32 bits; corresponds to the size of a register in MIPS.

Despite the slowdown caused by a large amount of registers, what is another good reason for not using more than 32?

The number of bits it would take in the instruction format.

What is spilling registers?

The process of putting less commonly used variables (or those needed later) into memory instead of putting them into registers. This is due to the fact that many programs have more variables than computers have registers.

caller

The program that instigates a procedure jal x where x is the procedure it calls and provides the necessary parameter values (placing them in $a0-$a3).

program counter

The register containing the address of the instruction in the program being executed.

global pointer

The register that is reserved to point to the static area. MIPS reserved the $gp (global pointer register) to simplify access to static data.

Least Significant Bit

The rightmost bit in a MIPS word.

Instruction Set

The vocabulary of commands understood by a given architecture.

The data transfer instruction that transfers data from memory to a register in MIPS

traditionally called a load, but in MIPS it is called lw or load word.

automatic variables

variables that are local to a procedure and discarded when a procedure exits.

static variables

variables that exist across the entries and exits of procedures.

PC-Relative Addressing

where the branch address is the sum of the PC and a constant in the instruction. op-rs-rt-address + PC

Pseudodirect addressing

where the jump address is the 26 bits of the instruction concatenated with the upper bits of the PC

Base Addressing

where the operand is at the memory location whose address is the sum of a register and a constant in the instruction op-rs-tr-address + register

How do assemblers keep track of labels?

with a symbol table that matches names of labels to the addresses of the memory words.

Register Addressing

operand is a register op-rs-rt-rd...funct

2^31 - 1 represents positive or negative numbers in 2's complement representation?

positive

What are leaf procedures?

procedures that do not call other procedures.

In MIPS, data must be in __________ to perform arithmetic.

registers

The data transfer instruction that transfers data from a register to memory in MIPS?

store, sw or Store word in MIPS.

$zero (number/use?)

0, The constant value 0

perform an AND operation on the following: 0000 0000 0000 0000 0000 1101 1100 0000 0000 0000 0000 0000 0011 1100 0000 0000

0000 0000 0000 0000 0000 1100 0000 0000

perform an OR operation of the following: 0000 0000 0000 0000 0000 1101 1100 0000 0000 0000 0000 0000 0011 1100 0000 0000

0000 0000 0000 0000 0011 1101 1100 0000

complete a shift left logical on the following by 4 00000000000000000000000000001001 (9 dec)

00000000000000000000000010010000 (144 dec)

How many instructions can MIPS have per line?

1

Each MIPS arithmetic instruction performs only ______ and must always have exactly _______ variables.

1 instruction, three

Which operation can isolate a field in a word?

1) AND 2) SLL followed by SRL

What are the 5 MIPS addressing modes?

1) Immediate Addressing 2) Register Addressing 3) Base Addressing 4) PC-Relative Addressing 5) Pseudodirect Addressing

What are the six steps a program must follow in the execution of a procedure?

1) Put parameters in a place where the procedure can access them. 2) Transfer control to the procedure. 3) Acquire the storage resources needed for the procedure. 4) Perform the desired task. 5) Put the result value in a place where the calling program can access it. 6) Return control to the point of origin, since a procedure can be called from several points in a program.

Why are languages quite similar to each other?

1) Similar underlying principles. 2) There are a few basic operations that all computers must provide. 3) Computer designers want a language that makes it easy to build the hardware and compiler while maximizing performance and minimizing costs.

What are the 4 design principles?

1) Simplicity favors regularity 2) Smaller is faster 3) Make the common case fast 4) Good design demands good compromises

$at (number/use?)

1, Assembler Temporary - reserved by the assembler to handle large constants.

Convert eca8 6420hex into binary

1110 1100 1010 1000 0110 0100 0010 0000

MIPS uses NOR instead of NOT in order to stay within the three-operand format. If one operand is 0, then NOR is equivalent to NOT. NOR the following: 0000 0000 0000 0000 0011 1100 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

1111 1111 1111 1111 1100 0011 1111 1111

Convert 0001 0011 0101 0111 1001 1011 1101 1111 to hex

1357 9bdf

$s0-$s7 (numbers/uses?)

16, 17, 18, 19, 20, 21, 22, 23 Saved temps (think C or java variables)

What is the range of addresses for conditional branches in MIPS (K=1024)?

Addresses up to about 128K before the branch to about 128K after.

When do comment terminate in MIPS?

Always at the end of a line.

Jump-and-link instruction

An instruction that jumps to an address and simultaneously saves the address of the following instruction in a register $ra.

Conditional branch

An instruction that requires the comparison of two values and that allows for a subsequent transfer of control to a new address in the program based on the outcome of the comparison.

Is MIPS use little-Indian or big-Indian as the word address?

Big-Indian - Left most byte

Machine Language

Binary representation used for communication within a computer system.

sometimes we need to use a larger constant than the 16 bit field of an instruction may allow. How could we do this?

By using load upper immediate lui and or immediate ori First, load the upper 16 bits of a 32 bit constant into a register using lui Then, load the lower 16 bits of the 32 bit constant into the same register using ori

What are the 5 components of a computer?

Control, memory, input, output, and data path

Make the common case fast.

Examples of making the common MIPS case fast include PC-relative addressing for conditional branches and immediate addressing for larger constant operands.

Registers are a great place for data structures since they are fast (True/False)

False - registers can hold only small amounts of data, but computer memory contains billions of data elements. Hence, data structures are kept in memory.

Convert the following into machine language code: lw $t0, 1200($t1) # temporary reg gets A[300] add $t0, $s2, $t0 # temporary reg gets h + A[300] sw $t0, 1200($t1) # Stores h + A[300] back into A[300]

First - they use different instruction formats. so list them out according to their respective instruction formats using decimal values: type op rs rt rd shamt funct I 35 9 8 [ 1200 ] R 0 18 8 8 0 32 I 43 9 8 [ 1200 ] Second - convert all decimals into binary 100011 01001 01000 0000 0100 1011 0000 000000 10010 01000 01000 00000 100000 101011 01001 01000 0000 0100 1011 0000

convert 00af8020 hex into machine instruction

First, look at the last 2 numbers in hex, those represent the funct. Therefore, you look it up on the reference card. And then convert the first 2 numbers to binary 0 = 0000, and 0 = 0000 to give 00000000 and we know that the opcode is the first 6 0's 000000 and that with the funct 20 hex is an add function in which is a R-Format. Convert to binary and partition the bits accordingly: op (6bits) rs(5bits) rt(5bits) rd(5bits) shamt(5bits) funct(6bits) 000000 00101 01111 10000 00000 100000

Alignment Restriction

In MIPS, words must start at addresses that are multiples of 4. This requirement is an alignment restriction.

Simplicity favors regularity.

Keeping all instructions a single size, always requiring three register operands in arithmetic instructions, and keeping the register fields in the same place in each instruction format.

Good design demands good compromises.

One MIPS example was the compromise between providing for larger addresses and constants in instructions and keep all instructions the same length.

What are the different MIPS instruction formats?

R-type or R-Format - register type I-type or I-Format - immediate type J-type or J-Format - jump type FR and FI for floating point instruction formats

describe the MIPS memory allocation top to bottom:

Stack Dynamic data Text PC Reserved

Smaller is faster.

The desire for speed is the reason that MIPS has 32 registers rather than many more.

Why does MIPS separate the registers $t0-$t9 and $s0-$s7 into the t and s groups?

To reduce registers spilling by avoiding the saving and restoring of a register whose value is never used. $t0-$t9 are not preserved by the callee on a procedure call and $s0-$s7 must be preserved on a procedure call (if used, the callee saves and restores them).

Immediate Addressing

operand is a constant within the instruction op-rs-rt-immediate

Describe a 2's complement shortcut for negating a number.

flip each bit in the MIPS word and then add 1

With $t1 = base of array A, and $s2 = h, Convert A[300] = h + A[300] into Assembly

lw $t0, 1200($t1) # temporary reg gets A[300] add $t0, $s2, $t0 # temporary reg gets h + A[300] sw $t0, 1200($t1) # Stores h + A[300] back into A[300]

-2^31 represents positive or negative numbers in 2's complement representation?

negative

MIPS fields in an J-Type Instruction Format and their meanings:

op: (6 bits) Basic operation of the instruction, traditionally called the opcode. Address: (26 bits)

MIPS fields in an I-Type Instruction Format and their meanings:

op: (6 bits) Basic operation of the instruction, traditionally called the opcode. rs: (5 bits) The first register source operand. rt: (5 bits) Constant or Address: (16 bits) The rd, shamt, and funct are combined to be used as a constant or address.

MIPS fields in an R-Type Instruction Format and their meanings:

op: (6 bits) Basic operation of the instruction, traditionally called the opcode. rs: (5 bits) The first register source operand. rt: (5 bits) The second register source operand rd: (5 bits) The register destination operand. It gets the result of the operation. shamt: (5 bits) Shift amount funct: (6 bits) Function, or function code, selects the specific variant of the operation in the op field


Ensembles d'études connexes

Modern World, Test 3, Chapters 17 & 18

View Set

Chapter 1 - Introduction - Connect Questions

View Set

Biol 252L lab 4 grqWhich bone of the axial skeleton is the only one to form a joint with the upper limb?

View Set

Human Services Final Exam Chapters 9-15

View Set