


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



ASCII character set - ANSWER-a universal chart which encodes the proper decimal and binary equivalent of different characters using 7 bits in assembly character constants can be denoted with hex code and the character in single quotes A string is an array of characters and can be initialized in memory one byte at a time (.byte 'h', 'e', 'l', 'l', 'o') or using the .ascii pseudo op (.ascii "hello") a string literal is a read only array of characters allocated in the .text section command line arguments - ANSWER-allow you to pass values from the shell into your program External arrays of pointers - ANSWER-are created with a list of labels .text fmt: .string "season[%d] = %s\n" spr_m: .string "spring" sum_m: .string "summer" fal_m: .string "fall" win_m .string "winter" external arrays of pointers - ANSWER-pointers are double word aligned .balign 8 external variables - ANSWER-.byte .hword .word. dword don't need to be allocated on the stack. ldr w20, [x19] adrp x19, j_m add x19, x19, :lo12:j_m used to load value of i_m External Variables - ANSWER-are non-local variables, allocated in the data or bss sections and are used to implement global and static local variables Can be allocated and initialized using .dword .word .hword .byte Form: label: pseudo-op values The labels represent 64 bit addresses. To use them use adrp and add to put the address into a register and then use ldr and str to access Ex: .data i_m .word 2 .text usual stuff adrp x19, i_m
add x19, x19, :lo12:i_m ldr w20, [x19] add w21, w20, w .skip can allocate uninitialized space (.bss section) .global can be used if the variable is to be made available by other compilation units Fixed point numbers - ANSWER- local variables - ANSWER-stack variables in assembly local, static local, static global and global variables - ANSWER-Local: scope = local to block of code where declared lifetime = life of the block of code Static local: scope = block of code where declared lifetime= life of program Static global: scope = local to file lifetime = life of program Global: scope = global lifetime = life of program pattern for open, reading or writing and closing file - ANSWER-open i.e connect to the device, get its file descriptor read from or write to the file i.e do device i/o, transferring bytes close the file i.e disconnect from the device Returning integers - ANSWER-Integers are returned using w0 and x Returning structures - ANSWER-Often structures are too big to return in x0 or w0. The calling code provides memory on the stack to store the returned result. The address of this memory is put into x8 prior to the function call. The called subroutine writes to memory at this address, using x8 as a pointer to it. format add baseAdd, x29, size str xzr, [baseAdd, variable] ldr x10, [baseAdd, variable] str x10, [x8, variable] separate compilation - ANSWER-divided into .c or .s files makes development of large projects easier can be compiled into relocatable object code put into .o files by gcc -c file.c as file2.s -o file2.o object code is linked together with gcc file.o file2.o -o combined Structures - ANSWER-Contains fields, which may be of different types
eg: mov x8, 56 svc, 0 text, data and .bss sections - ANSWER-text: contains machine code and read-only programmer initialized data. Attempts to write to this memory causes a segmentation fault. data: contains programmer initialized data and is read/write memory. .bss (block starting symbol): contains zero initialized data and is read/write memory. These sections are located in low memory, just after the section reserved for the OS kernel.