Loading in 2 Seconds...
Loading in 2 Seconds...
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
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.
The ALU • functions: • does either arithmetic or logic operations • 4 bits plus carry (in and out) • 4 bit function select
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.
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
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)
Sections of a computer: • ALU: does the math • Control: orchestrates and times the flow of data and processes
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
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.
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
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
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.
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
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”)
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
BASIC commands • INPUT: reads input from the keyboard or a file • Examples: INPUT “what is your name “, N$ INPUT #1, A$, X
BASIC commands • PRINT: writes data to the screen or to a file • Example: PRINT “hello” PRINT A PRINT #1 “I am”, Y, “ years old.” (here #1 is an out put device or file)
BASIC commands • GOTO: sends the “pointer” to a new location • Example: 10 GOTO 20 20 STOP Note: this is an endless loop: 10 GOTO 10
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 X ELSE PRINT –X END IF
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%
DO LOOP: repeats a block of statements while a condition is met • Examples: • DO WHILE X# <10 • PRINT X# • X#=X#+1 • LOOP
OPEN and CLOSE: open and close files for input or output • Examples: • OPEN “LIST.DAT” for output as #1 • PRINT #1, A • CLOSE #1
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”