## Machine Organization I V22.0201 - Fall 2003

Assignment 2

Due: Dewar's Section: Monday, Oct. 6th - Hull's Section: Thursday, Oct. 2nd

In class, we solved two problems from Chapter 2 of the Dewar Book - one of which converts a single binary byte in memory into three ASCII decimal digits (binasc.asm), and the other which reverses the process (ascbin.asm).

Your assignment is to convert a single WORD in memory into four ASCII hexadecimal digits, and reverse the process in the same program. The input should be pointed to by the WORD in location 1000H. At that new location, take the word and create four ASCII hex digits in the four bytes which follow it, and then the reconverted number in the word which follows those four (ASCII) bytes.

Thus if the input is:

 05 02 1000H 1001H
(This indicates that WORD PTR 0205H will contain the input)

 7F A8 ? ? ? ? ? ? 0205H 0206H 0207H 0208H 0209H 020Ah 020BH 020CH
(The input in the example is discovered to be A87F)

The output should look like:

 7F A8 41 38 37 46 7F A8 0205H 0206H 0207H 0208H 0209H 020Ah 020BH 020CH ('A') ('8') ('7') ('F')

Note that converting the digits 0-9 may be done in the same manner as the decimal conversion, but that the digits A-F do NOT follow immediately afterward in the ASCII table. Of course, the output WORD (Word 020BH in the example) should be computed by looking at the preceeding four bytes, NOT the input WORD!

Your program should accept the input from the location pointed to by 1000H. For output, it should not only leave the four bytes and one word in memory, it should also print the four output ASCII bytes to the screen, using INT 10H, subfunction 0EH, as described in class. It should print the four hex digits, followed by two spaces to separate one run of your program from the next.

Email your E-Tutor the ASM file.

By Popular Demand, here is a second example of a possible sample run of the program:

First, the first input is ALWAYS found at WORD PTR 1000H. There you find a pointer to the input word. So suppose you look at 1000H and find:

 A3 7B 1000H 1001H
(This indicates that WORD PTR 7BA3H will contain the actual input)

 CD 34 ? ? ? ? ? ? 7BA3H 7BA4H 7BA5H 7BA6H 7BA7H 7BA8h 7BA9H 7BAAH
(At that address the input found by the program has been set to 34CD)

Thus, the output should look like:

 CD 34 33 34 43 44 CD 34 7BA3H 7BA4H 7BA5H 7BA6H 7BA7H 7BA8h 7BA9H 7BAAH ('3') ('4') ('C') ('D')

On the computer's screen you should also print the following output:

34CD