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

., advantages and disadvantages of a header node

advantages and disadvantages of a header node

Determine the handles data rate of broad band isdn, Broad Band ISDN handles...

Broad Band ISDN handles data rate of about (A) 64 kbps                                      (B) 100 mbps (C) 5.4 mbps                                    (D) 2.048 mbps

Interpreted language and a compiled language, Difference between an interpr...

Difference between an interpreted language and a compiled language? Ans) A compiled language is written and then run by a compiler which checks its syntax and compresses it int

Xml can play when dynamically generating html pages , Explain the role that...

Explain the role that XML can play when dynamically generating HTML pages from a relational database? Ans) Even if student has never participated in a project involving this typ

What is critical section problem, What is critical section problem?  Co...

What is critical section problem?  Consider a system having of 'n' processes. Each process has segment of code known as a critical section, in which the process may be changing

What are the stages of data mining, What are the stages of data mining? ...

What are the stages of data mining? The procedure of data mining comprises three stages, which are given below: a) The initial exploration b) Model building c) Deploym

Explain about instruction cycle, Q. Explain about Instruction Cycle? Th...

Q. Explain about Instruction Cycle? The instruction cycle for this provided machine comprises four cycles. Presume a 2-bit instruction cycle code (ICC). The ICC can represent t

Network, Give an intuitive explanation of why the maximum throughput, for s...

Give an intuitive explanation of why the maximum throughput, for small beta, is approximately the same for CSMA slotted Aloha and FCFS splitting with CSMA. Show the optimal expecte

Give explanation of user datagram protocol, Explain UDP (User Datagram Prot...

Explain UDP (User Datagram Protocol). UDP utilizes a connectionless communication paradigm. It is an application of using UDP doesn't require preestablishing a connection befor

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