• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/57

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

57 Cards in this Set

  • Front
  • Back
Assembly
What are the compilation stages of gcc?
Pre-processing -> Compilation -> Assembly -> Linking
Define Pre-processing
Expanding Macros
Define Compilation
Converting source code into assembly language
Define Assembly
assembly -> machine code
Define Linking
Adding runtime library to create the final executable
Name the registers rsi/ rdi/ rsp/ rbp/
source index/destination index/ stack pointer/base pointer
Function of the rip register
Holds the address of the next instruction to be executed.
Function of rflags register
Bits represent various Cpu state, updated after various instructions.
Main memory info on Intel 64
Little endian/byte addressable/non-aligned access
What is the nasm instruction format
Label: Opcode operand operand
How what is the syntax which allows you to access the higher/lower bytes of the first 16 bits of a register?
{a...d}+h/l and rsi -> sil/rdi -> dil/rsp -> spl/rbp -> bpl

What is the size in bits of a byte, word, doubleword, quadword?, 8/16/32/64 bits
What are data declaration directives?
They are special commands that allow global data variables to be declared
What is the syntax for declaring data declaration directives?
Var_name <size(s)> <value(s)>
What is the syntax for declaring bytes
words, double words, quad words? , db, dw, dd, dq
Declare a variable called users of size 1 byte with the value 4
users db 3
Declare a variable string variable called name with value "hello"
name db "hello"
Declare a sequence seq
of size double word and values 1/2/3 , seq dw 1, 2, 3
Declare an array with size of 100 double words each with a value of 43
array times 100 dw 43
How do you create uninitialized data?
name res<b/w/d/q> <quantity>
How do you create constants?
Name equ <value>
Name the three types of operands
Register/Immediate/Memory operands*
How do you use a memory operand?
Only one memory location per instruction/ [mem_location]
Name the addition and subtraction instructions and their effects
They all change the rflags value
add/sub
inc/dec
cmp a b: compares a - b
neg
Usage of the multiply instruction
imul op1 op2 op3*/ operations can set both the carry and overflow flags
Integer divide operation usage
for 8bit integers   idiv <operand>  => ah = ax div op |
al = ax mod op else idiv <operand>  => ?ax* = rax div op |
?dx = rax mod op
Name instructions for bit shifting and its usage
Sal dest n: Shift arithmetic left by n
Sar dest
n: Shift arithmetic right by n
Name the instruction used to convert a byte into a word
cbw  => ax = al
Name the instruction used to convert a word into a double word
cwde => eax = ax
Name the instruction used to convert a double word into a quad word
cdq => eax:edx = eax
Name the instruction used to sign extend a quad word
cdo => rdx:rax = rax*
Convert to assembly alpha dw 7/ beta dw 4/ gamma dw -3 :- alpha = (alpha * beta + 5* gamma) * (alpha - beta)
1. mov rax, [alpha]
2. imul rax [beta]
3. mov rbx, [gamma]
4. imul gamma, 5
5. add rax, rbx
6. mov rbx [alpha]
7. sub rbx [beta]
8. imul rax, rbx
9. mov [alpha], rax
Write some code to test for overflow after adding two integers
1. add rax, rbx
2. jo ov_label
3. ov_label:
Write some code to test for integer divide by 0
1. cmp rbx, 0
2. je div_label
3. idiv rbx
List the five bit level instructions
and, or, xor, not, test
What does the bit level instruction "test" do?
test rax , rbx set rflags.* to 1 if bit patterns match 0 otherwise
Assuming the variables are bytes with value 1
convert this to assembly:- okay = (london && grey) || (! london),
1. mov rax [london]
2. and rax, [grey]
3. mov rbx, [london]
4. not rbx
5. or rax, rbx
6. mov [okay], rax
What is the format of jump instructions?
jmp_intr label

What are the instructions for jumps?,
1. jmp : unconditional jump
2. Je: jump if equal
3. Jz: jump if equal to zero
4. Jnz: jump if not equal to zero
5. Jl: jump if <
6. Jle: jump if <=
7. Jg: jump if >
8. Jge: jump if >=
Convert if(age < 100) …
1. if: cmp word[age], 100
2. jl endif
3. …
4. endif: …
Write a do while loop in assembly
1. While:
2. Statements
3. Cmp x, y
4. Jump_instruction while label
Write a while loop in assembly
1. While:
2. Cmp x, y
3. Jump_instruction end_while label
4. Statements
5. Jump while
6. Endwhile
Write a for loop in assembly
1. For mov word[age], 1
2. Next:
3. Cmp statement
4. Jump endfor
5. Statements
6. Inc word[age]
7. Jmp next
8. Endfor:
Convert if(age < 100) && (age > 12)
1. cmp [age], 100
2. jg label…
3. cmp [age], 12
4. jl label.. 5# statements
Convert if(age > 100) statements else statements
1. cmp word[age] 100
2. jl else_label
3. statements
4. elseif 5#stats


Describe what the stack is, The stack is a region in memory that is access via push and popping data of/on the top of the stack via the LIFO principle.
What is the relationship between rsp and the stack?
rsp always points to the address at the top of the stack.
What is the relationship between rbp and the stack?
rbp is used to point to the addresses of data on the stack. Like local variables
What data sizes can be pushed to the stack on the intel 64 architecture?
Only multiples of words.
How does the stack change when pushing/popping data?
The stack grows downward in memory, lower address are written to with each push, opposite for popping.
How does the register used effect push/pop operations?
The size of the register/operand determines how much data is pushed/popped to the stack. Only 2 or 8 bytes are transferred at a time.
Name the instruction for pushing data and the effect on rsp.
push <operand>, rsp = rsp - 2OR8
Name the instruction for popping data and the effect on rsp.
pop <operand>, rsp = rsp + 2OR8
Name the instruction for pushing rflags and the effect on rsp.
pushfq , rsp = rsp - 2OR8
Name the instruction for popping rflags and the effect on rsp.
popfq, rsp = rsp + 2OR8
What are the CALLER conventions before calling a method?
1. Push parameters in order first to last
2. Push object instance
3. call method
What are the CALLEE conventions?
1. Save registers
2. Execution
3. Copy any results to <r/e>ax
4. Restore register
5. return
What are the CALLER conventions after calling a method?
Remove object instance from stack
Remove parameter from stack
Implement max(a, b) in assembly,
1# max: