Skip to content

Instantly share code, notes, and snippets.

@radekk
Last active March 13, 2018 23:35
Show Gist options
  • Save radekk/e4f3708c58bafd1a0f0b59d96a0877db to your computer and use it in GitHub Desktop.
Save radekk/e4f3708c58bafd1a0f0b59d96a0877db to your computer and use it in GitHub Desktop.
Pseudo code from the book cover ported to Nasm
; compile: nasm -f elf book.cover.asm; ld -m elf_i386 -s -o book.cover book.cover.o
; ----------------------------------------------------------
bits 32
section .data
bk_cvr db 0xad,0x52,0x45,0x52,0x45,0x0f,0xc6,0xbf,0x40,0x63,0x8c,0x63,0x85,0x03,0xcf,0xc6,0x48,0xcb,0x45,0x52,0x45,0xd6,0x97,0x26,0x4d,0xa0,0x4a,0x6a,0xb5,0x90,0x04,0xb9,0xa8,0x0b,0x7c,0xd6,0xc8,0x6f,0x45,0x52,0x45,0x27,0x49,0x13,0xc5,0xab,0x52,0x27,0x9f,0xea,0x02,0x3d,0x2a,0x36,0x89,0xea,0x0b,0x1d,0x15,0x17,0x89,0x9c,0xd1,0x1f,0x13,0xd7,0x3c,0x1a,0x13,0xb4,0x23,0x3b,0x88,0x6a,0x10,0x49,0x3c,0xe5,0xfa,0x92,0xf8,0xc1,0xb0,0x99,0xcb,0xf0,0x81,0x00,0x83,0xa5,0xae,0xf1,0xd1,0xcc,0xf1,0x21,0x63,0x4c,0x36,0xa5,0xcc,0x16,0xae,0x93,0x77,0xd1,0xb5,0xd4,0x3d,0x16,0xfe,0xb0,0x17,0xf8,0xba,0xaf,0x82,0x08,0x45,0xab,0x2c,0xfe,0x06,0x15,0xa5,0x76,0xd0,0x70,0x01,0x33,0x6c,0x51,0xad,0x4c,0x4a,0x91,0xc9,0xf1,0x9b,0x1e,0x4d,0xff,0x94,0x1a,0xae,0x12,0xd2,0xd2,0xd5,0x08,0x68,0x7b,0xa1,0x06,0x30,0x26,0x24,0x38,0x12,0x22,0x2c,0x21,0x3f,0x06,0x24,0x38,0x2b,0x37,0x0d,0x33,0x36,0x3e,0x2a,0x73,0x64,0x73,0x45,0x52,0x00,0x00,0x00
rwx_mem times 100 db 0
section .text
global _start ;must be declared for using gcc
_start:
lea esi, [bk_cvr]
lea edi, [rwx_mem]
mov ecx, 89
dcd:
lodsw
xor ax, 0x5245
stosw
loop dcd
jmp rwx_mem
mov eax, 1 ;system call number (sys_exit)
mov ebx, 0
int 0x80 ;call kernel
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment