fix system program

This commit is contained in:
EgorGud
2026-09-29 11:01:49 +03:00
parent 7375674199
commit 6bbb436bf4
12 changed files with 84 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
/* Type your code here, or load an example. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
int main(void) {
int a = 26;
int b = 5;
int c = a / b;
return 0;
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

+17
View File
@@ -0,0 +1,17 @@
/* Type your code here, or load an example. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
// int main(void) {
// int a = 26;
// int b = 5;
// int c = a / b;
// return 0;
// }
unsigned short swap_bytes(unsigned short num) {
return ((num & 0x00FF) << 8) | ((num >> 8));
}
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

+13
View File
@@ -0,0 +1,13 @@
#include <stdio.h>
int main(void) {
const long long x = 5;
long long factorial = 1;
for (long long i = 1; i <= x; ++i) {
factorial *= i;
}
printf("%lld! = %lld\n", x, factorial);
return 0;
}
+18
View File
@@ -0,0 +1,18 @@
### Ex 1
![solution ex1](1.1.png)
### Ex 2
![solution ex2](1.2.png)
### Ex 3
![solution ex3](1.3.png)
### Ex 4
![solution ex4](1.4.png)
## Ex 5
## Описание уровней оптимизации
**-O0** — цикл остаётся циклом: генерируются инструкции сравнения, перехода и умножения в точном соответствии с исходным кодом.
- **-O1** — базовые оптимизации: структура цикла сохраняется, удаляются лишние операции.
- **-O2** — полное развёртывание цикла (loop unrolling): вместо цикла — последовательность умножений; инструкции сравнения и переходов отсутствуют.
- **-O3** — дополнительно применяется сворачивание констант (constant folding): при известных входных данных компилятор подставляет готовый результат (например, для `x = 5` — значение `120`).
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 109 KiB

+14
View File
@@ -0,0 +1,14 @@
## Лаба 02
```C
#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]);
}
```
+9
View File
@@ -0,0 +1,9 @@
### Ex2 2.1
![solution ex1](2.1.png)
### Ex2 2.2
![solution ex2](2.2.png)