Download presentation
Presentation is loading. Please wait.
Published byJade York Modified over 9 years ago
1
ECE291 Lecture 1 All about computers
2
ECE 291 Lecture 1Slide 2 of 45 Lecture outline Errata from yesterday Class and Lab Schedules Top-down view of computers Processor architecture RegistersMemoryPeripherals Assembly primer
3
ECE 291 Lecture 1Slide 3 of 45 HW0 Answers First Transistor: 1948 First Intel Microprocessor: 1985
4
ECE 291 Lecture 1Slide 4 of 45 Clarification on Sign Contraction Yesterday I said, “A number can be sign contracted if the bits that are to removed are all the same” “A number can be sign contracted if the bits that are to removed are all the same” I should have said, “A number can be sign contracted if the bits that are to removed and the sign bit of the resultant number are all the same” “A number can be sign contracted if the bits that are to removed and the sign bit of the resultant number are all the same”Example: 0001h = 1 01h = 1OK 0001h = 1 01h = 1OK FF80h = -128 80h = -128OK FF80h = -128 80h = -128OK FF40h = -192 40h = 64NO FF40h = -192 40h = 64NO 0080h = 128 80h = -128NO 0080h = 128 80h = -128NO
5
ECE 291 Lecture 1Slide 5 of 45 Class and Lab Schedules http://courses.ece.uiuc.edu/ece291/schedule.htmlhttp://courses.ece.uiuc.edu/ece291/schedule.html and http://courses.ece.uiuc.edu/ece291/labsched.html http://courses.ece.uiuc.edu/ece291/labsched.html http://courses.ece.uiuc.edu/ece291/schedule.html http://courses.ece.uiuc.edu/ece291/labsched.html This is what we decided on This is what we decided on Any comments, suggestions for improvement, or sarcastic retorts? Any comments, suggestions for improvement, or sarcastic retorts?
6
ECE 291 Lecture 1Slide 6 of 45 Computers from 50,000 feet Basic components Mouse Mouse Keyboard Keyboard Monitor Monitor Printer Printer Scanner Scanner Joystick Joystick “The box” “The box”
7
ECE 291 Lecture 1Slide 7 of 45 Computers from 10,000 feet Sound card Serial SCSI Parallel Keyboard/MouseUSBExpansionVGA Network Power
8
ECE 291 Lecture 1Slide 8 of 45 Computers from 100 feet Cooling fan Power supply Memory Processor Expansion bus Motherboard IDE and SCSI cables and devices
9
ECE 291 Lecture 1Slide 9 of 45 Motherboard Computers from 10 feet CPU Memory Expansion Bus Peripherals Control Data Address
10
ECE 291 Lecture 1Slide 10 of 45 Motherboard Computers from 10 feet Processor 8088 8086 80286 80386dx 80486 80586/Pentium (Pro) Data Bus 8 16 32 64 Address Bus 20 24 32 Max Addressable Memory 1,048,576 (1Mb) 16,777,21(16Mb) 4,294,976,296 (4Gb)
11
ECE 291 Lecture 1Slide 11 of 45 Computers from 1 micron Central Processing Unit – The Processor Control BIU ALU Control registers General purpose registers Special (floating-point, flag, sse) Control Data Address
12
ECE 291 Lecture 1Slide 12 of 45 The processor It’s a state machine Has a set of hard-coded operations Each operation has an associated code; an “opcode” Each operation has an associated code; an “opcode” Some examples are MOV, ADD, SUB, AND Some examples are MOV, ADD, SUB, AND All it can do is move data or perform some calculation on data Very simple, right?
13
ECE 291 Lecture 1Slide 13 of 45 The processor - components CPU Registers Special memory locations constructed from flip-flops and implemented on-chip Special memory locations constructed from flip-flops and implemented on-chip E.g., accumulator, count register, flag register E.g., accumulator, count register, flag register Arithmetic and logic Unit (ALU) Where most of the action takes place inside the CPU Where most of the action takes place inside the CPU Bus Interface Unit (BIU) Responsible for controlling the address and data busses when accessing main memory and data in the cache Responsible for controlling the address and data busses when accessing main memory and data in the cache Control Unit and Instruction Set CPU has a fixed set of instructions CPU has a fixed set of instructions E.g. MOV, CMP, ADD, JMP E.g. MOV, CMP, ADD, JMP
14
ECE 291 Lecture 1Slide 14 of 45 The registers Small memory locations that are quickly accessible by the processor Located on the chip Hold data and results for operations Point to main memory locations Contain status information about the results of operations
15
ECE 291 Lecture 1Slide 15 of 45 80x86 registers Accumulator EAX AHAL AX Base EBX BHBL BX Count ECX CHCL CX Data EDX DHDL DX General Purpose Inst Pointer EIP IP Flags EFLAG FLAG Special Registers Stack Segment Code Segment CS Data Segment DS Extra Segment ES SS FSGS Segment Registers Stack Pointer ESP SP Base Pointer EBP BP Dest Index EDI DI Source Index ESI SI Index Registers
16
ECE 291 Lecture 1Slide 16 of 45 Register specifics Accumulator (AL, AH, AX, EAX) Usually stores results from the ALU Usually stores results from the ALU It “accumulates” totals from math operations It “accumulates” totals from math operations General purpose General purpose Base (BL, BH, BX, EBX) Usually holds addresses – points to memory locations Usually holds addresses – points to memory locations
17
ECE 291 Lecture 1Slide 17 of 45 Register specifics Count (CL, CH, CX, ECX) Counting and looping Counting and looping Certain instructions automatically decrement the count register Certain instructions automatically decrement the count register Data (DL, DH, DX, EDX) Usually contains data for instructions Usually contains data for instructions Used in multiplication/division instructions along with accumulator Used in multiplication/division instructions along with accumulator
18
ECE 291 Lecture 1Slide 18 of 45 Register specifics Source index (SI, ESI) Often used to address a source variable or array Often used to address a source variable or array Destination index (DI, EDI) Often used to address a destination variable or array Often used to address a destination variable or array
19
ECE 291 Lecture 1Slide 19 of 45 Register specifics Stack pointer (SP, ESP) Used by stack operations Used by stack operations Usually you don’t want to mess with this one Usually you don’t want to mess with this one Base pointer (BP, EBP) Addresses stack memory Addresses stack memory It’s better to mess with this one, though you can still get you in trouble It’s better to mess with this one, though you can still get you in trouble Can be used to read subroutine arguments Can be used to read subroutine arguments
20
ECE 291 Lecture 1Slide 20 of 45 Register Specifics Get in the habit of using these registers for their intended tasks as much as possible It will greatly help you (and us) in reading and debugging your code!
21
ECE 291 Lecture 1Slide 21 of 45 Register specifics Code segment (CS) Points to the area in memory where instructions are stored Points to the area in memory where instructions are stored Instruction pointer (IP) An index into the code segment that points to the next instruction to be executed An index into the code segment that points to the next instruction to be executed Data segment (DS) Points to the area in memory where data needed by a program is stored Points to the area in memory where data needed by a program is stored
22
ECE 291 Lecture 1Slide 22 of 45 Register specifics Stack segment (SS) Points to the area in memory containing the system’s FIFO stack. We’ll have a whole lecture on this. Points to the area in memory containing the system’s FIFO stack. We’ll have a whole lecture on this. ES, FS, GS Extra segment registers available to point to additional data segments should that be necessary. Extra segment registers available to point to additional data segments should that be necessary.
23
ECE 291 Lecture 1Slide 23 of 45 Memory System memory or RAM holds data and instruction opcodes that are being used by the CPU Organized in banks, usually even and odd Always byte addressable More on all this tomorrow
24
ECE 291 Lecture 1Slide 24 of 45 Memory access example CPU wants to read memory at address 12345h CPUMemory Read Signal Data 12345h
25
ECE 291 Lecture 1Slide 25 of 45 Memory organization AB 1 FF 5512 1433 76DE 0146 F124 E911 9087 3 5 7 9 B D F 0 2 4 6 8 A C E Odd BankEven Bank Data Bus (15:8)Data Bus (7:0)
26
ECE 291 Lecture 1Slide 26 of 45 Memory organization In Real Mode: The address bus is 20-bits for memory operations. The address bus is 20-bits for memory operations. 2 20 = 1MB = how much memory an x86 processor can address in real mode 2 20 = 1MB = how much memory an x86 processor can address in real mode The data bus is 16-bits which means it can transfer two bytes in one operation The data bus is 16-bits which means it can transfer two bytes in one operation Limited to 16-bit registers Limited to 16-bit registers
27
ECE 291 Lecture 1Slide 27 of 45 Memory organization In Protected Mode: The memory address bus is 32-bits The memory address bus is 32-bits 2 32 = 4GB = the maximum addressable amount of memory in modern x86 processors 2 32 = 4GB = the maximum addressable amount of memory in modern x86 processors Data bus is also 32-bits meaning four bytes can be transferred in a single operation Data bus is also 32-bits meaning four bytes can be transferred in a single operation Gain access to the 32-bit extended registers Gain access to the 32-bit extended registers
28
ECE 291 Lecture 1Slide 28 of 45 Peripherals In our context, things like printers, joysticks, and scanners aren’t peripherals Some examples are parallel, serial and USB ports, the internal timers, interrupt controllers, network interface cards Many helper devices inside the processor, on the motherboard, or in expansion slots
29
ECE 291 Lecture 1Slide 29 of 45 Peripheral I/O bus There is a separate set of address/data busses commonly used for communication with peripheral devices The I/O address bus is 16-bits wide, meaning you can address 65,535 different I/O ports. The I/O data bus is 16-bits Example: In real mode, The keyboard input (scan code) is read in on port 60h. Each scan code is one byte. In real mode, The keyboard input (scan code) is read in on port 60h. Each scan code is one byte.
30
ECE 291 Lecture 1Slide 30 of 45 Peripheral I/O Peripheral devices don’t have to use the I/O bus. They can be memory mapped. Video cards are an example They have a large amount of memory (VRAM) and that is typically mapped to a range of addresses in the memory space
31
ECE 291 Lecture 1Slide 31 of 45 Peripheral example Network card Input/Output Range CC00-CC7F Memory Range FB000000-FB00007F This one is both memory mapped and I/O mapped
32
ECE 291 Lecture 1Slide 32 of 45 Peripherals All this really means to you is that sometimes you’ll use one set of instructions to access a device, and sometimes you’ll use a different set. We’ll talk about this again when we cover serial/parallel ports, timers, interrupts, and the video graphics adapter.
33
ECE 291 Lecture 1Slide 33 of 45 Intermission
34
ECE 291 Lecture 1Slide 34 of 45 Instruction processing Processing of an instruction by the microprocessor consists of three basic steps 1. fetch instruction from the memory 2. decode the instruction 3. execute (usually involves accessing the memory for getting operands and storing results) Operation of an early processor like the Intel 8085 Fetch 1 Decode 1 Execute 1 Fetch 2 Decode 2 Execute 2 …... Busy IdleBusy…... Busy IdleBusy Microprocessor Bus
35
ECE 291 Lecture 1Slide 35 of 45 Instruction processing Fetch 1 Fetch 2 Fetch 5 Fetch 3 Fetch 4 Modern microprocessors can process several instructions simultaneously at various stages of execution this ability is called pipelining this ability is called pipelining Operation of a pipelined microprocessor like the Intel 80486 Store 1 Fetch 6 Fetch 7 Read 2 Decode 1 Decode 2 Decode 3 Decode 4 Decode 5 Decode 6 Idle Execute 1 Idle Execute 2 Execute 3 Execute 4 Execute 5 Execute 6 Generate Address 1 Generate Address 2 Bus Unit Instruction Unit Execution Unit Address Unit
36
ECE 291 Lecture 1Slide 36 of 45 Assembly primer Everything in your assembly file is one of the following: A comment A comment A label A label An instruction or directive An instruction or directive Data Data
37
ECE 291 Lecture 1Slide 37 of 45 Assembly primer - comments ; Comments are denoted by semi-colons. ; These are comments ; Please comment your MP’s! ; It helps us figure out what you were doing ; It also helps you figure out what you were ; doing when you look back at code you ; wrote more than two minutes ago.
38
ECE 291 Lecture 1Slide 38 of 45 Assembly primer - labels You might be asking, “What about variables? Why aren’t they on the bulleted list?” You may also not care at all Variables are nothing more than labels that mark specific memory locations Labels can also mark the beginning of procedures or “jump to” locations in your code
39
ECE 291 Lecture 1Slide 39 of 45 Assembly primer - labels ; Labels can be global MyGlobalLabel:MyOtherGlobalLabel ; They can be local too.MyLocalLabel ; Local labels are good only back to the previous un-dotted label
40
ECE 291 Lecture 1Slide 40 of 45 Assembly primer - labels MyBigGlobalLabel.local_label1.local_label2MyNextBigGlobalLabel.local_label1; these are distinct.local_label2; to the ones above
41
ECE 291 Lecture 1Slide 41 of 45 Assembly primer - variables ; Let’s do something with labels now VAR1 DB 255 VAR2 DB 0FFh VAR3 DW 1234h ARR1 DB 12, 34, 56, 78, 90 ARR2 DW 12, 34, 56, 78, 90 STR1 DB ‘291 is awesome!!!’, 0 BUF1 RESB 80 labelsdirectivesdata
42
ECE 291 Lecture 1Slide 42 of 45 Assembly primer - directives EXTERN – allows you to declare external procedures so you can use them in your program. SEGMENT – lets you declare the beginning of a memory segment. We’ll talk in detail about memory segments tomorrow. EQU – lets you define pre-processor constants.
43
ECE 291 Lecture 1Slide 43 of 45 Assembly primer - directives ; Let’s declare some external functions EXTERN kbdine, dspout, dspmsg, dosxit ; Let’s begin our code segment SEGMENT code ; Normally variables would go here..start; This is a special label that ; denotes the execution starting ; point in NASM. The next instruction ; after..start will be the first ; to run when you execute your program
44
ECE 291 Lecture 1Slide 44 of 45 Assembly primer - instructions ; Here are some simple instructions mov ax, [VAR1] ; notice the brackets mov dx, STR1 ; notice the not brackets call dspmsg jmp done mov bx, [VAR2] ; this will never happen done
45
ECE 291 Lecture 1Slide 45 of 45 Example SEGMENT code var1db55h; 55 var2db0AAh; AA var3db12h; 12 str1db"Hello", 0; 48 65 6C 6C 6F 00..start moval,[var1]; A0 00 00 movbx,var3; BB 02 00 incbx; 43 moval,[bx]; 8A 07
46
ECE 291 Lecture 1Slide 46 of 45 Assignments Keep working on MP0 and HW0
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.