} foreach ($this->relocs as $CPC => $reloc) { if (!isset($this->symbols[$reloc[1]])) { printf("Unknown symbol '%s'\n", $reloc[1]); $this->symbols[$reloc[1]] = 0x7777; } //printf("%08X : %s\n", $CPC, $reloc[1]); switch ($reloc[0]) { case 1: $info = pack('c', $this->symbols[$reloc[1]]); $this->data[$CPC++] = $info[0]; break; case 2: $info = pack('v', $this->symbols[$reloc[1]]); $this->data[$CPC++] = $info[0]; $this->data[$CPC++] = $info[1]; break; } } file_put_contents("temp", $this->data); //print_r($labels); } function assemble_file($file) { printf("Processing '%s'...\n", $file); $this->assemble(file($file)); } } $asm = new Assembler(); $asm->assemble_file('data/data/cs104.asm');