Guest User

Untitled

a guest
Jul 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. .data # section declaration - variables only
  2.  
  3.  
  4.  
  5. msg:
  6.  
  7. .string "Hello, world!\n"
  8.  
  9. len = . - msg # length of our dear string
  10.  
  11.  
  12.  
  13. .text # section declaration - begin code
  14.  
  15.  
  16.  
  17. .global _start
  18.  
  19. .section ".opd","aw"
  20.  
  21. .align 3
  22.  
  23. _start:
  24.  
  25. .quad ._start,.TOC.@tocbase,0
  26.  
  27. .previous
  28.  
  29.  
  30.  
  31. .global ._start
  32.  
  33. ._start:
  34.  
  35.  
  36.  
  37. # write our string to stdout
  38.  
  39.  
  40.  
  41. li 0,4 # syscall number (sys_write)
  42.  
  43. li 3,1 # first argument: file descriptor (stdout)
  44.  
  45. # second argument: pointer to message to write
  46.  
  47.  
  48.  
  49. # load the address of 'msg':
  50.  
  51.  
  52.  
  53. # load high word into the low word of r4:
  54.  
  55. lis 4,msg@highest # load msg bits 48-63 into r4 bits 16-31
  56.  
  57. ori 4,4,msg@higher # load msg bits 32-47 into r4 bits 0-15
  58.  
  59.  
  60.  
  61. rldicr 4,4,32,31 # rotate r4's low word into r4's high word
  62.  
  63.  
  64.  
  65. # load low word into the low word of r4:
  66.  
  67. oris 4,4,msg@h # load msg bits 16-31 into r4 bits 16-31
  68.  
  69. ori 4,4,msg@l # load msg bits 0-15 into r4 bits 0-15
  70.  
  71.  
  72.  
  73. # done loading the address of 'msg'
  74.  
  75.  
  76.  
  77. li 5,len # third argument: message length
  78.  
  79. sc # call kernel
  80.  
  81.  
  82.  
  83. # and exit
  84.  
  85.  
  86.  
  87. li 0,1 # syscall number (sys_exit)
  88.  
  89. li 3,0 # first argument: exit code
  90.  
  91. sc # call kernel
Add Comment
Please, Sign In to add comment