Nand2Tetris_Part2_12

The last unit~🏆

Unit 12.1 Operating System

The Jack OS: Math/Memory/Screen/Output/Keyboard/String/Array/Sys

Unit 12.2 Efficiency Matters

Use logarithmic runtime algorithms instead of linear runtime algorithms.

Unit 12.3 Operating System: Mathematical Operations

Implementation notes:
multiply_1

multiply_2

division

squareRoot

Unit 12.4 Operating System: Memory Access

memory

Unit 12.5 Operating System: Heap Management

simple

detailed_1

detailed_2

detailed_3

🎈 Fragment recycle algorithm is not required, but it’s a nice extension for this OS.

pseudo_code

Unit 12.6 Graphics

Vector graphics images can be easily:

  • stored
  • transmitted
  • scaled
  • turned into bitmap

pixel

Unit 12.7 Operating System: Line Drawing

Line drawing:

  • drawLine is implemented through a sequence of drawPixel operations
  • In each stage we have to decide if we have to go right, or up

line

circle

drawPixel

drawLine

drawCircle

Unit 12.8 Operating System: Handling Textual Output

Hack font:

  • Each character occupies a fixed 11-pixel high and 8-pixel wide frame
  • The frame includes 2 empty right columns and 1 empty bottom row for character spacing

About cursor, must be managed as follows:

  • if asked to display newLine: move the cursor to the beginning of the next line
  • if asked to display backspace: move the cursor one column left
  • if asked to display any other character: display the character, and move the cursor one column to the right

Unit 12.9 Operating System: Input

Keyboard memory map:

  • when a key is pressed on the keyboard, the keyboard register is set to the key’s scan code
  • when no key is pressed, the keyboard register is set to 0

character_set

Unit 12.10 Operating System: String Processing

String

Unit 12.11 Operating System: Array Processing

Array

Unit 12.12 Operating System: The Sys Class

contract

sys.init

others

Unit 12.13 Project 12: Building the OS

Emmmm…after some thought, i would not display my codes for this project.😁

Unit 12.14 Perspective

  1. What are the major differences between the jack operating system and regular systems?
  • jack is very easy and limited functionality compared to industrial strength systems.
  1. How come the Jack OS is so wide open programmer can do whatever they want?
  • Everything is wide open in nand2tetris, so users can do everything they want. And yet in Hack platform, the user level code and OS code run in exactly the same execution level.
  1. How does the Jack OS rate in terms of efficiency?
  • Two areas: mathematical operations and graphics.

Buy me a coffee ? :)
0%