Created
April 24, 2019 01:37
-
-
Save kurtkaiser/cd7382f7b307765b4ef700190c416954 to your computer and use it in GitHub Desktop.
Simple multiplication calculation written in MASM Assembly language for the x86 processor.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Simple Multiplication Calculator | |
; Kurt Kaiser | |
INCLUDE Irvine32.inc | |
; .data is used for declaring and defining variables | |
.data | |
codeTitle BYTE " --------- Math Multiplication Magic --------- ", 0 | |
directions BYTE "Enter 2 numbers.", 0 | |
prompt1 BYTE "First number: ", 0 | |
prompt2 BYTE "Second number: ", 0 | |
equals BYTE " = ", 0 | |
times BYTE " * ", 0 | |
num1 DWORD ? | |
num2 DWORD ? | |
total DWORD ? | |
; .code is for the executable part of the program | |
.code | |
main PROC | |
; Output the title and author | |
mov edx, OFFSET codeTitle | |
call WriteString | |
call CrLf | |
; Prompt for the first number | |
mov edx, OFFSET prompt1 | |
call WriteString | |
call ReadInt | |
mov num1, eax | |
; Prompt for the second number | |
mov edx, OFFSET prompt2 | |
call WriteString | |
call ReadInt | |
mov num2, eax | |
; Multiply the two numbers using the eax registry | |
mov eax, num1 | |
mov ebx, num2 | |
mul ebx | |
mov total, eax | |
; Print the total to the console | |
; Print num1 | |
mov eax, num1 | |
call WriteDec | |
; Print the multiply sign | |
mov edx, OFFSET times | |
call WriteString | |
; Print num2 | |
mov eax, num2 | |
call WriteDec | |
; Print the equals sign | |
mov edx, OFFSET equals | |
call WriteString | |
; Print out the total | |
mov eax, total | |
call WriteDec | |
call CrLf | |
call CrLf | |
exit | |
main ENDP | |
END main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
which Irvine32 download did you use?