SlideShare ist ein Scribd-Unternehmen logo
1 von 17
LET’S MAKE UP A LANGUAGE

               000000
  op-code                               operand         Control Unit

                                                     Instruction Pointer
 INSTRUCTION          EXPLANATION
   000XXX      Load the value located at memory
               location XXX into the register

   001XXX      Put the value of register at memory          ALU
               location XXX

   010XXX      Add XXX to the value of register
                                                          Register
   011XXX      Subract XXX from the value of
               register

    111XXX     End program




                                                                           1
INSTR              EXPL



START PROGRAM
                      000XXX   Load XXX into REG


                      001XXX   Put REG into location XXX


                      010XXX   Add XXX to REG


                      011XXX   Subtract XXX from REG


                      111XXX   End program




ADDR   VALUE
 000   000110
 001   010001
                000
 010   001111
 011   111000
 100
 101
 110   000001
 111




                                                           2
INSTR              EXPL



FETCH INSTRUCTION
                             000XXX   Load XXX into REG


                             001XXX   Put REG into location XXX


                             010XXX   Add XXX to REG


                             011XXX   Subtract XXX from REG


                             111XXX   End program




ADDR   VALUE
 000   000110       000110
 001   010001
                     000
 010   001111
 011   111000
 100
 101
 110   000001
 111




                                                                  3
INSTR              EXPL



DECODE
                          000XXX   Load XXX into REG


                          001XXX   Put REG into location XXX


                          010XXX   Add XXX to REG


                          011XXX   Subtract XXX from REG


                          111XXX   End program




ADDR   VALUE             Load value
 000   000110   000110   located at
                         memory location
 001   010001
                         110 into register
                 000
 010   001111
 011   111000
 100
 101
 110   000001
 111




                                                               4
INSTR              EXPL



EXECUTE
                                000XXX   Load XXX into REG


                                001XXX   Put REG into location XXX


                                010XXX   Add XXX to REG


                                011XXX   Subtract XXX from REG


                                111XXX   End program




ADDR   VALUE
 000   000110      000110
 001   010001
                    000
 010   001111
 011   111000
 100
                Load from 110
 101
 110   000001      000001
 111




                                                                     5
INSTR             EXPL



INCREMENT IP
                          000XXX   Load XXX into REG


                          001XXX   Put REG into location XXX


                          010XXX   Add XXX to REG


                          011XXX   Subtract XXX from REG


                          111XXX   End program




ADDR   VALUE
 000   000110
 001   010001            Increment
                 001     instruction
 010   001111
                         pointer
 011   111000
 100
 101
 110   000001   000001
 111




                                                               6
INSTR              EXPL



FETCH INSTRUCTION
                             000XXX   Load XXX into REG


                             001XXX   Put REG into location XXX


                             010XXX   Add XXX to REG


                             011XXX   Subtract XXX from REG


                             111XXX   End program




ADDR   VALUE
 000   000110       010001
 001   010001
                     001
 010   001111
 011   111000
 100
 101
 110   000001       000001
 111




                                                                  7
INSTR             EXPL



DECODE
                         000XXX   Load XXX into REG


                         001XXX   Put REG into location XXX


                         010XXX   Add XXX to REG


                         011XXX   Subtract XXX from REG


                         111XXX   End program




ADDR   VALUE
 000   000110   010001   Add 001 to the
                         value of
 001   010001
                         register
                 001
 010   001111
 011   111000
 100
 101
 110   000001   000001
 111




                                                              8
INSTR              EXPL



EXECUTE
                                      000XXX   Load XXX into REG


                                      001XXX   Put REG into location XXX


                                      010XXX   Add XXX to REG


                                      011XXX   Subtract XXX from REG


                                      111XXX   End program




ADDR   VALUE
 000   000110        010001
 001   010001
                       001
 010   001111
 011   111000
 100
                Add 001 to register
 101
 110   000001         000010
 111




                                                                           9
INSTR             EXPL



INCREMENT IP
                          000XXX   Load XXX into REG


                          001XXX   Put REG into location XXX


                          010XXX   Add XXX to REG


                          011XXX   Subtract XXX from REG


                          111XXX   End program




ADDR   VALUE
 000   000110
 001   010001            Increment
                 010     instruction
 010   001111
                         pointer
 011   111000
 100
 101
 110   000001   000010
 111




                                                           10
INSTR              EXPL



FETCH INSTRUCTION
                             000XXX   Load XXX into REG


                             001XXX   Put REG into location XXX


                             010XXX   Add XXX to REG


                             011XXX   Subtract XXX from REG


                             111XXX   End program




ADDR   VALUE
 000   000110       001111
 001   010001
                     010
 010   001111
 011   111000
 100
 101
 110   000001       000010
 111




                                                              11
INSTR              EXPL



DECODE
                         000XXX   Load XXX into REG


                         001XXX   Put REG into location XXX


                         010XXX   Add XXX to REG


                         011XXX   Subtract XXX from REG


                         111XXX   End program




