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

Operations from events, Operations from events During analysis, events...

Operations from events During analysis, events which are sent to target objects. An operation on these object are presented as labels on transitions and should not be explicit

Show the steps of execution of instructions, Q. Show the steps of execution...

Q. Show the steps of execution of instructions? Fetch First Instruction into CPU: Step 1: Find/calculate the address of first instruction in memory. In this machine illust

Effect of tree supply on death rate, The effect of tree supply on death ra...

The effect of tree supply on death rate depends upon a ratio comparing the number of trees that are actually available per person per year to the desired number of trees per pers

Explain circuit switching versus packet switching, Explain difference of Ci...

Explain difference of Circuit switching versus Packet switching. Within circuit switching an end-to-end path is to be establishing before any data can be sent. Previously a con

What are types of applets, There are two different parts of applets. Truste...

There are two different parts of applets. Trusted Applets and Untrusted applets. Trusted Applets are applets with predefined security and Untrusted Applets are applets without any

Conversioin of the decimal number 82.67 into octal number , Conversioin of ...

Conversioin of the decimal number 82.67 into Octal number ? Ans. The binary equivalent is (1010010.10101011) 2 of decimal number 82.67. After that convert each 3-bit binary in

Biscuit factory circuit, Biscuits move on a conveyer through an oven where ...

Biscuits move on a conveyer through an oven where they are cooked.   Two sensors, H and C, measure the temperature of the oven, H = 1 if the oven is too hot and C = 1 if the ove

Describe characteristics needed for an e-commerce server, Describe the addi...

Describe the additional characteristics needed for an e-commerce server? E-commerce services need dynamic configuration abilities and seasonal and every day service configurat

What is DRAM and what do you understand by DRAM refreshing, What is DRAM? ...

What is DRAM? What do you understand by DRAM refreshing? With the help of a block diagram, demonstrate how DRAM can be interfaced to a microprocessor. Dynamic RAM (DRAM) is bas

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