Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Q. Explain Passing Parameters Using Pointers ?

This method overcomes the drawback of using variable names directly in procedure. It uses registers to pass procedure pointers to desired data. Let's explain it more with the help of a program.

Program version 2:

DATA_SEG               SEGMENT

                        BCD DB   25h; Storage for BCD test value

BIN      DB?  ; Storage for binary value

DATA_SEG ENDS

STACK_SEG SEGMENT    STACK

DW 100 DUP (0)    ; Stack of 100 words

TOP_STACK LABEL    WORD

STACK_SEG ENDS

CODE_SEG SEGMENT

ASSUME CS: CODE_SEG, DS: DATA_SEG, SS: STACK_SEG

START:           MOV AX, DATA_SEG   ; Initialize data

MOV DS, AX   ; segment using AX register

MOV AX, STACK_SEG   ; initialize stack

MOV SS, AX; segment. Why stack?

MOV SP, OFFSET TOP_STACK; initialize stack pointer

; Put pointer to BCD storage in SI and DI prior to procedure call.

                        MOV SI, OFFSET BCD   ; SI now points to BCD_IN 

                        MOV DI, OFFSET BIN; DI points BIN_VAL 

                                                            ; (returned value)

                        CALL BCD_BINARY   ; Call the conversion 

                                                            ; Procedure

                        NOP     ; Continue with program

                                                            ; Here

; PROCEDURE     : BCD_BINARY Converts BCD numbers to binary. 

; INPUT     : SI points to location in memory of data

; OUTPUT     : DI points to location in memory for result

; DESTROYS    : Nothing

BCD_BINARY PROC NEAR

PUSHF     ; Save flag register 

PUSH AX; and AX registers

PUSH BX; BX  

PUSH CX; and CX

MOV AL, [SI]   ; Get BCD value from memory

                                     ; For conversion

MOV BL, AL   ; copy it in BL also

AND   BL, 0Fh   ; and mask to get lower 4 digits

AND AL, 0F0h; Separate upper 4 bits in AL

MOV CL, 04   ; initialize counter CL so that upper digit 

ROR AL, CL; in AL can be brought to lower 4 bit 

                                    ; Positions in AL

MOV BH, 0Ah   ; Load 10 in BH

MUL BH; Multiply upper digit in AL by 10

                                    ; The result is stored in AL

ADD AL, BL   ; Add lower BCD digit in BL to result of 

                                    ; Multiplication

; End of conversion, now restore the original values prior to call. All calls will be in 

; reverse order to save above. The result is in AL register.

MOV [DI], AL   ; Store binary value to memory

POP CX; Restore flags and

POP BX; registers

POP AX  

POPF    

RET    

BCD_BINARY ENDP

CODE_SEG ENDS

             END START

Discussion:

In the program written above DI points to BIN and SI points to the BCD. The instruction MOV AL, [SI] copies the byte pointed by SI to AL register. In the same manner MOV [DI], AL transfers result back to memory location which is pointed by DI. 

This scheme allows you to pass procedure pointers to data anywhere in memory. You can pass pointer to individual data element or a group of data elements such as strings and arrays. This scheme is used for parameters passing to BIOS procedures.

Computer Engineering, Engineering

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

Have any Question?


Related Questions in Computer Engineering

What outside resources are available to assist technology

What outside resources are available to assist technology managers in the implementation and maintenance process of IT governances? Outline two resources.

There is a lot of information about how relevant this type

There is a lot of information about how relevant this type of thick clients is still. What are the advantages/disadvantages of these type of connections?

Assignmentanalyze web programs in order to test debug and

Assignment Analyze web programs in order to test, debug, and improve them. Provide your own original example for each of the explanations you provide. Explain how geologation can determine your location. Discuss the accu ...

A cartel is branch of an oligopoly there are still a

A cartel is branch of an oligopoly. There are still a handful of large firms and many smaller firms. For instance, the diamond industry and the petroleum industries are examples are oligopolies. However, the main differe ...

Question using a web browser search for any information

Question: Using a Web browser, search for any information security policies used at your academic institution. Compare them to the ones discussed in this chapter. Are there sections missing? If so, which ones? Whitman, M ...

Scenarioyour friend tim hall is an expert in creating

Scenario Your friend, Tim Hall, is an expert in creating websites. In Hall's opinion, creation of websites is now a simple task using tools such as Adobe Dreamweaver, and therefore, he does not feel the need to learn HTM ...

Describe the definition of ransomware and what is wannacry

Describe the definition of ransomware. And what is wannacry threat?

The project is the process of implementing an information

The project is the process of implementing an information system proposal that provides a specific strategic direction while setting company performance goals and delivering customer value. I need help Identifying 4 diff ...

Why hasnt health care in australia been entirely privatised

Why hasn't health care in Australia been entirely privatised, according to Boxall and Gillespie? Should health care (in Australia) be wholly privatised? Do you think it will be in the future?

What decimal number does the bit pattern 0xc0d40000

What decimal number does the bit pattern 0xC0D40000 represent if it is: A two's complement integer An unsigned integer A floating point number assuming the IEE 754 single precision format Please provide a detailed explan ...

  • 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