Skip to the task
Layout
Back to classic view

You are looking ahead. Your place is still task 1: Types.

CHECKTask 20 of 23 · step 8: Extra: how does the CPU see it?

Where is group?

Find the instruction that runs char group = 'A';. Why does it say BYTE PTR and the number 65?

Stuck?

mov BYTE PTR -9[rbp], 65: a char takes 1 byte (BYTE), and the character 'A' is just the number 65. The int variables next to it are written with DWORD PTR: 4 bytes.

Extra · x86-64 · Intel syntax · Windows (MinGW GCC)

-O0 -O1

C source main.c

#include <limits.h>
#include <stdio.h>
#include "input.h"
int main(void) {
const int current_year = 2026;
int study_year = 1;
char group = 'A';
int birth_year = read_int("Year of birth: ");
int g1 = read_int("Grade 1: ");
int g2 = read_int("Grade 2: ");
int g3 = read_int("Grade 3: ");
double average = (g1 + g2 + g3) / 3.0;
int age = current_year - birth_year;
printf("Year of study: %d\n", study_year);
printf("Group: PI25%c\n", group);
printf("Age: %d years\n", age);
printf("Average: %.2f\n", average);
printf("In memory: int %zu B, double %zu B, char %zu B\n", sizeof study_year, sizeof average,
sizeof group);
printf("\n");
printf("Largest int: %d\n", INT_MAX);
long long century = 100LL * 365 * 24 * 60 * 60;
printf("100 years: %lld s\n", century);
printf("0.1 + 0.2 = %.17f\n", 0.1 + 0.2);
return 0;
}

x86-64 assembly -O1

.LC0:
.ascii "Year of birth: \0"
.LC1:
.ascii "Grade 1: \0"
.LC2:
.ascii "Grade 2: \0"
.LC3:
.ascii "Grade 3: \0"
.LC4:
.ascii "Year of study: %d\12\0"
.LC5:
.ascii "Group: PI25%c\12\0"
.LC6:
.ascii "Age: %d years\12\0"
.LC8:
.ascii "Average: %.2f\12\0"
.LC9:
.ascii "In memory: int %zu B, double %zu B, char %zu B\12\0"
.LC10:
.ascii "\12\0"
.LC11:
.ascii "Largest int: %d\12\0"
.LC12:
.ascii "100 years: %lld s\12\0"
.LC14:
.ascii "0.1 + 0.2 = %.17f\12\0"
main:
push rbp
push rdi
push rsi
push rbx
sub rsp, 40
call __main
lea rcx, .LC0[rip]
call read_int
mov ebp, eax
lea rcx, .LC1[rip]
call read_int
mov ebx, eax
lea rcx, .LC2[rip]
call read_int
mov edi, eax
lea rcx, .LC3[rip]
call read_int
mov esi, eax
mov edx, 1
Note 1: study_year is gone: printf just gets 1.
lea rcx, .LC4[rip]
call printf
mov edx, 65
lea rcx, .LC5[rip]
call printf
mov edx, 2026
sub edx, ebp
lea rcx, .LC6[rip]
call printf
add ebx, edi
add ebx, esi
pxor xmm1, xmm1
cvtsi2sd xmm1, ebx
divsd xmm1, QWORD PTR .LC7[rip]
movq rdx, xmm1
lea rcx, .LC8[rip]
call printf
mov r9d, 1
mov r8d, 8
mov edx, 4
lea rcx, .LC9[rip]
call printf
lea rcx, .LC10[rip]
call printf
mov edx, 2147483647
lea rcx, .LC11[rip]
call printf
mov edx, 3153600000
lea rcx, .LC12[rip]
call printf
mov rax, QWORD PTR .LC13[rip]
movq xmm1, rax
movabs rdx, 0x3fd3333333333334
lea rcx, .LC14[rip]
call printf
mov eax, 0
add rsp, 40
pop rbx
pop rsi
pop rdi
pop rbp
ret
.LC7:
.long 0
.long 1074266112
.LC13:
.long 858993460
.long 1070805811