ADDR   VALUE
                         Put value of
 000   000110   001111   register at
 001   010001            memory
                 010     location 111
 010   001111
 011   111000
 100
 101
 110   000001   000010
 111




                                                          12
INSTR              EXPL



DECODE
                                           000XXX   Load XXX into REG


                                           001XXX   Put REG into location XXX


                                           010XXX   Add XXX to REG


                                           011XXX   Subtract XXX from REG


                                           111XXX   End program




ADDR   VALUE
 000   000110           001111
 001   010001
                         010
 010   001111
 011   111000
 100            Put value of register at
 101                     111
 110   000001           000010
 111   000010




                                                                            13
INSTR             EXPL



INCREMENT IP
                          000XXX   Load XXX into REG


                          001XXX   Put REG into location XXX


                          010XXX   Add XXX to REG


                          011XXX   Subtract XXX from REG


                          111XXX   End program




ADDR   VALUE
 000   000110
 001   010001            Increment
                 011     instruction
 010   001111
                         pointer
 011   111000
 100
 101
 110   000001   000010
 111   000010




                                                           14
INSTR              EXPL



FETCH INSTRUCTION
                                                   000XXX   Load XXX into REG


                                                   001XXX   Put REG into location XXX


                                                   010XXX   Add XXX to REG


                                                   011XXX   Subtract XXX from REG


                                                   111XXX   End program




     ADDR        VALUE
      000        000110                   111000
      001        010001
                                           011
      010         001111
      011         111000
      100
      101
      110        000001                   000010
       111       000010




Chapter 1: Computers and Digital Basics                                                 15
INSTR              EXPL



DECODE
                                                   000XXX   Load XXX into REG


                                                   001XXX   Put REG into location XXX


                                                   010XXX   Add XXX to REG


                                                   011XXX   Subtract XXX from REG


                                                   111XXX   End program




     ADDR        VALUE
      000        000110                   111000   End Program
      001        010001
                                           011
      010         001111
      011         111000
      100
      101
      110        000001                   000010
       111       000010




Chapter 1: Computers and Digital Basics                                                 16
INSTR             EXPL



INCREMENT IP
                                                      000XXX   Load XXX into REG


                                                      001XXX   Put REG into location XXX


                                                      010XXX   Add XXX to REG


                                                      011XXX   Subtract XXX from REG


                                                      111XXX   End program




ADDR   VALUE
 000   000110
 001   010001      What would happen if the last instruction
 010   001111      would write to 011 instead of 111?
 011   111000
 100
 101
 110   000001   What would I set the instruction pointer to
                110 instead to 000 at the beginning of the
 111   000010
                exercise?




                                                                                       17

Weitere ähnliche Inhalte

Andere mochten auch

Functions in Objective-C and C Programming
Functions in Objective-C and C ProgrammingFunctions in Objective-C and C Programming
Functions in Objective-C and C ProgrammingPaul Solt
 
Introduction to Linux Exploit Development
Introduction to Linux Exploit DevelopmentIntroduction to Linux Exploit Development
Introduction to Linux Exploit Developmentjohndegruyter
 
Exploit techniques and mitigation
Exploit techniques and mitigationExploit techniques and mitigation
Exploit techniques and mitigationYaniv Shani
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in CUri Dekel
 
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming BasicsReversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basicssecurityxploded
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploitshughpearse
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerPriyank Kapadia
 
Advanced exploit development
Advanced exploit developmentAdvanced exploit development
Advanced exploit developmentDan H
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
 
Flags
FlagsFlags
FlagsCME
 
How Functions Work
How Functions WorkHow Functions Work
How Functions WorkSaumil Shah
 
Introduction to 8086 microprocessor
Introduction to 8086 microprocessorIntroduction to 8086 microprocessor
Introduction to 8086 microprocessorShreyans Pathak
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutineAshim Saha
 
Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)Olve Maudal
 
Sigreturn Oriented Programming
Sigreturn Oriented ProgrammingSigreturn Oriented Programming
Sigreturn Oriented ProgrammingAngel Boy
 
How to Configure QinQ?
How to Configure QinQ?How to Configure QinQ?
How to Configure QinQ?Huanetwork
 

Andere mochten auch (20)

Functions in Objective-C and C Programming
Functions in Objective-C and C ProgrammingFunctions in Objective-C and C Programming
Functions in Objective-C and C Programming
 
Introduction to Linux Exploit Development
Introduction to Linux Exploit DevelopmentIntroduction to Linux Exploit Development
Introduction to Linux Exploit Development
 
Exploit techniques and mitigation
Exploit techniques and mitigationExploit techniques and mitigation
Exploit techniques and mitigation
 
Introduction to pointers and memory management in C
Introduction to pointers and memory management in CIntroduction to pointers and memory management in C
Introduction to pointers and memory management in C
 
Addressing
Addressing Addressing
Addressing
 
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming BasicsReversing & Malware Analysis Training Part 4 - Assembly Programming Basics
Reversing & Malware Analysis Training Part 4 - Assembly Programming Basics
 
