x86-64 assembly language Flashcards

1
Q

how to assemble .asm file with yasm to get object .o file

A

yasm -g dwarf2 -f elf64 example.asm -l example.txt

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

-g dwarf2

A

informs assembler to include debugging info in object file

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

-f elf64

A

informs assembler to create object file in ELF64 format

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

example.asm

A

name of assembly language source file

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

-l example.txt

A

informs assembler to create list file named example.list

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

link object files with ld to get executable program

A

ld -g -o example example.o

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

-g

A

informs linker to include debugging info in final executable file

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

-o example

A

specify and create executable file named example

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

data section of program

A

section .data; holds initialized variables and constants

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

variable format

A

<variableName> <dataType> <initialValue>
</initialValue></dataType></variableName>

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

text section of program

A

section .text; includes instructions

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

starting text section

A

global _start
_start:

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

(data types) db

A

8-bits

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

(data types) dw

A

16-bits

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

(data types) dd

A

32-bits

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

(data types) dq

A

64-bits

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

(data types) ddq

A

128-bit integer

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

(data types) dt

A

128-bit float

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

(data declarations) _Var

A

_bit variable (wVar dw = declaring 16 bit variable)

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

(data declarations) cVar

A

single character (8 bits)

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

(data declarations) strng

A

string

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

(data declarations) arr

A

array

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

(data declarations) flt1

A

float

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

constants are defined as

A

equ

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

lowest 32-bits registers

A

eax, ebx, ecx, edx, esi, edi, ebp, esp, r8d-r15d

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

64 bit registers

A

rax, rbx, rcx, rdx, rsi, rdi, rbp, rsp, r8-r15

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

how to access memory

A

brackets

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

brackets vs no brackets

A

no brackets obtain address of item, brackets access memory / value stored

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

size qualifiers

A

byte, dword, qword

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

labels

A

target or location to jump to for control statements (.loopStart) will know to jump back to that label

31
Q

global <label></label>

A

means label will be accessible from outside the file

32
Q

to access variables not in current file

A

extern <symbolName></symbolName>

33
Q

addition

A

add <dest> <src></src></dest>

34
Q

subtraction

A

sub <dest> <src></src></dest>

35
Q

increment

A

inc <dest></dest>

36
Q

decrement

A

dec <dest></dest>

37
Q

multiplication

A

imul <dest> <src></src></dest>

38
Q

division

A

div <dest></dest>

39
Q

and

A

and <dest> <src></src></dest>

40
Q

or

A

or <dest> <src></src></dest>

41
Q

not

A

not <dest></dest>

42
Q

shift right

A

shr <dest>, <imm></imm></dest>

43
Q

shift right

A

shr <dest>, cl</dest>

44
Q

shift left

A

shl <dest>, <imm></imm></dest>

45
Q

shift left

A

shl <dest>, cl</dest>

46
Q

shift arithmetic right

A

sar <dest>, <imm></imm></dest>

47
Q

shift arithmetic right

A

sar <dest>, cl</dest>

48
Q

jump

A

jmp <label></label>

49
Q

compare

A

cmp <dest> <src></src></dest>

50
Q

jump if equal

A

je <label></label>

51
Q

jump if not equal

A

jne <label></label>

52
Q

jump if greater than

A

jg <label></label>

53
Q

jump if greater or equal

A

jge <label></label>

54
Q

jump if less

A

jl <label></label>

55
Q

jump if less or equal

A

jle <label></label>

56
Q

call

A

call <label></label>

57
Q

return

A

ret

58
Q

put on stack

A

push <src></src>

59
Q

take off stack

A

pop <dest></dest>

60
Q

pushing examples

A

push rax
push qword [qVal] –> value
push qVal –> address

61
Q

pushing meaning

A

push 64 bit operand onto stack; first adjust rsp (rsp-8); copy operand to rsp

62
Q

pop meaning

A

pop 64 bit from the stack; first adjust rsp (rsp+8)

63
Q

item on top of stack

A

rsp

64
Q

second item on stack

A

rsp+8

65
Q

third item on stack

A

rsp+16

66
Q

rip register

A

points to next instruction to be executed

67
Q

call function

A

transfer control to named function; saves return address (where to go when function completes); places rip register onto stack

68
Q

ret function

A

pops current top of stack (rsp) into rip

69
Q

(accessing array elements) [A+8]

A

value stored at address A plus 8 bits

70
Q

(accessing array elements) general form

A

base + register * scale + displacement

71
Q

function declaration

A

global <procName></procName>

<procName>:
; function body
ret
</procName>

72
Q

rsp

A

stack pointer register

73
Q

rbp

A

stack base pointer