Separate Compilation & ASCII Flashcards
What is relocatable object code?
Means you can put machine instructions anywhere
How is source code divided?
Into several modules (compilation units) like separate .c or .s files which can be compiled into relocatable object code.
Describe the process of separate compilation and linking
- Modules (compilation units) are compiled into ROC (put in corresponding .o files)
- Object code is linked together to create an executable
- this is done by a loader ld (invoked by gcc)
- ld resolves any references to external data or functions in other modules
- code & data are relocated in mem as necessary to form contiguous text, data & bss sections
What does ASCII stand for and what does it do?
American Standard Code Information Interchange has 128 characters
encodes characters using 7 bits, stored in a byte. The 8th bit may be used to extend ASCII to include characters beyond english
In assembly, how are character constants denoted?
With hex code: mov w19, 0x5A
OR
The character in single quotes (better but may interfere w/m4): mov w19, ‘Z’
True or false: these both initialize a string:
.byte ‘c’, ‘h’, ‘e’, ‘e’, ‘r’, ‘s’
.ascii “cheers”
True. A string is an array of characters.
In C, strings are null-terminated. What does this mean?
Strings end with \0
How to indicate null-termination in assembly?
Use two pseudo-ops:
.ascii “cheers”
.byte 0
OR
Use .asciz or .string:
.string “cheers”
What is a string literal?
- A read-only array of characters allocated in the text section. A string literal is immutable.
- In c code, delimited with “…”
What section is a string stored in?
.data
What does the label for a string literal represent?
The address of the first character in the array
- this address can be passed as a pointer argument into a function using an x register:
Adrp x0, fmt
How are external arrays of pointers created?
With lists of labels
Command-line arguments allow you to pass values from the ____ into your program
Shell
In this C code, what are argc and argv?
main(int argc, char *argv[])
argc: the number of arguments
argv: an array of pointers to the arguments
- short for argument vector
- represented as strings