Advertisement
Guest User

Untitled

a guest
Oct 28th, 2015
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARK 1.96 KB | None | 0 0
  1. /* TriBulle : Programme du laboratoitre #4
  2.  
  3.    Entree :  aucune.
  4.    Sortie :  Tableau trié
  5.    Auteur :  Benjamin Ross (15 092 061)
  6.              Antoine Theberge (15 092 016)
  7.  
  8. */
  9.         .global TriBulle
  10.         .section ".text"    ! section d'instructions
  11. TriBulle:
  12.  
  13.     setx    tabNon,%l7,%l0
  14.     setx    tabTri,%l7,%l1
  15.     setx    ptfmt1,%l7,%o0 
  16.     call    printf
  17.    
  18.     clr %l2
  19. TriBulle0:
  20.     setx    pftmt3,%l7,%o0
  21.     lduw    [%l0+%l2],%o1
  22.     call    printf
  23.     nop
  24.     inc 4,%l2
  25.     sub %l2,40,%l3
  26.     brlz    %l3,TriBulle0
  27.     nop
  28.  
  29.     setx    ptfmt4,%l7,%o0 
  30.     call    printf
  31.     nop
  32.     clr %l2
  33. TriBulle03:
  34.     lduw    [%l0+%l2],%l3
  35.     stuw    %l3,[%l1+%l2]  
  36.     inc 4,%l2
  37.     cmp %l2,48
  38.     bl  TriBulle03
  39.     nop
  40.  
  41. TriBulle05:
  42.     mov 40,%l2      ! i/n
  43. TriBulle10:
  44.     clr %l3     ! j
  45. TriBulle11:
  46.     lduw    [%l1+%l3],%l4
  47.     add %l3,4,%l6
  48.     lduw    [%l1+%l6],%l5
  49.     cmp %l4,%l5
  50.     ble TriBulle20
  51.     nop
  52. TriBulle15:
  53.     stuw    %l5,[%l1+%l3]
  54.     stuw    %l4,[%l1+%l6]
  55.     nop
  56. TriBulle20:
  57.     inc 4,%l3
  58.     add %l3,4,%l6
  59.     cmp %l6,%l2
  60.     bge TriBulle25
  61.     nop
  62.     ba  TriBulle11
  63.     nop
  64. TriBulle25:         ! Outer Loop
  65.     dec 4,%l2
  66.     brlez   %l2,TriBulle50
  67.     nop
  68.     ba  TriBulle10
  69.     nop
  70.  
  71. TriBulle50:
  72.     setx    ptfmt2,%l7,%o0 
  73.     call    printf
  74.     nop
  75.     clr %l2
  76. TriBulle51:         ! Affichage final
  77.     setx    pftmt3,%l7,%o0
  78.     lduw    [%l1+%l2],%o1
  79.     call    printf
  80.     nop
  81.     inc 4,%l2
  82.     sub %l2,40,%l3
  83.     brlz    %l3,TriBulle51
  84.     nop
  85.  
  86.     setx    ptfmt4,%l7,%o0 
  87.     call    printf
  88.     nop
  89.  
  90. TriBulle100:
  91.                     ! terminaison du programme
  92.         clr     %o0     ! 1er parametre
  93.         call    fflush      ! vidange des tampons de fichiers
  94.         nop
  95.  
  96.         clr     %o0     ! 1er parametre
  97.         call    exit        ! sortie du programme
  98.         nop
  99.  
  100. /* Definition des donnees */
  101.         .section ".bss"     ! section de donnees non initialisees
  102.         .align  4
  103. tabTri: .skip   4*10
  104.  
  105.         .section ".rodata"  ! section de donnees en lecture seulement
  106. ptfmt1: .asciz  "Tableau non trie: \n"
  107. ptfmt2: .asciz  "Tableau trie: \n"
  108. pftmt3: .asciz  "%d "
  109. ptfmt4: .asciz  "\n"
  110.         .align   4
  111. tabNon: .word    15,2,65,54,8,12,61,32,94,88
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement