Skip to content

Instantly share code, notes, and snippets.

@kurtkaiser
Created April 24, 2019 01:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kurtkaiser/02d486b8934e315fb0f7fcdbaaf86818 to your computer and use it in GitHub Desktop.
Save kurtkaiser/02d486b8934e315fb0f7fcdbaaf86818 to your computer and use it in GitHub Desktop.
Simple division calculator written in MASM Assembly language for the x86 processors
; 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
@MohdMuzammil8
Copy link

Great job buddy!

@CemRoot
Copy link

CemRoot commented Mar 31, 2021

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