ParameterImplementation - Advanced Parameter Implementation...

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

View Full Document Right Arrow Icon
Advanced Parameter Implementation Beta Draft - Do not distribute © 2000, By Randall Hyde Page 1341 Ad vanced Parameter Implementation Chapter Four 4.1 Chapter Overview This chapter discusses adv anced parameter passing techniques in assembly language. Both lo w-le v el and high-le v el syntax appears in this chapter . This chapter discusses the more adv anced pass by v alue/result, pass by result, pass by name, and pass by lazy e v aluation parameter passing mechanisms. This chapter also discusses ho w to pass parameters in a lo w-le v el manner and describes where you can pass such parameters. 4.2 Parameters Although there is a lar ge class of procedures that are totally self-contained, most procedures require some input data and return some data to the caller . P arameters are v alues that you pass to and from a proce - dure. There are man y f acets to parameters. Questions concerning parameters include: where is the data coming from? •h ow do you pass and return data? what is the amount of data to pass? Previous chapters have touched on some of these concepts (see the chapters on beginning and interme- diate procedures as well as the chapter on Mixed Language Programming). This chapter will consider parameters in greater detail and describe their low-level implementation. 4.3 Where You Can Pass Parameters Up to this point we’ v e mainly used the 80x86 hardw are stack to pass parameters. In a fe w e xamples we’ v e used machine re gisters to pass parameters to a procedure. In this section we e xplore se v eral dif ferent places where we can pass parameters. Common places are in registers, in FPU or MMX registers, in global memory locations, on the stack, in the code stream, or in a parameter block referenced via a pointer. Finally, the amount of data has a direct bearing on where and how to pass it. For example, it’s generally a bad idea to pass large arrays or other large data structures by value because the procedure has to copy that data onto the stack when calling the procedure (when passing parameters on the stack). This can be rather slow. Worse, you cannot pass large parameters in certain locations; for example, it is not possible to pass a 16-element int32 array in a register. Some might argue that the only locations you need for parameters are the register and the stack. Since these are the locations that high level languages use, surely they should be sufficient for assembly language programmers. However, one advantage to assembly language programming is that you’re not as constrained as a high level language; this is one of the major reasons why assembly language programs can be more effi- cient than compiled high level language code. Therefore, it’s a good idea to explore different places where we can pass parameters in assembly language.
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 / 34

ParameterImplementation - Advanced Parameter Implementation...

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