Things to Know T3&4 Midterm 1

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/11

encourage image

There's no tags or description

Looks like no tags are added yet.

12 Terms

1
New cards

What is the Program Counter initialized to? What is it aka? What does it hold after first instruction?

Address of first instruction

PC = %eip

Address of next instruction

2
New cards

What is the Instruction Set Architecture (ISA / instruction API)?

Set of instructions provided by machine to allow translation of source code

3
New cards

What are the 3 main parts of a CPU and their subcomponents?

Control Unit:

  1. Instruction register (current instruction)

  2. Instruction counter (pointer of next instruction — auto increments)

  3. Status register (flags (stores) info from last operation)

  4. Decoder (“reads” instruction and decides signal to generate)

  5. Signal generator (communicates with rest of processor)

Execution Unit:

  1. Arithmetic Logic Unit (ALU — calculates)

  2. Registers (very fast memory for operands)

Memory:

  1. Stores data and program instructions (accessed by address)


4
New cards

What are the stages of execution?

Fetch → Decode → Get data → Execute → Write data

5
New cards

What assembly code commonly at beginning and end of a function?

push and ret

6
New cards

Which register used to return a value from a function?

%eax

7
New cards

When allocating an int array on the stack for 64 bytes, how do you reach array[7] from %ebp which was where %esp was before the allocation?

Beginning of array at -64 and want 7×4 = 28th byte so -64 + 28 = -36(%ebp)

8
New cards

How is %eax split up in terms of bytes?

eax = 8 bytes

ax = rightmost 4

ah = left 2 of ax

al = right 2 of ax

9
New cards

Which registers are caller save? Callee?

a d c = caller

bx si di = callee

10
New cards

How many values can be represented with n bits? What is the max value unsigned?

2n

2n-1

11
New cards

What does the call function do?

Push return address (%ebp) onto stack and subtracts as much as needed from %esp (it doesn’t literally do this but every function has to so technically)

12
New cards

How do you convert from base 10 to any base fast way?

  1. Divide by the base, record the quotient and remainder

  2. Repeat with the quotient and record the remainders going down

  3. Read the remainders bottom up and that’s the number in that base