Changes from August 15

This commit is contained in:
Val
2022-08-15 03:57:45 -05:00
parent 417ec16b59
commit 3532abb66e
6 changed files with 86 additions and 21 deletions

View File

@@ -17,7 +17,7 @@ while True:
h = hash(bytes.fromhex(line[1:]));
else:
h = hash(line.encode())
print(f"hash: {h:x}, box: {h&7:x}");
print(f"hash: {h:x}, box[3]: {h&7:x}, box[4]: {h&0xf:x}");
except EOFError:
break

View File

@@ -8,12 +8,12 @@ u16 walk (u16 r15);
u16 run ();
u16 *create_hash_table (u16 r15, u16 r14);
u16 add_to_table (u16 r15, u16 r14, u16 r13);
u16 add_to_table (u16 *table, char *username, u16 pin);
// Return address of a buffer from the table
// r15 = buffer address. r14
u16 get_from_table (void *r15, char *r14);
u16 hash (char *str);
u16 rehash (u16 r15, u16 r14);
u16 rehash (u16 *table, u16 r14);
// Strings, named after the position of the first character in memory
// Strings associated with <walk>

View File

@@ -108,8 +108,23 @@ u16 hash (char *addr) {
return hash;
}
u16 add_to_table (u16 r15, u16 r14, u16 r13) {
u16 add_to_table (u16 *table, char *username, u16 pin) {
// todo: add_to_table
u16 r14 = table[1]; // Box bitmask exponent? 3
u16 r12 = table[2]; // Box bitmask mantissa? 5
//! What the hell is going on here?
r12 <<= r14; // 3 <<= 5
if (r12 < 0) {
r12 = r12 + 3;
}
r12 >>= 2;
if (table[0] < r12) { // if there are more names in table than 10:
rehash(*table, r14); // Make more boxes, and shuffle them around?
}
table[0]++;
hash(r14);
r12 = 1 << table[1];
// Then do some boring stuff
return 0;
}
@@ -124,7 +139,8 @@ u16 get_from_table (void *r15, char *r14) {
return 0;
}
u16 rehash (u16 r15, u16 r14) {
// todo: this function is very long and performs dynalloc
u16 rehash (u16 *table, u16 exponent) { // Now I see the problem
// This function makes the hash table 2^exponent units long
// and rehashes all the usernames stored in each box
return 0;
}

View File

@@ -23,13 +23,39 @@ u16 get_w (u16 *addr) {
}
void *_malloc (u16 size) {
// if heap not initialized, initialize the heap
// if (get_w (HEAP_BASE + 4)) {
// u16 heap_ptr = HEAP_BASE;
// set_w (heap_ptr, HEAP_BASE);
// set_w (heap_ptr + 2, HEAP_BASE);
// }
// create a new block on the heap
/*
4678: 0b12 push r11
467a: c293 0424 tst.b &0x2404
467e: 0f24 jz $+0x20 <malloc+0x26>
4680: 1e42 0024 mov &0x2400, r14
4684: 8e4e 0000 mov r14, 0x0(r14)
4688: 8e4e 0200 mov r14, 0x2(r14)
468c: 1d42 0224 mov &0x2402, r13
4690: 3d50 faff add #0xfffa, r13
4694: 0d5d add r13, r13
4696: 8e4d 0400 mov r13, 0x4(r14)
469a: c243 0424 mov.b #0x0, &0x2404
; malloc+0x26:
469e: 1b42 0024 mov &0x2400, r11
46a2: 0e4b mov r11, r14
46a4: 1d4e 0400 mov 0x4(r14), r13
46a8: 1db3 bit #0x1, r13
46aa: 2820 jnz $+0x52 <46fc>
46fc: 0d4e mov r14, r13
46fe: 1e4e 0200 mov 0x2(r14), r14
4702: 0e9d cmp r13, r14
4704: 0228 jnc $+0x6 <malloc+0x92>
4706: 0e9b cmp r11, r14
4708: cd23 jnz $-0x64 <malloc+0x2c>
; puts("Heap exhausted. Aborting")
470a: 3f40 5e46 mov #0x465e, r15
470e: b012 504d call #0x4d50 <puts>
4712: 3040 3e44 br #0x443e <__stop_progExec__>
4716: 0f43 clr r15
4718: 3b41 pop r11
471a: 3041 ret
*/
// return the address of the new block
return 0;