MemoryAccessandOrg - Memory Access and Organization Memory...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Memory Access and Organization Beta Draft - Do not distribute © 2001, By Randall Hyde Page 157 Memor y Access and Organization Chapter Two 2.1 Chapter Overview In earlier chapters you sa w ho w to declare and access simple v ariables in an assembly language pro - gram. In this chapter you will learn ho w the 80x86 CPUs actually access memory (e.g., v ariables). Y ou will also learn ho w to ef fi ciently or g anize your v ariable declarations so the CPU can access them f aster . In this chapter you will also learn about the 80x86 stack and ho w to manipulate data on the stack with some 80x86 instructions this chapter introduces. Finally , you will learn about dynamic memory allocation. 2.2 The 80x86 Addressing Modes The 80x86 processors let you access memory in man y dif ferent w ays. Until no w , you’ v e only seen a single w ay to access a v ariable, the so-called displacement-only addressing mode that you can use to access scalar v ariables. No w it’ s time to look at the man y dif ferent w ays that you can access memory on the 80x86. The 80x86 memory addr essing modes pro vide fl e xible access to memory , allo wing you to easily access v ariables, arrays, records, pointers, and other comple x data types. Mastery of the 80x86 addressing modes is the fi rst step to w ards mastering 80x86 assembly language. When Intel designed the original 8086 processor , the y pro vided it with a fl e xible, though limited, set of memory addressing modes. Intel added se v eral ne w addressing modes when it introduced the 80386 micro - processor . Note that the 80386 retained all the modes of the pre vious processors. Ho we v er , in 32-bit en vi - ronments lik e W in32, BeOS, and Linux, these earlier addressing modes are not v ery useful; indeed, HLA doesn’ t e v en support the use of these older , 16-bit only , addressing modes. F ortunately , an ything you can do with the older addressing modes can be done with the ne w addressing modes as well (e v en better , as a matter of f act). Therefore, you w on’ t need to bother learning the old 16-bit addressing modes on today’ s high-per - formance processors. Do k eep in mind, ho we v er , that if you intend to w ork under MS-DOS or some other 16-bit operating system, you will need to study up on those old addressing modes. 2.2.1 80x86 Register Addressing Modes Most 80x86 instructions can operate on the 80x86’ s general purpose re gister set. By specifying the name of the re gister as an operand to the instruction, you may access the contents of that re gister . Consider the 80x86 MO V (mo v e) instruction : mov( source, destination ); This instruction copies the data from the sour ce operand to the destination operand. The eight-bit, 16-bit, and 32-bit re gisters are certainly v alid operands for this instruction. The only restriction is that both operands must be the same size. No w let’ s look at some actual 80x86 MO V instructions: mov( bx, ax ); // Copies the value from BX into AX mov( al, dl ); // Copies the value from AL into DL mov( edx, esi ); // Copies the value from EDX into ESI mov( bp, sp ); // Copies the value from BP into SP mov( cl, dh );
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/08/2011 for the course CS 101 taught by Professor Jitenderkumarchhabra during the Summer '11 term at National Institute of Technology, Calicut.

Page1 / 46

MemoryAccessandOrg - Memory Access and Organization Memory...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online