A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B....
-
Upload
grant-whitehead -
Category
Documents
-
view
224 -
download
1
Transcript of A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B....
![Page 1: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/1.jpg)
• A. computers do everything by adding:– 1. multiplication– 2. subtraction– 3. division
• B. The device which does the arithmetic is called the ALU– 1. composed of gates just like anything else– 2. represented by a black box.
![Page 2: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/2.jpg)
Serial Addition
![Page 3: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/3.jpg)
Parallel addition
![Page 4: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/4.jpg)
The ALU• functions:– does either arithmetic or
logic operations– 4 bits plus carry (in and
out)– 4 bit function select
![Page 5: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/5.jpg)
Memories• Computers, by definition, have memories
– hold the program• a program is what makes a computer a computer
– hold data
• Requirements of memory:– enter data– save data– retrieve data
• What is memory?– recording of a series of binary numbers (that's all)– in the case of data, these are actually numbers– in thee case of a program, these may be numbers or may be a truth table
showing the computer how to respond to a given circumstance.
![Page 6: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/6.jpg)
Memory types• Non-Volatile (mass storage device)
– - used for long-term storage– magnetic core = magnetized donuts which store bits
• isn't used very much any more• takes up quite a bit of space• random access• don't sweat the details of how this works
– tape drives• data stored in tracks (bits plus parity)• prone to errors • very cheap• slow sequential access
– disks (floppy, hard, laser etched)• data stored in tracks and sectors• may or may not be exchangeable
– ROM's • read only• simplest form is a series of diodes which select a current path• in more complicated form, they are semiconductor memories which are programmed using high
voltages• some are erasable using light or another voltage• act like a big truth table
![Page 7: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/7.jpg)
Memory
• 3. types of ROMS– mask programmed• mass produced• not field changeable
– Programmable ROMS (PROMs)• programmed by burning away a fusible link• not changeable unless you change ones to zeros
– Erasable PROMs (EPROMs)• written by using high voltage• erased by UV or electrically (EEPROMs)
![Page 8: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/8.jpg)
• Sections of a computer:• ALU: does the math• Control: orchestrates and times the flow of data and
processes
![Page 9: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/9.jpg)
the concept of the CPU:
• collectively, the ALU, the control section and a little memory is called the central processing unit, or the CPU.
• this is the heart of the computer and is what separates it from an adding machine
• the type and organization of the CPU vary from computer to computer.
• when this is on a single chip, it is called a microprocessor• Some “mainframe” computers do not have
microprocessors• Some PC’s have multiple processors
![Page 10: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/10.jpg)
The buses• usually a parallel package of at
least 8 wires, sometimes more.• every device is connected to
the buses • 1. The control bus
– this is a one-way bus– the controller uses this bus to
command the other devices– no other devices can apply signals
to this bus– but they must all be able to read
it.
• 2. The data/address bus– bi-directional bus– data can go to or from many of the
devices– for example, data to or from
memory. program counter etc– note that the control bus does not
put anything on the A/D bus, but only manipulates it through the other modules.
![Page 11: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/11.jpg)
a simple example
• suppose we want to get a 4 bit word from A to C; here's what we do:– a. A/R= 1 C/W=1 (these get
the data ready to go onto the bus)
– b. clock (nothing happens until the clock arrives)
• note that once the data is on the bus, as many devices as are available can read it
• HOWEVER, ONLY ONE DEVICE CAN READ DATA ONTO THE BUS AT ANY ONE TIME!!!
• The controller is responsible for ensuring that a jamup doesn't occur
![Page 12: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/12.jpg)
• The whole computer• Looks complicated but
it’s just a collection of the pieces we already understand
• The ALU and it’s registers does the math
• The Control unit reads an instruction and makes it happen
• The PROM stores the instructions
![Page 13: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/13.jpg)
The control PROM
![Page 14: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/14.jpg)
Languages• At the lowest level, commands are a series of 1’s and 0’s
– We call this “machine code”– No one programs in it
• If you apply mnemonics to machine code equivalents, that’s called “Assembly language”– This used to be popular– Almost never used today except by real geeks
• Higher level languages use commands that invoke a series of assembly language commands
• Operating systems are a set of definitions for programs– More on this later
• And there are other combinations of languages on top of languages.
![Page 15: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/15.jpg)
• Higher level languages: BASIC: Beginners All-Purpose Symbolic Instruction Code
• BASIC or any other high level language, can be stored in a rom just like the controller. That means that the computer uses the BASIC ROM to decode basic instructions into machine code sequences. Programs written directly in machine code are the most efficient to the computer, but not to us, so we use high level languages. The BASIC ROM then interfaces between us and the computer
![Page 16: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/16.jpg)
Programming: BASIC basics
• The program is just a list of instructions• Each one executed in turn– Much of programming is directing the flow:– Go to another line– If a condition is fulfilled, go to another line
• Can be interpereted or compiled (in our case “tokenized”)
![Page 17: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/17.jpg)
Variables
• % integer such as i%• $ string (text) such as A$• ! Single precision such as A!• # double precision such a X!• Comments: start the line with ‘• See help for other conventions
![Page 18: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/18.jpg)
• INPUT: reads input from the keyboard or a file• Examples:INPUT “what is your name “, N$INPUT #1, A$, X
BASIC commands
![Page 19: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/19.jpg)
• PRINT: writes data to the screen or to a file• Example:PRINT “hello”PRINT APRINT #1 “I am”, Y, “ years old.”(here #1 is an out put device or file)
BASIC commands
![Page 20: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/20.jpg)
BASIC commands
• GOTO: sends the “pointer” to a new location• Example: 10 GOTO 20 20 STOPNote: this is an endless loop:
10 GOTO 10
![Page 21: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/21.jpg)
• IF THEN ELSE: executes a statement or a block of statements
• Syntax: IF condition THEN• If the condition is satisfied, then it will execute
the then• Examples:IF X>0 THEN PRINT XELSE PRINT –XEND IF
![Page 22: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/22.jpg)
• FOR NEXT: executes a block of statements a set number of times
• Increments the counter automatically• Example:• FOR I% = 1 to 10• PRINT I%• NEXT I%
![Page 23: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/23.jpg)
• DO LOOP: repeats a block of statements while a condition is met
• Examples:• DO WHILE X# <10• PRINT X#• X#=X#+1• LOOP
![Page 24: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/24.jpg)
• OPEN and CLOSE: open and close files for input or output
• Examples:• OPEN “LIST.DAT” for output as #1• PRINT #1, A• CLOSE #1
![Page 25: A. computers do everything by adding: – 1. multiplication – 2. subtraction – 3. division B. The device which does the arithmetic is called the ALU – 1.](https://reader036.fdocuments.in/reader036/viewer/2022062717/56649e1a5503460f94b08264/html5/thumbnails/25.jpg)
Assignment
• Download and install Qbasic• Write a program per the instructions• This will build on itself– Start simple,– Edit to incorporate new features– Troubleshoot along the way
• Submit your work to us by email but change “.bas” to “.sab” because Microsoft blocks “.bas”