\(4.6.\)Working with register and memory

1.Operations towards D

  • Storing value: It turns out that there's no direct way to do it, we have to do it indirectly. For example, if we want to store 10 in register D:

    1
    2
    @10
    D = A

  • Incresing value: We can use C instructions directly:

    1
    D = D + 1

  • Setting D to RAM value: It's similar to storing value:

    1
    2
    @10
    D = M

2.Usage of D register

  D register is of great importance in assignment operations:

1
2
3
4
5
6
7
8
9
10
11
//set RAM[10] to 5
@5
D = A
@10
M = D

//set RAM[10] to RAM[5]
@ 5
D = M
@10
M = D

3.Built-in symbol