Assembly code program problem

liunx

Guest
Hi all,<br /><br />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! <br />The program is a simple hex to binary converter<br /><br />Here is the code: <br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><br />DOSSEG<br />.MODEL SMALL<br />.STACK 100h<br />.DATA<br />lf EQU 0Ah<br />cr EQU 0Dh<br /><br />mess3 DB lf,cr,"Processed output is: $"<br />mess1 DB lf,lf,cr,"Type a single hex digit(0 to 9, A to F)"<br />      DB lf,cr,"or any other key to terminate program: $"<br />mess2 DB lf,cr,"Error on input. Program Terminating.$"<br />h2b   DB "0000$","0001$","0010$","0011$","0100$","0101$","0110$","0111$"<br />      DB "1000$","1001$","xxxxx","xxxxx","xxxxx","xxxxx","xxxxx","xxxxx"<br />      DB "xxxxx","1010$","1011$","1100$","1101$","1110$","1111$"<br /><br />.CODE<br /><br />start: mov ax,@DATA<br />       mov ds,ax<br /><br />next:  mov  dx,offset mess1<br />       call disp<br />       call rdkey<br />       call check<br />       push ax<br />       mov  dx,offset mess3<br />       call disp<br />       pop  ax<br />       and  ah,ah<br />       jz   cont<br />       mov  dx,offset mess2<br />       call disp<br />       mov  ax,4c00h<br />       int  21h<br />cont:  mov  ah,0<br />       mov  dx,offset h2b<br />       add  dx,ax<br />       add  dx,ax<br />       add  dx,ax<br />       add  dx,ax<br />       add  dx,ax<br />       call disp<br />       jmp  next<br />check: cmp  al,'0'<br />       jl   bad<br />       cmp  al,'F'<br />       jg   bad<br />       cmp  al,'9'<br />       jle  ok<br />       cmp  al,'A'<br />       jge  ok<br />bad:   mov  ah,1<br />       ret<br />ok:    mov ah,0<br />       sub al,30h<br />       ret<br /><br />rdkey: mov ah,1<br />       int 21h<br />       and al,7fh<br />       ret<br /><br />disp:  mov ah,9<br />       int 21h<br />       ret<br />       END start<br /><!--c2--></div><!--ec2--><br /><br /><br />the questions are <br /><br />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.<br />I've tried numerous things and nothing works.<br /><br />Next question:<br /><br />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.<br />Also tried numerous things with no success.<br /><br />Anyone have any ideas?<br /><br />Anything would be a great help!<br /><br />Thanks
</div>
 
Top