Advertisement
Guest User

asfd

a guest
Apr 23rd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #void menjaj(short short *niz, int *rez)
  2.  
  3. #void funkcija, argumenti su adresa niza i adresa rezultata, niz se sastoji od 8 osmobitnih neoznacenih brojeva, treba napraviti dva nova broja tako da se jedan broj sastoji od najmanje znacajnih bitova clanova niza, a drugi od najznacajnijih, te brojeve posle pomnoziti sa 8 i posle ih sabrati i smestiti u rezultat koji je 32 bitan
  4.  
  5.  
  6. .section .data
  7. .section .text
  8. .globl menjaj
  9.  
  10. menjaj:
  11. pushl %ebp
  12. movl %esp, %ebp
  13. pushl %ebx
  14. pushl %esi
  15. pushl %edi
  16. movl 8(%ebp), %ecx
  17. movl $8, %ebx
  18. movl $0, %esi
  19. movl $0, %edi
  20.  
  21. prvi_broj:
  22. movb (%ecx), %al
  23. andl $1, %eax
  24. rorl $1, %eax
  25.  
  26. drugi_broj:
  27. movb (%ecx), %dl
  28. andl $8, %edx
  29. roll $1, %edx
  30.  
  31. sledeci_element:
  32. decl %ebx
  33. cmpl $0, %ebx
  34. je rezultat
  35. addl $1, %ecx
  36. jmp prvi_broj
  37.  
  38. rezultat:
  39. shll $3, %eax
  40. shll $3, %edx
  41. addl %edx, %eax
  42. movl 12(%ebp), %ecx
  43. movl %eax, (%ecx)
  44.  
  45. kraj:
  46. popl %edi
  47. popl %esi
  48. popl %ebx
  49. movl %ebp, %esp
  50. popl %esp
  51. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement