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

Interfacing assembly language routines, By now you can write procedures bot...

By now you can write procedures both internal andexternal and pass parameters particularly through stack.Let's us use these concepts to see how assembly language can be interfaced

Write shorts notes on remote procedure call, Write shorts notes on Remote P...

Write shorts notes on Remote Procedure Call (RPC) The facility whihc was created to help the programmers write client server software is termed as Remote Procedure Call. Within

Write a program to echo the string, Write a program to echo the string 'Hel...

Write a program to echo the string 'Hello' to the serial channel (SCI) using the protocol of baud rate 9600,8 bits , no parity and 1 stop bit  Consider the baud register as show

Kruskal''s, Image Segmentation with Minimum Spanning Forests (50 points). D...

Image Segmentation with Minimum Spanning Forests (50 points). Develop a Python 3 implementation of the image segmentation algorithm that we explored on the first day of class. Your

Bangla numeral recognition using multilayer feed forward, Assignment 4: Han...

Assignment 4: Handwritten Bangla Numeral Recognition using Multilayer Feed Forward Neural Network. In this assignment, you will design a multi layer feed forward neural network

What does "wire_read: unexpected eof" mean in gimp, This error message shou...

This error message should say something like "the plug-in (or the major GIMP app) I was talking to has existed before returning any results, so I suppose that it has crashed."

What is the cih, CIH, also known  as Chernobyl or Spacefiller, is a Microso...

CIH, also known  as Chernobyl or Spacefiller, is a Microsoft Windows computer virus which first emerged in 1998. It is one of the most damaging viruses, overwriting critical inform

What are the reasons behind using intranet, Reason behind using Intranet ...

Reason behind using Intranet The major reasons for doing this include: -  Safer as there is less chance of external viruses or hacking -  It's possible to prevent employe

Write Your Message!

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