Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .586
- .MODEL FLAT, C
- .DATA
- advOper DB 1 ;Set to 0 if addition or subtraction, 1 if multiplication and division
- oper DB 1 ;Set to 0 if addition or multiplication, 1 if subtraction or division
- a DWORD 25
- b DWORD 5
- .CODE
- MAIN PROC
- mov ebx, 1 ;move 0 to EBX register for counter
- mov eax, a
- cmp advOper, 0
- je simpCall
- jmp advCall
- simpCall:
- cmp oper, 0
- je additionCall
- jmp subtractionCall
- advCall:
- cmp oper, 0
- je multiplyCall
- jmp divideCall
- additionCall:
- call ADDITION
- jmp endSect
- subtractionCall:
- call SUBTRACTION
- jmp endSect
- multiplyCall:
- call MULTIPLY
- jmp endSect
- divideCall:
- call DIVIDE
- jmp endSect
- endSect:
- mov eax, eax
- MAIN ENDP
- ADDITION PROC
- mov eax, a
- add eax, b
- ret
- ADDITION ENDP
- SUBTRACTION PROC
- mov eax, a
- sub eax, b
- ret
- SUBTRACTION ENDP
- MULTIPLY PROC
- multi:
- add eax, a
- inc ebx
- cmp ebx, b
- jl multi
- ret
- MULTIPLY ENDP
- DIVIDE PROC
- divi:
- sub eax, b
- inc ebx
- cmp eax, 1
- jg divi
- mov eax, ebx
- dec eax
- ret
- DIVIDE ENDP
- END
Advertisement
Add Comment
Please, Sign In to add comment