dosseg .186 .model large ; xword operations (in particular xwordprint) use a lot of stack space. .stack 1024 include xword.ash .data ; xwords to store user input and results xword1 db __XWORDSIZE__ dup (0) xword2 db __XWORDSIZE__ dup (0) xword3 db __XWORDSIZE__ dup (0) xword4 db __XWORDSIZE__ dup (0) ; interface strings str0 db 'NOTE: Division is costly, and for that reason this program is very slow. Please be patient!',13,10 db 'NOTE 2: All values must be between $' str1 db ' and $' str3 db '.',13,10,13,10,'Enter value 1: $' str4 db 'Enter value 2 (not zero!): $' str5 db 13,10,'You entered $' str6 db ' and $' str7 db '.',13,10,13,10,'$' str8 db ' + $' str9 db ' = $' str10 db ' - $' str11 db ' * $' str12 db ' / $' str13 db 13,10,'$' str14 db ' r. $' .code main proc mov ax, @data mov ds, ax ; prepare to print strings via int 21h mov ah, 9 ; tell the user the acceptable range of values mov dx, offset str0 int 21h push offset __XWORD_IMIN__ call xwordiprint mov dx, offset str1 int 21h push offset __XWORD_IMAX__ call xwordiprint ; read values for xword1 and xword2 mov dx, offset str3 int 21h push offset xword1 call xwordread mov dx, offset str4 int 21h push offset xword2 call xwordread ; write back the values that were just entered mov dx, offset str5 int 21h push offset xword1 call xwordiprint mov dx, offset str6 int 21h push offset xword2 call xwordiprint mov dx, offset str7 int 21h ; display results of addition push offset xword4 push offset xword1 call xwordcpy push offset xword4 push offset xword2 call xwordadd push offset xword1 call xwordiprint mov dx, offset str8 int 21h push offset xword2 call xwordiprint mov dx, offset str9 int 21h push offset xword4 call xwordiprint mov dx, offset str13 int 21h ; display results of subtraction push offset xword4 push offset xword1 call xwordcpy push offset xword4 push offset xword2 call xwordsub push offset xword1 call xwordiprint mov dx, offset str10 int 21h push offset xword2 call xwordiprint mov dx, offset str9 int 21h push offset xword4 call xwordiprint mov dx, offset str13 int 21h ; display results of multiplication push offset xword4 push offset xword1 call xwordcpy push offset xword4 push offset xword2 call xwordmul push offset xword1 call xwordiprint mov dx, offset str11 int 21h push offset xword2 call xwordiprint mov dx, offset str9 int 21h push offset xword4 call xwordiprint mov dx, offset str13 int 21h ; display results of division push offset xword4 push offset xword1 call xwordcpy push offset xword4 push offset xword2 push offset xword3 call xwordidiv push offset xword1 call xwordiprint mov dx, offset str12 int 21h push offset xword2 call xwordiprint mov dx, offset str9 int 21h push offset xword4 call xwordiprint mov dx, offset str14 int 21h push offset xword3 call xwordiprint mov dx, offset str13 int 21h mov ah, 4ch int 21h main endp end main