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

Why data bus is bidirectional, Why data bus is bidirectional and address bu...

Why data bus is bidirectional and address bus is unidirectional in most microprocessors? The data bus is bidirectional because the data bus has to transfer data among the CPU a

Accessing the internet, Before we can use Internet, we have to gain access ...

Before we can use Internet, we have to gain access to it. This access is achieved in one of numerous ways. Above all, the Internet is a collection of networks which are connected t

Basic definition of program, Q. Basic defination of program? A program ...

Q. Basic defination of program? A program generally consists of a set of instructions and data specifying the solution of a particular problem. Programs (and data) expressed in

Explain difference between scanning and parsing, Explain difference between...

Explain difference between Scanning and parsing. Scanning and parsing: Scanning process is the process of recognizing the lexical components in a source string whereas parsin

What is hyper-threading, Hyper-threading officially known as Hyper-threadin...

Hyper-threading officially known as Hyper-threading Technology (HTT) is Intel's trademark for their functioning of simultaneous multithreading technology on Pentium 4 micro-archite

The types of parameters in the function modules, What are the types of para...

What are the types of parameters in the function modules? In general, function module can have four types of parameters: EXPORTING : for passing data to the called function

Differentiate between EPROM and EEPROM, Differentiate between EPROM and EEP...

Differentiate between EPROM and EEPROM. EPROM: The meaning of this term is Erasable PROM. This can be reprogrammed through first erasing the existing program. EPROM uses N-MO

what is ecc memory, Error-correcting code memory (ECC memory) is a type of...

Error-correcting code memory (ECC memory) is a type of computer data storage that can notice and correct the more general kinds of internal data corruption. ECC memory is used in m

Explain efficiency performance and issues in pipelining, Efficiency The...

Efficiency The effectiveness of pipeline can be measured the same as the ratio of busy time span to total time span counting the idle time. Let c be clock period of a pipeline

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