The document discusses machine language and the Hack computer architecture. It provides an overview of machine language as an abstraction of hardware that allows programs to manipulate memory using a processor and registers. It then describes the specific instruction set and components of the Hack computer, including its registers, ALU, program counter, and 16-bit instruction set consisting of A-instructions and C-instructions. Examples are provided of machine language commands and how high-level programming constructs can be implemented using the Hack instruction set.
CISC & RISC Architecture with contents
History Of CISC & RISC
Need Of CISC
CISC
CISC Characteristics
CISC Architecture
The Search for RISC
RISC Characteristics
Bus Architecture
Pipeline Architecture
Compiler Structure
Commercial Application
Reference
CISC & RISC Architecture with contents
History Of CISC & RISC
Need Of CISC
CISC
CISC Characteristics
CISC Architecture
The Search for RISC
RISC Characteristics
Bus Architecture
Pipeline Architecture
Compiler Structure
Commercial Application
Reference
The main Objective of this presentation is to define computer buses , especially system bus . which is consists of data bus , address bus and control bus.
This PPT is for First year engineering student,It covered all about C Programming according to Rajastha Technical University Kota.
flowchart, pseudo code, Programming Languages and Language Translators, Identifiers, Constants, Variables, Basic Data Types, Operators, Expressions, type casting, Input / Output Statement, Scope Rules and Storage classes, Preprocessor and Macro Substitution.
This is a brief introductory lecture I conducted on von Neumann Architecture. Von Neumann is a fundamental computer hardware architecture based on the store program concept, designed by John von Neumann.
The main Objective of this presentation is to define computer buses , especially system bus . which is consists of data bus , address bus and control bus.
This PPT is for First year engineering student,It covered all about C Programming according to Rajastha Technical University Kota.
flowchart, pseudo code, Programming Languages and Language Translators, Identifiers, Constants, Variables, Basic Data Types, Operators, Expressions, type casting, Input / Output Statement, Scope Rules and Storage classes, Preprocessor and Macro Substitution.
This is a brief introductory lecture I conducted on von Neumann Architecture. Von Neumann is a fundamental computer hardware architecture based on the store program concept, designed by John von Neumann.
ironSource's security application expert, Tomer Zait, shares his insights on engineering in the stack. Tomer, an Ort Singalovsky alumnus himself, gave this presentation to the Ort Singalovsky students on their tour of ironSource's headquarters in Tel Aviv.
Want to learn more about ironSource? Visit our website: www.ironsrc.com
Follow us on Twitter @ironSource
ironSource is looking for new talent! Check out our openings: http://bit.ly/Work-at-ironSource
Computer architecture is made up of two main components the Instruct.docxbrownliecarmella
Computer architecture is made up of two main components the Instruction Set Architecture (ISA) and the RTL model for the CPU.
In this class, we will have two software projects that will help in your understanding of the ISA and RTL model for the CPU.
The projects can be done in any software language that you chose to use.
The first project is the creation of an assembler.
The assembler will be use for you to write assembly language programs that will be executed on the CPU you will design in project #2.
The CPU we will be using is based on the DLX design.
What is an assembler?
All computer software goes through a set of applications to create an executable file that can be used by the end user.
The first program a programmer will used is a high level language program (C, C++, etc.).
The programmer writes in a very high level abstract environment writing code such as:
For(x=0; x< 10; x++)
A[x] = x;
The high level language allows the programmer to write his program without knowing how the ISA and hardware architecture functions.
The language hides all the hardware from the programmer.
At some point, the source code needs to be transfer to a language that takes into account the ISA and hardware architecture.
The complier is the next step in the development process.
The complier will take in high-level source code and translate the program into assembly language.
Assembly language is the ISA for a computer.
Assembly is the instructions that the computer can perform.
The compiler will do the following:
C language:
c = a + b;
Assembly:
load r1, a
Load r2,b
Add r3,r1,r2
Store r3,c
The last part of the development process is taking the assembly code created by the complier and transferring into machine code that the computer will execute.
A computer is not able to run written language such as ADD r1,r2,r3.
The computer runs a program by reading data stored in memory.
The memory does not the store the command ADD r1,r2,r3 but store machine code.
Machine code is the binary representation of an assembly language instruction.
The DLX Machine code
All the information for the DLX machine code and assembly instructions can be found in the handouts given in class. Each of the DLX instruction is 32-bits in length.
Each part of the instruction is assigned a set of bits in the instruction.
DLX break down the instructions into three different types R,I, and J.
R-type instruction
An example of the R-type instruction is ADD rd, rs1, rs2
The instruction is 32-bits in length:
Bits 31-26 is the opcode. The opcode tell the CPU what instruction it is doing
Bits 25-21 is the rs1
Bits 20-16 is the rs2
Bits 15-11 is the rd
Bits 10-0 is the funct.
Funct tells what type of ALU operation is being conducted.
I-type instruction
Ex ADDI rs1,rs2,immm
Bits 31-26 is the opcode
Bits 25-21 is rs1
Bits 20-16 is rs2
Bits 15-0 is immediate.
The immediate value is the constant value to use in the instruction
J-type instruction
Ex J address
Bits ...
Chapter 1
Syllabus
Catalog Description: Computer structure, machine representation of data,
addressing and indexing, computation and control instructions, assembly
language and assemblers; procedures (subroutines) and data segments,
linkages and subroutine calling conventions, loaders; practical use of an
assembly language for computer implementation of illustrative examples.
Course Goals
0 Knowledge of the basic structure of microcomputers - registers, mem-
ory, addressing I/O devices, etc.
1 Knowledge of most non-privileged hardware instructions for the Ar-
chitecture being studied.
2 Ability to write small programs in assembly language
3 Knowledge of computer representations of data, and how to do simple
arithmetic in binary & hexadecimal, including conversions
4 Being able to implementing a moderately complicated algorithm in
assembler, with emphasis on efficiency.
5 Knowledge of procedure calling conventions and interfacing with high-
level languages.
Optional Text: Kip Irvine, Assembly Language for the IBM PC, Prentice
Hall, 4th or 5th edition
1
Additional References: Intel and DOS API documentation as presented
in Intel publications and online at www.x86.org; lecture notes (to be sup-
plied as we go).
Prerequisites by Topic. Working knowledge of some programming lan-
guage (102/103: C/C++); Minimal programming experience
Major Topics Covered in the Course:
1 Low-level and high-level languages; why learn assembler?
2 How does one study a new computer: the CPU, memory, addressing
modes, operation modes.
3 History of the Intel family of microprocessors.
4-5 Registers; simple arithmetic instructions; byte order; Arithmetic and
logical operations.
6 Implementing longer integer type support; carry and overflow.
7 Shifts, multiplication and division.
8 Memory layout.
9 Direct video memory access; discussion of the first project.
10 Assembler syntax; how to use the tools.
11-13 Conditional & unconditional jumps; loops; emulating high-level lan-
guage constructions; Stack; call and return; procedures
14-15 String instructions: effcient memory-to-memory operations.
16 Interrupts overview: interrupt table; how do interrupts work; classif-
cation.
17 Summary of the most important interrupts.
18-20 DOS interrupt; File I/O functions; file-copy program; discussion of
the second project
21 Interrupt handlers; keyboard drivers; timer-driven processes; viruses
and virus-protection software.
2
22 Debug interrupts; how do debuggers and profilers work.
23-24 (Optional).interfacing with high level languages; Protected mode fun-
damentals
Grading The grading is based on two projects, midterm project is 49%
and the final is 51%. Please note that the projects are individual, submitting
projects that are similar to submissions of others and/or are essentially
downloads from the Web would result in a fail.
Office Hours My hours this term for CSc 210 will be 3:45 ¶Ł 4:45 on
Mondays.
Zoom links:
11am https://ccny.zoom.us/j/8 ...
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
The Art Pastor's Guide to Sabbath | Steve ThomasonSteve Thomason
What is the purpose of the Sabbath Law in the Torah. It is interesting to compare how the context of the law shifts from Exodus to Deuteronomy. Who gets to rest, and why?
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
How to Split Bills in the Odoo 17 POS ModuleCeline George
Bills have a main role in point of sale procedure. It will help to track sales, handling payments and giving receipts to customers. Bill splitting also has an important role in POS. For example, If some friends come together for dinner and if they want to divide the bill then it is possible by POS bill splitting. This slide will show how to split bills in odoo 17 POS.
Basic phrases for greeting and assisting costumers
Machine language
1. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 1
www.nand2tetris.org
Building a Modern Computer From First Principles
Machine Language
2. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 2
Where we are at:
Assembler
Chapter 6
H.L. Language
&
Operating Sys.
abstract interface
Compiler
Chapters 10 - 11
VM Translator
Chapters 7 - 8
Computer
Architecture
Chapters 4 - 5
Gate Logic
Chapters 1 - 3 Electrical
Engineering
Physics
Virtual
Machine
abstract interface
Software
hierarchy
Assembly
Language
abstract interface
Hardware
hierarchy
Machine
Language
abstract interface
Hardware
Platform
abstract interface
Chips &
Logic Gates
abstract interface
Human
Thought
Abstract design
Chapters 9, 12
3. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 3
Machine language
Abstraction – implementation duality:
Machine language ( = instruction set) can be viewed as a programmer-
oriented abstraction of the hardware platform
The hardware platform can be viewed as a physical means for realizing
the machine language abstraction
Another duality:
Binary version
Symbolic version
Loose definition:
Machine language = an agreed-upon formalism for manipulating
a memory using a processor and a set of registers
Same spirit but different syntax across different hardware platforms.
4. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 4
Binary and symbolic notation
Evolution:
Physical coding
Symbolic documentation
Symbolic coding
Translation and execution
Requires a translator.
1010 0001 0010 1011 ADD R1, R2, R3
Jacquard loom
(1801)
Augusta Ada King,
Countess of Lovelace
(1815-1852)
5. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 5
Typical machine language commands (a small sample)
// In what follows R1,R2,R3 are registers, PC is program counter,
// and addr is some value.
ADD R1,R2,R3 // R1 R2 + R3
ADDI R1,R2,addr // R1 R2 + addr
AND R1,R1,R2 // R1 R1 and R2 (bit-wise)
JMP addr // PC addr
JEQ R1,R2,addr // IF R1 == R2 THEN PC addr ELSE PC++
LOAD R1, addr // R1 RAM[addr]
STORE R1, addr // RAM[addr] R1
NOP // Do nothing
// Etc. – some 50-300 command variants
6. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 6
The Hack computer
A 16-bit machine consisting of the following elements:
Data memory: RAM – an addressable sequence of registers
Instruction memory: ROM – an addressable sequence of registers
Registers: D, A, M, where M stands for RAM[A]
Processing: ALU, capable of computing various functions
Program counter: PC, holding an address
Control: The ROM is loaded with a sequence of 16-bit instructions, one per memory
location, beginning at address 0. Fetch-execute cycle: later
Instruction set: Two instructions: A-instruction, C-instruction.
7. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 7
The A-instruction
@value // A value
Where value is either a number or a symbol referring to some number.
Used for:
Entering a constant value
( A = value) @17 // A = 17
D = A // D = 17
Coding example:
@17 // A = 17
D = M // D = RAM[17]
Selecting a RAM location
( register = RAM[A])
@17 // A = 17
JMP // fetch the instruction
// stored in ROM[17]
Selecting a ROM location
( PC = A )
Later
8. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 8
The C-instruction (first approximation)
Exercise: Implement the following tasks
using Hack commands:
Set D to A-1
Set both A and D to A + 1
Set D to 19
Set both A and D to A + D
Set RAM[5034] to D - 1
Set RAM[53] to 171
Add 1 to RAM[7],
and store the result in D.
dest = x + y
dest = x - y
dest = x
dest = 0
dest = 1
dest = -1
x = {A, D, M}
y = {A, D, M , 1}
dest = {A, D, M, MD, A, AM, AD, AMD, null}
9. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 9
The C-instruction (first approximation)
j 3012
sum 4500
q 3812
arr 20561
Symbol table:
(All symbols and values
are arbitrary examples)
Exercise: Implement the following tasks
using Hack commands:
sum = 0
j = j + 1
q = sum + 12 – j
arr[3] = -1
arr[j] = 0
arr[j] = 17
etc.
dest = x + y
dest = x - y
dest = x
dest = 0
dest = 1
dest = -1
x = {A, D, M}
y = {A, D, M , 1}
dest = {A, D, M, MD, A, AM, AD, AMD, null}
10. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 10
Control (focus on the yellow chips only)
ALU
Mux
D
A/M
a-bit
D register
A register
A
MRAM
(selected
register)
ROM
(selected
register)
PC
Instruction
In the Hack architecture:
ROM = instruction memory
Program = sequence of 16-bit
numbers, starting at
ROM[0]
Current instruction = ROM[PC]
To select instruction n from the ROM,
we set A to n, using the instruction @n
address
input
address
input
11. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 11
Coding examples (practice)
Exercise: Implement the following
tasks using Hack commands:
goto 50
if D==0 goto 112
if D<9 goto 507
if RAM[12] > 0 goto 50
if sum>0 goto END
if x[i]<=0 goto NEXT.
sum 2200
x 4000
i 6151
END 50
NEXT 120
Symbol table:
(All symbols and
values in are
arbitrary examples)
In the command dest = comp; jump, the jump materialzes
Hack commands:
A-command: @value // set A to value
C-command: dest = comp ; jump // dest = and ;jump
// are optional
Where:
comp = 0 , 1 , -1 , D , A , !D , !A , -D , -A , D+1 ,
A+1 , D-1, A-1 , D+A , D-A , A-D , D&A ,
D|A , M , !M , -M ,M+1, M-1 , D+M , D-M ,
M-D , D&M , D|M
dest = M , D , MD , A , AM , AD , AMD, or null
jump = JGT , JEQ , JGE , JLT , JNE , JLE , JMP, or null
In the command dest = comp; jump, the jump materialzes
if (comp jump 0) is true. For example, in D=D+1,JLT,
we jump if D+1 < 0.
Hack convention:
True is represented by -1
False is represented by 0
12. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 12
if condition {
code block 1
}
else {
code block 2
}
code block 3
High level:
D condition
@IF_FALSE
D;J_NotConditionRelation
code block 1
@END
0;JMP
(IF_FALSE)
code block 2
(END)
code block 3
Hack:
IF logic – Hack style
Hack convention:
True is represented by -1
False is represented by 0
Re-write the condition so
that 0 is on one side and use
the Not of the condition’s
relation.
13. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 13
WHILE logic – Hack style
while condition {
code block 1
}
Code block 2
High level:
(LOOP)
D condition
@END
D;J_NotConditionRelation
code block 1
@LOOP
0;JMP
(END)
code block 2
Hack:
Hack convention:
True is represented by -1
False is represented by 0
Re-write the condition so
that 0 is on one side and use
the Not of the condition’s
relation
14. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 14
Side note (focus on the yellow chip parts only)
ALU
Mux
D
A/M
a-bit
D register
A register
A
MRAM
(selected
register)
ROM
(selected
register)
PC
Instruction
address
input
address
input
In the Hack architecture, the A register
addresses both the RAM and the ROM,
simultaneously. Therefore:
Command pairs like @addr followed by
D=M;someJumpDirective make no sense
Best practice: in well-written Hack
programs, a C-instruction should contain
either a reference to M, or
a jump directive,
but not both.
15. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 15
Complete program example
// Adds 1+...+100.
into i = 1;
into sum = 0;
while (i <= 100){
sum += i;
i++;
}
C language code:
100
END
LOOP
// Adds 1+...+100.
@i // i refers to some RAM location
M=1 // i=1
@sum // sum refers to some RAM location
M=0 // sum=0
(LOOP)
@i
D=M // D = i
@100
D=D-A // D = i - 100
@END
D;JGT // If (i-100) > 0 goto END
@i
D=M // D = i
@sum
M=D+M // sum += i
@i
M=M+1 // i++
@LOOP
0;JMP // Goto LOOP
(END)
@END
0;JMP // Infinite loop
Hack assembly code:
Demo
CPU emulator
Hack assembly convention:
Variables: lower-case
Labels: upper-case
Commands: upper-case
16. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 16
Symbols in Hack assembly programs
Symbols created by Hack programmers and code generators:
Label symbols: Used to label destinations of goto commands. Declared by
the pseudo command (XXX). This directive defines the symbol XXX to
refer to the instruction memory location holding the next command in
the program (within the program, XXX is called “label”)
Variable symbols: Any user-defined symbol xxx appearing in an assembly
program that is not defined elsewhere using the (xxx) directive is
treated as a variable, and is “automatically” assigned a unique RAM
address, starting at RAM address 16
By convention, Hack programmers use lower-case and upper-case letters
for variable names and labels, respectively.
Predefined symbols:
I/O pointers: The symbols SCREEN and KBD are “automatically”
predefined to refer to RAM addresses 16384 and 24576, respectively
(base addresses of the Hack platform’s screen and keyboard memory
maps)
Virtual registers: covered in future lectures.
VM control registers: covered in future lectures.
// Typical symbolic
// Hack code, meaning
// not important
@R0
D=M
@INFINITE_LOOP
D;JLE
@counter
M=D
@SCREEN
D=A
@addr
M=D
(LOOP)
@addr
A=M
M=-1
@addr
D=M
@32
D=D+A
@addr
M=D
@counter
MD=M-1
@LOOP
D;JGT
(INFINITE_LOOP)
@INFINITE_LOOP
0;JMP
Q: Who does all the “automatic” assignments of symbols to RAM addresses?
A: The assembler, which is the program that translates symbolic Hack
programs into binary Hack program. As part of the translation process,
the symbols are resolved to RAM addresses. (more about this in future lectures)
17. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language slide 17
Perspective
Hack is a simple machine language
User friendly syntax: D=D+A instead of ADD D,D,A
Hack is a “½-address machine”: any operation that needs to operate on the
RAM must be specified using two commands: an A-command to address the
RAM, and a subsequent C-command to operate on it
A Macro-language can be easily developed
A Hack assembler is needed and will be discusses and developed later in
the course.