78 lines
1.2 KiB
NASM
78 lines
1.2 KiB
NASM
.data
|
|
|
|
## Variablen ##
|
|
|
|
a: .long 3
|
|
b: .long 11
|
|
c: .long 67
|
|
d: .long 16
|
|
e: .long 15
|
|
f: .long 2
|
|
g: .long 5
|
|
h: .long -2
|
|
|
|
|
|
intout:
|
|
.string "Wert %d\n"
|
|
|
|
.text
|
|
|
|
.globl main
|
|
|
|
main:
|
|
|
|
pushl c # c to stack
|
|
|
|
movl a, %eax # load a
|
|
movl b, %ebx # load b
|
|
imull %ebx, %eax # a*b # a b *
|
|
|
|
popl %ebx # c from stack # >
|
|
|
|
subl %eax, %ebx # c - a*b # -
|
|
|
|
pushl %ebx # c - a*b to stack # <
|
|
|
|
pushl d # d to stack # d<
|
|
|
|
cdq # edx = 0 für divison
|
|
movl e, %eax # load e
|
|
movl f, %ebx # load f
|
|
idivl %ebx # e % f # e f %
|
|
movl %edx, %eax # rest in %edx
|
|
|
|
movl g, %ebx # load g
|
|
|
|
subl %ebx, %eax # e%f - g # g -
|
|
|
|
popl %ebx # d from stack # >
|
|
|
|
xchg %ebx, %eax
|
|
cdq # edx = 0 für divison
|
|
|
|
idivl %ebx # d / (e%f - g) # /
|
|
|
|
movl h, %ebx # load h
|
|
|
|
cdq # edx = 0 für divison
|
|
idivl %ebx # (d/e%f)/h # /
|
|
|
|
popl %ebx # c - a*b from stack # >
|
|
|
|
add %ebx, %eax # (c - a*b) + (d/e%f)/h # +
|
|
|
|
|
|
|
|
# Wert im %eax ausgeben
|
|
pushl %eax
|
|
pushl $intout
|
|
call printf
|
|
|
|
##clear stack
|
|
popl %ebx
|
|
popl %ebx
|
|
|
|
|
|
# Exit
|
|
movl $1, %edx
|
|
int $0x80 |