Chapter 1 Flashcards

1
Q

Distinguish between RISC and CISC.

A

A Reduced Instruction Set Computer (RISC) is designed to perform a small set of simple machine instructions at high speed.

A Complex Instruction Set Computer (CISC) is designed to perform a large set of compound machine instructions, each consisting of several operations.

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

What does MMIO stand for?

A

Memory Mapped Input Output

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

Distinguish between Harvard and Von Neumann architecture.

A

Harvard has separate program and data memories.

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

Distinguish between machine language and assembly language. What is an assembler?

A

Machine language is made up of all possible binary words.
Assembly language assigns mnemonic to each of these binary words to make them easier for a human to understand.

A program that converts assembly mnemonics into equivalent machine instructions.

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

Syntax for comment in RiscV.

A

#

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

Give syntax for basic binary ops in RiscV.

A

add s0, s1, s2 #data in registers

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

Give syntax for loading constant in RISC-V. Give syntax for loading address.

A

li reg, constant
la reg, address

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

Give syntax for copying data from one register to another.

A

mv reg1, reg2

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

What does register a7 do in RISC-V? What do registers a0, a1 do in RISC-V.

A

Tells the OS environment to perform certain commands based on its value.

Holds the parameter(s) passed to the commands.

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

Explain possible values for a7 and their meanings.

A

1 = print integer
4 = print string
5 = read integer
8 = read string
9 = sbrk (allocate heap memory)
10 = exit (terminate execution)

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

Syntax for printing an integer in address x23 using OS.

A

li a7, 1 # request service 1 (to print an integer)
mv a0, x23 # copy the value to print into a0 from x23
ecall # call OS

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

What is the actual address of a0, a1 and a7? Same for ra and zero?

A

a0 = x10
a1 = x11
a7 = x17

ra = x1
zero = x0

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

Distinguish between a memory word and a byte.

A

A memory word contains 4 bytes, where the LS byte is stored at the address of the word, and an offset is added for each subsequent byte.

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

Explain memory space allocation directives.

A

.data = begins declaration of data area
.byte n = allocates a byte with value n.
.word n = allocates a word with value n.
.space m = allocates m consecutive bytes of memory, without initialization.
.asciiz “string” = Let x be the length of the string in characters, x + 1 bytes of memory are allocated and initialized with ASCII codes of string s characters, with the last allocated byte initialized to 0.

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

What does .text directive do?

A

Tells assembler this is where program begins.

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

Explain lw, sw and there syntax.

A

lw reg1, offset(reg2) reads a word from memory location reg2 + offset and puts in reg1

sw reg1, offset(reg2) writes a word from reg1 to memory location reg2 + offset.

17
Q

What are lb and sb? How is sb unique from sw?

A

Same as lw and sw but operate on single bytes.

Sb writes 8 least significant bits from reg1.

18
Q

Syntax for defining a variable in java.

A

Name: .data_assignment initial_value

E.g.
A: .word 1 #Creates a variable A if length 4 bytes with initial value 1.

19
Q

What is a memory mapped register?

A

A special memory address reserved for a peripheral device that will perform some action when the address is read from/written to.

20
Q

What is the memory address space? For example what is it for 32 bit address bus.

A

The range of all possible memory addresses accessible to the program.

2^32 = 4294967296 distinct memory locations from 0x00000000 to 0xFFFFFFFF

21
Q

A 7 segment LED
_
| |
_
| |
_ .

is as above, explain how it is mapped in binary.

A

Start at top - go around clockwise ending with middle -. Then do .
This order is the binary from right to left.

22
Q

Explain bitwise operations syntax. If we wanted to turn on specific bit how would we do that? If we wanted to turn off specific bit how would we do that?

A

ori out, src, value
andi out, src, value

ORing number with a value, anywhere there are 1’s in value they will be set to 1 in output.

Anding number with a value, anywhere there are 0’s in value they will be set to 0 in output.

23
Q

Syntax for shifting bits to the left and right. What is really going on here?

A

slli reg, reg, numofbitstoshift
slri reg, reg, numofbitstoshift

multiply by 2^numofbitstoshift, divide by 2^numofbitstoshift

24
Q

RISC-V branching instruction syntaxs.

A

j label (True)
blt reg1, reg2, label (if reg1 < reg2)
beq reg1, reg2, label (if reg1 == reg2)
bne reg1, reg2, label (if reg1 != reg2)

25
Explain subroutine syntax.
Subroutines are defined with labels. We use jal procedureLabel to call a subroutine and jr reg to return from a subroutine to the place where it was called.
26
What is a binary executable file?
A particular way of storing machine language programs in a file.
27
Explain the tools in GNU Binary Utilities (binutils).
as: assembler ld: linker objcopy: copy object files and possibly make changes objdump: dump information about object files.
28
Where is .text and .data stored respectively in RARS memory?
.text stored in ROM .data stored in RAM
29
Define an object file.
Contains machine language output produced by the assembler from a single source code file. May contain unresolved (i.e. missing) references to program labels defined in other source code files.
30
Define Linker.
Takes one or more object files, merges their data and text sections and fixes all unresolved references to create an executable file.
31
What is the advantage of using object files?
Much faster as we dont have to re-assemble each individual file every time but only the files that have been changed. Then we simply run just linker again which is much faster than re-assembling every time.
32
Explain .globl and .extern directives.
Any label that is defined in another file must be defined with .extern so the assembler wont throw an error. Similarly, any label that we want to be accessible from any file must be defined with .globl.
33
Basic Makefile syntax. Using three files main, puts and gets.
prog: main.o puts.o gets.o \t ld -o prog main.o puts.o gets.o repeat below [ main.o: main.asm \t as -o main.o main.asm ] repeat above for puts and gets.
34
Syntax in C for writing value to 7 segmentLED at address 0xffff0010
volatile char *right_led_display = (volatile char *) 0xffff0010; *right_led_display = 0x06;