77 lines
1.9 KiB
NASM
77 lines
1.9 KiB
NASM
########################################################################
|
|
.data
|
|
########################################################################
|
|
a: .long 3
|
|
b: .long 11
|
|
c: .long 67
|
|
d: .long 16
|
|
e: .long 15
|
|
f: .long 2
|
|
g: .long 5
|
|
h: .long 0
|
|
intout: .string "%d"
|
|
########################################################################
|
|
.text
|
|
########################################################################
|
|
.global _main # global entry point
|
|
.global _mainCRTStartup # debugging 4 msvs/windows
|
|
|
|
_mainCRTStartup: # do nothing
|
|
jmp _main # jump to _main
|
|
|
|
########################################################################
|
|
_main:
|
|
|
|
pushl c # c to stack # c<
|
|
|
|
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 # +
|
|
|
|
#lr: c< a b * >-< d< e f % g - >/ h / >+ : 3x<, 3x>
|
|
|
|
jmp _exit # jump to program-end
|
|
|
|
########################################################################
|
|
_exit: # global exit point
|
|
|
|
pushl %eax # nochmal eine ausgabe von eax
|
|
pushl $intout
|
|
call _printf
|
|
popl %ebx # clear stack
|
|
popl %eax # schreibe a in eax
|
|
|
|
ret |