Creating a program Flashcards
Understand the program requirements to build a program in assembly.
What are the sections of a program?
A text section, data section,
What is the file extension for a assembly program in Linux system?
.asm
How do you create a text section.
In the editor type:
“section .text”
How do you create a data section?
“section .data”
What goes inside the data section?
The message the program needs to print placed inside of the data section.
Ex:
section .data
message: db “Hello World!”
What is the linker of a program?
It is the entry point of a program.
Ex.
global _start
section .text
_start:
How do you invoke a system call?
A user space program calls a system call by invoking it with a generated interrupt such as “int 0x80”, “SYSENTER” or VDSO.
What are system calls?
Provides a interface for user space programs to request the kernel to execute tasks.
Where are system calls located?
/usr/include/1386-linux-gnu/asm/unistd_32.h
What command can be used to count a string in an asm program?
mlen equ $-message
What system call can be used to write a program to screen?
_write identified in a program by the number 4
What system call will exit a program?
_exit closes a program with the status code given by the programmer.
Where in the program is the system call located?
It is located in the text section of the program. Below is code to print the message on the screen. Ex: _start: mov eax, 0x4 mov ebx, 0x1 mov ecx, message mov edx, mlen int 0x80 (invokes syscall)