Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Program: A good illustration of code conversion: Write a program to convert a; 4-digit BCD number into its binary equivalent. BCD number is stored as a; word in memory location known as BCD. The result is to be stored in location HEX.

; ALGORITHM:

; Let us assume the BCD number as 4567

; Put the BCD number into 4, 16bit registers

; Extract the first digit (4 in this case)

; By masking out the other three digits. Since, its place value is 1000.

; So multiply by 3E8h (that is 1000 in hexadecimal) to get 4000 = 0FA0h

; Extract the second digit (5)

; By masking out the other three digits.

; Multiply by 64h (100)

; Add to first digit and get 4500 = 1194h

; Extract the third digit (6)

; By masking out the other three digits (0060)

; Multiply by 0Ah (10)

; Add to first and second digit to get 4560 = 11D0h

; Extract the last digit (7)

; By masking out the other three digits (0007)

; Add the first, second, and third digit to get 4567 = 11D7h

; PORTS    : None used

; REGISTERS: Uses CS, DS, AX, CX, BX, DX

 

THOU             EQU    3E8h    ; 1000 = 3E8h

DATA             SEGMENT

                        BCD    DW     4567h

                        HEX    DW?    ; Storage reserved for result

DATA ENDS

 

CODE SEGMENT

            ASSUME CS: CODE, DS: DATA

START:           MOV AX, DATA; initialise data segment

                        MOV DS, AX; using AX register

                        MOV AX, BCD; get the BCD number AX = 4567

                        MOV BX, AX; copy number into BX; BX = 4567

                        MOV AL, AH; place for upper 2 digits in AX = 4545

                        MOV BH, BL; place for lower 2 digits in BX = 6767

                                                ; split up numbers so that we have one digit 

                                                 ; In each register

                        MOV CL, 04; bit count for rotate

                        ROR AH, CL; digit 1 (MSB) in lower four bits of AH. 

                                                 ; AX = 54 45

                        ROR BH, CL; digit 3 in lower four bits of BH.

; BX = 76 67

                        AND AX, 0F0FH; mask upper four bits of each digit. 

                                                ; AX = 04 05

AND BX, 0F0FH; BX = 06 07

                        MOV CX, AX; copy AX into CX so that can use AX for 

                                                 ; Multiplication CX = 04 05

; CH comprises digit 4 having place value 1000, CL comprises digit 5 

 ; having place value 100, BH comprises digit 6 having place value 10 and 

 ; BL comprises digit 7 having unit place value.

 ; So attain the number as CH × 1000 + CL × 100 + BH × 10 + BL

 

MOV AX, 0000H; zero AH and AL

            ; Now multiply every number by its place 

            ; Value

MOV AL, CH; digit 1 to AL for multiply 

MOV DI, THOU; no immediate multiplication is allowed so 

     ; move thousand to DI

MUL DI; digit 1 (4)*1000

            ; result in DX and AX. Because BCD digit

            ; will not be greater than 9999, the result will 

            ; be in AX only. AX = 4000

 MOV DH, 00H; zero DH

 MOV DL, BL; move BL to DL, so DL = 7

 ADD DX, AX; add AX; so DX = 4007

 MOV AX, 0064h; load value for 100 into AL

 MUL CL; multiply by digit 2 from CL

ADD DX, AX; add to total in DX.  DX now comprises

            ; (7 + 4000 + 500)

 MOV AX, 000Ah; load value of 10 into AL

 MUL BH; multiply by digit 3 in BH

 ADD DX, AX; add to total in DX; DX comprises

            ; (7 + 4000 + 500 +60)

MOV HEX, DX; put result in HEX for return

MOV AX, 4C00h

INT 21h

CODE ENDS

END START

Computer Engineering, Engineering

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

Have any Question?


Related Questions in Computer Engineering

Assignmentsuppose a particular fa called fin has the

Assignment Suppose a particular FA, called FIN, has the property that it had only one final state that was not the start state. During the night, vandals come and switch the + sign with the - sign and reverse the directi ...

Short answer1 what must be installed or prepared to utilize

Short answer: 1. What must be installed or prepared to utilize Windows Remote Management (WinRM) on a Windows Server 2012 R2? 2. What is the PowerShell command to check the status of Windows Remote Management (WinRM)? 3. ...

Tell us about the starbucks corp what it does and makes

Tell us about the Starbucks Corp. what it does, and makes; publically traded or privately owned; how big, etc. 'what' is; it is exposition. Although who is the founders and history of the company; and its sense of social ...

A study investigated whether time perception an indication

A study investigated whether time perception, an indication of a person's ability to concentrate, is impaired during nicotine withdrawal. Smokers were randomly selected and asked to estimate how much time has passed duri ...

Making note of the differences and similarities between a

Making note of the differences and similarities between a non-profit vs a for-profit organization, i.e. the user experience, the style and content what would the differences and simliarities be? I do need something to ba ...

Without doing any math or drawing a graph which is bigger

Without doing any math, or drawing a graph, which is bigger, compensating variation or equivalent variation for a tax? Consider an individual with Cobb-Douglas preferences over some good and all other goods. In what sens ...

Assignmentnbspon information systems audit and

Assignment  on Information Systems audit and controls  Assignment purpose: Elaborate on the different types of control that are applied in a hospital (Preventive, detective and corrective control). Evaluate the logical a ...

System analysis and design1 describe the difference between

System Analysis and Design: 1) Describe the difference between behavioral and structural UML diagrams and provide an example UML diagram type for each and explain how the diagram selected is either behavioral or structur ...

Question suppose a destination computer receives several

Question : Suppose a destination computer receives several packets from a source. How can it be sure that the fragments belonging to a datagram are not mixed with the fragments belonging to another datagram?

You are putting together a trip to kamino to pick up clones

You are putting together a trip to Kamino to pick up clones and need to take a group of droids along to help. You have 11 droids from which to select, and decide to take 4. How many different groups of droids could you t ...

  • 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