HACK Machine Language & Assembler Flashcards

Week 2.1 (36 cards)

1
Q

what is machine language

A

an agreed upon formalism, designed to code low-level programs as a series of machine instructions

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

use of machine language

A
  • define the interface between programming & logic gates
  • define low level operations:
    • manipulating memory
    • basic logic operations
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is opcode

A

corresponds to operations defined in the decoder circuitry

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

what are the HACK machine registers

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

what is the HACK machine computer

A

is a theoretical, simplified computer architecture designed for educational purposes
- von neumann
- 16-bit registers

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

what does the D register store

A

data

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

what does the A register store

A

data or address

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

what does M stand for

A

implicit label which refers to the value of memory location pointed to by A
- RAM[A]

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

what register do jump instructuions use

A

A

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

how to load an immediate value into A

A

@value

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

what is D;JGT condition

A

D > 0

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

what is D;JGE condition

A

D >= 0

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

what is D;JLT condition

A

D < 0

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

what is D;JLE condition

A

D <= 0

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

what is D;JEQ condition

A

D = 0

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

what is D;JNE condition

17
Q

what is 0;JMPcondition

A

unconditional jump

18
Q

how to define a jump in HACK machine language

A

@label
condition

i.e
@positive
D;JGE

19
Q

command to load data in memory into the data register

20
Q

command to store data in data register into memory

21
Q

binary syntax of a C-instruction

A

111accccccdddjjj
- first 1 = C-instruction opcode
- second & third 1s = not used
- acccccc = comp bits
- ddd = dest bits
- jjj = jump bits

22
Q

binary syntax of A value

A

0vvvvvvvvvvvvvvvv
- 0 = A-instruction op-code
- vvvvvvvvvvvvvvv - 15-bit binary representation of the constant, therefore <= 32767

23
Q

HACK assembler translation steps

A
  1. symbols
  2. non-instructions
  3. instructions
24
Q

types of symbols

A
  1. predefined
  2. labels
  3. variables
25
symbolic syntax of A instructions
@xxx
26
symbolic syntax of C instructions
dest = comp;jump
27
what are predefined symbols
- R0 - SCREEN - KBD - SP - LCL - ARG - THIS - THAT
28
how are predefined symbols assembled
@SYM - replace SYM with its value
29
what are labels
- LOOP - STOP
30
how are labels assembled
- (SYM) - add to the table row - SYM|label's line number - @SYM - replace SYM with its value
31
what are variable symbols
examples: i, sum
32
how are variable synmbols assembled
- @SYM - first occurence: bind SYM to unsused value starting from 16 ELSE replace SYM with its value
33
3 steps in assembling overview
1. initialisation 2. first pass 3. second pass
34
what happens in the initialisation stage
1. open the source file 2. construct sumbol table (ST) 3. add default to ST
35
what happens in the first pass
1. count lines 2. add labels to ST
36
what happens in the second pass
1. add variables to ST 2. parse instructions 3. translate instructions 4. write binary code to output file