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

## 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:

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

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)

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

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 80386 and later

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 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) 9087 11 9087 E911 9087 F1 E911 9087 24F1 E911 9087 46 24F1 E911 9087 0146 24F1 E911 9087 76 0146 24F1 E911 9087 DE76 0146 24F1 E911 9087 33 DE76 0146 24F1 E911 9087 1433 DE76 0146 24F1 E911 9087 55 1433 DE76 0146 24F1 E911 9087 1255 1433 DE76 0146 24F1 E911 9087 FF 1255 1433 DE76 0146 24F1 E911 9087 AB FF 1166 2344 1AAD 09C6 54FE EA22 8097

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)

8086 physical memory 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) 9087 11 9087 E911 9087 F1 E911 9087 24F1 E911 9087 46 24F1 E911 9087 0146 24F1 E911 9087 76 0146 24F1 E911 9087 DE76 0146 24F1 E911 9087 33 DE76 0146 24F1 E911 9087 1433 DE76 0146 24F1 E911 9087 55 1433 DE76 0146 24F1 E911 9087 1255 1433 DE76 0146 24F1 E911 9087 FF 1255 1433 DE76 0146 24F1 E911 9087 AB FF 1166 2344 1AAD 09C6 54FE EA22 8097 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

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

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= 00111000 (38 Hex) and -56 =10111000(B8 Hex)  One’s complement  A negative number is represented by the one’s complement of the absolute value  Example: +56= 00111000 (38 Hex) and -56 =11000111(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= 00111000 (38 Hex) and -56 =11001000(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