this is a part of my calculator code.This code will convert the input values to ASCII value.My problem is when i input negative values, it will not result to desired output.I want to modify this code if ever the input values is negative.I don't know how to modify this program in order for it to convert negative values to 2's compliment.can u help me?
CONVERT_ASSCII PROC NEAR MOV AH , BYTE PTR RESULT ;MOVE FIRST TWO BYTE OF RESULT TO AX MOV AL , BYTE PTR RESULT + 1 ;AT FIRST CHECK IF AX IS POSITIVE OR NEGETIVE TEST EAX , 8000H ;CHECK THE LAST BIT . IF THATS 1 THEN AX IS NEG , OTHERWISE THATS POSITIVE MOV EDI , 0 ;AT FIRST SET OUR FLAG TO ZERO JZ EAX_POSITIVE ;AX IS POSITIVE NEG EAX ;CALCULATE NEGETIVE OF AX MOV EDI , 1 ;DI INDICATES THAT AX IS NEG EAX_POSITIVE : MOV ECX , 10 LEA ESI , ASSCII_NUM ADD ESI , 29 ;MOVE TO THE LAST SPACE MOV EBP , 0 ;THIS IS THE COUNTER OF CHARS ASSCII_LOOP : MOV EDX , 0 DIV ECX OR DL , 30H ;MAKE REMINDER ASSCII MOV [ESI] , DL ;PUT ASSCII IN ASSCII_NUM DEC ESI INC EBP ;ADD ONE TO THE CHAR'S COUNTER CMP EAX , 0 ;IF AX > 0 GOTO JA ASSCII_LOOP ;ASSCII_LOOP CMP EDI , 0 ;CHECK IF THAT WAS A NEGETIVE NUMBER JZ REST ;IF THATS NOT NEGETIVE GOTO REST MOV DL , '-' MOV [ESI] , DL ;ADD A MINES SIGN TO THE STRING DEC ESI INC EBP REST : LEA EDI , ASSCII_NUM ;MOVE THE ASSCII CODE TO IT'S RIGHT PLCAE IN ASSCII_NUM ORDER_ASSCII : INC ESI MOV AL , BYTE PTR [ESI] MOV BYTE PTR [EDI] , AL INC EDI DEC EBP CMP EBP , 0 JA ORDER_ASSCII MOV CL , '$' MOV BYTE PTR [EDI] , CL ;AT LAST PUT A DOLLOR SIGN AT THE END OF ASSCII_NUM RET CONVERT_ASSCII ENDP