Show the code conversion with example, Computer Engineering

Assignment Help:

Q. Show the Code Conversion with example?

The conversion of data from one form to another is required. Consequently we will discuss an illustration for converting a hexadecimal digit attained in ASCII form to binary form.

Program:

; This program converts an ASCII input to equivalent hex digit which it represents.

; So valid ASCII digits are 0 to 9, A to F and program presumes that the 

; ASCII digit is read from a location in memory known as ASCII. The hex result is 

; left in the AL. Because the program converts just one digit number the AL is 

; Sufficient for the results. Result in AL is made FF if character in ASCII 

; is not proper hex digit.

; ALGORITHM 

; IF number <30h THEN error

; ELSE

; IF number <3Ah THEN Subtract 30h (it's a number 0-9)

; ELSE (number is >39h)

; IF number <41h THEN error (number in range 3Ah-40h which is not a valid

; A-F character range)

; ELSE

; IF number <47h THEN Subtract 37h for letter A-F 41-46 (Please note 

; that 41h - 37h = Ah)

; ELSE ERROR

;

; PORTS: None used

; PROCEDURES: None

; REGISTERS: Uses CS, DS, AX,

;

DATA                         SEGMENT

ASCII DB 39h                       ; any experimental data

DATA ENDS

CODE SEGMENT

                                    ASSUME CS: CODE, DS: DATA

START:                       MOV AX, DATA ; initialise data segment

                                    MOV DS, AX  ; Register using AX

                                    MOV AL, ASCII ; Get the ASCII digits of the number

                                                                        ; start the conversion 

                                    CMP AL, 30h; If the ASCII digit is below 30h then it is not 

JB ERROR; a proper Hex digit

                                    CMP AL, 3Ah; compare it to 3Ah

                                    JB NUMBER; if greater then possibly a letter between A-F

                                    CMP AL, 41h; this step will be done if equal to or above 

; 3Ah

                                    JB ERROR; between 3Ah and 40h is error

                                    CMP AL, 46h

                                    JA ERROR; The ASCII is out of 0-9 and A-F range

                                    SUB AL, 37h; it's a letter in the range A-F so convert

                                    JMP CONVERTED

NUMBER:                  SUB AL, 30h; it is a number in the range 0-9 so convert

JMP CONVERTED

ERROR: MOV AL, 0FFh; you can also display some message here

CONVERTED: MOV AX, 4C00h

INT 21h; the hex result is in AL

CODE ENDS

END START


Related Discussions:- Show the code conversion with example

What is program annotation packages, Q. What is Program Annotation Packages...

Q. What is Program Annotation Packages? A quite renowned scheme in this field is OpenMP a newly designed industry standard for shared memory programming on architectures with u

Cse 320, Explain the functionality of the quadrant approach in the Spiral M...

Explain the functionality of the quadrant approach in the Spiral Model ?

Can a .net web application consume java web service, Can a .NET web applica...

Can a .NET web application consume Java web service? Yes Offcourse.Actually Webservices are independent  to language. It depends on WSDL and SOAP. so any single can develope t

Translate the following sentences into predicate logic, Translate the follo...

Translate the following sentences into predicate logic. Give as much structure as possible. Provide a translation key for each predicate letter and individual constant. In your tra

Difference between write back and write through cache, What is Difference b...

What is Difference between write back and write through cache? A caching method wherein modifications to data into the cache aren't copied to the cache source till absolutely n

Explain the term internet, Explain the term Internet. Internet: ...

Explain the term Internet. Internet: The Internet, an umbrella term covering countless network and services that comprise a super-network, is a global network of compute

Define parity generator, Define parity generator During transmission, a...

Define parity generator During transmission, at sending end the message is applied to a parity generator, where the needed bit is formed.

Explain logical shift micro-operations, Q. Explain logical shift Micro-oper...

Q. Explain logical shift Micro-operations? In logical shift data entering by serial input to left most or right most flip-flop (which depends on right or left shift operations

Explain function of network layer in tcp/ip protocol stack, Explain about t...

Explain about the function of network layer briefly in TCP/IP protocol stack. Internetwork Layer: The best-called TCP/IP protocol at internetwork layer is Internet Protoc

How are the function code handles in flow logic, How are the function code ...

How are the function code handles in Flow Logic? When the User selects a function in a transaction, the system copies the function code into a           specially   designated

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