Chapter 1 Flashcards
Distinguish between RISC and CISC.
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.
What does MMIO stand for?
Memory Mapped Input Output
Distinguish between Harvard and Von Neumann architecture.
Harvard has separate program and data memories.
Distinguish between machine language and assembly language. What is an assembler?
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.
Syntax for comment in RiscV.
#
Give syntax for basic binary ops in RiscV.
add s0, s1, s2 #data in registers
Give syntax for loading constant in RISC-V. Give syntax for loading address.
li reg, constant
la reg, address
Give syntax for copying data from one register to another.
mv reg1, reg2
What does register a7 do in RISC-V? What do registers a0, a1 do in RISC-V.
Tells the OS environment to perform certain commands based on its value.
Holds the parameter(s) passed to the commands.
Explain possible values for a7 and their meanings.
1 = print integer
4 = print string
5 = read integer
8 = read string
9 = sbrk (allocate heap memory)
10 = exit (terminate execution)
Syntax for printing an integer in address x23 using OS.
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
What is the actual address of a0, a1 and a7? Same for ra and zero?
a0 = x10
a1 = x11
a7 = x17
ra = x1
zero = x0
Distinguish between a memory word and a byte.
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.
Explain memory space allocation directives.
.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.
What does .text directive do?
Tells assembler this is where program begins.
Explain lw, sw and there syntax.
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.
What are lb and sb? How is sb unique from sw?
Same as lw and sw but operate on single bytes.
Sb writes 8 least significant bits from reg1.
Syntax for defining a variable in java.
Name: .data_assignment initial_value
E.g.
A: .word 1 #Creates a variable A if length 4 bytes with initial value 1.
What is a memory mapped register?
A special memory address reserved for a peripheral device that will perform some action when the address is read from/written to.
What is the memory address space? For example what is it for 32 bit address bus.
The range of all possible memory addresses accessible to the program.
2^32 = 4294967296 distinct memory locations from 0x00000000 to 0xFFFFFFFF
A 7 segment LED
_
| |
_
| |
_ .
is as above, explain how it is mapped in binary.
Start at top - go around clockwise ending with middle -. Then do .
This order is the binary from right to left.
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?
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.
Syntax for shifting bits to the left and right. What is really going on here?
slli reg, reg, numofbitstoshift
slri reg, reg, numofbitstoshift
multiply by 2^numofbitstoshift, divide by 2^numofbitstoshift
RISC-V branching instruction syntaxs.
j label (True)
blt reg1, reg2, label (if reg1 < reg2)
beq reg1, reg2, label (if reg1 == reg2)
bne reg1, reg2, label (if reg1 != reg2)