top of page

ASSEMBLY LANGUAGE ADDITIONAL NOTES ON: SYSCALLS, LABELS AND SECTIONS

===========================================

SYSCALL

===========================================

Takes 7 arguments based on values stored in registers, as shown below in a table

Argument Registers

----------------------

ID rax * Can either be 0 for sys_read, 1 for sys_write to screen or 2 for sys_open can find the rest online

1 rdi * should hold filedescriptor

2 rsi * should hold buffer , location of string

3 rdx * hold length

4 r10

5 r8

6 r9

* # is a physical number, $ is an address

syscall ID ARG1 ARG2 ARG3 ARG4 ARG5 ARG6

sys_write 1 #filedescriptor $buffer #count

filedescriptor = 0 standard input, 1 standard output, 2 standard error

Buffer = location of string to write

Count = Length of string

===========================================

SECTIONS

===========================================

There are 3 sections in the x86_64

.data * Where all the data is defined memory we use BEFORE compilation

.text * Where the code goes

.bss * Allocate/REserve memory for future use

===========================================

LABELS

===========================================

label part of the code, upon compilation the compiler will calculate the location in which the label will sit in memory

The _start label is essential for all programs, if the linker cannof find _start it will throw an error

===========================================

GLOBAL

===========================================

Used when you want the linker to be able to know the address of some label.


2 views0 comments

Recent Posts

See All

Closing Thoughts

For my final blog post I would like to discuss what I have learned and plan to utilize in the future from this course. So although I was not able to successfully improve my package to operate function

Stage 3 Optimization(COMPUTER ARCHITECTURE ENDIANESS)

Seeing as how the compiler flags did not provide any optimization I will on to my next attempt which is converting big endian to small endian. The aarch64 architecture uses the little endian byte orde

Stage 3 Optimization(Compiler Flags)

My first attempt to optimize the project will be to work with the compiler flag options. By default the compiler is set to compile in this manner "gcc -E -g -o2" The -E option represents preprocesses

bottom of page