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

How do we call one script-fu script from another, he trick to calling scrip...

he trick to calling script-fu-scripts from any more script is to just reference the main define for the script and not to try to use the pdb call. All the scripts in script-fu shar

Define program counter, Define Program Counter(PC) The Program Counter ...

Define Program Counter(PC) The Program Counter holds the address of the next instruction to be read from memory after the current instruction is implemented.

Write a linux terminal shell, Write a Linux terminal shell. Your shell shou...

Write a Linux terminal shell. Your shell should act similar to bash. At a high level, your shell should accomplish the following: 1. Print a prompt when waiting for input from t

Explain usenet and newsgroups, Q. Explain Usenet and Newsgroups? In Int...

Q. Explain Usenet and Newsgroups? In Internet there exists another way to meet people and share information. One such way is through Usenet newsgroups. These are special groups

Explain about binning?, Binning process is very helpful to save space. Perf...

Binning process is very helpful to save space. Performance may differ depending upon the query generated sometimes solution to a query can come within some seconds and sometimes it

Illustrate the working of flip-flops, Q. Illustrate the working of FLIP-FLO...

Q. Illustrate the working of FLIP-FLOPS? A flip-flop is a binary cell that stores 1-bit of information. It itself is a sequential circuit. We know that flip-flop can change its

Can we use write statements in screen fields, Can we use WRITE statements i...

Can we use WRITE statements in screen fields? If not how is data transferred from field data to screen fields? We cannot write field data to the screen using the WRITE stateme

Automated reasoning - first-order logic, Automated Reasoning - first-order ...

Automated Reasoning - first-order logic: The topic known as "Automated Reasoning" in "AI"concentrates mostly on deductive reasoning, here new facts are logically deduced from

Complex micro-controller, The 68Hc11 is actually a complex micro-controller...

The 68Hc11 is actually a complex micro-controller its contains internally RAM, EEPROM, Parallel IO and serial ports, hardware timers and a 8 channel ADC.  The internal structure is

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