Advertisement
Guest User

Untitled

a guest
Apr 5th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. hello: dodawanie.o
  2.     ld -o dodawanie dodawanie.o
  3. hello.o: dodawanie.s
  4.     as -ggtabs -o dodawanie.o dodawanie.s
  5. lub
  6. gcc dodawanie.s -o dodawanie -g
  7.  
  8.  
  9. DODAWANIE
  10. //DZIALA!!
  11. //pomyslec nad napisaniem tego prosciej...
  12. SYSEXIT = 1
  13. EXIT_SUCCESS = 0
  14. SYSREAD = 3
  15. SYSWRITE = 4
  16. STDIN = 0
  17. STDOUT = 1
  18. size = 512
  19.  
  20. .bss
  21. .lcomm bufor,size
  22.  
  23. .data
  24. liczba1: .long 0xFFFFFFFF,0xF0000000,0x00000000,0xF0000000
  25. liczba2: .long 0x00000000,0x10000000,0x00000000,0xF0000001
  26.  
  27. .text
  28. .global _start
  29. _start:
  30. movl $3, %edi
  31. movl $0, %ecx
  32. clc
  33. pushf
  34. loop_start:
  35.     movl liczba1(,%edi,4), %eax
  36.     movl liczba2(,%edi,4), %ebx
  37.     popf
  38.     adcl %ebx, %eax
  39.     pushl %eax
  40.     pushf
  41.     cmpl $0, %edi
  42.     je carry
  43.     decl %edi
  44.     jmp loop_start
  45.  
  46. carry:
  47.     xorl %ecx, %ecx
  48.     popf
  49.     rcll $1, %ecx
  50.     pushl %ecx
  51.  
  52. exit:
  53. movl $SYSEXIT, %eax
  54. movl $EXIT_SUCCESS,%ebx
  55. int $0x80
  56.  
  57. ODEJMOWANIE
  58.  
  59. //DZIALA!!
  60. //pomyslec nad napisaniem tego prosciej...
  61. SYSEXIT = 1
  62. EXIT_SUCCESS = 0
  63. SYSREAD = 3
  64. SYSWRITE = 4
  65. STDIN = 0
  66. STDOUT = 1
  67. size = 512
  68.  
  69. .bss
  70. .lcomm bufor,size
  71.  
  72. .data
  73. liczba1: .long 0xFFFFFFFF,0xF0000000,0x00000000,0xF0000000
  74. liczba2: .long 0x00000000,0x10000000,0x00000000,0xF0000001
  75.  
  76. .text
  77. .global _start
  78. _start:
  79. movl $3, %edi
  80. movl $0, %ecx
  81. clc
  82. pushf
  83. loop_start:
  84.     movl liczba1(,%edi,4), %eax
  85.     movl liczba2(,%edi,4), %ebx
  86.     notl %eax
  87.     popf
  88.     adcl %ebx, %eax
  89.     notl %eax
  90.     pushl %eax
  91.     pushf
  92.     cmpl $0, %edi
  93.     je carry
  94.     decl %edi
  95.     jmp loop_start
  96.  
  97. carry:
  98.     andl %edx, %edx
  99.     xorl %ecx, %ecx
  100.     popf
  101.     adcl %ecx, %edx
  102.     negl %edx
  103.     pushl %edx
  104.  
  105. exit:
  106. movl $SYSEXIT, %eax
  107. movl $EXIT_SUCCESS,%ebx
  108. int $0x80
  109.  
  110. MNOŻENIE
  111.  
  112. SYSEXIT = 1
  113. EXIT_SUCCESS = 0
  114. SYSREAD = 3
  115. SYSWRITE = 4
  116. STDIN = 0
  117. STDOUT = 1
  118. LICZBA1_OSTATNI = 3
  119. LICZBA2_OSTATNI = 3
  120.  
  121. .data
  122. liczba1: .long 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF
  123. liczba2: .long 0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF
  124.  
  125. .text
  126. .global _start
  127. _start:
  128. movl $0, %edi
  129.  
  130. fill_stack_with_zeros:
  131.     push $0
  132.     cmpl $LICZBA1_OSTATNI, %edi
  133.     je loop_start
  134.     incl %edi
  135.     jmp fill_stack_with_zeros  
  136.  
  137. loop_start:
  138.     movl $LICZBA2_OSTATNI, %esi
  139.     movl liczba1(,%edi, 4), %ebx
  140.     movl $0, %ecx
  141.  
  142. multiply:
  143.    
  144.     movl liczba2(,%esi,4), %eax
  145.     movl $0, %edx
  146.     mul %ebx
  147.     addl %ecx, %eax
  148.     adcl $0, %edx
  149.     movl %edx, %ecx
  150.     movl (%esp,%esi,4), %edx
  151.     addl %edx, %eax
  152.     movl %eax, (%esp, %esi, 4)
  153.     adcl $0, %ecx
  154.  
  155.     cmpl $0, %esi
  156.     je carry
  157.     decl %esi
  158.     jmp multiply
  159.          
  160. carry:
  161.     pushl %ecx
  162.     cmpl $0, %edi
  163.     je exit
  164.     decl %edi
  165.     jmp loop_start
  166.  
  167. exit:
  168. movl $SYSEXIT, %eax
  169. movl $EXIT_SUCCESS,%ebx
  170. int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement