Guest User

Untitled

a guest
Dec 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. svc 0
  2. mov fdr, w0
  3.  
  4. cmp fdr, 0
  5. b.ge calcBufBase
  6.  
  7. adrp x0, fmt1
  8. add x0, x0, :lo12:fmt1
  9. adrp x1, fileName
  10. add x1, x1, :lo12:fileName
  11. bl printf
  12.  
  13. mov w0, -1
  14. b exit
  15.  
  16. define(fdr, w9)
  17. define(nReadr, x10)
  18. define(bufBaser, x11)
  19. define(input, d25)
  20.  
  21. fp .req x29
  22. lr .req x30
  23.  
  24. .balign 4
  25. fmt1: .string "Error opening file n"
  26. filename: .string "input.bin"
  27. fmt2: .string "long int %ldn"
  28.  
  29. bufSize = 8
  30. alloc = -(16 + bufSize) & -16
  31. dealloc = -alloc
  32. bufs = 16
  33. atFDCWD = -100
  34.  
  35. .balign 4
  36. .global main
  37.  
  38. main:
  39. stp fp, lr, [sp, alloc]!
  40. mov fp, sp
  41.  
  42. openFile:
  43. mov w0, atFDCWD
  44. adrp x1, filename
  45. add x1, x1, :lo12:fileName
  46. mov w2, 0
  47. mov w3, 0
  48. mov x8, 56
  49. svc 0
  50. mov fdr, w0
  51.  
  52. cmp fdr, 0
  53. b.ge calcBufBase
  54.  
  55. adrp x0, fmt1
  56. add x0, x0, :lo12:fmt1
  57. adrp x1, filename
  58. add x1, x1, :lo12:fileName
  59. bl printf
  60. mov w0, -1
  61.  
  62. b exit
  63.  
  64. calcBufBase:
  65. add bufBaser, fp, bufs
  66.  
  67. readFile:
  68. mov w0, fdr
  69. mov x1, bufBaser
  70. mov x8, 63
  71. svc 0
  72. mov nReadr, x0
  73.  
  74. cmp nReadr, bufSize
  75. b.ne closeFile
  76.  
  77. adrp x0, fmt2
  78. add x0, x0, :lo12:fmt2
  79. ldr d0, [bufBaser]
  80. bl printf
  81.  
  82. b readFile
  83.  
  84. closeFile:
  85. mov w0, fdr
  86. mov x8, 57
  87. svc 0
  88.  
  89. mov w0, 0
  90. ldp fp, lr, [sp], dealloc
  91.  
  92. mainContin:
  93. fmov d0, input
  94.  
  95. ...
  96.  
  97. exit:
  98. mov w0, 0
  99. ldp fp, lr, [sp], dealloc
  100. ret
Add Comment
Please, Sign In to add comment