how to add two numbers of 2 digits each
im using this code but it doesnt work when there is a carry on the MSB
VB Code:
.MODEL SMALL .STACK 200 .DATA CRLF DB 0DH,0AH,'$' PROMPT1 DB 'Enter the first positive integer: ','$' PROMPT2 DB 'Enter the second positive integer: ','$' PROMPT3 DB 'The sum of the two numbers is: : ','$' .CODE .STARTUP LEA DX,PROMPT1 MOV AH,09H INT 21H MOV AH,01H INT 21H SUB AL,30H ; convert character to number MOV CH,AL MOV AH,01H INT 21H SUB AL,30H ; convert character to number MOV CL,AL LEA DX,CRLF MOV AH,09H INT 21H LEA DX,PROMPT2 MOV AH,09H INT 21H MOV AH,01H INT 21H SUB AL,30H ; convert character to number MOV BH,AL MOV AH,01H INT 21H SUB AL,30H ; convert character to number MOV BL,AL ADD CL,BL ADC CH,BH ADD CL,30H ; convert number to character ;ADD CH,30H LEA DX,CRLF MOV AH,09H INT 21H LEA DX,PROMPT3 MOV AH,09H INT 21H MOV DL,CH MOV AH,02H INT 21H MOV DL,CL MOV AH,02H INT 21H .EXIT END
can someone help




Reply With Quote