Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .386
- .model flat,stdcall
- option casemap:none
- include \masm32\include\masm32.inc
- include \masm32\include\gdi32.inc
- include \masm32\include\user32.inc
- include \masm32\include\kernel32.inc
- include \masm32\include\shell32.inc
- include \masm32\macros\macros.asm
- include \masm32\include\msvcrt.inc
- includelib \masm32\lib\masm32.lib
- includelib \masm32\lib\gdi32.lib
- includelib \masm32\lib\user32.lib
- includelib \masm32\lib\kernel32.lib
- includelib \masm32\lib\shell32.lib
- includelib \masm32\lib\msvcrt.lib
- P proto :DWORD, :DWORD
- .DATA
- Hello db "Type your command!: ",0
- InvalidOp db "This is invalid..",0Ah,0
- FirstOp db "Type first operand: ",0
- SecOp db "Type second operand: ",0
- Answer db "%d %c %d = %d",0Ah,0
- AnswerF db "%d %c %d = %d,%d",0Ah,0
- Oper byte 0
- Plus db "+",0
- Op db 8 dup (0)
- Numa db 8 dup (0)
- N_a dword ?
- Numb db 8 dup (0)
- N_b dword ?
- .CODE
- START:
- lea eax,Hello
- push eax
- call StdOut
- push 8
- lea eax,Op
- push eax
- call StdIn
- xor eax,eax
- lea eax,Op
- cmp byte ptr[eax],'+'
- je ADDICTION
- cmp byte ptr[eax],'-'
- je SUBSTRACTION
- cmp byte ptr[eax],'/'
- je DIVISION
- cmp byte ptr[eax],'*'
- je MULTIPLY
- jmp INVALID
- CONTINUE:
- cls
- lea eax, FirstOp
- push eax
- call StdOut
- xor eax,eax
- push 8
- lea eax,Numa
- push eax
- call StdIn
- lea eax,Numa
- push eax
- call atol
- mov N_a,eax
- cls
- push 8
- lea eax,SecOp
- push eax
- call StdOut
- push 8
- lea eax,Numb
- push eax
- call StdIn
- lea eax,Numb
- push eax
- call atol
- mov N_b,eax
- cmp Oper,1
- je AD
- cmp Oper,2
- je SU
- cmp Oper,3
- je DV
- jne MU
- jmp INVALID
- AD:
- mov eax,N_a
- add eax,N_b
- push eax
- push N_b
- push '+'
- push N_a
- lea eax,Answer
- push eax
- call crt_printf
- jmp START
- SU:
- mov eax,N_a
- sub eax,N_b
- push eax
- push N_b
- push '-'
- push N_a
- lea eax, Answer
- push eax
- call crt_printf
- jmp START
- DV:
- mov eax,N_a
- push edx
- xor edx,edx
- div N_b
- mov ebx,edx
- pop edx
- push ebx
- push eax
- push N_b
- push '/'
- push N_a
- lea eax, AnswerF
- push eax
- call crt_printf
- jmp START
- MU:
- mov eax,N_a
- mul N_b
- push eax
- push N_b
- push '*'
- push N_a
- lea eax, Answer
- push eax
- call crt_printf
- jmp START
- ADDICTION:
- mov Oper,1
- jmp CONTINUE
- SUBSTRACTION:
- mov Oper,2
- jmp CONTINUE
- DIVISION:
- mov Oper,3
- jmp CONTINUE
- MULTIPLY:
- mov Oper,4
- jmp CONTINUE
- INVALID:
- push offset InvalidOp
- call StdOut
- jmp START
- EXIT:
- invoke ExitProcess, 0
- END START
Advertisement
Add Comment
Please, Sign In to add comment