CSC-205 Computer Organization Lecture #010 Section 4.4...

19
1/19 4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files CSC-205 Computer Organization Lecture #010 Section 4.4, Gates and machine instructions Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge Dr. Chuck Cartledge 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017 24 Oct. 2017

Transcript of CSC-205 Computer Organization Lecture #010 Section 4.4...

  • 1/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    CSC-205 Computer OrganizationLecture #010

    Section 4.4, Gates and machine instructions

    Dr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck CartledgeDr. Chuck Cartledge

    24 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 201724 Oct. 2017

  • 2/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Table of contents (1 of 1)

    1 4.4Bringing the Pep/8 to“life”

    2 Fun with FibonacciHystorical perspective (nothat isn’t a typo)

    3 Chap. 4 review

    Computer architecture4 Conclusion5 References6 Files

  • 3/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Bringing the Pep/8 to “life”

    Pep/8 needs an operating system.

    “An operating system acts as an intermediary (providing communication) between the user of acomputer and computer hardware. The purpose of anoperating system is to provide an environment in which auser can execute programs in a convenient and efficientmanner.An operating system is software that manages thecomputer hardware. The hardware must provideappropriate mechanisms to ensure the correct operationof the computer system and to prevent user programsfrom interfering with the proper operation of the system.”

    Silberschatz, Galvin, and Gange [3]

    While there are computers without operating systems, they are farfrom the norm.

  • 4/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Bringing the Pep/8 to “life”

    The Pep/8 OS from 30,000 feet.

    The OS “lives” in a specificpart of RAM.

    When the Pep/8 is turnedon, the OS is automaticallyloaded into system RAM.

    Image from [5].

  • 5/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Bringing the Pep/8 to “life”

    The OS, really has two distinct parts, RAM and ROM

    RAM has data and programsthat can change

    ROM memory locations cannot be changed

    Locations in ROM are“hardwired” into the OSapplication

    ROM locations usuallycontain “pointers” to otherlocations for the “real” data

    Two very special ROMlocations are: FFFA, andFFFC Image from [5].

  • 6/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Bringing the Pep/8 to “life”

    The Pep/8 OS from 300 feet.

    Special memory locations:

    FFF8 - bottom of the user stackFFFA - SP the stack pointerFFFC - PC the program counterFFFE - start of interrupt service vector

    The loader is responsible for “loading” auser program into memory, setting thespecial memory locations to the correctvalues

    The I/O buffer is used by the OS forinput and output

    The system stack is for system variables

    User applications are loaded into lowestnumbered memory

    User variables are created in the userstack

    Image from [5].

  • 7/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Bringing the Pep/8 to “life”

    Bringing the pieces together

    1 The SP and PC registers are inan unknown state

    2 The loader from the OS loads auser program into low memory

    3 The loader copies the contents ofmemory location FFFA to the SPregister

    4 The loader copies the contents ormemory location FFFC to the PCregister

    5 Program execution begins withthe user application fetching thecontents pointed to by the PC.

    Image from [5].

  • 8/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Bringing the Pep/8 to “life”

    Same image.

    Image from [5].

  • 9/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Hystorical perspective (no that isn’t a typo)

    Leonardo Bonacci (c. 1170 – c. 1250)

    Considered to be the most talentedWestern mathematician of the MiddleAges.

    Most notable work Liber Abaci

    (1202) introduced:

    Arabic numbersPlace valuesPromoted his ideas byapplying them tobookkeeping

    Image from [4].

    Posed a problem having to do with rabbits.

  • 10/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Hystorical perspective (no that isn’t a typo)

    Fibonacci’s rabbits (the background)

    The growth of an idealized rabbit population, assuming that:

    1 A newly born pair of rabbits, one male, one female, are put ina field;

    2 Rabbits are able to mate at the age of one month so that atthe end of its second month a female can produce anotherpair of rabbits;

    3 Rabbits never die and a mating pair always produces one newpair (one male, one female) every month from the secondmonth.

  • 11/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Hystorical perspective (no that isn’t a typo)

    Fibonacci’s rabbits (the puzzle)

    How many pairs will there be in one year?

    1 At the end of the first month, they mate, but there is still only1 pair.

    2 At the end of the second month the female produces a newpair, so now there are 2 pairs of rabbits in the field.

    3 At the end of the third month, the original female produces asecond pair, making 3 pairs in all in the field.

    4 At the end of the fourth month, the original female hasproduced yet another new pair, the female born two monthsago produces her first pair also, making 5 pairs.

    At the end of the nth month, the number of pairs of rabbits isequal to the number of new pairs (which is the number of pairs inmonth n - 2) plus the number of pairs alive last month (n - 1).

  • 12/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Hystorical perspective (no that isn’t a typo)

    Fibonacci’s rabbits (math)

    The Fibonacci series:

    Fn = Fn−1 + Fn−2It starts:

    Traditional: F1 = F2 = 1Modern: F0 = 0,F1 = 1

    Negative Fibonacci numberexist as well

    Fn−2 = Fn − Fn−1F−n = (−1)n+1Fn

  • 13/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Hystorical perspective (no that isn’t a typo)

    Fibonacci numbers (solutions)

    More than one way to skin a cat(number 49 with duct tape isexciting):

    For loops

    Recursive function

    Function (direct look up)

    State machine

    A process queue is left forconjecture. Image from [2].

    Sample programs are attached to this PDF.

  • 14/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Hystorical perspective (no that isn’t a typo)

    Fibonacci appears, and reappears all over the place

    Search for images using:Fibonacci pattern

    Search for scholarly worksusing: Fibonacci pattern

    Search for ArXiv articlesusing: Fibonacci pattern

    Ratio of two consecutiveFibonacci numbers is the“golden ratio”(≈ 1.6180327868852)

    https:

    //www.flickr.com/photos/

    michaelpaukner/4260592085/

    https://www.flickr.com/photos/michaelpaukner/4260592085/https://www.flickr.com/photos/michaelpaukner/4260592085/https://www.flickr.com/photos/michaelpaukner/4260592085/

  • 15/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Computer architecture

    The hardware “nuts and bolts”

    Pep/8 hardware model,

    Machine code (page 159),

    Memory addressing modes(immediate, direct, indirect,etc.),

    Load, store, and output abyte,

    von Neumann, vonNeumann, von Neumann,

    Programming at ISA3,

    Heap and stack Image from [1].

    von Neumann is very, very dumb.

  • 16/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    What have we covered?

    Programming at level ISA3Chapter review

    Next period:

    Test, Section 5.1, Machine instructions and assemblers

  • 17/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    References (1 of 2)

    [1] Barry Sarner,Information Part #2: Information Aggregation using ’The p.e.e.e Concept’: Practice, Explore, Experiment, Experience,http://www.itsallpossible.com/information-part-2-

    the-p-e-e-e-concept-information-aggregation-for-

    your-personal-or-business-success-quest/, 2017.

    [2] Hanson Schmidt-Cornelius, Recursion for Runaways,http://livecode.com/recursion-for-runaways/, 2014.

    [3] Abraham Silberschatz, Peter Baer Galvin, and Greg Gange,Operating System Principles, John Wiley and Sons, 2006.

    [4] Wikipedia Staff, Fibonacci,https://en.wikipedia.org/wiki/Fibonacci, 2015.

    http://www.itsallpossible.com/information-part-2-the-p-e-e-e-concept-information-aggregation-for-your-personal-or-business-success-quest/http://www.itsallpossible.com/information-part-2-the-p-e-e-e-concept-information-aggregation-for-your-personal-or-business-success-quest/http://www.itsallpossible.com/information-part-2-the-p-e-e-e-concept-information-aggregation-for-your-personal-or-business-success-quest/http://livecode.com/recursion-for-runaways/https://en.wikipedia.org/wiki/Fibonacci

  • 18/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    References (2 of 2)

    [5] J. Stanley Warford, Computer Systems, Jones & BartlettPublishers, 2010.

  • 19/19

    4.4 Fun with Fibonacci Chap. 4 review Conclusion References Files

    Files of interest

    1 Fibonacci as a for-loop2 Fibonacci as a function call

    3 Fibonacci as a function

    lookup4 Fibonacci as a number

    generator

    5 Fibonacci as a process

    queue

    6 Fibonacci as a recursive

    function

    7 Fibonacci as a state

    machine

    #include using namespace std;

    // http://www.miniwebtool.com/list-of-fibonacci-numbers/?number=100

    int main () { int number; int first = 0; int second = 1; int next = 0; cout > number;

    switch(number) { case 0: next = 0; break; case 1: case 2: next = 1; break; default:

    for (int i = number - 1; i; i --){ next = first + second; first = second; second = next;} }

    cout