Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 2 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.

Similar presentations


Presentation on theme: "Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 2 Department of Computer Science and Software Engineering University of Wisconsin-Platteville."— Presentation transcript:

1 Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 2 Department of Computer Science and Software Engineering University of Wisconsin-Platteville

2 General-Purpose Registers  AX(accumulator) often holds the temporary result after an arithmetic and logic operation (also addressed as EAX, AH, or AL)  BX (base) often holds the base (offset) address of data located in the memory (also addressed as EBX, BX, BL)  CX (count) contains the count for certain instructions such as shift count (CL) for shifts and a counter (CX or ECX) with the LOOP instruction (also addressed as ECX, CH, or CL)  DX (data) holds  the most significant part of the product after a 16- or 32-bit multiplication,  the most significant part of the dividend before a division, and  I/O port number for a variable I/O instruction (also addressed as EDX, DH, DL)

3 Pointer and Index Registers  SP (stack pointer) used to address data in a LIFO (last-in, first- out) stack memory, most often used when  the PUSH and POP instructions are executed  a subroutine is CALLed or RETurned within a program  Don’t ever mess with this directly  BP (base pointer) often used to address an array of data in the stack memory  SI (source index) used to address source data indirectly for use with the string instructions  DI (destination index) normally used to address destination data indirectly for use with the string instructions  IP (instruction pointer) always used to address the next instruction executed by the microprocessor

4 Logical vs. physical memory  Logical memory is the “view” of memory seen by the programmer  A large byte-addressable array of bytes  We can read/write bytes, words or doublewords  Physical memory  The physical organization of memory cells, which is not “visible” to the programmer  The unit of access to physical memory is equal to the width of the data bus  E.g. 16 bits in 8086, 32 bits in and later

5 8086 physical memory Read Data from address 0:  Read a byte: result=FF  Read a word: result=ABFF  Read a doubleword: result=6611ABFF AB 1 FF DE 0146 F124 E B D F A C E Odd BankEven Bank Data Bus (15:8)Data Bus (7:0) E F1 E F1 E F1 E F1 E F1 E DE F1 E DE F1 E DE F1 E DE F1 E DE F1 E FF DE F1 E AB FF AAD 09C6 54FE EA

6 x86 byte ordering  Memory locations 0 and 1 contain FF and AB…  But a word access from address 0 returns ABFF  x86 uses “little endian” byte order  The requested address (0) points to the lower order byte of the result  The higher order byte of the result is taken from the next higher sequential address (1)

7 8086 physical memory AB 1 FF DE 0146 F124 E B D F A C E Odd BankEven Bank Data Bus (15:8)Data Bus (7:0) E F1 E F1 E F1 E F1 E F1 E DE F1 E DE F1 E DE F1 E DE F1 E DE F1 E FF DE F1 E AB FF AAD 09C6 54FE EA Read a word from address 0:  data(15:8)=AB,data(7:0)=FF  This is an aligned memory access Read a word from address 1:  It is a valid memory access  Result should be 11AB  But the bytes in the data bus are not aligned data(15:8)=AB,data(7:0)=11

8 Integer Representation  Three general techniques that have been used to represent signed integers in computer memory  Signed magnitude  One’s complement  Two’s complement  All of above methods use the most significant bit of the integer as a sign bit  Signed byte can be used to represent the decimal numbers −128 to +127  Signed word can be used to represent the decimal numbers −32, 768 to +32, 767  Signed double word can be used to represent the decimal numbers −2 billion to +2 billion approximately

9 Integer Representation (cont.)  Signed magnitude  It represents the integer as two parts. The first part is the sign bit and the second is the magnitude of the integer  Example: +56= (38 Hex) and -56 = (B8 Hex)  One’s complement  A negative number is represented by the one’s complement of the absolute value  Example: +56= (38 Hex) and -56 = (C7 Hex)  Two’s complement (used by x86 and modern computers)  A negative number is represented by the two’s complement of the absolute value (ignore the carry bit)  Example: +56= (38 Hex) and -56 = (C8 Hex)


Download ppt "Computer Architecture and Operating Systems CS 3230 :Assembly Section Lecture 2 Department of Computer Science and Software Engineering University of Wisconsin-Platteville."

Similar presentations


Ads by Google