Created
August 24, 2013 23:16
-
-
Save jdiez17/6330948 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if __name__ == '__main__': | |
| with open("quine.asm") as f: | |
| with open("quine.small.asm", "w") as fw: | |
| lines = f.readlines() | |
| lines = map(lambda line: line.strip().replace('\t', '').replace('\n', ''), lines) | |
| fw.write('\\\\'.join(lines)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| quine.small.asm: quine.asm | |
| python convert.py human_to_small | |
| quine.bin: quine.asm | |
| nasm -f bin -o quine.bin quine.asm | |
| floppy: quine.bin | |
| dd status=noxfer conv=notrunc if=quine.bin of=floppy | |
| emu: floppy | |
| qemu -fda floppy | |
| clean: | |
| rm quine.small.asm | |
| rm floppy | |
| rm *.bin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [bits 16] | |
| start: | |
| mov ax, 07C0h | |
| mov ds, ax | |
| mov ah, 0 | |
| mov al, 03h | |
| int 10h | |
| mov si, code | |
| call print_string | |
| jmp $ | |
| print_string: | |
| mov ah, 0Eh | |
| .repeat: | |
| lodsb | |
| cmp al, 0 | |
| je .done | |
| cmp bx, 0x42 | |
| jne .special | |
| .continue: | |
| int 10h | |
| jmp .repeat | |
| .special: | |
| cmp al, 94 | |
| je .rec | |
| cmp al, 45 | |
| je .quote | |
| jmp .continue | |
| .quote: | |
| mov al, 34 | |
| jmp .continue | |
| .rec: | |
| push si | |
| mov bx, 0x42 | |
| mov si, code | |
| call print_string | |
| mov bx, 0 | |
| pop si | |
| jmp print_string | |
| .done: | |
| ret | |
| code: db "[bits 16]\\start:\\mov ax, 07C0h\\mov ds, ax\\mov ah, 0\\mov al, 03h\\int 10h\\mov si, code\\call print_string\\jmp $\\print_string:\\mov ah, 0Eh\\.repeat:\\lodsb\\cmp al, 0\\je .done\\cmp bx, 0x42\\jne .special\\.continue:\\int 10h\\jmp .repeat\\.special:\\cmp al, 94\\je .rec\\cmp al, 45\\je .quote\\jmp .continue\\.quote:\\mov al, 34\\jmp .continue\\.rec:\\push si\\mov bx, 0x42\\mov si, code\\call print_string\\mov bx, 0\\pop si\\jmp print_string\\\\.done:\\ret\\\\code: db -^-\\times 510-($-$$) db 0\\dw 0xAA55" | |
| times 510-($-$$) db 0 | |
| dw 0xAA55 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment