SlideShare une entreprise Scribd logo
1  sur  67
Molecules to Machine Code
James Lawson
Agenda
• Part 1 - Semiconductors
– Electromagnetic theory
• Part 2 – Electrical Primitives
– Diodes, Transistors
• Part 3 – Integrated Circuits
– Logic Gates, Memory and Arithmetic units, CPUs
• Part 4 – Programming
– Machine Code and Assembly Language
Part 1
Semiconductors
Conductors vs Semiconductors
What is the difference?
[discuss]
A non exhaustive list of semiconductors…
• Diamond
• Silicon
• Germanium
• Selenium
• Tellurium
For a more extensive list please refer to: -
http://en.wikipedia.org/wiki/List_of_semiconductor_materials
Atomic composition
• Lets look at the atomic composition of a couple of
these semiconductors in their pure form.
• An even number of
valence electrons (outer
shell electrons)
• 4 valence electrons in
both elements.
Pure Silicon forms a tight lattice…
Getting your semi on…
• A lack of spare electrons in the Silicon lattice
makes it difficult for electrical current to flow.
• Electrical current flows when electrons can skip
along the material.
• This is why semiconductors are not called
conductors – they need a little helping hand.
Lets get doped up…
• Semiconductor ‘Doping’ is a technique where a
trace amount of a second material is added to the
semiconductor to make it less pure.
• By doing so, we can alter the electro-magnetic
properties of the semiconductor.
Lets get doped up…
• Arsenic has 5 valence electrons.
• Adding a trace amount of arsenic to
Silicon can have a nice side effect.
• Lets look at the atomic composition Arsenic.
A Silicon lattice doped with Arsenic: -
Types of doping…
• An excess of electrons in the lattice has now made
the Silicon take on a negative charge (because
electrons are negatively charged).
• This is called N-Type Arsenic doped Silicon.
Types of doping…
• Doping can also be used to provide a shortage of
electrons. Any ideas on what you would use to do
this?
• Doping with Boron (which has only 3 valence
electrons) will result in positively charged Silicon.
This is called P-Type Boron doped Silicon.
Part 2
Electrical Primitives
• So we can create a nice semiconductor with Silicon
by increasing the number of free electrons – this is
great for our mundane circuitry, but what else can
we use it for?
• Lets layer the stuff…
Uses for our doped semiconductor?
Uses for our doped semiconductor?
• In the presented arrangement we have P-Type
Silicon (with electron holes) layered above N-Type
Silicon (with an excess of electrons).
• Lets investigate what happens if we add an
electrical current to this arrangement.
Negative current to N-Type Silicon
• If we connect a negative current to the side with
the N-Type Silicon…
• The incoming electrons will dislodge the electrons
in the Lattice and push them towards the P-Type
silicon to fill the holes.
• Likewise, the lack of electrons on the P side will
cause electrons to be pulled up and out the top of
the Silicon.
+
-
Negative current to N-Type Silicon
Electricity will flow!
+
-
Negative current to P-Type Silicon
• What happens if we reverse the connections?
• The lack of electrons at the will pull the N-Type
spare electrons down.
• The excess electrons at the P-Type silicon will
cause the holes in the lattice to be ‘pulled’
upwards.
-
+
Negative current to P-Type Silicon
+
-
Electricity will NOT flow!
The Diode!
• We’ve just invented a Diode…
• A component that allows current to flow in
one direction only.
+
-
• Lets take a look if at what happens if we layer this
stuff some more!
More uses for our doped semiconductor?
More uses for our doped semiconductor?
• Here we have essentially created a barrier -
you can think of this as two back-to-back
diodes.
• It’s difficult to see how we could get current
to flow either way.
• However, all is not lost…
More uses for our doped semiconductor?
• If we apply a small amount of current to the N-
Type Silicon in the middle then we will end up
with a base flow.
• The base flow will take the charge collecting at
one end and drag through the layers.
• The overall current will be emitted at the other
end.
More uses for our doped semiconductor?
This stuff is pretty mental to visualise so its probably a good time
to show a simplified model using some water…
• We’ve just invented a P-N-P Transistor…
• An electrical component that allows current to flow in one
direction that can be switched on or off.
The Transistor!
Part 3
Integrated Circuits
Boolean Logic
• The advent of the transistor and digital electronics
was revolutionary.
• Before we investigate why – lets have a quick
refresher on Boolean logic…
AND
A B Q
0 0 0
0 1 0
1 0 0
1 1 1
Boolean Logic
OR
A B Q
0 0 0
0 1 1
1 0 1
1 1 1
Boolean logic…
NOR
A B Q
0 0 1
0 1 0
1 0 0
1 1 0
Boolean logic…
XOR
A B Q
0 0 0
0 1 1
1 0 1
1 1 0
Boolean logic…
NOT
A Q
0 1
1 0
Boolean logic…
NAND
A B Q
0 0 1
0 1 1
1 0 1
1 1 0
Boolean logic…
NAND Logic
• NAND gates can be used to create all of the other
Boolean operators…
A B Q
0 0 1
0 1 1
1 0 1
1 1 0
A Q
0 1
1 0
NAND Logic
• Now that we have used a NAND to make a NOT,
can make this…
A B Q
0 0 0
0 1 0
1 0 0
1 1 1
NAND Logic
• …and so on. Feel free to carry this on in your own
time and have a go at making the other logic gates.
A B Q
0 0 0
0 1 0
1 0 0
1 1 1
NAND Logic
• Why focus on the NAND operator?
• Because it’s relatively easy to make from a couple
of transistors!
A B Q
- - +
- + +
+ - +
+ + -
NAND Logic
• So… by using Silicon doped with Arsenic and Boron
we can now do exactly what Texas Instruments do
and create one of these bad boys…
• A 14 pin integrated circuit with 4 NAND
gates.
• 2 pins reserved for power (pins 7 and 14)
• Implemented internally using 8 NPN
transistors.
What can we build with a NAND gate?
• This pairing of NAND gates is
called an RS-Flipflop.
• Sending a brief pulse along S will
SET the value of Q to 1. Sending
a brief pulse along R will RESET
the value of Q to 0.
S R Q
0 0 Q
0 1 0
1 0 1
What can we build with a NAND gate?
• That’s correct - we’ve now just built
ourselves a 1 bit memory.
• If you stick 64 of these together on
a single CPU dye and you have a
single 64 bit register – that’s 128
transistors.
S R Q
0 0 Q
0 1 0
1 0 1
What else can we build with a NAND gate?
• Actually – lots of things!
What else can we build with a NAND gate?
• Lets imagine we’re going to take on Intel and
building a 1 bit CPU – we certainly need to have
logic inside the CPU to ADD a couple of 1 bit
numbers…
• What would the truth table look like for that?
What else can we build with a NAND gate?
A B R C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
• Okay - It’s not rocket science. We have a result and
a carry bit (the overflow flag).
• How could we achieve this using NAND logic?
What else can we build with a NAND gate?
A B R C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
• R looks like a simple XOR of A and B…
What else can we build with a NAND gate?
A B R C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
• R looks like a simple XOR of A and B…
• C looks like a simple AND of A and B…
What else can we build with a NAND gate?
A B R C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
• Combined…
What else can we build with a NAND gate?
A B R C
0 0 0 0
0 1 1 0
1 0 1 0
1 1 0 1
• And converted to NAND logic…
What else can we build with a NAND gate?
• With a minor tweak we can change this to include a carry in too!
• Not bad – a 1 bit adder with carryover (overflow) using only 18
transistors.
What else can we build with a NAND gate?
• Yikes - We could chain this stuff together to make a larger
adder!
Putting it all together…
• So we have created a 4 bit adder.
• And lets pretend we followed the same process to create some
4 bit subtraction logic.
• And we have created three 4 bit registers using 12 RS-Flipflops.
• And we have used a single RS-Flipflop for a carryover register.
Putting it all together…
Part 4
Programming
The instruction set…
Op4 Op3 Op2 Op1 D0 D1 D2 D3
0 0 0 1 Set the value of Register A to D0-D3
0 0 1 0 Set the value of Register B to D0-D3
0 0 1 1 Add Register A to Register B and store the result in
Register R.
Will set Register C if an overflow occurs.
0 0 0 0 Subtract Register B from Register A and store the result in
Register R.
Will set Register C if an underflow occurs.
Programming the machine
The following 3 bytes of machine code show how a
CPU would add two numbers together: -
1A 26 30
0001 1010 1A Sets Register A to 10
0010 0110 26 Sets Register B to 6
0011 0000 30 Add Register A to Register B
Assembly language is nothing special
Is simply a set of mnemonics to make the
hexadecimal more memorable: -
LDA A 0001 1010 1A Sets Register A to 10
LDB 6 0010 0110 26 Sets Register B to 6
ADD 0011 0000 30 Add Register A to Register B
A modern CPU
• The program counter (PC)
– A register that contains the memory address for the
next machine code instruction to be executed.
– A number of instructions exist to alter the PC register:
JMP, JNE, JEQ, etc.
A modern CPU
• The stack pointer (SP)
02 LDA 3
03 PUSH PC
04 JMP 1A
.
.
.
1A LDB 4
1B POP PC
Questions?

Contenu connexe

En vedette

Attracting Team Members and Investors
Attracting Team Members and InvestorsAttracting Team Members and Investors
Attracting Team Members and InvestorsPlugginto
 
AMAL RESUME 2015
AMAL RESUME 2015AMAL RESUME 2015
AMAL RESUME 2015Amal Makki
 
Lighting Tech Summit 2016 - Khaled M. Abdelgawad - Lighting Design in Landsca...
Lighting Tech Summit 2016 - Khaled M. Abdelgawad - Lighting Design in Landsca...Lighting Tech Summit 2016 - Khaled M. Abdelgawad - Lighting Design in Landsca...
Lighting Tech Summit 2016 - Khaled M. Abdelgawad - Lighting Design in Landsca...Khaled M. Abdel-Gawad
 
Intern Report on System Analysis & Design (NGO in Bangladesh)
Intern Report on System Analysis & Design (NGO in Bangladesh)Intern Report on System Analysis & Design (NGO in Bangladesh)
Intern Report on System Analysis & Design (NGO in Bangladesh)Sadia Tasnim
 

En vedette (6)

Attracting Team Members and Investors
Attracting Team Members and InvestorsAttracting Team Members and Investors
Attracting Team Members and Investors
 
LOlsenPortfolio
LOlsenPortfolioLOlsenPortfolio
LOlsenPortfolio
 
AMAL RESUME 2015
AMAL RESUME 2015AMAL RESUME 2015
AMAL RESUME 2015
 
LANDSCAPE LIGHTING
LANDSCAPE LIGHTING LANDSCAPE LIGHTING
LANDSCAPE LIGHTING
 
Lighting Tech Summit 2016 - Khaled M. Abdelgawad - Lighting Design in Landsca...
Lighting Tech Summit 2016 - Khaled M. Abdelgawad - Lighting Design in Landsca...Lighting Tech Summit 2016 - Khaled M. Abdelgawad - Lighting Design in Landsca...
Lighting Tech Summit 2016 - Khaled M. Abdelgawad - Lighting Design in Landsca...
 
Intern Report on System Analysis & Design (NGO in Bangladesh)
Intern Report on System Analysis & Design (NGO in Bangladesh)Intern Report on System Analysis & Design (NGO in Bangladesh)
Intern Report on System Analysis & Design (NGO in Bangladesh)
 

Similaire à Molecules to Machine Code

Computer design and architecture with simple cpu
Computer design and architecture with simple cpuComputer design and architecture with simple cpu
Computer design and architecture with simple cpuNaohiko Shimizu
 
basic electronics
 basic   electronics basic   electronics
basic electronicsATTO RATHORE
 
A few fundamental concepts in digital electronics
A few fundamental concepts in digital electronicsA few fundamental concepts in digital electronics
A few fundamental concepts in digital electronicsJoy Prabhakaran
 
Digital clock workshop
Digital clock workshopDigital clock workshop
Digital clock workshopKedarv
 
Quantum Computers PART 4 Quantum Computer’sHardware by Lili Saghafi
Quantum Computers PART 4 Quantum Computer’sHardware by Lili SaghafiQuantum Computers PART 4 Quantum Computer’sHardware by Lili Saghafi
Quantum Computers PART 4 Quantum Computer’sHardware by Lili SaghafiProfessor Lili Saghafi
 
Logic gates and circuits
Logic gates and circuitsLogic gates and circuits
Logic gates and circuitsAswiniT3
 
04 Unit IV DTE.pptx
04 Unit IV DTE.pptx04 Unit IV DTE.pptx
04 Unit IV DTE.pptxHarsheye
 
Circuitrix@Pragyan 2015 NITT
Circuitrix@Pragyan 2015 NITTCircuitrix@Pragyan 2015 NITT
Circuitrix@Pragyan 2015 NITTSrivignessh Pss
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC MicrocontrollerDivya Bansal
 
Silicon to software share
Silicon to software shareSilicon to software share
Silicon to software shareNarendra Patel
 
Digital ic ajal crc
Digital ic ajal crcDigital ic ajal crc
Digital ic ajal crcAJAL A J
 
integrated circutits -324567654-12-345-.pptx
integrated circutits -324567654-12-345-.pptxintegrated circutits -324567654-12-345-.pptx
integrated circutits -324567654-12-345-.pptxFermanIbrahim
 
DLD(Good LAB)-5-10.pdf
DLD(Good LAB)-5-10.pdfDLD(Good LAB)-5-10.pdf
DLD(Good LAB)-5-10.pdfGodfreyD2
 

Similaire à Molecules to Machine Code (20)

Computer design and architecture with simple cpu
Computer design and architecture with simple cpuComputer design and architecture with simple cpu
Computer design and architecture with simple cpu
 
basic electronics
 basic   electronics basic   electronics
basic electronics
 
A few fundamental concepts in digital electronics
A few fundamental concepts in digital electronicsA few fundamental concepts in digital electronics
A few fundamental concepts in digital electronics
 
pedals.pdf
pedals.pdfpedals.pdf
pedals.pdf
 
Making a peaking filter by Julio Marqués
Making a peaking filter by Julio MarquésMaking a peaking filter by Julio Marqués
Making a peaking filter by Julio Marqués
 
Chapter 3.pptx
Chapter 3.pptxChapter 3.pptx
Chapter 3.pptx
 
Digital clock workshop
Digital clock workshopDigital clock workshop
Digital clock workshop
 
Quantum Computers PART 4 Quantum Computer’sHardware by Lili Saghafi
Quantum Computers PART 4 Quantum Computer’sHardware by Lili SaghafiQuantum Computers PART 4 Quantum Computer’sHardware by Lili Saghafi
Quantum Computers PART 4 Quantum Computer’sHardware by Lili Saghafi
 
Logic gates and circuits
Logic gates and circuitsLogic gates and circuits
Logic gates and circuits
 
04 Unit IV DTE.pptx
04 Unit IV DTE.pptx04 Unit IV DTE.pptx
04 Unit IV DTE.pptx
 
Circuitrix@Pragyan 2015 NITT
Circuitrix@Pragyan 2015 NITTCircuitrix@Pragyan 2015 NITT
Circuitrix@Pragyan 2015 NITT
 
PIC Microcontroller
PIC MicrocontrollerPIC Microcontroller
PIC Microcontroller
 
Silicon to software share
Silicon to software shareSilicon to software share
Silicon to software share
 
Digital ic ajal crc
Digital ic ajal crcDigital ic ajal crc
Digital ic ajal crc
 
Vlsi ppt priyanka
Vlsi ppt priyankaVlsi ppt priyanka
Vlsi ppt priyanka
 
Technotoy
TechnotoyTechnotoy
Technotoy
 
integrated circutits -324567654-12-345-.pptx
integrated circutits -324567654-12-345-.pptxintegrated circutits -324567654-12-345-.pptx
integrated circutits -324567654-12-345-.pptx
 
kbaps_VLSI
kbaps_VLSIkbaps_VLSI
kbaps_VLSI
 
Solid State Memory Technology
Solid State Memory TechnologySolid State Memory Technology
Solid State Memory Technology
 
DLD(Good LAB)-5-10.pdf
DLD(Good LAB)-5-10.pdfDLD(Good LAB)-5-10.pdf
DLD(Good LAB)-5-10.pdf
 

