Separate Compilation & ASCII Flashcards

1
Q

What is relocatable object code?

A

Means you can put machine instructions anywhere

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is source code divided?

A

Into several modules (compilation units) like separate .c or .s files which can be compiled into relocatable object code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe the process of separate compilation and linking

A
  1. Modules (compilation units) are compiled into ROC (put in corresponding .o files)
  2. 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does ASCII stand for and what does it do?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

In assembly, how are character constants denoted?

A

With hex code: mov w19, 0x5A

OR

The character in single quotes (better but may interfere w/m4): mov w19, ‘Z’

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or false: these both initialize a string:

.byte ‘c’, ‘h’, ‘e’, ‘e’, ‘r’, ‘s’

.ascii “cheers”

A

True. A string is an array of characters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

In C, strings are null-terminated. What does this mean?

A

Strings end with \0

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to indicate null-termination in assembly?

A

Use two pseudo-ops:
.ascii “cheers”
.byte 0

OR

Use .asciz or .string:
.string “cheers”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a string literal?

A
  • A read-only array of characters allocated in the text section. A string literal is immutable.
  • In c code, delimited with “…”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What section is a string stored in?

A

.data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the label for a string literal represent?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How are external arrays of pointers created?

A

With lists of labels

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Command-line arguments allow you to pass values from the ____ into your program

A

Shell

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

In this C code, what are argc and argv?
main(int argc, char *argv[])

A

argc: the number of arguments

argv: an array of pointers to the arguments
- short for argument vector
- represented as strings

How well did you know this?
1
Not at all
2
3
4
5
Perfectly