Can anyone assist with my understanding of these directions? I'm currently learning x86 Assembly, but I cannot seem to display the output I'm looking for. I understand AL contains the byte I need to display..but how can I display the correct output, considering these requirements:
I am getting stuck on WriteChar for DH and DL, as the output I'm looking for with my solution does not appear to be correct...I can't tell what I'm missing. I can initialize AL and DL/DH correctly, but when I use WriteChar, it prints a completely different character.
- store in the register DH the ASCII code of the most significant nibble.
- store in the register DL the ASCII code of the least significant nibble.
- Display (using WriteChar) on the console the character stored in DH (recall that WriteChar uses AL for the character to display).
- Display (using WriteChar) on the console the character stored in DL.
- Display ‘h’ to indicate that the number is a hexadecimal number.
- ‘Display’ the ‘line feed’ character (ASCII code is 0Ah) to go to the next line.
- ‘Display’ the ‘carriage’ character (ASCII code is 0Dh) to go to the next line.
Here is an example and below that is what I have so far...
Example : If AL contains the number 94h, your program 1) must store 39h (ASCII code of the character ‘9’) in DH , 2) must store 34h (ASCII code of the character ‘4’) in DL, 3) must display the characters ‘9’, ‘4’, ‘h’, ‘linefeed’, and ‘carriage return’.
Code Attempt:
INCLUDE Irvine32.inc
.data
myHex BYTE "h", 0
.code
ExerciseTwo proc
MOV EAX, 0
MOV AL, 94h
CALL WriteChar
MOV DH, AL
SHR DX, 4
SHR DL, 4
MOV EDX, OFFSET myHex
CALL WriteString
invoke ExitProcess, 0
ExerciseTwo endp
end ExerciseTwo