Advertisement
Guest User

Untitled

a guest
Nov 6th, 2014
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SPARK 2.05 KB | None | 0 0
  1. ! Prints "Hello, world!\n" in the msgarea.
  2. ! SRCTools version: vph 6/29/00, updated rez 4/16/02
  3. ! ARCTools version: mww converted 6/17/05
  4.  
  5.     .begin
  6. BASE    .equ 0x3fffc0       !Starting point of the memory mapped region
  7. COUT    .equ 0x0        !0xffff0000 Console Data Port
  8. COSTAT  .equ 0x4        !0xffff0004 Console Status Port.
  9.  
  10.     one: 0      !Day one
  11.     two: 0  !Day two
  12.     three: 0    !Day three
  13.     total: -1   !Total days rained
  14.     const1: 1
  15.     const2: 2
  16.     String2:    0x4e, 0
  17.     String: 0x59, 0
  18.  
  19.     .org 2048
  20.  
  21.     !---- Loading stuff into registers and adding them 
  22.     ld [one], %g5
  23.     ld [two], %g6
  24.     ld [three], %g7
  25.     ld [total], %g9
  26.     ld [const1], %g10
  27.     ld [const2], %g11
  28.     add %g5, %g9, %g9
  29.     add %g6, %g9, %g9
  30.     add %g7, %g9, %g9
  31.     sethi BASE, %r4
  32.  
  33. !-- if statement start --------------------------------------------
  34. cmp %g11, %g9 !-- it rained 3 times
  35. bge else
  36. nop
  37.  
  38. Loop:   ld [%r2 + String], %r3  !Load next char into r3
  39.     addcc %r3,%r0,%r3
  40.     be End          ! stop if null.
  41. Wait:   ldub [%r4+COSTAT], %r1
  42.     andcc %r1, 0x80, %r1
  43.     be Wait
  44.     stb %r3, [%r4+COUT] !Print to console
  45.     add %r2, 4, %r2     !increment String offset (r2)
  46.     ba Loop
  47.  
  48. and %g8, %g0, %g8
  49. add %g8, 1, %g8
  50.  
  51. ba next
  52. nop
  53. !-- else statement start ------------------------------------------
  54.  
  55. else:   cmp %g9, 1  !--- it rained 2 times
  56.         bge else2
  57.             nop
  58.  
  59.             Loop2:  ld [%r2 + String], %r3  !Load next char into r3
  60.                 addcc %r3,%r0,%r3
  61.                 be End          ! stop if null.
  62.             Wait2:  ldub [%r4+COSTAT], %r1
  63.                 andcc %r1, 0x80, %r1
  64.                 be Wait
  65.                 stb %r3, [%r4+COUT] !Print to console
  66.                 add %r2, 4, %r2     !increment String offset (r2)
  67.                 ba Loop
  68.  
  69.             and %g8, %g0, %g8
  70.             add %g8, 1, %g8
  71.  
  72.             ba next
  73.             nop
  74.         !-- rained less than 2 times so turn on
  75.         else2: mov 0, %g8
  76.  
  77.             Loop3:  ld [%r2 + String2], %r3 !Load next char into r3
  78.                 addcc %r3,%r0,%r3
  79.                 be End          ! stop if null.
  80.             Wait3:  ldub [%r4+COSTAT], %r1
  81.                 andcc %r1, 0x80, %r1
  82.                 be Wait
  83.                 stb %r3, [%r4+COUT] !Print to console
  84.                 add %r2, 4, %r2     !increment String offset (r2)
  85.                 ba Loop
  86.  
  87. next: or %g8, 42, %g8
  88.  
  89. End:    halt
  90.  
  91.     .org 3000
  92.  
  93.  
  94.    
  95.  
  96.  
  97.     .end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement