Joseph Haugh
University of New Mexico
C Data Type | Typical 32-bit | Typical 64-bit | x86-64 |
---|---|---|---|
char | 1 | 1 | 1 |
short | 2 | 2 | 2 |
int | 4 | 4 | 4 |
long | 4 | 8 | 8 |
float | 4 | 4 | 4 |
double | 8 | 8 | 8 |
long double | — | — | 10/16 |
pointer | 4 | 8 | 8 |
Decimal: 15213
Binary: 0011 1011 0110 1101
Hex: 3 B 6 D
int b = -15213;
int *p = &b;
typedef unsigned char *pointer;
void show_bytes(pointer start, size_t len) {
size_t i;
for (i = 0; i < len; i++)
printf("%p\t0x%.2x\n", start+i, start[i]);
printf("\n");
}
int a = 15213;
printf("int a = 15213;\n");
show_bytes((pointer) &a, sizeof(int));
int a = 15213;
0x7ffee15d7e8c 0x6d
0x7ffee15d7e8d 0x3b
0x7ffee15d7e8e 0x00
0x7ffee15d7e8f 0x00
int fib(int n)
{
int r = 1;
for (; n > 0; n--) {
r = r * n;
/* Loop decr. */
/* Loop end chk. */
}
return r;
}
Disassembly of section .text:
Address Insn Bytes Assembly Code
40057d: 55 push %rbp
40057e: 48 89 e5 mov %rsp,%rbp
400581: 89 7d ec mov %edi,-0x14(%rbp)
400584: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%rbp)
40058b: eb 0e jmp 40059b <fib+0x1e>
40058d: 8b 45 fc mov -0x4(%rbp),%eax
400590: 0f af 45 ec imul -0x14(%rbp),%eax
400594: 89 45 fc mov %eax,-0x4(%rbp)
400597: 83 6d ec 01 subl $0x1,-0x14(%rbp)
40059b: 83 7d ec 00 cmpl $0x0,-0x14(%rbp)
40059f: 7f ec jg 40058d <fib+0x10>
4005a1: 8b 45 fc mov -0x4(%rbp),%eax
4005a4: 5d pop %rbp
4005a5: c3 retq