Files
prog-puzanova/works/SysProg/ПЗ_2/Readme.md
T
2026-09-17 12:06:20 +03:00

53 lines
1.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Студент: [Пузанова Анна Андреевна]
* **Группа:** [228]
* **Курс:** [2]
## Список работ
Практическое задание
Код:
#include <stdio.h>
#include <stdint.h>
void main() {
uint32_t magic = 0xAABBCCDD;
uint8_t *byte_ptr = (uint8_t*)&magic;
printf("Byte 0: 0x%02X\n", byte_ptr[0]);
printf("Byte 1: 0x%02X\n", byte_ptr[1]);
printf("Byte 2: 0x%02X\n", byte_ptr[2]);
printf("Byte 3: 0x%02X\n", byte_ptr[3]);
}
Задания
1.Какие значения выведут  printf ?
Значения выводятся в обратном порядке
x86-64 gcc 16.2
x86-64 gcc 16.2
Compiler options for execution
-O2 -fno-verbose-asm
Program returned: 13
Program stdout
Byte 0: 0xDD
Byte 1: 0xCC
Byte 2: 0xBB
Byte 3: 0xAA
2.Посмотрите в ассемблер на то, как компилятор кладет  0xAABBCCDD  в память.
Найдите инструкцию  mov DWORD PTR [rsp+...], 2864434397  (или в hex  0xaabbccdd ).
DWORD означает 32 бита = 4 байта;
[rsp+12] — адрес в стеке, куда записывается значение;
0xAABBCCDD — само 32-битное число.
В нашем коде:
mov DWORD PTR [rbp-12], -1430532899
Как она выглядит? (Компилятор может использовать  mov r32, imm32  или  movabs ).