Question: x86 assembly calculator program written in the format below. TITLE TBA8 - Test 8 bit binary to ASCII cnverter PAGE 60,132 ; ; This program

x86 assembly calculator program written in the format below. TITLE TBA8 - Test 8 bit binary to ASCII cnverter PAGE 60,132 ; ; This program is a test stub for the 8 bit binary to ASCII converter ; ; Define constants ; CR EQU 0DH ;define carriage return LF EQU 0AH ;define line feed EOT EQU '$' ;define end of text marker ; JMP START ;bypass the variables ; ; Define variables ; PROMPT DB CR, LF, LF, "Enter a three byte number between 000 and 255: ", EOT M1 DB CR, LF, "The value entered in binary is ", EOT M2 DB CR, LF, "The number converted back to ASCII is " OBUF DB 3 DUP ? DB CR, LF, LF, "Want to take another crack at it? ", EOT INBUF DB 5, ?, 5 DUP ? ; ; Code Section ; START: LEA DX, PROMPT ;write input request message MOV AH, 09H INT 21H LEA DX, INBUF ;get input number MOV AH, 0AH INT 21H LEA SI, INBUF+2 ;point to input data CALL ASCBIN8 ;convert to binary MOV BL,AL ;save binary value LEA DX, M1 ;write output message MOV AH, 09H INT 21H MOV CX, 8 ;set loop counter PUSH BX ;save binary value on stack DOUT: SHL BL,1 ;move bits left to carry flag JC P1 ;if it's a 1 jump MOV DL, '0' ;if it;s a zero, print it L1: MOV AH, 02H INT 21H JMP DONE ;a character is printed P1: MOV DL, '1' ;print the 1 JMP L1 DONE: LOOP DOUT ;keep doing for all 8 bits ; ; At this point a value has been entered and converted to binary ; Now, convert it back to ASCII adn display it ; POP AX ;restore binary value, but put it into AL LEA SI, OBUF ;point to where the ASCII characters will go CALL BINASC8 ;convert it LEA DX, M2 ;point to message MOV AH, 09H ;get string output function code INT 21H ;write it ; MOV AH, 01H ;get answer to question INT 21H CMP AL, 'y' ;if yes, do it again JE START CMP AL, 'Y' ;if the other yes, do it again JE START ; ; If the answer was anything other than 'y' or 'Y', then exit the program MOV AX, 4C00H ;clean exit INT 21H ; ;*********************************************************************************************** ; Subroutine ASCBIN8 ; ; A subroutine to convert 3 bytes of ASCII to 8 bit binary ; ; Note: This version of the subroutine does not perform any ; error testing. It assumes the input values are value ASCII ; characters representing values between 0 and 255 decimal. ; A separate subroutine could perform the validity tests. ; ; ENTRY: SI points to a 3 byte ASCII buffer ; DI is used internally ; EXIT: AL holds the 8 bit converted value ; DI preserved ; USE: Input must be three bytes ; ASCBIN8: PUSH DI ;save DI on entry LEA DI, MULT ;point to placeholder values SUB B[SI],30H ;remove ASCII bias from numbers SUB B[SI+1],30H SUB B[SI+2],30H MOV CX,3 ;initialize loop counter MOV BL,0 ;initialize sum register AB1: MOV AL,[SI] ;get first byte MOV AH,0 ;clear upper byte of AX MUL B[DI] ;multiply by placeholder ADD BL,AL ;save value INC DI ;point to next place holder INC SI ;point to next byte LOOP AB1 MOV AL,BL ;place sum into output register POP DI ;restore DI RET MULT DB 100,10,1 ; ;******************************************************************************************** ; Subroutine BINASC8 ; ; A subroutine to convert an 8 bit binary value to 3 bytes of ; printable ASCII. No errors are detected in this module since none ; are possible. ; ; ENTRY: AL holds the 8 bit binary value to be converted to ASCII ; SI points to a 3 byte buffer to store the ASCII characters ; DI is used internally as part of the conversion routine ; EXIT: DI is preserved, AL destroyed ; BINASC8: PUSH DI ;save DI on entry MOV W[SI],3030H ;preload ASCII buffer with number bias MOV B[SI+2],30H LEA DI, MULP ;point to the place holder values MOV CX,2 ;set up count for loop iteration B2A1: SUB AL,[DI] ;subtract placeholder value JC B2A2 ;if negative, we subtracted too much INC B[SI] ;if positive, add 1 to ASCII byte JMP B2A1 ;continue counting place values until minus B2A2: ADD AL,B[DI] ;restore AL to previous value oversubtracted INC DI ;point to next place holder INC SI ;point to next ASCII byte LOOP B2A1 ;continue for next place ADD B[SI],AL ;add units to units byte bias POP DI ;restore DI RET ;return to calling routine MULP DB 100,10 ; ;***************************************************************************************** ; END 

x86 assembly calculator program written in the format below. TITLE TBA8 -

Test 8 bit binary to ASCII cnverter PAGE 60,132 ; ; Thisprogram is a test stub for the 8 bit binary to ASCII

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!