Low Level Exploits
Low Level ExploitsLow Level Exploits
Low Level Exploits
 
Debugging Applications with GNU Debugger
Debugging Applications with GNU DebuggerDebugging Applications with GNU Debugger
Debugging Applications with GNU Debugger
 
The Stack Frame
The Stack FrameThe Stack Frame
The Stack Frame
 
Virtual Machine Constructions for Dummies
Virtual Machine Constructions for DummiesVirtual Machine Constructions for Dummies
Virtual Machine Constructions for Dummies
 
Advanced exploit development
Advanced exploit developmentAdvanced exploit development
Advanced exploit development
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
Flags
FlagsFlags
Flags
 
How Functions Work
How Functions WorkHow Functions Work
How Functions Work
 
Introduction to 8086 microprocessor
Introduction to 8086 microprocessorIntroduction to 8086 microprocessor
Introduction to 8086 microprocessor
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
Insecure coding in C (and C++)
Insecure coding in C (and C++)Insecure coding in C (and C++)
Insecure coding in C (and C++)
 
Sigreturn Oriented Programming
Sigreturn Oriented ProgrammingSigreturn Oriented Programming
Sigreturn Oriented Programming
 
How to Configure QinQ?
How to Configure QinQ?How to Configure QinQ?
How to Configure QinQ?
 
Ctf hello,world!
Ctf hello,world! Ctf hello,world!
Ctf hello,world!
 

Cpu cycle

  • 1. LET’S MAKE UP A LANGUAGE 000000 op-code operand Control Unit Instruction Pointer INSTRUCTION EXPLANATION 000XXX Load the value located at memory location XXX into the register 001XXX Put the value of register at memory ALU location XXX 010XXX Add XXX to the value of register Register 011XXX Subract XXX from the value of register 111XXX End program 1
  • 2. INSTR EXPL START PROGRAM 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 001 010001 000 010 001111 011 111000 100 101 110 000001 111 2
  • 3. INSTR EXPL FETCH INSTRUCTION 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 000110 001 010001 000 010 001111 011 111000 100 101 110 000001 111 3
  • 4. INSTR EXPL DECODE 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE Load value 000 000110 000110 located at memory location 001 010001 110 into register 000 010 001111 011 111000 100 101 110 000001 111 4
  • 5. INSTR EXPL EXECUTE 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 000110 001 010001 000 010 001111 011 111000 100 Load from 110 101 110 000001 000001 111 5
  • 6. INSTR EXPL INCREMENT IP 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 001 010001 Increment 001 instruction 010 001111 pointer 011 111000 100 101 110 000001 000001 111 6
  • 7. INSTR EXPL FETCH INSTRUCTION 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 010001 001 010001 001 010 001111 011 111000 100 101 110 000001 000001 111 7
  • 8. INSTR EXPL DECODE 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 010001 Add 001 to the value of 001 010001 register 001 010 001111 011 111000 100 101 110 000001 000001 111 8
  • 9. INSTR EXPL EXECUTE 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 010001 001 010001 001 010 001111 011 111000 100 Add 001 to register 101 110 000001 000010 111 9
  • 10. INSTR EXPL INCREMENT IP 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 001 010001 Increment 010 instruction 010 001111 pointer 011 111000 100 101 110 000001 000010 111 10
  • 11. INSTR EXPL FETCH INSTRUCTION 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 001111 001 010001 010 010 001111 011 111000 100 101 110 000001 000010 111 11
  • 12. INSTR EXPL DECODE 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE Put value of 000 000110 001111 register at 001 010001 memory 010 location 111 010 001111 011 111000 100 101 110 000001 000010 111 12
  • 13. INSTR EXPL DECODE 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 001111 001 010001 010 010 001111 011 111000 100 Put value of register at 101 111 110 000001 000010 111 000010 13
  • 14. INSTR EXPL INCREMENT IP 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 001 010001 Increment 011 instruction 010 001111 pointer 011 111000 100 101 110 000001 000010 111 000010 14
  • 15. INSTR EXPL FETCH INSTRUCTION 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 111000 001 010001 011 010 001111 011 111000 100 101 110 000001 000010 111 000010 Chapter 1: Computers and Digital Basics 15
  • 16. INSTR EXPL DECODE 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 111000 End Program 001 010001 011 010 001111 011 111000 100 101 110 000001 000010 111 000010 Chapter 1: Computers and Digital Basics 16
  • 17. INSTR EXPL INCREMENT IP 000XXX Load XXX into REG 001XXX Put REG into location XXX 010XXX Add XXX to REG 011XXX Subtract XXX from REG 111XXX End program ADDR VALUE 000 000110 001 010001 What would happen if the last instruction 010 001111 would write to 011 instead of 111? 011 111000 100 101 110 000001 What would I set the instruction pointer to 110 instead to 000 at the beginning of the 111 000010 exercise? 17