Created
April 24, 2019 01:55
-
-
Save kurtkaiser/02d486b8934e315fb0f7fcdbaaf86818 to your computer and use it in GitHub Desktop.
Simple division calculator written in MASM Assembly language for the x86 processors
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 Division Calculator | |
; Kurt Kaiser | |
INCLUDE Irvine32.inc | |
; .data is used for declaring and defining variables | |
.data | |
codeTitle BYTE " --------- Math Magic --------- ", 0 | |
directions BYTE "Enter 2 numbers.", 0 | |
prompt1 BYTE "First number: ", 0 | |
prompt2 BYTE "Second number: ", 0 | |
remaintxt BYTE " remainder ", 0 | |
divide BYTE " / ", 0 | |
equals BYTE " = ", 0 | |
num1 DWORD ? | |
num2 DWORD ? | |
total DWORD ? | |
remainder DWORD ? | |
; .code is for the executable part of the program | |
.code | |
main PROC | |
; Output the title | |
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 | |
; Perform the calculation | |
mov eax, num1 | |
mov ebx, num2 | |
xor edx, edx | |
div ebx | |
mov total , eax | |
mov remainder , edx | |
call CrLf | |
; Print the total to the console | |
; Print num1 | |
mov eax, num1 | |
call WriteDec | |
; Print the divide sign | |
mov edx, OFFSET divide | |
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 | |
mov edx, OFFSET remaintxt | |
call WriteString | |
mov eax, remainder | |
call WriteDec | |
call CrLf | |
call CrLf | |
exit | |
main ENDP | |
END main |
May you share code INCLUDE Irvine32.inc
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Great job buddy!