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 are the advantages of batch processing, What are the advantages of bat...

What are the advantages of batch processing This has the advantage which jobs can be processed when computer resources are less busy (for example during the evening or at night

Draw a diagram to illustrate the design pattern, Problem: (a) What show...

Problem: (a) What shows a Pattern a Pattern? (b) Which pattern is given below? Justify your answer. public class A { private static A instance = null; private A() {

Convergence mean with respect to e-commerce, What does the term convergence...

What does the term convergence mean with respect to E-commerce? Convergence with respect to e-commerce   The ability to leverage and integrate the several data sources and

Describe about data warehouse development life cycle, Data Warehousing 1....

Data Warehousing 1.  With necessary diagram, Describe about Data Warehouse Development Life Cycle. 2. Elucidate Metadata and what is its use in Data Warehouse Architecture?

The advantage of using a database management system, The advantage of using...

The advantage of using a Database Management System The advantage of using a Database Management System for a data store is that databases have mechanisms for describing data,

What do you mean by e-brokerage, What do you mean by e-brokerage? E-bro...

What do you mean by e-brokerage? E-brokerage is an investment house which permits you to buy and sell stocks and acquire investment information through its Web site. E-comme

What is combinational circuits, Q. What is Combinational circuits? Comb...

Q. What is Combinational circuits? Combinational circuits are interconnected circuits of gates according to definite rules to generate an output relying on its input value. A w

Selecting integerated learning experiences, Q. Selecting integerated learni...

Q. Selecting integerated learning experiences? It is important that we select appropriate experiences for children, more so those that are from the child's world and emerge fro

Explain normans execution-evaluation cycle model, Question 1: (a) How ...

Question 1: (a) How would you explain human reasoning? (b) Explain the different types of human reasoning? Question 2: (a) What are the computational factors affec

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