EoC-1 - Lecture - 17 - Machine Language - Part 2

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 22

22AIE102

Elements of Computing Systems-II


Hack machine Language
Sreelakshmi K, Assistant Professor
Center for Excellence in Computational Engineering and
Networking (CEN)
Amrita School of Engineering, Coimbatore
Acknowledgment: Prof. Noam Nisan, Prof. Shimon Schocken

22AIE102|CEN 1
Input / output

I/O handling (high-level):


Software libraries enabling text, graphics, audio, video, etc.

I/O handling (low-level):


Bits manipulation.
22AIE102|CEN 2
Memory mapped output

Memory mapped output

A designated memory area, dedicated to manage a display unit

The physical display is continuously refreshed from the memory map,


many times per second

Output is effected by writing code that manipulates the screen memory map

22AIE102|CEN 3
Screen memory map

To set pixel (row,col) on/off:

22AIE102|CEN 4
DEMO of Screen memory map in Hardware
Simulator

22AIE102|CEN 5
Memory mapped input

The physical keyboard is associated with a keyboard memory map.

22AIE102|CEN 6
When a key is pressed on the keyboard, the key’s scan code appears in
the keyboard memory map

 When no key is pressed, the resulting code is 0.

22AIE102|CEN 7
The Hack character set

22AIE102|CEN 8
Handling the keyboard
To check which key is currently pressed:
• Probe the contents of the Keyboard chip
• In the Hack computer: probe the contents of
RAM[24576].

22AIE102|CEN 9
DEMO of Keyboard memory map in Hardware
Simulator

22AIE102|CEN 10
Hack assembly language (overview)

22AIE102|CEN 11
Hack Programming
• Working with registers and memory
• Branching
• Variables
• Iteration
• Pointers
• input/output
22AIE102|CEN 12
Registers and memory

22AIE102|CEN 13
Typical operations

22AIE102|CEN 14
Program example: add two numbers

Implicit line
numbers

22AIE102|CEN 15
Program example: add two numbers

22AIE102|CEN 16
Terminating a program

22AIE102|CEN 17
Terminating a program

NOP slide
22AIE102|CEN 18
Terminating a program

22AIE102|CEN 19
Built-in symbols
• The Hack assembly language features built-in symbols:

These symbols can be used to denote “virtual registers”

• Example: suppose we wish to use RAM[5] to represent some variable,


say x, and we wish to let x=7

20
Built-in symbols
• The Hack assembly language features built-in symbols:

• SCREEN and KBD : base addresses of I/O memory maps


• Remaining symbols: used in the implementation of the Hack virtual machine

21
Thank You

22AIE102|CEN 22

You might also like