Różne programy na zajęcia laboratoryjne z AK2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Jan Potocki 2023
  2. # Wersja przystosowana do zbudowania jako PIE (Position Independent Executable)
  3. # Definicje numerow funkcji systemowych i ich parametrow
  4. SYSEXIT64 = 60
  5. # Stale okreslajace rozmiar przetwarzanych danych
  6. word_length = 8
  7. .global main
  8. # Segment niezainicjalizowanych danych
  9. .bss
  10. element: .space word_length
  11. # Segment zainicjalizowanych danych
  12. .data
  13. format_s: .asciz "%lu"
  14. format_p: .asciz "%lu\n"
  15. # Segment kodu
  16. .text
  17. main:
  18. # To jest potrzebne zeby printf i scanf nie konczyly sie segfaultem
  19. push %rbp
  20. mov %rsp, %rbp
  21. lea format_s(%rip), %rdi # Adresowanie wzgledem rip, wprowadzone w x86-64
  22. #mov $format_s, %rdi # ...tu nam wystarczy sam adres
  23. lea element(%rip), %rsi
  24. #mov $element, %rsi
  25. mov $0, %rax # Nie ma argumentow dla scanf() w rejestrach xmm
  26. call scanf
  27. lea element(%rip), %r8 # Tutaj trzeba jakis posredni rejestr...
  28. movq (%r8), %rdi # ...zeby odwolac sie do wartosci
  29. #movq element, %rdi
  30. call fibb
  31. lea format_p(%rip), %rdi
  32. #mov $format_p, %rdi
  33. mov %rax, %rsi # rax - wartosc zwrocona przez fibb()
  34. mov $0, %rax # Nie ma argumentow dla printf() w rejestrach xmm
  35. call printf
  36. mov $SYSEXIT64, %rax
  37. mov $0, %rdi
  38. syscall