Skip to content

Instantly share code, notes, and snippets.

@william-lohan
Created November 16, 2022 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save william-lohan/624d0a4eb2fca468beab56124f38dacb to your computer and use it in GitHub Desktop.
Save william-lohan/624d0a4eb2fca468beab56124f38dacb to your computer and use it in GitHub Desktop.
Unholy abomination
const fs = require('fs');
const MOV_AH = 0xb4;
const MOV_BH = 0xb7;
const MOV_BL = 0xb3;
const MOV_AL = 0xb0;
const INT = 0xcd;
const JMP = 0xeb;
const bin = new Uint8Array(512);
const code = [
MOV_AH, 0x0e,
MOV_BH, 0x00,
MOV_BL, 0x07,
MOV_AL, 'h'.charCodeAt(0),
INT, 0x10,
MOV_AL, 'e'.charCodeAt(0),
INT, 0x10,
MOV_AL, 'l'.charCodeAt(0),
INT, 0x10,
MOV_AL, 'l'.charCodeAt(0),
INT, 0x10,
MOV_AL, 'o'.charCodeAt(0),
INT, 0x10,
MOV_AL, ' '.charCodeAt(0),
INT, 0x10,
MOV_AL, 'j'.charCodeAt(0),
INT, 0x10,
MOV_AL, 's'.charCodeAt(0),
INT, 0x10,
JMP, 0x26,
];
code.forEach((ins, index) => {
bin[index] = ins;
});
bin[510] = 0x55;
bin[511] = 0xaa;
fs.createWriteStream("out.bin").write(Buffer.from(bin.buffer));
console.log(bin);
// run qemu-system-x86_64 out.bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment