EoC-1 - Lecture - 18 - Machine Language - Part 3
EoC-1 - Lecture - 18 - Machine Language - Part 3
22AIE102|CEN 1
Hack assembly language (overview)
22AIE102|CEN 2
CPU Emulator
22AIE102|CEN 3
Hack Programming
• Working with registers and memory
• Branching
• Variables
• Iteration
• Pointers
• input/output
22AIE102|CEN 4
Registers and memory
22AIE102|CEN 5
Typical operations
22AIE102|CEN 6
Program example: add two numbers
Implicit line
numbers
22AIE102|CEN 7
Program example: add two numbers
22AIE102|CEN 8
DEMO
22AIE102|CEN 9
Terminating a program
22AIE102|CEN 10
Terminating a program
22AIE102|CEN 11
Terminating a program
22AIE102|CEN 12
Built-in symbols
• The Hack assembly language features built-in symbols:
22AIE102|CEN 13
Built-in symbols
• The Hack assembly language features built-in symbols:
22AIE102|CEN 14
Hack Programming
• Working with registers and memory
• Branching
• Variables
• Iteration
• Pointers
• input/output
22AIE102|CEN 15
example:
Branching
If you remove
the comments,
and preamble
the code
becomes cryptic
22AIE102|CEN 16
Labels
22AIE102|CEN 17
Labels
22AIE102|CEN 18
Hack Programming
• Working with registers and memory
• Branching
• Variables
• Iteration
• Pointers
• input/output
22AIE102|CEN 19
Variables
22AIE102|CEN 20
Hack Programming
• Working with registers and memory
• Branching
• Variables
• Iteration
• Pointers
• input/output
22AIE102|CEN 21
Iterative processing
22AIE102|CEN 22
22AIE102|CEN 23
22AIE102|CEN 24
Hack Programming
• Working with registers and memory
• Branching
• Variables
• Iteration
• Pointers
• input/output
22AIE102|CEN 25
Pointers
Suppose arr=100, and n=10 Variable arr = 100
address (pointer)
22AIE102|CEN 26
22AIE102|CEN 27
22AIE102|CEN 28
Thank You
22AIE102|CEN 29