## Machine Organization I V22.0201 - Spring 2009

Assignment 2

Due: Wednesday, Feb. 25th

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 byte in memory into two ASCII hexadecimal digits, and reverse the process in the same program. The input should be in location 1000H. At that new location, take the byte and create two ASCII hex digits in the two bytes which follow it, and then the reconverted number in the byte which follows those two (ASCII) bytes.

Thus if the input is:

 7F ? ? ? 1000H 1001H 1002H 1003H

The output should look like:

 7F 37 46 7F 1000H 1001H 1002H 1003H

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 final output byte (Byte 1003H) should be computed by looking at the preceeding two bytes, NOT by inspecting the original input byte!

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

So, the printed output for the above example would be:

7F

### Email your ASM file to the grader, Eli Bildirici, at:    s90201 [at] cs [dot] nyu [dot] edu

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

If the input is:

 C4 ? ? ? 1000H 1001H 1002H 1003H

The output should look like:

 C4 43 34 C4 1000H 1001H 1002H 1003H

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

C4