This repository has been archived on 2026-07-28. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
cmc/3sem/seminars/l9/02.c
T
2025-04-13 21:48:15 +03:00

42 lines
723 B
C
Executable File

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <wait.h>
#include <errno.h>
// 8-ми сегментная таблица сегментов
// 32-х разрядная система
typedef struct
{
int size;
int base;
} segment;
unsigned int
f(segment *segtable, unsigned int VAdr)
{
int bit = 3;
unsigned int segnum = VAdr >> (32 - bit);
unsigned int segoff = VAdr & ((1 << (32 - bit)) - 1);
int addr = segtable[segnum].base + segoff;
int size = segtable[segnum].size;
if (segoff >= size) {
return 25;
// exit(1);
}
return addr;
}
int
main(int argc, char *argv[])
{
segment segtable[8] = {};
return 0;
}