Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Write a procedure which divides a 32-bit number by a 16-bit number. The procedure must be general which is it's defined in one module and can be called from another assembly module.

; REGISTERS   : Uses CS, DS, SS, AX, SP, BX, CX

; PROCEDURES: Far Procedure SMART_DIV

DATA_SEG SEGMENT   WORD PUBLIC

     DIVIDEND DW 2345h, 89AB; Dividend = 

    ; 89AB2345H

     DIVISOR DW 5678H; 16-bit divisor

     MESSAGE DB 'INVALID DIVIDE', '$'

DATA_SEG ENDS    

 

MORE_DATA   SEGMENT     WORD

                                 QUOTIENT   DW   2 DUP (0)

                                 REMAINDER   DW      0 

MORE_DATA ENDS

STACK_SEG   SEGMENT   STACK

                                 DW   100 DUP (0); Stack of 100 words

                                 TOP - STACK   LABEL WORD; top of stack pointer

STACK_SEG   ENDS

PUBLIC       DIVISOR

PROCEDURES SEGMENT   PUBLIC                    ; SMART_DIVis declared as an

EXTRN SMART_DIV: FAR                                    ; external label in procedure 

                                                                                    ; Segment of type FAR

PROCEDURES ENDS

; declare the code segment as PUBLIC so that it can be merged with other PUBLIC

; Segments

CODE_SEG SEGMENT WORD   PUBLIC

            ASSUME CS: CODE, DS: DATA_SEG, SS: STACK SEG

            START:  MOV AX, DATA_SEG; Initialize data segment

            MOV DS, AX   ; using AX register

            MOV AX, STACK_SEG   ; Initialize stack segment

            MOV SS, AX; using AX register

            MOV SP, OFFSET TOP_STACK; Initialize stack pointer

            MOV AX, DIVIDEND   ; Load low word of

                                                ; Dividend

            MOV   DX DIVIDEND + 2; Load high word of

                                                ; Dividend

            MOV CX, DIVISOR   ; Load divisor

            CALL SMART_DIV   

; This procedure returns Quotient in the DX: AX pair and Remainder in CX register. 

; Carry bit is set if result is invalid.

                                 JNC SAVE_ALL; IF carry = 0, result valid

                                 JMP STOP          ; ELSE carry set, don't

                                                             ; save result

                                 ASSUME DS: MORE_DATA   ; Change data segment

SAVE_ALL:  PUSH DS   ; Save old DS 

MOV BX, MORE_DATA          ; Load new data segment

MOV DS, BX                              ; register

MOV QUOTIENT, AX              ; Store low word of

                                                     ; Quotient

MOV QUOTIENT + 2, DX   ; Store high word of

                                                     ; Quotient

MOV REMAINDER, CX   ; Store remainder

ASSUME DS: DATA_SEG  

POP   DS; Restore initial DS

JMP ENDING

STOP:                       MOV DL, OFFSET MESSAGE

                                 MOV AX, AH 09H

                                 INT   21H  

ENDING:   NOP

CODE_SEG ENDS

                                 END START

Computer Engineering, Engineering

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

Have any Question?


Related Questions in Computer Engineering

Question research microwave serices and report on what

Question : Research microwave serices and report on what kinds of applications can be supported, what equipment will be necessary, where the equipment will be located, and what services these companies that offers.

Recall that the cpu execution time of a program is given by

Recall that the CPU execution time of a program is given by CPU time = IC times CPI times T. Suppose two different processors P 1 and P 2 execute the same number of instructions for a given benchmark. If P 1 is a 2 Ghz p ...

If the probability that an individual suffers from a bad

If the probability that an individual suffers from a bad reaction from an injection of a given serum is 0.001, determine the probability that out of 2000 individuals (a) exactly 3, (b) more than 2 individuals will suffer ...

In relation to internet connectivity both you and the

In relation to Internet connectivity, both you and the chemists at Plains Research are concerned about security. What network device or devices can be used to address the concern about security?

Question capstone project - informationalthis part of the

Question: Capstone Project - Informational This part of the assignment is NOT FOR GRADING this week. This part of the assignment is to contribute to the capstone project and also to show the instructor that progress is b ...

State the required answer precisely and then provide proper

State the required answer precisely and then provide proper explanation. It is not enough to provide one- word or one-line answers. Provide examples and state precisely the meaning of the following features supported by ...

Suppose a lawn care company can install either mulch or

Suppose a lawn care company can install either mulch or pine straw for flowerbeds of their residential customers. A workday typically runs 12.5 hours (or 750 minutes) and the company can install mulch in 30 minutes and p ...

The sample distribution on individual iq scores raw scores

The sample distribution on individual IQ scores (raw scores) has a sample mean of 100 and a standard deviation of 16. What proportion of the sample mean will fall at or above a mean of 102.56? Round the answers to no mor ...

What pieces of hardware and software do the collision

What pieces of hardware and software do the collision detection?

University bookstores order books that instructors adopt

University bookstores order books that instructors adopt for the courses. The number of copies order matches the projected the demand. However, at the end of the semester the bookstore has too many copies on hand and mus ...

  • 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