_takumi

hw4n17.asm

Apr 18th, 2022 (edited)
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. %include "io.inc"
  2.  
  3. section .bss
  4.     a resd 1
  5.     b resd 1
  6.     c resd 1
  7.     ans resd 3
  8.  
  9. section .text
  10. global CMAIN
  11. CMAIN:
  12.     mov ebp, esp
  13.     GET_UDEC 4, [a]
  14.     GET_UDEC 4, [b]
  15.     GET_UDEC 4, [c]
  16.     push dword [c]
  17.     push dword [b]
  18.     push dword [a]
  19.     push ans
  20.     call mul96
  21.    
  22.     xor eax, eax
  23.     mov esp, ebp
  24.     ret
  25.    
  26. to_string:
  27.     push ebp
  28.     mov ebp, esp
  29.    
  30.     leave
  31.     ret
  32.    
  33. mul96:
  34.     push ebp
  35.     mov ebp, esp
  36.     push ebx
  37.     sub esp, 16
  38.     mov eax, [ebp + 12]
  39.     mov ecx, [ebp + 16]
  40.     mul ecx
  41.     mov [esp + 4], edx
  42.     mov [esp], eax
  43.     mov eax, [ebp + 20]
  44.     mul dword [esp]
  45.     mov [esp + 8], eax ; eax1
  46.     mov [esp + 12], edx; edx1
  47.     mov eax, [ebp + 20]
  48.     mul dword [esp + 4]
  49.     add [esp + 12], eax
  50.     adc edx, 0
  51.     mov ecx, [esp + 12]
  52.     mov eax, [esp + 8]; edx:ecx:eax
  53.     mov ebx, [ebp + 8]
  54.     mov [ebx], eax
  55.     mov [ebx + 4], ecx
  56.     mov [ebx + 8], edx
  57.     add esp, 16
  58.     pop ebx
  59.     pop ebp
  60.     ret
Add Comment
Please, Sign In to add comment