CS 300 - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

CS 300

Description:

CS 300 Lecture 8. Intro to Computer Architecture / Assembly Language ... Mips: and, andi, or, ori, nor. How do we use these with bit field constants? Shifting ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 10
Provided by: johnpe2
Learn more at: http://wiki.western.edu
Category:
Tags: andi

less

Transcript and Presenter's Notes

Title: CS 300


1
CS 300 Lecture 8
  • Intro to Computer Architecture
  • / Assembly Language
  • Branching and Function Calling

2
Homework 4
  • Will be in the wiki SOON!

3
Operations So Far
  • Arithmetic add, sub, addi (why not subi?)
  • Memory access lw, sw What next?
  • Byte oriented memory access
  • lb, lbu, sb, lh, lhu, sh Signed and unsigned
  • Byte /
    halfword
  • Logical operations
  • and
  • or
  • nor
  • left shift, right shift (logical)

4
Packed Structures
  • What sort of code sequences do packed structures
    require? Note that C doesn't explicitly support
    packing at the bit level but C programmers can
    use shifts / logical operations to simulate this.
  • typedef struct a
  • long a
  • char b
  • short c
  • short d __attribute__((packed)) A

5
And, Or, Not
  • Note that these operations are really easy to
    implement in hardware!!
  • In C. these are , , and
  • Mips and, andi, or, ori, nor
  • How do we use these with bit field constants?

6
Shifting
  • The other logical operation is shifting
  • Shift left
  • Shift right
  • Arithmetic shift right (not in MIPS)
  • Circular shifting (not in MIPS)
  • This is ltlt and gtgt in C
  • What does shifting do to the arithmetic value of
    a number?

7
Program Flow
  • Unconditional Jump instructions (j)
  • Conditional beq, bne (register comparisons)
  • Set instructions to capture booleans (not
    really a program flow instruction but similar!)
  • How do you compile if, while, for, case, ???

8
Dynamic Memory Management
  • Dynamic memory is used to handle memory needs
    that can't be anticipated statically.
  • Two forms
  • Stack based for objects that are no longer
    needed upon function exit
  • Heap based for objects that have "indefinite"
    extent.
  • In Java, you can't see the difference between
    these. In C, all local variables are stack
    based only malloc() used the heap. Need to
    explicitly free heap objects.

9
Sharing Memory
  • On the MIPS, memory is allocated to a process as
    follows

Stack
Unused
Heap
Static memory allocation
Stack Pointer (sp)
If the pointers cross, you're out of memory
Heap Pointer (gp)
code, constants, static vars, system stuff
Write a Comment
User Comments (0)
About PowerShow.com