Hi all,
Very new to this, and currently studying it part time. I have been supplied with program code to assemble in MASM (only allowed to use MASM, no other assembler) and am a bit stuck on 2 questions... baring in mind we have only really studied this for about an hour at the most i think its a bit cruel to say the least!
The program is a simple hex to binary converter
Here is the code:
CODE
DOSSEG
.MODEL SMALL
.STACK 100h
.DATA
lf EQU 0Ah
cr EQU 0Dh
mess3 DB lf,cr,"Processed output is: $"
mess1 DB lf,lf,cr,"Type a single hex digit(0 to 9, A to F)"
DB lf,cr,"or any other key to terminate program: $"
mess2 DB lf,cr,"Error on input. Program Terminating.$"
h2b DB "0000$","0001$","0010$","0011$","0100$","0101$","0110$","0111$"
DB "1000$","1001$","xxxxx","xxxxx","xxxxx","xxxxx","xxxxx","xxxxx"
DB "xxxxx","1010$","1011$","1100$","1101$","1110$","1111$"
.CODE
start: mov ax,@DATA
mov ds,ax
next: mov dx,offset mess1
call disp
call rdkey
call check
push ax
mov dx,offset mess3
call disp
pop ax
and ah,ah
jz cont
mov dx,offset mess2
call disp
mov ax,4c00h
int 21h
cont: mov ah,0
mov dx,offset h2b
add dx,ax
add dx,ax
add dx,ax
add dx,ax
add dx,ax
call disp
jmp next
check: cmp al,'0'
jl bad
cmp al,'F'
jg bad
cmp al,'9'
jle ok
cmp al,'A'
jge ok
bad: mov ah,1
ret
ok: mov ah,0
sub al,30h
ret
rdkey: mov ah,1
int 21h
and al,7fh
ret
disp: mov ah,9
int 21h
ret
END start
the questions are
Explain why the string "xxxxx" appears several times in lines 12 and 13 of the program. Modify the program in a manner which makes these strings unnecessary and provide a commented printout of your mods.
I've tried numerous things and nothing works.
Next question:
Modify the program so that it accepts and correctly processes the lower case alphabetic chars a to f as valid input instead of the upper case characters A to F.
Also tried numerous things with no success.
Anyone have any ideas?
Anything would be a great help!
Thanks