• 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/8

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;

8 Cards in this Set

  • Front
  • Back
What file contains the 32bit system calls for reference?
On BT5:

/usr/include/asm/unistd_32.h
How do you define the following places within the asm source?

1. The start of "main"
2. Text section
3. Data section
4. A label
1. _start:
-You'll also need global _start at the top of the source

2. section .text

3. section .data

4. <label name>: label data
When invoking a system call, which register contains the syscall number, and what is the appropriate order for the following arguments?
eax - syscall number
ebx - 1st argument
ecx - 2nd argument
edx - 3rd argument
esi - 4th argument
edi - 5th argument
Which register typically contains the function's return value?
EAX
If you had a label which contained a string, how can you have nasm automatically count the length for you?
message: db "Hello World!" <---- label for string
mlen eq $-message <----- mlen now has the value 12
How do you assemble and link the program with nasm and ld?
How to assemble with nasm:

nasm -f elf32 -o hello_world.o hello_world.asm

How to link:

ld -o hello_world hello_world.o
What are the 4 things to know when calling libc functions from within nasm?
1. define all libc functions with "extern" without quotes

2. All arguments must be pushed onto the stack in reverse order.

3. Adjust the stack after calling libc functions

4. Link with gcc instead of ld (use main instead of _start)
Here is an example of calling libc functions from within nasm.
extern printf
extern exit

global main

section .text
main:
push message
call printf
add esp, 0x4 ; adjust the stack by 4 bytes for the pushed pointer to message string