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

Measure of speed in page or line printer, Q. Measure of speed in Page or li...

Q. Measure of speed in Page or line Printer? Measure of speed relies on whether the printer is a Page Printer or Line. Printer: Let's understand these:  Line Printer:

How do you perform functional testing under load, Functionality under load ...

Functionality under load can be tested by running various Vusers concurrently. By enhancing the amount of Vusers, we can verify how much load the server can sustain.

Elaborate the various steps in performing a mail merge, COMPUTER FUNDAMENTA...

COMPUTER FUNDAMENTALS 1. Elaborate the various steps in performing a Mail Merge. Perform one mail merge operation for sending invitation for a conference which is being conduc

What does realized mean, Realized mean that the component has been painted ...

Realized mean that the component has been painted on screen or that is prepared to be painted. Realization can take place by invoking any of these methods. setVisible(true), show()

Era of first generation computers, Q. Era of first generation computers? ...

Q. Era of first generation computers? The trends that were encountered at the time of the era of first generation computers were: Centralized control in a single CPU (al

Working of fully parallel associative processor, Q. Working of Fully Parall...

Q. Working of Fully Parallel Associative Processor? Fully Parallel Associative Processor: This processor accepts the bit parallel memory organisation. There are 2 kinds of this

Explain about the term- video conferencing, Video Conferencing Video co...

Video Conferencing Video conferencing continues to grow in popularity. Why is this? Some reasons are listed below: - Communication links are now much faster thus sound quali

Tightly coupled system- shared memory system, Tightly Coupled System- Share...

Tightly Coupled System- Shared Memory System Shared memory multiprocessorshas has following description: Every processor commune through a shared global memory. For

What are value types and reference types, What are value types and referenc...

What are value types and reference types?  Value type - bool, byte, chat, decimal, double, enum, float, int, long, sbyte, short, strut, uint, ulong, ushort. Value types are sto

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