Rules for calling assembly subroutines from, Computer Engineering

Assignment Help:

Q. Rules for calling assembly subroutines from?

The rules for calling assembly subroutines from C are:

(i)  Memory model: The calling program and called assembly programs should be defined with the same memory model. One of the most common convention which makes NEAR calls is .MODEL SMALL, C.

(ii) The naming convention generally involve an underscore (_) character preceding the segment or function name. However this underscore is not used while making a call from C function. Please be careful about Case-sensitivity.

You should give a specific segment name to code segment of your assembly language subroutine. The name differs from compiler to compiler. Microsoft C and Turbo C need the code segment name to be_TEXT or a segment name with suffix_TEXT. Also it needs the segment name _DATA for data segment.

(iii)  Arguments from C to assembly language are passed through stack.

For illustration a function call in C:

function_name (arg1, arg2, ..., argn) ;

Would push the value of every argument on the stack in reverse order. Which is, the argument argn is pushed first and arg1 is pushed last on stack. A pointer or a value to a variable can also be passed on the stack. Because the stack in 8086 is a word stack thuspointers and values are stored as words on stack or multiples of the word size in case value exceeds 16 bits.

(iv) Youmust remember to save any special purpose registers (like CS, DS, SS, ES, BP, SI or DI) which may be modified by the assembly language routine. If you fail to save them then you might have unexplainable / undesirable consequences when control is returned to C program. Though there is no need to save AX, BX, CX or DX registers as they are considered volatile.

(v)   Please note the compatibility of data-types:

            char Byte (DB)

            int Word (DW)

            long Double Word (DD)

(vi) Returned value: The called assembly routine uses the followed registers for returned values:

            char   AL

            Near/ int   AX

            Far/ long DX: AX


Related Discussions:- Rules for calling assembly subroutines from

Internal conditioning, types of internal conditioning with explanations and...

types of internal conditioning with explanations and examples

Explain the structure of a c program, Explain the Structure of a C Program?...

Explain the Structure of a C Program? Each C program consists of one or more functions one of the which must be main(). A function name is forever followed by a pair of parenth

Defining data definition, Defining Types of Data ? The subsequent forma...

Defining Types of Data ? The subsequent format is used for defining data definition:  Format for data definition:  {Name}  Name -   a program references the data

Background and foreground colors can be interchanged, Background and foregr...

Background and foreground colors can be interchanged using the command?? Format Inverse command.

Create a system dynamic model, Easter Island is a small island (about 150 s...

Easter Island is a small island (about 150 square miles in area) in the Pacific Ocean about 2,000 miles from South America. In about 400 AD there was a small population of settlers

Subsequent step in karnaugh map, The subsequent step in Karnaugh map is to ...

The subsequent step in Karnaugh map is to map truth table in the map. Mapping is done by putting a 1 in respective square belonging to 1 value in truth table. This mapped map is us

What is application analysis, What is application analysis? The purpose...

What is application analysis? The purpose of analysis is to understand the problem so that a correct design can be constructed. The application analysis focuses on major applic

What is an accessor in c++, An accessor is a class operation that does not ...

An accessor is a class operation that does not change the state of an object in C++. The access or functions require to be declared as const operations

Explain significance of init() & destroy( ) method of applet, Explain the s...

Explain the significance of init() and destroy( ) methods of an applet? Also explain two ways of invoking an applet. The init( ) method is utilized for fundamental initializati

What is gimp?, The GNU Image Manipulation Program, or GIMP, is a raster gra...

The GNU Image Manipulation Program, or GIMP, is a raster graphics editor application with some support for vector graphics. GIMP is used to process digital graphics & photographs.

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd