jagomart
digital resources
picture1_Assembly Language Pdf 184305 | Lec08 Hackml 4up


 142x       Filetype PDF       File size 0.46 MB       Source: www.csie.ntu.edu.tw


File: Assembly Language Pdf 184305 | Lec08 Hackml 4up
where we are at machine assembly language human abstract design software thought abstract interface hierarchy chapters 9 12 h l language compiler abstract interface operating sys chapters 10 11 virtual ...

icon picture PDF Filetype PDF | Posted on 01 Feb 2023 | 2 years ago
Partial capture of text on file.
                                                                                                                                                                                                                                      Where we are at:
                                            Machine (Assembly) Language                                                                                                                                                                      Human            Abstract design                                                                             Software
                                                                                                                                                                                                                                            Thought                                    abstract interface                                                hierarchy
                                                                                                                                                                                                                                                               Chapters 9, 12          H.L. Language           Compiler
                                                                                                                                                                                                                                                                                               &                                 abstract interface
                                                                                                                                                                                                                                                                                      Operating Sys.         Chapters 10 - 11
                                                                                                                                                                                                                                                                                                                                      Virtual           VM Translator
                                                                                                                                                                                                                                                                                                                                    Machine                                    abstract interface
                                                                                                                                                                                                                                                                                                                                                        Chapters 7 - 8
                                                                                                                                                                                                                                                                                                                                                                                  Assembly
                                                                                                                                                                                                                                                                                                                                                                                  Language
                                                                                                                                                                                                                                                                                                              Assembler
                                                                                                                                                                                                                                                                                                               Chapter 6
                                                                                                                                                                                                                                                 abstract interface
                                                          Building a Modern Computer From First Principles                                                                                                                                                               Computer
                                                                                                                                                                                                                                                     Machine             Architecture
                                                                                                                                                                                                                                                    Language                                  abstract interface
                                                                                     www.nand2tetris.org                                                                                                                                                                 Chapters  4 - 5                             Gate Logic
                                                                                                                                                                                                                                                                                                 Hardware                                 abstract interface
                                                                                                                                                                                                                                                                                                 Platform             Chapters  1 - 3                             Electrical
                                                                                                                                                                                                                                                                 Hardware                                                                     Chips &             Engineering
                                                                                                                                                                                                                                                                 hierarchy                                                                  Logic Gates                                   Physics
                          Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                                        slide 1                                                 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                                        slide 2
                        Machine language                                                                                                                                                                                              Machine language
                              Abstraction – implementation duality:                                                                                                                                                                        Abstraction – implementation duality:
                               Machine language ( = instruction set) can be viewed as a programmer-                                                                                                                                        Machine language ( = instruction set) can be viewed as a programmer-
                                     oriented abstraction of the hardware platform                                                                                                                                                                oriented abstraction of the hardware platform
                               The hardware platform can be viewed as a physical means for realizing                                                                                                                                       The hardware platform can be viewed as a physical means for realizing 
                                     the machine language abstraction                                                                                                                                                                             the machine language abstraction
                                                                                                                                                                                                                                           Another duality:
                                                                                                                                                                                                                                            Binary version:                                   0001 0001 0010 0011   (machine code)
                                                                                                                                                                                                                                            Symbolic version                                  ADD R1, R2, R3   (assembly)
                          Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                                        slide 3                                                 Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                                        slide 4
                      Machine language                                                                                                                                                                    Lecture plan
                           Abstraction – implementation duality:
                            Machine language ( = instruction set) can be viewed as a programmer-                                                                                                                                            Machine languages at a glance
                                oriented abstraction of the hardware platform
                            The hardware platform can be viewed as a physical means for realizing                                                                                                                                           The Hack machine language:
                                the machine language abstraction
                           Another duality:                                                                                                ALU                                                                                                       Symbolic version
                                                                                                                                     combinational
                            Binary version                                                                                                                                                                                                          Binary version
                            Symbolic version
                                                                                                                                        Memory                                                                                               Perspective
                          Loose definition:                                                                                                state
                           Machine language = an agreed-upon formalism for manipulating                                                                                                                                                    (The assembler will be covered in chapter 6).
                                                                   a memory using a processor and a set of registers
                           Same spirit but different syntax across different hardware platforms.
                       Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 5                                           Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 6
                      Typical machine language commands (3 types)                                                                                                                                         Typical machine language commands (a small sample)
                        ALU operations                                                                                                                                                                        // In what follows R1,R2,R3 are registers, PC is program counter,
                        Memory access operations                                                                                                                                                              // and addr is some value.
                            (addressing mode: how to specify operands)                                                                                                                                         ADD R1,R2,R3     // R1  R2 + R3
                               Immediate addressing, LDA R1, 67 // R1=67                                                                                                                                      ADDI R1,R2,addr  // R1  R2 + addr
                               Direct addressing, LD R1, 67 // R1=M[67]                                                                                                                                       AND R1,R1,R2     // R1  R1 and R2 (bit-wise)
                               Indirect addressing, LDI R1, R2 // R1=M[R2]                                                                                                                                    JMP addr         // PC  addr
                        Flow control operations                                                                                                                                                               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
                       Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 7                                           Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 8
                      The Hack computer                                                                                                                                                                   The Hack computer
                            A 16-bit machine consisting of the following elements:                                                                                                                           The ROM is loaded with a Hack program
                                                                                                                                                                                                             The reset button is pushed
                                                                                                                                                                                                             The program starts running
                                     reset                                                                                           Screen
                                                              Computer
                                                                                                                                 Keyboard
                       Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 9                                           Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 10
                      The Hack computer                                                                                                                                                                   The Hack computer (CPU)
                            A 16-bit machine consisting of the following elements:                                                                                                                               A 16-bit machine consisting of the following elements:
                                                                                                                                                                                                                                                                                ALU output
                                                                                inM
                                                                                                                                                                                                                                                                                               C              C
                                                                                                       writeM                                                                                                                                 C
                                                                                                                                                                                                                                                                                               D        D
                                                   Instruction                                          outM                     Data
                                                     Memory              instruction                                           Memory                                                                                                      decode               C           C
                                                                                              CPU      addressM                                                                                                                                                                                               ALU                 outM
                                                                                                                                                                                                                                                                                                  C
                                                    (ROM32K)                                            pc                    (Memory)                                                                                                                         Mux          A             A                            C
                                                                                                                                                                                                                      instruction                                                               Mux   A/M
                                                                                                                                                                                                                             inM                                                          M
                                                                                                                                                                                                                                                                                                                   C              writeM
                                                                                                                                                                                                                                                                                          A                                       addressM
                                                                                                                                                                                                                           reset                                                                         C
                                                                                                                                                                                                                                                                                          A         PC                             pc
                                                                        reset
                            Both memory chips are 16-bit wide and have 15-bit address space.
                       Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 11                                          Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 12
                      The Hack computer                                                                                                                                                                   The A-instruction
                            A 16-bit machine consisting of the following elements:                                                                                                                                                                    @value          // A  value
                            Data memory:              RAM – an addressable sequence of registers                                                                                                             Where value is either a number or a symbol referring to some number.
                                                                                                                                                                                                             Why A-instruction? 
                            Instruction memory:                 ROM–an addressable sequence of registers                                                                                                         In TOY, we store address in the instruction (fmt #2). But, it is impossible 
                                                                                                                                                                                                                 to pack a 15-bit address into a 16-bit instruction. So, we have the A-
                            Registers:          D,  A, M, where M stands for RAM[A]                                                                                                                              instruction for setting addresses if needed.
                            Processing: ALU, capable of computing various functions                                                                                                                          Example:                           @21
                            Program counter:               PC, holding an address                                                                                                                            Effect:
                            Control: The ROM is loaded with a sequence of 16-bit instructions, one per memory 
                                  location, beginning at address 0.  Fetch-execute cycle: later                                                                                                               Sets the A register to 21
                            Instruction set: Two instructions: A-instruction, C-instruction.                                                                                                                  RAM[21] becomes the selected RAM register M 
                       Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 13                                          Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 14
                      The A-instruction                                                                                                                                                                   The C-instruction
                                                                 @value          // A  value                                                                                                                                                        dest = comp ; jump
                                                                                                                                                                                                             Both dest and jump are optional. 
                                 Used for:                                                     Coding example:                                                                                               First, we compute something.
                                  Entering a constant value                                                                                                                                                 Next, optionally, we can store the result, or use it to jump to somewhere to 
                                       ( A = value)                                               @17    // A = 17                                                                                                 continue the program execution.
                                                                                                  D = A  // D = 17
                                                                                                                                                                                                            comp:
                                 Selecting a RAM location                                        @17    // A = 17                                                                                          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
                                      ( register = RAM[A])                                        D = M  // D = RAM[17]                                                                                                              M,    !M,      -M,      M+1,      M-1, D+M, D-M, M-D, D&M, D|M
                                                                                                  M = -1 // RAM[17]=-1
                                       Selecting a ROM location                                                                                                                                            dest: null, A, D, M, MD, AM, AD, AMD
                                           ( PC = A )                                             @17    // A = 17
                                                                                                  JMP    // fetch the instruction                                                                                                                                                                          Compare to zero. If the 
                                                                                                              // stored in ROM[17]                                                                          jump: null, JGT, JEQ, JLT, JGE, JNE, JLE, JMP                                                  condition holds, jump to 
                                                                                                                                                                                                                                                                                                           ROM[A] 
                       Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 15                                          Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 4: Machine Language                      slide 16
The words contained in this file might help you see if this file matches what you are looking for:

...Where we are at machine assembly language human abstract design software thought interface hierarchy chapters h l compiler operating sys virtual vm translator assembler chapter building a modern computer from first principles architecture www nandtetris org gate logic hardware platform electrical chips engineering gates physics elements of computing systems nisan schocken mit press slide abstraction implementation duality instruction set can be viewed as programmer oriented the physical means for realizing another binary version...

no reviews yet
Please Login to review.