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 of keyboards, Q. Interfacing of keyboards? The keyboard emp...

Q. Interfacing of keyboards? The keyboard employs a special Input/output port which is similar to a serial port however doesn't explicitly follow the RS-232 serial port standar

What is event-driven control, What is event-driven control? Control res...

What is event-driven control? Control resides within a dispatcher or monitors that language, subsystem or OS provider. Developers attach application process to events and dispa

For what purpose Karnaugh map is used, Karnaugh map is used for the purpose...

Karnaugh map is used for the purpose of ? Ans. Karnaugh map is used for, to minimize the terms in a Boolean expression.

What is algorithm design technique, What is Algorithm Design Technique? ...

What is Algorithm Design Technique? An  algorithm  design  method  is  a  general  approach  to  solving  problems  algorithmically  that  is applicable to a variety of proble

Explain naming convention in arrays, Explanation Arrays in many programm...

Explanation Arrays in many programming-languages generally show a fixed list of values (e.g. a list of lastnames). Though within SQABasic the size for an array can either be fix

Why a function should have at least one input, Why a function should have a...

Why a function should have at least one input? There is no strong reason for this in verilog. I think this restriction isn't removed fin SystemVerilog. Some requirements where

What is unique port number, Q. What is Unique port number? A port is an...

Q. What is Unique port number? A port is an extra 16-bit number which uniquely identifies particular service on any given machine on Internet. Port numbers are 16 bit wide, con

What is fork swap, What is Fork swap? "Fork ()" is a system call to mak...

What is Fork swap? "Fork ()" is a system call to make a child process. When the parent process calls "fork()" system call, the child process is formed and if there is short of

Asp.net, in asp project is i have to crate database every time when i move ...

in asp project is i have to crate database every time when i move my project on different server

Communication between memory and the processor, How are instructions sent b...

How are instructions sent between memory and the processor? Both the instruction pointer (IP) and program counter (PC) utilized to holds the memory address of the next inst

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