Advertisement
DanilaG

Untitled

May 12th, 2019
915
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .386
  2. .model flat, stdcall
  3. option casemap : none
  4.  
  5. ;Подключаем вспомогательные модули
  6. include \masm32\include\kernel32.inc
  7. include \masm32\include\masm32.inc
  8. include \masm32\include\msvcrt.inc
  9. includelib \masm32\lib\kernel32.lib
  10. includelib \masm32\lib\masm32.lib
  11. includelib \masm32\lib\msvcrt.lib
  12. include \masm32\macros\macros.asm
  13.  
  14. .data
  15.     text_out_sum db "Sum: %lu %lu %lu %lu", 10, 13, 0
  16.     text_out_mul db "Mul: %lu %lu %lu %lu %lu %lu %lu %lu", 10, 13, 0
  17.     text_out_lu db "%lu ", 0
  18.    
  19.     n dd 4
  20.    
  21.     a_sum dd 4294967295, 4294967295, 4294967293, 0
  22.     b_sum dd 1, 1, 2, 0
  23.    
  24.     ;a_mul dd 2147483648, 0, 0, 0
  25.    ;b_mul dd 2, 0, 0, 0
  26.    
  27.     ;a_mul dd 1, 1, 0, 0
  28.    ;b_mul dd 0, 1, 0, 0
  29.    
  30.     a_mul dd 2147483648, 2147483648, 2147483648, 2147483648
  31.     b_mul dd 2, 2, 2, 2
  32.    
  33.     c_mul dd 0, 0, 0, 0, 0, 0, 0, 0
  34.    
  35.     mul_i dd 0
  36.     mul_j dd 0
  37.     mul_buff1 dd 0
  38.     mul_buff2 dd 0
  39.     mul_add_buff dd 0, 0, 0, 0
  40.  
  41. .code
  42. _ladd proc
  43.     mov ecx, 0
  44.     mov ebx, [ebp]
  45.     lable_next_digit:
  46.     mov eax, [ebx + ecx * 4]
  47.     mov edx, [ebp - 4 * 1]
  48.     add eax, [edx + ecx * 4]
  49.     mov [ebx + ecx * 4], eax
  50.     JNC next
  51.         mov edx, ecx
  52.         lable_offset:
  53.         add edx, 1
  54.         mov eax, [ebx + edx * 4]
  55.         add eax, 1
  56.         mov [ebx + edx * 4], eax
  57.         JC lable_offset
  58.     next:
  59.     inc ecx
  60.     cmp ecx, n
  61.     JNZ lable_next_digit
  62.     ret
  63. _ladd endp
  64.  
  65. start:  
  66.     lable_mul:
  67.     mov ecx, mul_i
  68.     mov eax, a_mul[ecx * 4]
  69.     mov ebx, mul_j
  70.     mul b_mul[ebx * 4]
  71.     mov mul_add_buff[0], eax
  72.     mov mul_add_buff[1 * 4], edx
  73.     enter 8, 0
  74.     mov ecx, mul_i
  75.     add ecx, mul_j
  76.     lea eax, c_mul[ecx * 4]
  77.     mov [ebp], eax
  78.     lea eax, mul_add_buff
  79.     mov [ebp - 1 * 4], eax
  80.     call _ladd
  81.     leave
  82.     inc mul_j
  83.     mov eax, mul_j    
  84.     cmp eax, n
  85.     JNZ lable_mul
  86.     mov eax, 0
  87.     mov mul_j, eax
  88.     inc mul_i
  89.     mov eax, mul_i    
  90.     cmp eax, n
  91.     JNZ lable_mul
  92.     invoke crt_printf, addr text_out_mul, c_mul[7 * 4], c_mul[6 * 4], c_mul[5 * 4], c_mul[4 * 4], c_mul[12], c_mul[8], c_mul[4], c_mul[0]
  93.    
  94.     enter 8, 0
  95.     lea eax, a_sum
  96.     mov [ebp], eax
  97.     lea eax, b_sum
  98.     mov [ebp - 1 * 4], eax
  99.     call _ladd
  100.     invoke crt_printf, addr text_out_sum, a_sum[12], a_sum[8], a_sum[4], a_sum[0]
  101.     leave    
  102.    
  103.     exit
  104. end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement