MushOS  0.1
A UNIX-like OS prototype, written from scratch
Loading...
Searching...
No Matches
memory.c
1#include "memory.h"
2
3
4void memory_copy (byte* source, byte* dest, u_dword num_bytes) {
5 for (int i = 0; i < num_bytes; ++i) {
6 *(dest + i) = *(source + i);
7 }
8}
9
10void memory_clear (byte* start, u_dword num_bytes, byte sample) {
11 for (int i = 0; i < num_bytes; ++i) {
12 *(start + i) = sample;
13 }
14}
15
16void memory_fill (byte* dest, byte* source, u_dword source_bytes, u_dword times) {
17 for (int i = 0; i < times; ++i) {
18 for (int j = 0; j < source_bytes; ++j) {
19 *(dest + (i * source_bytes + j)) = *(source + j);
20 }
21 }
22}
23
24boolean memory_compare (byte* comp1, byte* comp2, u_dword length) {
25 boolean equal = true;
26 for (int i = 0; i < length; ++i) {
27 equal &= (*(comp1 + i) == *(comp2 + i));
28 }
29 return equal;
30}