Advertisement
Guest User

Untitled

a guest
Oct 9th, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARK 1.78 KB | None | 0 0
  1.  
  2. print:  .asciz      "Multiplicand: 0x%x, Product: 0x%x, Multiplier: 0x%x\n"
  3.         .section    ".text"
  4.         .align      4
  5.  
  6.         .global main
  7. main:   save        %sp,    -96,    %sp
  8.        
  9. calc1:  set         83754,  %l0             !multiplier
  10.         set         23421,  %l1             !multiplicand        
  11.         mov         0,      %l2             !product
  12.  
  13.         mov         1,      %l3             !counter      
  14.  
  15.         set         print,  %o0
  16.         mov         %l1,    %o1
  17.         mov         %l2,    %o2
  18.         mov         %l0,    %o3             !print1
  19.         call        printf
  20.         nop
  21.  
  22.         clr         %l6
  23.         tst         %l0
  24.         bl,a        loop
  25.         mov         1,      %l6
  26.  
  27. loop:   cmp         %l3,    32
  28.         bg          ifneg
  29.         nop
  30.         btst        0x1,    %l0
  31.         be          next
  32.         nop
  33.         add         %l2,    %l1,    %l2     !add multiplicand to product      
  34.  
  35. next:   and         %l2,    1,      %l5
  36.         srl         %l2,    1,      %l2
  37.         srl         %l0,    1,      %l0     !shifty      
  38.         sll         %l5,    31,     %l5
  39.         bset        %l5,    %l0
  40.  
  41.         inc         %l3
  42.         ba          loop
  43.         nop
  44.  
  45. ifneg:  cmp         %l6,    1
  46.         bne         pos
  47.         nop
  48. !        tst         %l1
  49. !        bl          else
  50. !        nop
  51.         sub         %l2,    %l1,    %l2
  52. !        ba          pos
  53. !        nop
  54. !else:   clr         %l2
  55.  
  56. pos:    set         print,  %o0             !print2
  57.         mov         %l1,    %o1
  58.         mov         %l2,    %o2
  59.         mov         %l0,    %o3
  60.         call        printf
  61.         nop
  62.  
  63. end:    mov         1,      %g1             !trap dispatch
  64.         ta          0                       !trap to system
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement