Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; aufgabenteil b
- SECTION .data
- message1: db "Choose mode: (SUB = 0; ADD = 1; MUL = 2)): ", 0
- message2: db "Enter first number: ", 0
- message3: db "Enter second number: ", 0
- message4: db "Illegal mode", 0
- formatin: db "%d", 0
- formatout: db "%d", 10, 0
- mode: times 4 db 0 ; mode
- integer1: times 4 db 0 ; a
- integer2: times 4 db 0 ; b
- SECTION .text
- global _start
- global _add
- global _sub
- global _mul
- global _exit
- extern scanf
- extern printf
- _start:
- push ebx
- push ecx
- push eax
- push message1
- call printf
- add esp, 4
- push mode
- push formatin
- call scanf
- add esp, 8
- push message2
- call printf
- add esp, 4
- push integer1
- push formatin
- call scanf
- add esp, 8
- push message3
- call printf
- add esp, 4
- push integer2
- push formatin
- call scanf
- add esp, 8
- ;in register schreiben
- mov eax, dword [integer1]
- mov ebx, dword [integer2]
- mov ecx, dword [mode]
- cmp ecx, 0
- je _sub
- cmp ecx, 1
- je _add
- cmp ecx, 2
- je _mul
- cmp ecx, 3
- jge _exit
- ret
- _add:
- add eax, ebx
- push eax
- push formatout
- call printf
- add esp, 8
- pop ebx
- pop ecx
- pop eax
- mov eax, 0
- ret
- _sub:
- sub eax, ebx
- push eax
- push formatout
- call printf
- add esp, 8
- pop ebx
- pop ecx
- pop eax
- mov eax, 0
- ret
- _mul:
- mul ebx
- push eax
- push formatout
- call printf
- add esp, 8
- pop ebx
- pop ecx
- pop eax
- mov eax, 0
- ret
- _exit:
- push message4
- call printf
- add esp, 4
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement