Assembly Part 2 Flashcards

1
Q

.file

A

Allows a name to be assigned to assembly language source code file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

.section

A

This makes the specified section the current section (required)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

.rodata

A

Specifies that the following data to be placed in the read only memory portion of the executable (required if you have read only data)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

.data

A

Changes or sets the current section to the data section

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

.text

A

Changes or sets the current section to the text (or code) section

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

.globl

A

A directive needed by linker for symbol resolution: followed by name of function

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

.type

A

Needed by the linker to identify the label associated with a function, as opposed to data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

.size

A

Needed by the linker to identify the size of the text for the program

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

.align

A

Needed if we want to declare values on the head to start an address that has a particular byte alignment (1,2,4,8)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What happens if you want to declare static class variables

A

In the .data or .rodata section of program, you need to declare the values

.quad value
.long value
.word value
.byte value
.string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

.quad

A

Places given value in memory encoded by 8 bytes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Other data sizes

A

.long, .,words, .byte, .string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Leaq

A

Address computation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Sale

A

Shift arithmetic left

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Imulq

A

Signed multiply

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The program stack is divided conceptually into ____

A

Frames

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Each procedure or function has its own part of the stack to use which is called the ____

A

Stack frame

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

The stack frame goes from the stack address pointed to by ___. This is called the ___/____ pointer to %______ which points to the ____ of the stack

A

%rbp, frame,base, top

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

_____ must be set when the procedure is entered

A

%rbp

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

First use of stack
Save the _____ %rbp before setting our frame pointer

21
Q

Second use of stack
Before calling another function, perverse values needed using ____/_____

22
Q

Third use of stack
To pass _____ to another function (only if there are more than 6 parameters to pass)

A

Parameters

23
Q

Fourth use of stack
To store the _______ ________ when a call instruction is executed

A

Return address

25
Fifth use of the stack If we need more _______ _______ than available registers (automatic, block scope)
Temp data
26
PushX source
Decrement %rsp by number of bytes specified in oppose suffix and write bytes (of size specified by suffix) to memory address %rsp
27
We can push a value of a _____, a value from _____ to the stack, and a _____ to the stack
Register, memory, stack
28
_____ and _____ push instructions are NOT valid
Push, pushb
29
Only push and pop _____ byte value to stack
8
30
PopX destination
Reads number of bytes specified by suffix from the address %rsp and store in destination. Increment %rsp by number of bytes specified by oppose suffix so rsp points to next value on stack
31
First thing to do when setting up program stack 1. Set %rbp to point to _____ of current stack frame
Bottom
32
Setting up program stack 2. Set %rsp to current ____ of stack (same address as the stack bottom initially)
Top
33
At the end of function, what to do with rsp and rbp?
Put them back
34
CallX does two things 1. The _____ of the instruction immediately after the call instruction is pushed onto the stack (that is, the return address is pushed) 2. The _____ is assigned to the PC (%rip) register
Address, Dest
35
Setting up stack frame
1. Push %rbp #save caller’s base pointer 2. Movq %rsp, %rbp #set my base pointer %rbp is equal to %rsp, the stack frame is empty and we are ready to use the stack
36
When leaving a function
Leave. # set caller’s stack frame back up
37
Leave is equivalent to
Movq %rbp, %rsp Pop %rbp
38
RetX 1. The ____ of the instruction immediately after the ______ instruction that got us here is popped from the stack 2. The address is assigned to the PC (%rip) register
Address, call
39
1st step in setting up stack frames
Pushq %rbp —> save caller’s base pointer of the stack
40
2nd step in setting up stack frame
Move %rsp, %rbp -> set the base pointer Now rsp equals rbp, this means the stack frame is empty and stack is ready to use
41
RetX does 2 things 1. The ____ of the instruction immediately after the call instruction that got us here is popped from the stack 2. That address is assigned to the ______ (___) register
Address, PC, %rip
42
What instructions change %rsp
Push, pop, call, ret
43
Push
Decrements rsp and stores value on stack
44
Pop
Increments tsp and pops value from stack
45
Call
Pushes the return address (current %rip) on the stack
46
RetX
Pops return address off the stack Ret —> pops address into rip, rsp += 8 1. The address of the instruction immediately after the call instruction that got is here is popped from stack 2. Address is assigned to PC (%rip) register
47
Reverse to accessing memory using a base address and a offset (usually a constant or a register that holds and offset in bytes)
Conventional index
48
Uses a register multiplied (scaled) by a constant factors (1,2,4,8) to automatically compute byte offsets when working with arrays of primate types (like int double, or pointers)
Scales index Ex: Movl (%rdi, %rsi, 4), %eax