d4dag-gcc-wa.s 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. 1 .file "d4dag.c"
  2. 2 .text
  3. 3 .Ltext0:
  4. 4 .local d4d__main
  5. 5 .comm d4d__main,8,8
  6. 6 .globl d4d_version
  7. 8 d4d_version:
  8. 9 .LFB0:
  9. 10 .file 1 "d4dag.c"
  10. 1:d4dag.c ****
  11. 2:d4dag.c **** /*
  12. 3:d4dag.c **** * Copyright t lefering
  13. 4:d4dag.c **** * Copyright Simon Speich 2013
  14. 5:d4dag.c **** *
  15. 6:d4dag.c **** * This program is free software: you can redistribute it and/or modify
  16. 7:d4dag.c **** * it under the terms of the GNU General Public License as published by
  17. 8:d4dag.c **** * the Free Software Foundation, either version 3 of the License, or
  18. 9:d4dag.c **** * (at your option) any later version.
  19. 10:d4dag.c **** *
  20. 11:d4dag.c **** * This program is distributed in the hope that it will be useful,
  21. 12:d4dag.c **** * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. 13:d4dag.c **** * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. 14:d4dag.c **** * GNU General Public License for more details.
  24. 15:d4dag.c **** *
  25. 16:d4dag.c **** * You should have received a copy of the GNU General Public License
  26. 17:d4dag.c **** * along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. 18:d4dag.c **** *
  28. 19:d4dag.c **** * These are the four essential freedoms with GNU GPL software:
  29. 20:d4dag.c **** * 1: freedom to run the program, for any purpose
  30. 21:d4dag.c **** * 2: freedom to study how the program works, and change it to make it do what you wish
  31. 22:d4dag.c **** * 3: freedom to redistribute copies to help your Free Software friends
  32. 23:d4dag.c **** * 4: freedom to distribute copies of your modified versions to your Free Software friends
  33. 24:d4dag.c **** * , ,
  34. 25:d4dag.c **** * / \
  35. 26:d4dag.c **** * ((__-^^-,-^^-__))
  36. 27:d4dag.c **** * `-_---' `---_-'
  37. 28:d4dag.c **** * `--|o` 'o|--'
  38. 29:d4dag.c **** * \ ` /
  39. 30:d4dag.c **** * ): :(
  40. 31:d4dag.c **** * :o_o:
  41. 32:d4dag.c **** * "-"
  42. 33:d4dag.c **** *
  43. 34:d4dag.c **** * SPDX-License-Identifier: GPL-3.0+
  44. 35:d4dag.c **** * License-Filename: LICENSE
  45. 36:d4dag.c **** */
  46. 37:d4dag.c ****
  47. 38:d4dag.c **** /**
  48. 39:d4dag.c **** * all routines have prefix d4d_
  49. 40:d4dag.c **** * all static routines and vars have prefix d4d___
  50. 41:d4dag.c **** * the prefix d4d_ has no special meaning but hopefully
  51. 42:d4dag.c **** * does not problems because of limited C namespace
  52. 43:d4dag.c **** */
  53. 44:d4dag.c ****
  54. 45:d4dag.c **** /* only in debug version linkage needed to printf */
  55. 46:d4dag.c **** #if D4D_DEBUG
  56. 47:d4dag.c **** #include <stdio.h>
  57. 48:d4dag.c **** #define print_debug(str, ...) printf(str" - %s:%u\n", ##__VA_ARGS__, __FILE__, __LINE__);
  58. 49:d4dag.c **** #endif
  59. 50:d4dag.c ****
  60. 51:d4dag.c **** /* datatypoes used are
  61. 52:d4dag.c **** * int, as signed 32bits integer value
  62. 53:d4dag.c **** * unsigned int, as 32bits integer value
  63. 54:d4dag.c **** * char, as signed 8bits integer value
  64. 55:d4dag.c **** * unsigned char, as 8bits integer value
  65. 56:d4dag.c **** */
  66. 57:d4dag.c ****
  67. 58:d4dag.c **** /**
  68. 59:d4dag.c **** * set here version number as int
  69. 60:d4dag.c **** */
  70. 61:d4dag.c **** #define D4DAG_VERSION 10
  71. 62:d4dag.c ****
  72. 63:d4dag.c **** /* defs and prototypes of routines for user program */
  73. 64:d4dag.c **** #include "d4dag.h"
  74. 65:d4dag.c ****
  75. 66:d4dag.c **** /* mallocer/freeer */
  76. 67:d4dag.c **** typedef void *(*malloc_fn)(unsigned int n);
  77. 68:d4dag.c **** typedef void (*free_fn)(void *ptr);
  78. 69:d4dag.c ****
  79. 70:d4dag.c **** /* toplevel control struct */
  80. 71:d4dag.c **** struct d4d__maing {
  81. 72:d4dag.c **** /* wrappers for malloc/free and all malloc's will be below 4Gb at once */
  82. 73:d4dag.c **** malloc_fn d4d__malloc;
  83. 74:d4dag.c **** free_fn d4d__free;
  84. 75:d4dag.c **** };
  85. 76:d4dag.c ****
  86. 77:d4dag.c **** /* main control */
  87. 78:d4dag.c **** static struct d4d__maing *d4d__main = (struct d4d__maing *)0;
  88. 79:d4dag.c ****
  89. 80:d4dag.c **** /* forward decl. */
  90. 81:d4dag.c **** static void d4d__memzero(void *ptr, unsigned int n);
  91. 82:d4dag.c **** /**
  92. 83:d4dag.c **** * returns version number as int
  93. 84:d4dag.c **** */
  94. 85:d4dag.c **** int d4d_version(void)
  95. 86:d4dag.c **** {
  96. 11 .loc 1 86 1
  97. 12 .cfi_startproc
  98. 13 0000 55 pushq %rbp
  99. 14 .cfi_def_cfa_offset 16
  100. 15 .cfi_offset 6, -16
  101. 16 0001 4889E5 movq %rsp, %rbp
  102. 17 .cfi_def_cfa_register 6
  103. 87:d4dag.c **** return (D4DAG_VERSION);
  104. 18 .loc 1 87 9
  105. 19 0004 B80A0000 movl $10, %eax
  106. 19 00
  107. 88:d4dag.c **** }
  108. 20 .loc 1 88 1
  109. 21 0009 5D popq %rbp
  110. 22 .cfi_def_cfa 7, 8
  111. 23 000a C3 ret
  112. 24 .cfi_endproc
  113. 25 .LFE0:
  114. 27 .globl d4d_init
  115. 29 d4d_init:
  116. 30 .LFB1:
  117. 89:d4dag.c ****
  118. 90:d4dag.c **** /**
  119. 91:d4dag.c **** *
  120. 92:d4dag.c **** * returns:
  121. 93:d4dag.c **** * 0 if oke
  122. 94:d4dag.c **** * -1 if missing malloc/free pointer
  123. 95:d4dag.c **** * -2 if malloc failed
  124. 96:d4dag.c **** * For embedded devices this source has no linkage to libraries
  125. 97:d4dag.c **** * which means here pointer to malloc/free must be supplied.
  126. 98:d4dag.c **** * when malloc returns zero then these routines crashes
  127. 99:d4dag.c **** */
  128. 100:d4dag.c **** int d4d_init(void *(*mallocer)(unsigned int n), void(*freeer)(void *ptr))
  129. 101:d4dag.c **** {
  130. 31 .loc 1 101 1
  131. 32 .cfi_startproc
  132. 33 000b 55 pushq %rbp
  133. 34 .cfi_def_cfa_offset 16
  134. 35 .cfi_offset 6, -16
  135. 36 000c 4889E5 movq %rsp, %rbp
  136. 37 .cfi_def_cfa_register 6
  137. 38 000f 4883EC10 subq $16, %rsp
  138. 39 0013 48897DF8 movq %rdi, -8(%rbp)
  139. 40 0017 488975F0 movq %rsi, -16(%rbp)
  140. 102:d4dag.c **** /* malloc/free pointers must be specified */
  141. 103:d4dag.c **** if(!mallocer) {
  142. 41 .loc 1 103 4
  143. 42 001b 48837DF8 cmpq $0, -8(%rbp)
  144. 42 00
  145. 43 0020 7507 jne .L4
  146. 104:d4dag.c **** return(-1);
  147. 44 .loc 1 104 9
  148. 45 0022 B8FFFFFF movl $-1, %eax
  149. 45 FF
  150. 46 0027 EB69 jmp .L5
  151. 47 .L4:
  152. 105:d4dag.c **** }
  153. 106:d4dag.c **** if (!freeer) {
  154. 48 .loc 1 106 5
  155. 49 0029 48837DF0 cmpq $0, -16(%rbp)
  156. 49 00
  157. 50 002e 7507 jne .L6
  158. 107:d4dag.c **** return (-1);
  159. 51 .loc 1 107 10
  160. 52 0030 B8FFFFFF movl $-1, %eax
  161. 52 FF
  162. 53 0035 EB5B jmp .L5
  163. 54 .L6:
  164. 108:d4dag.c **** }
  165. 109:d4dag.c **** d4d__main = (struct d4d__maing *)(*mallocer) ((unsigned int)sizeof(struct d4d__maing));
  166. 55 .loc 1 109 36
  167. 56 0037 488B45F8 movq -8(%rbp), %rax
  168. 57 003b BF100000 movl $16, %edi
  169. 57 00
  170. 58 0040 FFD0 call *%rax
  171. 59 .LVL0:
  172. 60 .loc 1 109 12
  173. 61 0042 48890500 movq %rax, d4d__main(%rip)
  174. 61 000000
  175. 110:d4dag.c **** if (!d4d__main) {
  176. 62 .loc 1 110 6
  177. 63 0049 488B0500 movq d4d__main(%rip), %rax
  178. 63 000000
  179. 64 .loc 1 110 5
  180. 65 0050 4885C0 testq %rax, %rax
  181. 66 0053 7507 jne .L7
  182. 111:d4dag.c **** return (-2);
  183. 67 .loc 1 111 10
  184. 68 0055 B8FEFFFF movl $-2, %eax
  185. 68 FF
  186. 69 005a EB36 jmp .L5
  187. 70 .L7:
  188. 112:d4dag.c **** }
  189. 113:d4dag.c **** /* set pointers to malloc/free in toplevel control */
  190. 114:d4dag.c **** d4d__memzero(d4d__main, sizeof(struct d4d__maing));
  191. 71 .loc 1 114 2
  192. 72 005c 488B0500 movq d4d__main(%rip), %rax
  193. 72 000000
  194. 73 0063 BE100000 movl $16, %esi
  195. 73 00
  196. 74 0068 4889C7 movq %rax, %rdi
  197. 75 006b E8640000 call d4d__memzero
  198. 75 00
  199. 115:d4dag.c **** d4d__main->d4d__malloc = mallocer;
  200. 76 .loc 1 115 11
  201. 77 0070 488B0500 movq d4d__main(%rip), %rax
  202. 77 000000
  203. 78 .loc 1 115 25
  204. 79 0077 488B55F8 movq -8(%rbp), %rdx
  205. 80 007b 488910 movq %rdx, (%rax)
  206. 116:d4dag.c **** d4d__main->d4d__free = freeer;
  207. 81 .loc 1 116 11
  208. 82 007e 488B0500 movq d4d__main(%rip), %rax
  209. 82 000000
  210. 83 .loc 1 116 23
  211. 84 0085 488B55F0 movq -16(%rbp), %rdx
  212. 85 0089 48895008 movq %rdx, 8(%rax)
  213. 117:d4dag.c **** return (0);
  214. 86 .loc 1 117 9
  215. 87 008d B8000000 movl $0, %eax
  216. 87 00
  217. 88 .L5:
  218. 118:d4dag.c **** }
  219. 89 .loc 1 118 1
  220. 90 0092 C9 leave
  221. 91 .cfi_def_cfa 7, 8
  222. 92 0093 C3 ret
  223. 93 .cfi_endproc
  224. 94 .LFE1:
  225. 96 .globl d4d_deinit
  226. 98 d4d_deinit:
  227. 99 .LFB2:
  228. 119:d4dag.c ****
  229. 120:d4dag.c **** /**
  230. 121:d4dag.c **** *
  231. 122:d4dag.c **** */
  232. 123:d4dag.c **** int d4d_deinit(void)
  233. 124:d4dag.c **** {
  234. 100 .loc 1 124 1
  235. 101 .cfi_startproc
  236. 102 0094 55 pushq %rbp
  237. 103 .cfi_def_cfa_offset 16
  238. 104 .cfi_offset 6, -16
  239. 105 0095 4889E5 movq %rsp, %rbp
  240. 106 .cfi_def_cfa_register 6
  241. 125:d4dag.c **** /* check if active */
  242. 126:d4dag.c **** if (!d4d__main) {
  243. 107 .loc 1 126 6
  244. 108 0098 488B0500 movq d4d__main(%rip), %rax
  245. 108 000000
  246. 109 .loc 1 126 5
  247. 110 009f 4885C0 testq %rax, %rax
  248. 111 00a2 7507 jne .L9
  249. 127:d4dag.c **** return (0);
  250. 112 .loc 1 127 10
  251. 113 00a4 B8000000 movl $0, %eax
  252. 113 00
  253. 114 00a9 EB27 jmp .L10
  254. 115 .L9:
  255. 128:d4dag.c **** }
  256. 129:d4dag.c **** /* free structs */
  257. 130:d4dag.c **** /* free control */
  258. 131:d4dag.c **** d4d__main->d4d__free(d4d__main);
  259. 116 .loc 1 131 11
  260. 117 00ab 488B0500 movq d4d__main(%rip), %rax
  261. 117 000000
  262. 118 00b2 488B5008 movq 8(%rax), %rdx
  263. 119 .loc 1 131 2
  264. 120 00b6 488B0500 movq d4d__main(%rip), %rax
  265. 120 000000
  266. 121 00bd 4889C7 movq %rax, %rdi
  267. 122 00c0 FFD2 call *%rdx
  268. 123 .LVL1:
  269. 132:d4dag.c **** d4d__main = (struct d4d__maing *)0;
  270. 124 .loc 1 132 12
  271. 125 00c2 48C70500 movq $0, d4d__main(%rip)
  272. 125 00000000
  273. 125 000000
  274. 133:d4dag.c **** return (0);
  275. 126 .loc 1 133 9
  276. 127 00cd B8000000 movl $0, %eax
  277. 127 00
  278. 128 .L10:
  279. 134:d4dag.c **** }
  280. 129 .loc 1 134 1
  281. 130 00d2 5D popq %rbp
  282. 131 .cfi_def_cfa 7, 8
  283. 132 00d3 C3 ret
  284. 133 .cfi_endproc
  285. 134 .LFE2:
  286. 137 d4d__memzero:
  287. 138 .LFB3:
  288. 135:d4dag.c ****
  289. 136:d4dag.c **** /* like memset(ptr,0,n)
  290. 137:d4dag.c **** * note that intel icc compiler does inline this and gcc not
  291. 138:d4dag.c **** */
  292. 139:d4dag.c **** static void d4d__memzero(void *ptr, unsigned int n)
  293. 140:d4dag.c **** {
  294. 139 .loc 1 140 1
  295. 140 .cfi_startproc
  296. 141 00d4 55 pushq %rbp
  297. 142 .cfi_def_cfa_offset 16
  298. 143 .cfi_offset 6, -16
  299. 144 00d5 4889E5 movq %rsp, %rbp
  300. 145 .cfi_def_cfa_register 6
  301. 146 00d8 48897DE8 movq %rdi, -24(%rbp)
  302. 147 00dc 8975E4 movl %esi, -28(%rbp)
  303. 141:d4dag.c **** unsigned char *p = (unsigned char *)0;
  304. 148 .loc 1 141 17
  305. 149 00df 48C745F8 movq $0, -8(%rbp)
  306. 149 00000000
  307. 142:d4dag.c **** p = (unsigned char *)ptr;
  308. 150 .loc 1 142 4
  309. 151 00e7 488B45E8 movq -24(%rbp), %rax
  310. 152 00eb 488945F8 movq %rax, -8(%rbp)
  311. 143:d4dag.c **** while (n) {
  312. 153 .loc 1 143 8
  313. 154 00ef EB10 jmp .L12
  314. 155 .L13:
  315. 144:d4dag.c **** *p = 0;
  316. 156 .loc 1 144 6
  317. 157 00f1 488B45F8 movq -8(%rbp), %rax
  318. 158 00f5 C60000 movb $0, (%rax)
  319. 145:d4dag.c **** p++;
  320. 159 .loc 1 145 4
  321. 160 00f8 488345F8 addq $1, -8(%rbp)
  322. 160 01
  323. 146:d4dag.c **** n--;
  324. 161 .loc 1 146 4
  325. 162 00fd 836DE401 subl $1, -28(%rbp)
  326. 163 .L12:
  327. 143:d4dag.c **** *p = 0;
  328. 164 .loc 1 143 8
  329. 165 0101 837DE400 cmpl $0, -28(%rbp)
  330. 166 0105 75EA jne .L13
  331. 147:d4dag.c **** }
  332. 148:d4dag.c **** return;
  333. 167 .loc 1 148 2
  334. 168 0107 90 nop
  335. 149:d4dag.c **** }
  336. 169 .loc 1 149 1
  337. 170 0108 5D popq %rbp
  338. 171 .cfi_def_cfa 7, 8
  339. 172 0109 C3 ret
  340. 173 .cfi_endproc
  341. 174 .LFE3:
  342. 176 .Letext0: