123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- 1 .file "d4dag.c"
- 2 .text
- 3 .Ltext0:
- 4 .local d4d__main
- 5 .comm d4d__main,8,8
- 6 .globl d4d_version
- 8 d4d_version:
- 9 .LFB0:
- 10 .file 1 "d4dag.c"
- 1:d4dag.c ****
- 2:d4dag.c **** /*
- 3:d4dag.c **** * Copyright t lefering
- 4:d4dag.c **** * Copyright Simon Speich 2013
- 5:d4dag.c **** *
- 6:d4dag.c **** * This program is free software: you can redistribute it and/or modify
- 7:d4dag.c **** * it under the terms of the GNU General Public License as published by
- 8:d4dag.c **** * the Free Software Foundation, either version 3 of the License, or
- 9:d4dag.c **** * (at your option) any later version.
- 10:d4dag.c **** *
- 11:d4dag.c **** * This program is distributed in the hope that it will be useful,
- 12:d4dag.c **** * but WITHOUT ANY WARRANTY; without even the implied warranty of
- 13:d4dag.c **** * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- 14:d4dag.c **** * GNU General Public License for more details.
- 15:d4dag.c **** *
- 16:d4dag.c **** * You should have received a copy of the GNU General Public License
- 17:d4dag.c **** * along with this program. If not, see <http://www.gnu.org/licenses/>.
- 18:d4dag.c **** *
- 19:d4dag.c **** * These are the four essential freedoms with GNU GPL software:
- 20:d4dag.c **** * 1: freedom to run the program, for any purpose
- 21:d4dag.c **** * 2: freedom to study how the program works, and change it to make it do what you wish
- 22:d4dag.c **** * 3: freedom to redistribute copies to help your Free Software friends
- 23:d4dag.c **** * 4: freedom to distribute copies of your modified versions to your Free Software friends
- 24:d4dag.c **** * , ,
- 25:d4dag.c **** * / \
- 26:d4dag.c **** * ((__-^^-,-^^-__))
- 27:d4dag.c **** * `-_---' `---_-'
- 28:d4dag.c **** * `--|o` 'o|--'
- 29:d4dag.c **** * \ ` /
- 30:d4dag.c **** * ): :(
- 31:d4dag.c **** * :o_o:
- 32:d4dag.c **** * "-"
- 33:d4dag.c **** *
- 34:d4dag.c **** * SPDX-License-Identifier: GPL-3.0+
- 35:d4dag.c **** * License-Filename: LICENSE
- 36:d4dag.c **** */
- 37:d4dag.c ****
- 38:d4dag.c **** /**
- 39:d4dag.c **** * all routines have prefix d4d_
- 40:d4dag.c **** * all static routines and vars have prefix d4d___
- 41:d4dag.c **** * the prefix d4d_ has no special meaning but hopefully
- 42:d4dag.c **** * does not problems because of limited C namespace
- 43:d4dag.c **** */
- 44:d4dag.c ****
- 45:d4dag.c **** /* only in debug version linkage needed to printf */
- 46:d4dag.c **** #if D4D_DEBUG
- 47:d4dag.c **** #include <stdio.h>
- 48:d4dag.c **** #define print_debug(str, ...) printf(str" - %s:%u\n", ##__VA_ARGS__, __FILE__, __LINE__);
- 49:d4dag.c **** #endif
- 50:d4dag.c ****
- 51:d4dag.c **** /* datatypoes used are
- 52:d4dag.c **** * int, as signed 32bits integer value
- 53:d4dag.c **** * unsigned int, as 32bits integer value
- 54:d4dag.c **** * char, as signed 8bits integer value
- 55:d4dag.c **** * unsigned char, as 8bits integer value
- 56:d4dag.c **** */
- 57:d4dag.c ****
- 58:d4dag.c **** /**
- 59:d4dag.c **** * set here version number as int
- 60:d4dag.c **** */
- 61:d4dag.c **** #define D4DAG_VERSION 10
- 62:d4dag.c ****
- 63:d4dag.c **** /* defs and prototypes of routines for user program */
- 64:d4dag.c **** #include "d4dag.h"
- 65:d4dag.c ****
- 66:d4dag.c **** /* mallocer/freeer */
- 67:d4dag.c **** typedef void *(*malloc_fn)(unsigned int n);
- 68:d4dag.c **** typedef void (*free_fn)(void *ptr);
- 69:d4dag.c ****
- 70:d4dag.c **** /* toplevel control struct */
- 71:d4dag.c **** struct d4d__maing {
- 72:d4dag.c **** /* wrappers for malloc/free and all malloc's will be below 4Gb at once */
- 73:d4dag.c **** malloc_fn d4d__malloc;
- 74:d4dag.c **** free_fn d4d__free;
- 75:d4dag.c **** };
- 76:d4dag.c ****
- 77:d4dag.c **** /* main control */
- 78:d4dag.c **** static struct d4d__maing *d4d__main = (struct d4d__maing *)0;
- 79:d4dag.c ****
- 80:d4dag.c **** /* forward decl. */
- 81:d4dag.c **** static void d4d__memzero(void *ptr, unsigned int n);
- 82:d4dag.c **** /**
- 83:d4dag.c **** * returns version number as int
- 84:d4dag.c **** */
- 85:d4dag.c **** int d4d_version(void)
- 86:d4dag.c **** {
- 11 .loc 1 86 1
- 12 .cfi_startproc
- 13 0000 55 pushq %rbp
- 14 .cfi_def_cfa_offset 16
- 15 .cfi_offset 6, -16
- 16 0001 4889E5 movq %rsp, %rbp
- 17 .cfi_def_cfa_register 6
- 87:d4dag.c **** return (D4DAG_VERSION);
- 18 .loc 1 87 9
- 19 0004 B80A0000 movl $10, %eax
- 19 00
- 88:d4dag.c **** }
- 20 .loc 1 88 1
- 21 0009 5D popq %rbp
- 22 .cfi_def_cfa 7, 8
- 23 000a C3 ret
- 24 .cfi_endproc
- 25 .LFE0:
- 27 .globl d4d_init
- 29 d4d_init:
- 30 .LFB1:
- 89:d4dag.c ****
- 90:d4dag.c **** /**
- 91:d4dag.c **** *
- 92:d4dag.c **** * returns:
- 93:d4dag.c **** * 0 if oke
- 94:d4dag.c **** * -1 if missing malloc/free pointer
- 95:d4dag.c **** * -2 if malloc failed
- 96:d4dag.c **** * For embedded devices this source has no linkage to libraries
- 97:d4dag.c **** * which means here pointer to malloc/free must be supplied.
- 98:d4dag.c **** * when malloc returns zero then these routines crashes
- 99:d4dag.c **** */
- 100:d4dag.c **** int d4d_init(void *(*mallocer)(unsigned int n), void(*freeer)(void *ptr))
- 101:d4dag.c **** {
- 31 .loc 1 101 1
- 32 .cfi_startproc
- 33 000b 55 pushq %rbp
- 34 .cfi_def_cfa_offset 16
- 35 .cfi_offset 6, -16
- 36 000c 4889E5 movq %rsp, %rbp
- 37 .cfi_def_cfa_register 6
- 38 000f 4883EC10 subq $16, %rsp
- 39 0013 48897DF8 movq %rdi, -8(%rbp)
- 40 0017 488975F0 movq %rsi, -16(%rbp)
- 102:d4dag.c **** /* malloc/free pointers must be specified */
- 103:d4dag.c **** if(!mallocer) {
- 41 .loc 1 103 4
- 42 001b 48837DF8 cmpq $0, -8(%rbp)
- 42 00
- 43 0020 7507 jne .L4
- 104:d4dag.c **** return(-1);
- 44 .loc 1 104 9
- 45 0022 B8FFFFFF movl $-1, %eax
- 45 FF
- 46 0027 EB69 jmp .L5
- 47 .L4:
- 105:d4dag.c **** }
- 106:d4dag.c **** if (!freeer) {
- 48 .loc 1 106 5
- 49 0029 48837DF0 cmpq $0, -16(%rbp)
- 49 00
- 50 002e 7507 jne .L6
- 107:d4dag.c **** return (-1);
- 51 .loc 1 107 10
- 52 0030 B8FFFFFF movl $-1, %eax
- 52 FF
- 53 0035 EB5B jmp .L5
- 54 .L6:
- 108:d4dag.c **** }
- 109:d4dag.c **** d4d__main = (struct d4d__maing *)(*mallocer) ((unsigned int)sizeof(struct d4d__maing));
- 55 .loc 1 109 36
- 56 0037 488B45F8 movq -8(%rbp), %rax
- 57 003b BF100000 movl $16, %edi
- 57 00
- 58 0040 FFD0 call *%rax
- 59 .LVL0:
- 60 .loc 1 109 12
- 61 0042 48890500 movq %rax, d4d__main(%rip)
- 61 000000
- 110:d4dag.c **** if (!d4d__main) {
- 62 .loc 1 110 6
- 63 0049 488B0500 movq d4d__main(%rip), %rax
- 63 000000
- 64 .loc 1 110 5
- 65 0050 4885C0 testq %rax, %rax
- 66 0053 7507 jne .L7
- 111:d4dag.c **** return (-2);
- 67 .loc 1 111 10
- 68 0055 B8FEFFFF movl $-2, %eax
- 68 FF
- 69 005a EB36 jmp .L5
- 70 .L7:
- 112:d4dag.c **** }
- 113:d4dag.c **** /* set pointers to malloc/free in toplevel control */
- 114:d4dag.c **** d4d__memzero(d4d__main, sizeof(struct d4d__maing));
- 71 .loc 1 114 2
- 72 005c 488B0500 movq d4d__main(%rip), %rax
- 72 000000
- 73 0063 BE100000 movl $16, %esi
- 73 00
- 74 0068 4889C7 movq %rax, %rdi
- 75 006b E8640000 call d4d__memzero
- 75 00
- 115:d4dag.c **** d4d__main->d4d__malloc = mallocer;
- 76 .loc 1 115 11
- 77 0070 488B0500 movq d4d__main(%rip), %rax
- 77 000000
- 78 .loc 1 115 25
- 79 0077 488B55F8 movq -8(%rbp), %rdx
- 80 007b 488910 movq %rdx, (%rax)
- 116:d4dag.c **** d4d__main->d4d__free = freeer;
- 81 .loc 1 116 11
- 82 007e 488B0500 movq d4d__main(%rip), %rax
- 82 000000
- 83 .loc 1 116 23
- 84 0085 488B55F0 movq -16(%rbp), %rdx
- 85 0089 48895008 movq %rdx, 8(%rax)
- 117:d4dag.c **** return (0);
- 86 .loc 1 117 9
- 87 008d B8000000 movl $0, %eax
- 87 00
- 88 .L5:
- 118:d4dag.c **** }
- 89 .loc 1 118 1
- 90 0092 C9 leave
- 91 .cfi_def_cfa 7, 8
- 92 0093 C3 ret
- 93 .cfi_endproc
- 94 .LFE1:
- 96 .globl d4d_deinit
- 98 d4d_deinit:
- 99 .LFB2:
- 119:d4dag.c ****
- 120:d4dag.c **** /**
- 121:d4dag.c **** *
- 122:d4dag.c **** */
- 123:d4dag.c **** int d4d_deinit(void)
- 124:d4dag.c **** {
- 100 .loc 1 124 1
- 101 .cfi_startproc
- 102 0094 55 pushq %rbp
- 103 .cfi_def_cfa_offset 16
- 104 .cfi_offset 6, -16
- 105 0095 4889E5 movq %rsp, %rbp
- 106 .cfi_def_cfa_register 6
- 125:d4dag.c **** /* check if active */
- 126:d4dag.c **** if (!d4d__main) {
- 107 .loc 1 126 6
- 108 0098 488B0500 movq d4d__main(%rip), %rax
- 108 000000
- 109 .loc 1 126 5
- 110 009f 4885C0 testq %rax, %rax
- 111 00a2 7507 jne .L9
- 127:d4dag.c **** return (0);
- 112 .loc 1 127 10
- 113 00a4 B8000000 movl $0, %eax
- 113 00
- 114 00a9 EB27 jmp .L10
- 115 .L9:
- 128:d4dag.c **** }
- 129:d4dag.c **** /* free structs */
- 130:d4dag.c **** /* free control */
- 131:d4dag.c **** d4d__main->d4d__free(d4d__main);
- 116 .loc 1 131 11
- 117 00ab 488B0500 movq d4d__main(%rip), %rax
- 117 000000
- 118 00b2 488B5008 movq 8(%rax), %rdx
- 119 .loc 1 131 2
- 120 00b6 488B0500 movq d4d__main(%rip), %rax
- 120 000000
- 121 00bd 4889C7 movq %rax, %rdi
- 122 00c0 FFD2 call *%rdx
- 123 .LVL1:
- 132:d4dag.c **** d4d__main = (struct d4d__maing *)0;
- 124 .loc 1 132 12
- 125 00c2 48C70500 movq $0, d4d__main(%rip)
- 125 00000000
- 125 000000
- 133:d4dag.c **** return (0);
- 126 .loc 1 133 9
- 127 00cd B8000000 movl $0, %eax
- 127 00
- 128 .L10:
- 134:d4dag.c **** }
- 129 .loc 1 134 1
- 130 00d2 5D popq %rbp
- 131 .cfi_def_cfa 7, 8
- 132 00d3 C3 ret
- 133 .cfi_endproc
- 134 .LFE2:
- 137 d4d__memzero:
- 138 .LFB3:
- 135:d4dag.c ****
- 136:d4dag.c **** /* like memset(ptr,0,n)
- 137:d4dag.c **** * note that intel icc compiler does inline this and gcc not
- 138:d4dag.c **** */
- 139:d4dag.c **** static void d4d__memzero(void *ptr, unsigned int n)
- 140:d4dag.c **** {
- 139 .loc 1 140 1
- 140 .cfi_startproc
- 141 00d4 55 pushq %rbp
- 142 .cfi_def_cfa_offset 16
- 143 .cfi_offset 6, -16
- 144 00d5 4889E5 movq %rsp, %rbp
- 145 .cfi_def_cfa_register 6
- 146 00d8 48897DE8 movq %rdi, -24(%rbp)
- 147 00dc 8975E4 movl %esi, -28(%rbp)
- 141:d4dag.c **** unsigned char *p = (unsigned char *)0;
- 148 .loc 1 141 17
- 149 00df 48C745F8 movq $0, -8(%rbp)
- 149 00000000
- 142:d4dag.c **** p = (unsigned char *)ptr;
- 150 .loc 1 142 4
- 151 00e7 488B45E8 movq -24(%rbp), %rax
- 152 00eb 488945F8 movq %rax, -8(%rbp)
- 143:d4dag.c **** while (n) {
- 153 .loc 1 143 8
- 154 00ef EB10 jmp .L12
- 155 .L13:
- 144:d4dag.c **** *p = 0;
- 156 .loc 1 144 6
- 157 00f1 488B45F8 movq -8(%rbp), %rax
- 158 00f5 C60000 movb $0, (%rax)
- 145:d4dag.c **** p++;
- 159 .loc 1 145 4
- 160 00f8 488345F8 addq $1, -8(%rbp)
- 160 01
- 146:d4dag.c **** n--;
- 161 .loc 1 146 4
- 162 00fd 836DE401 subl $1, -28(%rbp)
- 163 .L12:
- 143:d4dag.c **** *p = 0;
- 164 .loc 1 143 8
- 165 0101 837DE400 cmpl $0, -28(%rbp)
- 166 0105 75EA jne .L13
- 147:d4dag.c **** }
- 148:d4dag.c **** return;
- 167 .loc 1 148 2
- 168 0107 90 nop
- 149:d4dag.c **** }
- 169 .loc 1 149 1
- 170 0108 5D popq %rbp
- 171 .cfi_def_cfa 7, 8
- 172 0109 C3 ret
- 173 .cfi_endproc
- 174 .LFE3:
- 176 .Letext0:
|