Chapter 6-assembler Flashcards

1
Q

Programs in binary code have extension of?

A

Hack

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

Programs in assembly code have extension?

A

Asm

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

When a machine code is loaded into the computer’s memory to which segment of memory is it loaded and what will be the address of the n’th line?

A

Loaded into the instruction memory and will have address n

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

What does an assembly file composed from?

A

Instructions A and C and symbol

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

What is binded to the symbol?

A

The memory location into which the next command in the program will be stored

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

What is the A instruction?

A

@value is either non negative number or a symbol referring to such number.
The binary rep of A command is
0vvv vvvv vvvv vvvv where v is 0 or 1

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

What is c instruction?

A

Dest=comp;jump
Notice that comp or jump can be empty
The rep is
111a c1c2c3c4 c5c6d1d2 d3j1j2j3

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

Name the hack predefined symbols

A

SP LCL ARG THIS THAT R0-R15 SCREEN KBD

0. 1. 2. 3. 4. 0-15. 16384. 24576

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

How to define a symbol in assembly code?

A

(Xxx) it can be defined only once and can be used anywhere in the program also before the definition

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

What is a variable symbol in assembly code?

A

Any symbol Xxx which is not predefined and is not defined using (Xxx) is treated as a variable.
Variables are mapped to consecutive memory locations as they are first encounter, starting at ram address 16

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

What is the input and the output of the assembler?

A

The input is a prog.asm file and the output is

Prog.hack file

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

How to write the assembler?

A
  1. Parser which parse each line into command type, symbol, dest, comp, jump
  2. Code module which translate assembly into binary
    Dest into 3 bits, comp into 7 bits and jump into 3 bits
  3. The symbolTable module which is hash table of symbol to address RAM OR ROM
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Assembly program can use labels before they are defined. What is the solution for this problem for assembly developers?

A

Two pass assembler.
First pass the assembler builds the symbol table and generates no code.
First init the table with all the predefined symbols.
First pass: go through line by line while keeping a running number of the ROM address, increment when C or A commands
When pseudo command (Xxx), add it to the symbol table,
Key: Xxx value: the ROM address that will store the next command.
In the second pass resolve the program variables symbols

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

When and how does the program variables are handled

A

In the second pass of the assembler.
Each time we have A command @xxx where xxx are not a number, lookup Xxx at the symbol table. If found, replace it with it’s numerical number,
If not found add to the table
Key Xxx, value: next available RAM address.
Now complete the command’s translation.

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