Molecules to Machine Code

  • 1. Molecules to Machine Code James Lawson
  • 2. Agenda • Part 1 - Semiconductors – Electromagnetic theory • Part 2 – Electrical Primitives – Diodes, Transistors • Part 3 – Integrated Circuits – Logic Gates, Memory and Arithmetic units, CPUs • Part 4 – Programming – Machine Code and Assembly Language
  • 4. Conductors vs Semiconductors What is the difference? [discuss]
  • 5. A non exhaustive list of semiconductors… • Diamond • Silicon • Germanium • Selenium • Tellurium For a more extensive list please refer to: - http://en.wikipedia.org/wiki/List_of_semiconductor_materials
  • 6. Atomic composition • Lets look at the atomic composition of a couple of these semiconductors in their pure form. • An even number of valence electrons (outer shell electrons) • 4 valence electrons in both elements.
  • 7. Pure Silicon forms a tight lattice…
  • 8. Getting your semi on… • A lack of spare electrons in the Silicon lattice makes it difficult for electrical current to flow. • Electrical current flows when electrons can skip along the material. • This is why semiconductors are not called conductors – they need a little helping hand.
  • 9. Lets get doped up… • Semiconductor ‘Doping’ is a technique where a trace amount of a second material is added to the semiconductor to make it less pure. • By doing so, we can alter the electro-magnetic properties of the semiconductor.
  • 10. Lets get doped up… • Arsenic has 5 valence electrons. • Adding a trace amount of arsenic to Silicon can have a nice side effect. • Lets look at the atomic composition Arsenic.
  • 11. A Silicon lattice doped with Arsenic: -
  • 12. Types of doping… • An excess of electrons in the lattice has now made the Silicon take on a negative charge (because electrons are negatively charged). • This is called N-Type Arsenic doped Silicon.
  • 13. Types of doping… • Doping can also be used to provide a shortage of electrons. Any ideas on what you would use to do this? • Doping with Boron (which has only 3 valence electrons) will result in positively charged Silicon. This is called P-Type Boron doped Silicon.
  • 15. • So we can create a nice semiconductor with Silicon by increasing the number of free electrons – this is great for our mundane circuitry, but what else can we use it for? • Lets layer the stuff… Uses for our doped semiconductor?
  • 16. Uses for our doped semiconductor? • In the presented arrangement we have P-Type Silicon (with electron holes) layered above N-Type Silicon (with an excess of electrons). • Lets investigate what happens if we add an electrical current to this arrangement.
  • 17. Negative current to N-Type Silicon • If we connect a negative current to the side with the N-Type Silicon… • The incoming electrons will dislodge the electrons in the Lattice and push them towards the P-Type silicon to fill the holes. • Likewise, the lack of electrons on the P side will cause electrons to be pulled up and out the top of the Silicon. + -
  • 18. Negative current to N-Type Silicon Electricity will flow! + -
  • 19. Negative current to P-Type Silicon • What happens if we reverse the connections? • The lack of electrons at the will pull the N-Type spare electrons down. • The excess electrons at the P-Type silicon will cause the holes in the lattice to be ‘pulled’ upwards. - +
  • 20. Negative current to P-Type Silicon + - Electricity will NOT flow!
  • 21. The Diode! • We’ve just invented a Diode… • A component that allows current to flow in one direction only. + -
  • 22. • Lets take a look if at what happens if we layer this stuff some more! More uses for our doped semiconductor?
  • 23. More uses for our doped semiconductor? • Here we have essentially created a barrier - you can think of this as two back-to-back diodes. • It’s difficult to see how we could get current to flow either way. • However, all is not lost…
  • 24. More uses for our doped semiconductor? • If we apply a small amount of current to the N- Type Silicon in the middle then we will end up with a base flow. • The base flow will take the charge collecting at one end and drag through the layers. • The overall current will be emitted at the other end.
  • 25. More uses for our doped semiconductor? This stuff is pretty mental to visualise so its probably a good time to show a simplified model using some water…
  • 26. • We’ve just invented a P-N-P Transistor… • An electrical component that allows current to flow in one direction that can be switched on or off. The Transistor!
  • 28. Boolean Logic • The advent of the transistor and digital electronics was revolutionary. • Before we investigate why – lets have a quick refresher on Boolean logic…
  • 29. AND A B Q 0 0 0 0 1 0 1 0 0 1 1 1 Boolean Logic
  • 30. OR A B Q 0 0 0 0 1 1 1 0 1 1 1 1 Boolean logic…
  • 31. NOR A B Q 0 0 1 0 1 0 1 0 0 1 1 0 Boolean logic…
  • 32. XOR A B Q 0 0 0 0 1 1 1 0 1 1 1 0 Boolean logic…
  • 33. NOT A Q 0 1 1 0 Boolean logic…
  • 34. NAND A B Q 0 0 1 0 1 1 1 0 1 1 1 0 Boolean logic…
  • 35. NAND Logic • NAND gates can be used to create all of the other Boolean operators… A B Q 0 0 1 0 1 1 1 0 1 1 1 0 A Q 0 1 1 0
  • 36. NAND Logic • Now that we have used a NAND to make a NOT, can make this… A B Q 0 0 0 0 1 0 1 0 0 1 1 1
  • 37. NAND Logic • …and so on. Feel free to carry this on in your own time and have a go at making the other logic gates. A B Q 0 0 0 0 1 0 1 0 0 1 1 1
  • 38. NAND Logic • Why focus on the NAND operator? • Because it’s relatively easy to make from a couple of transistors! A B Q - - + - + + + - + + + -
  • 39. NAND Logic • So… by using Silicon doped with Arsenic and Boron we can now do exactly what Texas Instruments do and create one of these bad boys… • A 14 pin integrated circuit with 4 NAND gates. • 2 pins reserved for power (pins 7 and 14) • Implemented internally using 8 NPN transistors.
  • 40. What can we build with a NAND gate? • This pairing of NAND gates is called an RS-Flipflop. • Sending a brief pulse along S will SET the value of Q to 1. Sending a brief pulse along R will RESET the value of Q to 0. S R Q 0 0 Q 0 1 0 1 0 1
  • 41. What can we build with a NAND gate? • That’s correct - we’ve now just built ourselves a 1 bit memory. • If you stick 64 of these together on a single CPU dye and you have a single 64 bit register – that’s 128 transistors. S R Q 0 0 Q 0 1 0 1 0 1
  • 42. What else can we build with a NAND gate? • Actually – lots of things!
  • 43. What else can we build with a NAND gate? • Lets imagine we’re going to take on Intel and building a 1 bit CPU – we certainly need to have logic inside the CPU to ADD a couple of 1 bit numbers… • What would the truth table look like for that?
  • 44. What else can we build with a NAND gate? A B R C 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 • Okay - It’s not rocket science. We have a result and a carry bit (the overflow flag). • How could we achieve this using NAND logic?
  • 45. What else can we build with a NAND gate? A B R C 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 • R looks like a simple XOR of A and B…
  • 46. What else can we build with a NAND gate? A B R C 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 • R looks like a simple XOR of A and B… • C looks like a simple AND of A and B…
  • 47. What else can we build with a NAND gate? A B R C 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 • Combined…
  • 48. What else can we build with a NAND gate? A B R C 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 • And converted to NAND logic…
  • 49. What else can we build with a NAND gate? • With a minor tweak we can change this to include a carry in too! • Not bad – a 1 bit adder with carryover (overflow) using only 18 transistors.
  • 50. What else can we build with a NAND gate? • Yikes - We could chain this stuff together to make a larger adder!
  • 51. Putting it all together… • So we have created a 4 bit adder. • And lets pretend we followed the same process to create some 4 bit subtraction logic. • And we have created three 4 bit registers using 12 RS-Flipflops. • And we have used a single RS-Flipflop for a carryover register.
  • 52. Putting it all together…
  • 53.
  • 54.
  • 55.
  • 56.
  • 57.
  • 58.
  • 59.
  • 60.
  • 62. The instruction set… Op4 Op3 Op2 Op1 D0 D1 D2 D3 0 0 0 1 Set the value of Register A to D0-D3 0 0 1 0 Set the value of Register B to D0-D3 0 0 1 1 Add Register A to Register B and store the result in Register R. Will set Register C if an overflow occurs. 0 0 0 0 Subtract Register B from Register A and store the result in Register R. Will set Register C if an underflow occurs.
  • 63. Programming the machine The following 3 bytes of machine code show how a CPU would add two numbers together: - 1A 26 30 0001 1010 1A Sets Register A to 10 0010 0110 26 Sets Register B to 6 0011 0000 30 Add Register A to Register B
  • 64. Assembly language is nothing special Is simply a set of mnemonics to make the hexadecimal more memorable: - LDA A 0001 1010 1A Sets Register A to 10 LDB 6 0010 0110 26 Sets Register B to 6 ADD 0011 0000 30 Add Register A to Register B
  • 65. A modern CPU • The program counter (PC) – A register that contains the memory address for the next machine code instruction to be executed. – A number of instructions exist to alter the PC register: JMP, JNE, JEQ, etc.
  • 66. A modern CPU • The stack pointer (SP) 02 LDA 3 03 PUSH PC 04 JMP 1A . . . 1A LDB 4 1B POP PC