Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. /// c_array.c
  2. #include <stdint.h>
  3. #include <stdlib.h>
  4. #include <stdio.h>
  5.  
  6. int main(void)
  7. {
  8. const uint8_t array_c[10] =
  9. { 0x01, 0x02, 0x03, 0x04, 0x05,
  10. 0x06, 0x07, 0x08, 0x09, 0x0A };
  11.  
  12. for ( uint8_t i = 0;
  13. i < ( sizeof(array_c) / sizeof(array_c[0]));
  14. i++ ) {
  15. printf("0x%x\r\n", array_c[i]);
  16. }
  17.  
  18. return 0;
  19. }
  20.  
  21. /**
  22. * Result:
  23. * Toolchain: arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170215 (release)
  24. * Compile: arm-none-eabi-gcc -S c_array.c -mthumb -mcpu=cortex-m4 -O3 -std=c11
  25. */
  26.  
  27. .cpu cortex-m4
  28. .eabi_attribute 20, 1
  29. .eabi_attribute 21, 1
  30. .eabi_attribute 23, 3
  31. .eabi_attribute 24, 1
  32. .eabi_attribute 25, 1
  33. .eabi_attribute 26, 1
  34. .eabi_attribute 30, 2
  35. .eabi_attribute 34, 1
  36. .eabi_attribute 18, 4
  37. .file "c_array.c"
  38. .section .text.startup,"ax",%progbits
  39. .align 1
  40. .p2align 2,,3
  41. .global main
  42. .syntax unified
  43. .thumb
  44. .thumb_func
  45. .fpu softvfp
  46. .type main, %function
  47. main:
  48. @ args = 0, pretend = 0, frame = 16
  49. @ frame_needed = 0, uses_anonymous_args = 0
  50. push {r4, r5, r6, lr}
  51. ldr r3, .L6
  52. ldr r6, .L6+4
  53. ldm r3, {r0, r1, r2}
  54. sub sp, sp, #16
  55. add r3, sp, #4
  56. stmia r3!, {r0, r1}
  57. add r4, sp, #4
  58. strh r2, [r3] @ movhi
  59. add r5, sp, #14
  60. .L2:
  61. ldrb r1, [r4], #1 @ zero_extendqisi2
  62. mov r0, r6
  63. bl printf
  64. cmp r4, r5
  65. bne .L2
  66. movs r0, #0
  67. add sp, sp, #16
  68. @ sp needed
  69. pop {r4, r5, r6, pc}
  70. .L7:
  71. .align 2
  72. .L6:
  73. .word .LANCHOR0
  74. .word .LC1
  75. .size main, .-main
  76. .section .rodata
  77. .align 2
  78. .set .LANCHOR0,. + 0
  79. .LC0:
  80. .byte 1
  81. .byte 2
  82. .byte 3
  83. .byte 4
  84. .byte 5
  85. .byte 6
  86. .byte 7
  87. .byte 8
  88. .byte 9
  89. .byte 10
  90. .section .rodata.str1.4,"aMS",%progbits,1
  91. .align 2
  92. .LC1:
  93. .ascii "0x%x\015\012\000"
  94. .ident "GCC: (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170215 (release) [ARM/embedded-6-branch revision 245512]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement