Advertisement
Guest User

Untitled

a guest
Feb 7th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         .text
  2.         .global mul64p
  3. mul64p: // (a(12), b(8)) * (c(20), d(16))
  4.         pushl   %ebp
  5.         movl    %esp, %ebp
  6.         xorl    %eax, %eax
  7.         subl    $16, %esp
  8.         movl    $0, (%esp)
  9.         movl    $0, 4(%esp)
  10.         movl    $0, 8(%esp)
  11.         movl    $0, 12(%esp)
  12.  
  13.         // d * b
  14.         movl    8(%ebp), %eax
  15.         mull    16(%ebp)
  16.         movl    %eax, (%esp)
  17.         movl    %edx, 4(%esp)
  18.  
  19.         //  a * d
  20.         movl    12(%ebp), %eax
  21.         mull    16(%ebp)
  22.         addl    %eax, 4(%esp)
  23.         adcl    %edx, 8(%esp)
  24.         adcl    $0, 12(%esp)
  25.  
  26.         //  c * b
  27.         movl    8(%ebp), %eax
  28.         mull    20(%ebp)
  29.         addl    %eax, 4(%esp)
  30.         adcl    %edx, 8(%esp)
  31.         adcl    $0, 12(%esp)
  32.  
  33.         //  a * c
  34.         movl    12(%ebp), %eax
  35.         mull    20(%ebp)
  36.         addl    %eax, 8(%esp)
  37.         adcl    %edx, 12(%esp)
  38.        
  39.         //  write number
  40.         //  first
  41.         xorl    %ebx, %ebx
  42.         movl    12(%esp), %eax
  43.         testl   %eax, %eax
  44.         jz      f2
  45.         movl    $1, %ebx
  46.         pushl   %eax
  47.         pushl   $fout
  48.         call    printf
  49.         addl    $8, %esp
  50.         jmp     n2
  51.  
  52. f2:     movl    8(%esp), %eax
  53.         testl   %eax, %eax
  54.         jz      f3
  55.         pushl   %eax
  56.         pushl   $fout
  57.         call    printf
  58.         addl    $8, %esp
  59.         jmp     n3
  60.  
  61. f3:     movl    4(%esp), %eax
  62.         testl   %eax, %eax
  63.         jz      f4
  64.         pushl   %eax
  65.         pushl   $fout
  66.         call    printf
  67.         addl    $8, %esp
  68.         jmp     n4
  69.  
  70. f4:     pushl   $fout
  71.         call    printf
  72.         addl    $4, %esp
  73.         jmp     end
  74.  
  75. n2:     movl    8(%esp), %eax
  76.         pushl   %eax
  77.         pushl   $nout
  78.         call    printf
  79.         addl    $8, %esp
  80.  
  81. n3:     movl    4(%esp), %eax
  82.         pushl   %eax
  83.         pushl   $nout
  84.         call    printf
  85.         addl    $8, %esp
  86.  
  87. n4:     pushl   $nout
  88.         call    printf
  89.         addl    $4, %esp
  90.  
  91. end:    pushl   $nl
  92.         call    printf
  93.         addl    $20, %esp
  94.         popl    %ebp
  95.         ret
  96.  
  97.  
  98.         .data
  99. zero:   .quad   0x0
  100. fout:   .asciz  "%x"
  101. nout:   .asciz  "%08x"
  102. nl:     .asciz  "\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement