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

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

19
Q

_____ must be set when the procedure is entered

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
Q

Fifth use of the stack
If we need more _______ _______ than available registers (automatic, block scope)

26
Q

PushX source

A

Decrement %rsp by number of bytes specified in oppose suffix and write bytes (of size specified by suffix) to memory address %rsp

27
Q

We can push a value of a _____, a value from _____ to the stack, and a _____ to the stack

A

Register, memory, stack

28
Q

_____ and _____ push instructions are NOT valid

A

Push, pushb

29
Q

Only push and pop _____ byte value to stack

30
Q

PopX destination

A

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
Q

First thing to do when setting up program stack
1. Set %rbp to point to _____ of current stack frame

32
Q

Setting up program stack
2. Set %rsp to current ____ of stack (same address as the stack bottom initially)

33
Q

At the end of function, what to do with rsp and rbp?

A

Put them back

34
Q

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

A

Address, Dest

35
Q

Setting up stack frame

A
  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
Q

When leaving a function

A

Leave. # set caller’s stack frame back up

37
Q

Leave is equivalent to

A

Movq %rbp, %rsp
Pop %rbp

38
Q

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

A

Address, call

39
Q

1st step in setting up stack frames

A

Pushq %rbp —> save caller’s base pointer of the stack

40
Q

2nd step in setting up stack frame

A

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
Q

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

A

Address, PC, %rip