CSI 1101 Lab - PowerPoint PPT Presentation

1 / 27
About This Presentation
Title:

CSI 1101 Lab

Description:

Exercises. a) Draw a circuit for the following expression: (a' c)(b d' ... Construct a circuit that implements the expression AB CD using only NAND gates ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 28
Provided by: Sanda4
Category:
Tags: csi | lab

less

Transcript and Presenter's Notes

Title: CSI 1101 Lab


1
CSI 1101Lab 11 April 4, 2003
  • Romelia Plesa
  • rplesa_at_site.uottawa.ca

2
Agenda
  • A9 discussion
  • Assembly language
  • Switching Algebra
  • Assignment 10 discussion

3
Assignment 9
  • Any Questions?
  • Solution
  • http//www.site.uottawa.ca/turcotte/teaching/csi
    -1101/assignments/09

4
Assembly language
  • High level language C, Java, etc
  • Low level language
  • Assembly language
  • Close to the instruction set that the hardware
    can execute.
  • Programs are highly dependent on the type of
    processor, and cannot be ported to another
    computer.
  • Situations where assembly language is used
  • writing drivers
  • mix with high level code, the critical parts are
    written in assembly language directly to achieve
    greater speeds (not so true with modern
    compilers)
  • writing compilers (back-end) necessitates
    knowledge of the assembly language of the machine
    for which the compiler is written.
  • Machine code Number representation of
    instruction and data

5
TC-1101 Instruction Set
6
Assembly language
  • one instruction per line
  • mnemonics replace instruction codes
  • instructions can be designated by labels
  • allows for comments generally prefixed by
  • Format of a line
  • starts with an optional label
  • followed by the mnemonic of the instruction
  • followed by a symbolic name for the operand
    (optional, depends on the instruction)

7
Machine code
  • Reading programs
  • Since the instructions and the data are both
    represented as numbers (same format) we cannot
    distinguish one from the other.
  • Some instructions have an operand others not,
    this makes it difficult to identify the start and
    end of an instruction.
  • Writing programs
  • Instructions are using absolute addresses, any
    change to a program implies several changes
    elsewhere in the program.
  • Instruction codes are not easy to memorize.

8
Machine code vs Assembly language
9
ExampleMultiplying two numbers by succesive
additions
  • Assembly language
  • JMP  1 X    BYTE 06 Y    BYTE
    12Prod BYTE 00 Cst1 BYTE 01 1 
    CLA            STA  Prod     CLA      
         ADD  Y    2 JZ   6     3 
    LDA  Prod    ADD  X         STA  Prod
    4  LDA  Y          SUB  Cst1     
    STA  Y      5   JMP  2     6
      DSP  Prod      HLT         
  • Java code
  • public static int mult (int x, int y)     int
    res 0    while (y gt 0)         res res
    x        y y - 1        return res
  • pseudo-code
  • 1. set prod to 02. if y 0 goto 63. add x
    to prod4. decrement y5. goto 26. halt

10
Translating the assembly program to machine code
  • There is a 1-to-1 correspondence between assembly
    and machine language.
  • 2 steps process
  • Translate the mnemonics to codes
  • Translate the symbolic operands to absolute
    addresses (need symbol table)

11
Symbol table
  • Its a table that associates to each symbol a
    memory address.
  • The symbols correspond to the labels of the
    statements, variables and constants.
  • Mnemonic Opcode
  • JMP 15
  • CLA 08
  • STA 39
  • ADD 12
  • JZ 15
  • LDA 91
  • SUB 61
  • DSP 01
  • HLT 64

Symbol Table Label Address 1 00 07 2 00
15 3 00 18 4 00 27 5 00 36    
6 00 39 X 00 03 Y 00 04 Prod 00
05 Cst1 00 06
12
Translating the assembly program to machine code
  • Assembly-code Address OpCode OpAddr H-L
    JMP  1 00 00 15 
          00 07  X   BYTE 06 00 03
         06Y    BYTE 12 00 04
        12Prod BYTE 00 00 05
          00Cst1 BYTE 01 00 06      
    011  CLA        00 07
    08     STA  Prod 00 08
    39    00 05    
    CLA       00 11        08    
    ADD  Y    00 12         99
           00 042  JZ   6      00
    15 17       00
    393  LDA  Prod 00 18
    91      00 05     ADD 
    X    00 21 99     
    00 03     STA  Prod 00 24
    39       00 054 
    LDA  Y      00 27 91      
    00 04     SUB  Cst1   00 30    
    61     00 06    
    STA  Y       00 33 39
       00 045  JMP  2     00 36
    15     00
    156  DSP  Prod   00 39
    01      00 05    
    HLT           00 42 64

13
Switching Algebra
  • Definition
  • A Boolean function of N variables (or inputs) is
    a function that has N input variables and
    produces 1 output.
  • "Boolean" means the variables and outputs can
    have only two possible values
  • usually these are called FALSE and TRUE, but
    because we want to use Boolean functions to do
    Binary arithmetic, we equate FALSE with the value
    0 and TRUE with the value 1.  
  • We will look at 3 different ways of writing down
    Boolean functions
  • a) functional notation, e.g. (X AND Y) OR (NOT
    Z)
  • (exactly like a Boolean expression in Java,
    except we use words for the operators, or math
    symbols ( ) not the Java operators.)
  • b) truth tables
  • c) logic circuits
  • truth table --gt functional notation --gt logic
    circuit

14
Switching Algebra
  • Propositional logic consists of an ensemble of
    values, TRUE(1),FALSE(0) and the following 3
    operators
  • AND, OR and NOT

15
Truth Tables
  • A truth table is a simple way of representing a
    boolean function
  • it is very convenient as long as the function
    does not have too many inputs.
  • A truth table has one column for every input
    variable, and one extra column for the function
    output.
  • It has one row for every possible combination of
    inputs (2-to-the-N).
  • In the "input" columns you write down the
    particular input values (for the particular
    combination/row you're looking at)
  • in the function column you put the output of the
    function given that input.

16
Truth Tables
17
Using truth tables to prove a property
  • Show that
  • a a.b a b

18
Using truth tables to prove a property
  • Show that
  • a a' 1

19
Using truth tables to prove a property
  • Show that
  • a.(bc) a.b a.c

20
16 different 2-input Boolean functions
21
Logic Gates
  • 2-input boolean functions are the building blocks
    out of which almost all computer circuits are
    made. When we draw these circuits, we have
    special ways of drawing the most important
    functions

You dont have to memorize the symbols for the
final, there will be an appendix
22
Logic Gates
  • We imagine that the values flow along wires. So
    if we want to make a more complex circuit we just
    connect the output of one logic gate to the input
    of another.
  • Example
  • suppose we wanted to test if X and Y and Z were
    all true.
  • Assuming we only have 2-input AND gates, we'd
    have to use several gates.
  • We'd break the expression down into (X AND Y)
    AND Z.
  • The AND in brackets would be done with one gate,
    and its output would be connected to one of the
    inputs of a second AND gate (Z would be connected
    to the other input).

X
Y
Z
23
Logic Gates Special Symbols
NOR gate
NAND gate
XOR gate
24
Rules for Logic Circuits Drawing
  • There is one vertical line per input variable
  • The gates are connected to those lines with
    horizontal lines       
  • A connection is shown as a dot at the
    intersection of a vertical and horizontal line

25
Rules for Logic Circuits Drawing
a a.b
a.b
aa.b
b
a
26
Exercises
  • a) Draw a circuit for the following expression
    (a c)(b d))
  • b) Simplify the circuit to have only single
    variables inverted.
  • 2. Construct a circuit that implements the
    expression AB CD using only NAND gates
  • 3. Using only NAND gates, construct the circuit
    for the expression
  • A BC

27
Assignment 10
  • Question 1 For the giving Java code(adding the
    odd numbers from 1 to 2N-1 )
  • - write the line to line assembly
    language program
  • - transform the assembly language into
    machine code
  • Question 2 1. 3-way jump
  • 2. translate the assembly code into machine
    code
Write a Comment
User Comments (0)
About PowerShow.com