SlideServe
Menu
Préférences
© SlideServe · v2026

SPARC Programming Model for Temperature Conversion

orpah avatar
20 diapositives · 312 Views · Sep 05, 2014

Learn SPARC programming model with examples on temperature conversion using logical and arithmetic operations, control transfer instructions, and efficient coding practices.

SPARC Programming Model for Temperature Conversion - slide 1
01 / 20SPARC Programming Model for Temperature Conversion
1 / 17

Télécharger la présentation

SPARC Programming Model for Temperature Conversion
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation

  1. SPARC Programming Model • 24 “window” registers • 8 global registers • Control registers • Multiply step • PSR (status flags, etc.) • Trap Base register • Window Invalid Mask • Two program counters (PC and nPC)

  2. SPARC Program /* This program converts a temperature in Celcius to Fahrenheit. George Wells - 30 May 2003 */ offs = 32 /* Variables c and f are stored in %l0 and %l1 */ .global main main: mov 24, %l0! Initialize c = 24 mov 9, %o0! 9 into %o0 for multiplication mov %l0, %o1! c into %o1 for multiplication call .mul ! Result in %o0 nop ! Delay slot mov 5, %o1! 5 into %o1 for division call .div ! Result in %o0 nop ! Delay slot

  3. Example (cont.) ... add %o0, offs, %l1 ! f = result + offs mov 1, %g1! Trap dispatch ta 0 ! Trap to system

  4. mov 9, %o0! 9 into %o0 for multiplication call .mul ! Result in %o0 mov %l0, %o1! c into %o1 for multiplication • Better! Filling Delay Slots mov 9, %o0! 9 into %o0 for multiplication mov %l0, %o1! c into %o1 for multiplication call .mul ! Result in %o0 nop ! Delay slot • Not very efficient

  5. Modified Program main: mov 24, %l0! Initialize c = 24 mov 9, %o0! 9 into %o0 for multiplication call .mul ! Result in %o0 mov %l0, %o1! c into %o1 for multiplication call .div ! Result in %o0 mov 5, %o1! 5 into %o1 for division ...

  6. 3. Control Transfer Instructions • Branching • Unconditional: ba bn • Conditional: bicc • icc= Integer Condition Codes • Condition flags are set explicitly by arithmetic and logical operations • E.g. addcc

  7. Delayed Control Transfer • Increases the efficiency of pipelining

  8. Example /* This program converts temperatures between 10 and 20 in Celcius to Fahrenheit. George Wells - 30 May 2003 */ offs = 32 /* Variables c and f are stored in %l0 and %l1 */ .global main main: mov 10, %l0 ! Initialize c = 10 loop: mov 9, %o0 ! 9 into %o0 for .mul call .mul ! Result in %o0 mov %l0, %o1 ! c into %o1 for .mul call .div ! Result in %o0 mov 5, %o1 ! 5 into %o1 for .div . . .

  9. Example (cont.) . . . add %o0, offs, %l1 ! f = result + offs add %l0, 1, %l0 ! c++ cmp %l0, 21 ! c < 21 ? bl loop nop ! Delay slot mov 1, %g1 ! Trap dispatch ta 0 ! Trap to system

  10. Annulled Branches • Delay slot instruction is ignored • Conditional: if branch is not taken • Unconditional: always annulled

  11. Unoptimised assembler: ! Assumes a is in %l0 and b is in %l1 b test ! See if loop should execute nop ! Delay slot loop: add %l0, %l1, %l0 ! a = a + b test: cmp %l0, 17 ! a <= 17 ble loop ! If so branch back to start nop ! Delay slot An Annulled Branch • Java/C Code: while (a <= 17) a = a + b;

  12. Optimised Assembler ! Assumes a is in %l0 and b is in %l1 b test ! See if loop should execute nop ! Delay slot loop: test: cmp %l0, 17 ! a <= 17 ble,a loop ! If so branch back to start add %l0, %l1, %l0 ! a = a + b

  13. 4. Logical and Arithmetic Operations • Logical Operators • and or xor • xnor andn orn • + cc to set the condition codes • Shift Operators • sra srl sll

  14. Arithmetic Operators • Only addition and subtraction • add[x][cc] • sub[x][cc] • [x] — with carry • [cc] — to set the flags

  15. Multiplication • Long multiplication is supported by the “multiply step” instruction: • mulscc

  16. Division • Use the standard routines: • .div .rem • .udiv .urem