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

Survey of advanced applications, 1. Conduct a literature survey of advanced...

1. Conduct a literature survey of advanced applications of the finite element method for engineering design and analysis. 2. Identify at least one application, which interests y

Determine the fastest logic, Which of the fastest logic: TTL, ECL, CMOS and...

Which of the fastest logic: TTL, ECL, CMOS and LSI ? Ans. The fastest logic family of all logic families ECL. High  speeds  are  possible  in  ECL  since the  transistors  a

Why should you use bugzilla?, Bugzilla can dramatically enhance the product...

Bugzilla can dramatically enhance the productivity and accountability of individual employees by giving a documented workflow and positive feedback for good performance.

Explain criteria for choosing type of file organization, What criteria shou...

What criteria should be adopted for choosing type of file organization. Selecting a file organization is a design decision; therefore it must be done having in mind the achieve

Perceptrons of artificial neural networks, Perceptrons: However the we...

Perceptrons: However the weights in any ANN are usually just real numbers and the learning problem boils down to choosing the best value for each weight in the network. Becaus

Explain the importance of computer architecture, Explain the importance of ...

Explain the importance of computer architecture Studying the architecture implies working on machine language programs. However, this isn't practical when we design a computer

Explain client server model, Explain Client Server Model. In the client...

Explain Client Server Model. In the client- server model, communication usually takes the form of a request message from the client to the server asking for several works to be

4, Ask question 4#Minimum 100 words accepted#

Ask question 4#Minimum 100 words accepted#

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