Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9574792

Have any Question?


Related Questions in Computer Engineering

Algorithms assignment -task -1 design and implement an

Algorithms Assignment - TASK - 1. Design and implement an efficient algorithm for determining the best route between two given stations in a given rail network. 2. The rail network should be passed to your program as an ...

Sales bar chartwrite a program that asks the user to enter

Sales Bar Chart Write a program that asks the user to enter today's sales for 5 stores. The program should then display a bar graph comparing each store's sales. Create each bar in the bar graph by displaying a row of as ...

Question you recently have been hired as the director of

Question: You recently have been hired as the Director of Systems Administration operations for ViralMedia, a provider of software tools for graphics artists. The company's core product, DigiWorld, runs under Windows and ...

What is 4g and its benefits how fast is your internet

What is 4G and its benefits. How fast is your Internet service supposed to be for stationary users?

Can someone help me do this i need trace route of

Can someone help me do this i need trace route of Massachusetts Use trace route to trace the route from your home or work computer to the website of a university or company on another continent. Show the traceroute outpu ...

The freezing point depression constant forwater is -186 cm

The freezing point depression constant forwater is -1.86 C/m. If 5.00 g Na2SO4 is dissolved in 45.0 g H2O, the freezing point is changed by -3.82 C. Calculate the van't Hofffactor for Na2SO4.

For the following c statement what is the corresponding

For the following C statement, what is the corresponding RISC-V assembly code? Assume that the variables f, g, h, and i are given and could be considered integers as declared in a C program. Use a minimal number of assem ...

Inverse elasticityimagine youve started a new pizza

Inverse Elasticity: Imagine you've started a new pizza restaurant. It costs you about $3 to produce a pizza. Last week you sold 450 pizzas for $12 each. This week you raised your price and sold 300 pizzas for $16 each. W ...

Question include the following items in your paper and

Question: Include the following items in your paper and formal presentation: • A description of the Performance Check and Proficiency Testing targeted for improvement • An As-Is flow chart of the Performance Check and Pr ...

Question suppose three items r s and t are placed in a

Question : Suppose three items R, S, and T are placed in a queue in that order. Then one item is removed from the queue before a fourth item, X is placed in the queue. Then one item is removed from the queue, the items Y ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As