ConstsVarsAndDataTypes - Constants, Variables, and Data...

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

View Full Document Right Arrow Icon
Constants, Variables, and Data Types Beta Draft - Do not distribute © 2001, By Randall Hyde Page 393 Constants, Variables, and Data Types Chapter One V olume One discussed the basic format for data in memory . V olume T w o co v ered ho w a computer sys - tem ph ysically or g anizes that data. This chapter fi nishes this discussion by connecting the concept of data r epr esentation to its actual ph ysical representation. As the title implies, this chapter concerns itself with three main topics: constants, v ariables and data structures. This chapter does not assume that you’ v e had a formal course in data structures, though such e xperience w ould be useful. 1.1 Chapter Overview This chapter discusses ho w to declare and use constants, scalar v ariables, inte gers, reals, data types, pointers, arrays, and structures. Y ou must master these subjects before going on to the ne xt chapter . Declar - ing and accessing arrays, in particular , seems to present a multitude of problems to be ginning assembly lan - guage programmers. Ho we v er , the rest of this te xt depends on your understanding of these data structures and their memory representation. Do not try to skim o v er this material with the e xpectation that you will pick it up as you need it later . Y ou will need it right a w ay and trying to learn this material along with later material will only confuse you more. 1.2 Some Additional Instructions: INTMUL, BOUND, INTO This chapter introduces arrays and other concepts that will require the e xpansion of your 80x86 instruc - tion set kno wledge. In particular , you will need to learn ho w to multiply tw o v alues; hence the fi rst instruc - tion we will look at is the intmul (inte ger multiply) instruction. Another common task when accessing arrays is to check to see if an array inde x is within bounds. The 80x86 bound instruction pro vides a con v e - nient w ay to check a re gister’ s v alue to see if it is within some range. Finally , the into (interrupt on o v erfl o w) instruction pro vides a quick check for signed arithmetic o v erfl o w . Although into isn’ t really necessary for array (or other data type access), its function is v ery similar to bound , hence the presentation at this point. The intmul instruction tak es one of the follo wing forms: // The following compute destreg = destreg * constant intmul( constant, destreg 16 ); 32 // The following compute dest = src * constant constant, srcreg , destreg constant, srcmem // The following compute dest = dest * src intmul( srcreg 16 16 intmul( srcmem 16 16 32 32 32 32 Note that the syntax of the intmul instruction is different than the add and sub instructions. In particular, note that the destination operand must be a register ( add and sub both allow a memory operand as a destina- tion). Also note that intmul allows three operands when the first operand is a constant. Another important
Background image of page 1

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

View Full DocumentRight Arrow Icon
Chapter One Volume Three Page 394 © 2001, By Randall Hyde Beta Draft - Do not distribute difference is that the intmul instruction only allows 16-bit and 32-bit operands; it does not allow eight-bit operands.
Background image of page 2
Image of page 3
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 / 26

ConstsVarsAndDataTypes - Constants, Variables, and Data...

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

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