77 lines
1.7 KiB
C
77 lines
1.7 KiB
C
|
#include <stdio.h>
|
||
|
#include <string.h>
|
||
|
#include <stdlib.h>
|
||
|
#include <time.h>
|
||
|
#include <stdint.h>
|
||
|
|
||
|
int *tits = 43;
|
||
|
|
||
|
uint8_t memory[1024];
|
||
|
uint8_t opcode;
|
||
|
uint8_t destination;
|
||
|
uint8_t source1;
|
||
|
uint8_t source2;
|
||
|
uint8_t sourceimm;
|
||
|
|
||
|
uint16_t tmpip = 0;
|
||
|
|
||
|
int thomasgay() {
|
||
|
memory[1] = 0x01; //ip
|
||
|
memory[2] = 0x00; //ip2 (i think this is big endianness)
|
||
|
memory[256] = 1;
|
||
|
memory[257] = 5;
|
||
|
memory[258] = 0;
|
||
|
memory[259] = 0;
|
||
|
memory[260] = 69;
|
||
|
|
||
|
int Halted = 0;
|
||
|
while (!Halted){
|
||
|
//fetch
|
||
|
opcode = memory[memory[1]*256+memory[2]];
|
||
|
destination = memory[(memory[1]*256+memory[2])+1];
|
||
|
source1 = memory[(memory[1]*256+memory[2])+2];
|
||
|
source2 = memory[(memory[1]*256+memory[2])+3];
|
||
|
sourceimm = memory[(memory[1]*256+memory[2])+4];
|
||
|
printf("asd %d %d %d %d %d asd", opcode, destination, source1, source2, sourceimm);
|
||
|
switch (opcode) {
|
||
|
case 1:
|
||
|
if (!source1 && !source2) {
|
||
|
memory[destination] = sourceimm;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
int main () {
|
||
|
if (strlen(getenv("HOME")) != 12) {
|
||
|
puts("Segmentation fault (core dumped)");
|
||
|
return 0;
|
||
|
} else {
|
||
|
asm volatile ("mov $20, %rax");
|
||
|
puts("first check pass");
|
||
|
goto fucktits;
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
if (*tits > 93) {
|
||
|
fucktits:
|
||
|
puts("we finally landing");
|
||
|
clock_t prevtime, currenttime;
|
||
|
prevtime = clock();
|
||
|
puts("a");
|
||
|
currenttime = clock();
|
||
|
if (currenttime - prevtime > 8) {
|
||
|
//GDB USER REEEEEEEEEE
|
||
|
tits = NULL;
|
||
|
puts(tits);
|
||
|
}
|
||
|
thomasgay();
|
||
|
}
|
||
|
}
|
||
|
|