Download presentation
Presentation is loading. Please wait.
Published byRalph Riley Modified over 9 years ago
1
CEG 320/520: Computer Organization and Assembly Language Programming1 CEG 320/520 Computer Organization and Assembly Language Programming
2
CEG 320/520: Computer Organization and Assembly Language Programming2 Assembly Language Programming CPU –ALU –Registers –Control logic Memory –Organization –Cache –Virtual Memory I/O –Organization of an I/O device –Polled, Interrupt driven, DMA Computer Organization CPU Memory I/O High level code Assembly code Compiler Machine code Assembler CPU We will write assembly language code, and assemble it into machine code. We will examine in detail how the CPU executes that code. &
3
CEG 320/520: Computer Organization and Assembly Language Programming3 Computer Organization Very Brief Introduction
4
CEG 320/520: Computer Organization and Assembly Language Programming4 Intro to Computer Organization: Goals General –Basic types of computer operations Instruction cycle –Fetch-execute-store cycle Data Representation –Binary, hex, 2’s complement Memory organization –Big Endian vs Little Endian –BYTE, WORD, LONG WORD –How memory is addressed in the 68000 Registers –Defining feature of a Von Neumann machine –Register size and how bits are numbered in the 68000 Reading: –General Computer Organization: HVZ Chapter 1, 7.1, 7.2 –Memory: HVZ Chapter 2.2
5
CEG 320/520: Computer Organization and Assembly Language Programming5 Intro to Computer Organization: Von Neumann The Von Neumann model of computer processing –Stored Program: Program and data are both stored as sequences of bits in the computer’s memory. –The program is executed one instruction at a time under the direction of the control unit. The instruction-execution cycle –Instruction Fetch (IF) stage Get next instruction from the memory address in the program counter (PC) Place the new instruction in the Instruction Register (IR) Increment the PC to the next instruction address –Execute operation (EX) stage Execute the operation specified by the machine instruction in the IR –Branch instructions may update the PC –Repeat
6
CEG 320/520: Computer Organization and Assembly Language Programming6 Intro to Computer Organization: Instructions Machine-level instructions either move data and/or addresses, or do simple math or logic operations on data and/or addresses. –Data and/or addresses can be moved to or from memory, and in and out of CPU registers. –Addresses are really just a special type of data. There are three basic types of computer instructions –Arithmetic Instructions: operate on values stored in memory or registers Arithmetic, Shift, and Logic instructions –Move Instructions: move data between memory and registers Load/Store instructions Move/Copy portions of memory –Branch Instructions: select one of two possible next instructions to execute Branch on condition, Unconditional branch (Jump)
7
CEG 320/520: Computer Organization and Assembly Language Programming7 Intro to Computer Organization: Data Representation Binary –Any unsigned whole number can be represented in base 2 (binary) as a string of 1’s and 0’s. –A binary number can be thought of as a series of “bits” (binary digits), each of which can have the value 1 or 0: 4-bit example: 0101 2 = 5 10 –Range of representation N-bit binary numbers represent the range of numbers from 0 … 2 n-1 4-bit binary numbers represent 0 … +16. –There are 10 kinds of people in the world: those who understand binary and those who don’t.
8
CEG 320/520: Computer Organization and Assembly Language Programming8 Intro to Computer Organization: Data Representation Hexadecimal –Easier and more compact for humans to view, write, and understand. –There is a one-to one mapping from binary to hexadecimal (hex), where each 4 bits represents one hexadecimal digit. Example: 010100111011 2 = 53B 16 –For this reason, computer memory and register contents are usually shown in hex. Note: base is generally indicated only when it is not obvious from context.
9
CEG 320/520: Computer Organization and Assembly Language Programming9 Intro to Computer Organization: Data Representation 2’s Complement - Signed number representation –Positive numbers: Sign (leftmost) bit = 0. Magnitude: binary representation of number. –Negative numbers: Sign (leftmost) bit = 1. Magnitude: complement binary representation to form 1’s complement, then add 1. –Range of Representation: For n-bit 2’s complement, range of numbers that may be represented is -2 n-1 … 2 n-1 – 1. 4-bit 2’s complement represents numbers -8 … +7.
10
CEG 320/520: Computer Organization and Assembly Language Programming10 Intro to Computer Organization: Data Representation 2’s Complement - Why? –Only one representation for ‘0’ Signed magnitude: 00 (positive 0) or 10 (negative 0) 1’s complement: 00 (positive 0) or 10 (negative 0) 2’s complement: 00 –Arithmetic is simplified Addition is performed identically for positive and negative numbers Carry generated by adding sign bits can be thrown away
11
CEG 320/520: Computer Organization and Assembly Language Programming11 Intro to Computer Organization: Data Representation 2’s Complement – Hexadecimal –Converting a 2’s complement number to a hexadecimal representation merely involves breaking up the 2’s complement representation into 4-bit binary chunks, and converting those to hexadecimal. –Don’t get fancy! Don’t convert the 2’s complement to unsigned binary then convert that to hexadecimal! You will get the wrong value. 2’s complement: 1100 00100100 1010 1001 Hexadecimal: C 28 A 9
12
CEG 320/520: Computer Organization and Assembly Language Programming12 Intro to Computer Organization: Memory Most basic operation: getting information from memory to the CPU and back. Conceptually, computer memory is simply a collection of locations where information can be stored as bits. Most often, memory is byte-addressable. This means it is divided into bytes (8-bit quantities) each identified by a unique address. Generally, bytes are addressed sequentially, beginning with address 0.
13
CEG 320/520: Computer Organization and Assembly Language Programming13 Intro to Computer Organization: Memory Each byte has its own address.
14
CEG 320/520: Computer Organization and Assembly Language Programming14 Intro to Computer Organization: Memory A WORD is the basic unit of information –Most CPU operations take place using words –The word-length is the amount of information retrieved in a single memory access. It is usually easiest to think of memory as a collection of words Pentium – 32-bit words Motorola 68000 – 16-bit words 68030 – 32-bit words Dec Alpha – 64-bit words
15
CEG 320/520: Computer Organization and Assembly Language Programming15 Intro to Computer Organization: Memory Note that 16-bit word addresses are all divisible by 2. The word at address n contains the bytes at addresses n and n+1. –Big Endian addressing: left byte is considered at address n. (makes sense to look at) –Little Endian: the opposite is true. (easy to get the low-order byte of a word)
16
CEG 320/520: Computer Organization and Assembly Language Programming16 Intro to Computer Organization: Memory The Motorola 68000 memory addressing: –Memory is divided into 16-bit words, each having a unique even address (0,2,4…). –Bytes are addressed using the Big Endian scheme. –A long word is a 32-bit value which can begin at any word address.
17
CEG 320/520: Computer Organization and Assembly Language Programming17 Intro to Computer Organization: Registers Registers are temporary storage locations –Much faster than memory (10–100×) –Inside the CPU, gated directly to components –Special registers: program counter (PC), instruction register (IR), memory address register (MAR), memory data register (MDR) Data is typically transferred to a register before operating on it, then results are stored back to memory. Motorola 68000 –Eight data registers named D0-D7 –Eight address registers named A0-A7 A7 is a special register - the stack pointer (SP) –Program Counter (PC) –Status Register (SR)
18
CEG 320/520: Computer Organization and Assembly Language Programming18 Data registers are 32 bits wide. –Operations on data registers can be performed on BYTE, WORD, or LONG word values. Registers are accessed like Little Endian memory –WORD operations use only bits 15-0. –BYTE operations use only bits 7-0. Address registers are 32 bits wide. –Only WORD and LONG word operations can be performed on address registers. –The 68000 uses just 24-bits to address memory, but we will always consider addresses to be LONG words. 31 30 29 28 27 26 25 … 15 14 13 12 11 10 … 7 6 5 4 3 2 1 0 Intro to Computer Organization: Registers
19
CEG 320/520: Computer Organization and Assembly Language Programming19 Intro to Computer Organization: You Should Know General –Basic types of computer operations Instruction cycle –Fetch-execute-store cycle Data Representation –Binary, hex, 2’s complement Memory organization –Big Endian vs Little Endian –BYTE, WORD, LONG WORD –How memory is addressed in the 68000 Registers –Defining feature of a Von Neumann machine –Register size and how bits are numbered in the 68000 Reading: –General Computer Organization: HVZ Chapter 1, 7.1, 7.2 –Memory: HVZ Chapter 2.2
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.