.586 .MODEL FLAT INCLUDE io.h ; header file for input/output .STACK 4096 .DATA pennies DWORD ? nickels DWORD ? dimes DWORD ? quarters DWORD ? numberOfCoins DWORD ? total DWORD ? prompt1 BYTE "How many pennies do you have?", 0 prompt2 BYTE "How many nickels do you have?", 0 prompt3 BYTE "How many dimes do you have?", 0 prompt4 BYTE "How many quarters do you have?", 0 string BYTE 40 DUP (?) resultLbl BYTE "Coin Information", 0 sum BYTE 11 DUP (?), 0 .CODE _MainProc PROC input prompt1, string, 40; read ASCII characters atod string ; convert to integer mov pennies, eax; store in memory input prompt2, string, 40; repeat for second number atod string mov nickels, ebx input prompt3, string, 40; read ASCII characters atod string ; convert to integer mov dimes, ecx; store in memory input prompt4, string, 40; repeat for second number atod string mov quarters, edx mov eax, pennies; pennies to EAX mov numberOfCoins, eax; numberOfCoins = number of pennies mov total, eax; total = pennies mov ebx, nickels; nickels to EBX add numberOfCoins, ebx; add numberOfNickels to numberOfCoins mul numberOfNickels, 5; multiply numberOfNickels by 5 add total, ebx; total = total + 5*numberOfNickels mov ecx, dimes; dimes to ECX add numberOfCoins, ecx; add numberOfDimes to numberOfCoins mul numberOfDimes, 10; total = total + 10*numberOfDimes add total, ecx mov edx, quarters; quarters to EDX add numberOfCoins, edx; add numberOfQuarters to numberOfCoins mul numberOfQuarters, 25; total = total + 25*numberofQuarters add total, edx dtoa sum, eax; convert to ASCII characters output resultLbl, sum; output label and sum mov eax, 0 ; exit with return code 0 ret _MainProc ENDP END ; end of source code
I know the mul command doesn't have the right syntax, but I have no idea how to write that command. Also, I am currently using 4 different registers. Is there a way to use just the EAX register?
Thanks in advance!
This post has been edited by Wilbur: 08 October 2008 - 10:10 AM

New Topic/Question
Reply



MultiQuote




|