Skip to content

Instantly share code, notes, and snippets.

@rastating
Created August 28, 2018 21:38
Show Gist options
  • Save rastating/dd227a3c5ea06d4acbc2f50a3e92b982 to your computer and use it in GitHub Desktop.
Save rastating/dd227a3c5ea06d4acbc2f50a3e92b982 to your computer and use it in GitHub Desktop.
global _start
section .text
_start:
xor ecx, ecx
mov cl, 0x63
song:
mov eax, ecx
call convert_to_ascii
push eax
push ecx
call verse_part_one
pop ecx
pop eax
push ecx
call verse_part_two
pop ecx
loop song
call outro
xor eax, eax
mov al, 0x01
xor ebx, ebx
int 0x80
convert_to_ascii:
push ebp
mov ebp, esp
; divide number by 10
xor ebx, ebx
mov bl, 0xb
sub bl, 0x01
div bl
; normalise values into ASCII
add ah, 0x30
add al, 0x30
; remove leading zeros
cmp al, 0x30
jnz exit_convert_to_ascii
xor al, al
exit_convert_to_ascii:
leave
ret
verse_part_one:
push ebp
mov ebp, esp
xor ebx, ebx
xor edx, edx
cmp al, dl
jnz build_v1_string
cmp ah, 0x31
jnz build_v1_string
mov bl, 0x01
build_v1_string:
xor ecx, ecx
mov cl, 0xb
sub cl, 0x01
push cx
push 0x2e726565
push 0x6220666f
push 0x20
cmp bl, 0x01
jz build_v1_string_2
push 0x73
build_v1_string_2:
mov cx, 0x656c
push cx
push 0x74746f62
xor cx, cx
mov cl, 0x20
push cx
push ax
push 0x202c6c6c
push 0x61772065
push 0x6874206e
push 0x6f207265
push 0x65622066
mov cx, 0x6f20
push cx
cmp bl, 0x01
jz build_v1_string_3
xor cx, cx
mov cl, 0x73
push cx
build_v1_string_3:
xor cx, cx
mov cl, 0x65
push cx
push 0x6c74746f
mov cx, 0x6220
push cx
push ax
xor eax, eax
mov al, 0x04
xor ebx, ebx
mov bl, 0x01
mov ecx, esp
mov edx, ebp
sub edx, esp
int 0x80
leave
ret
verse_part_two:
push ebp
mov ebp, esp
mov eax, ecx
sub eax, 0x01
call convert_to_ascii
xor ebx, ebx
xor edx, edx
cmp al, dl
jnz build_v2_string
cmp ah, 0x31
jnz build_v2_string
mov bl, 0x01
build_v2_string:
xor ecx, ecx
mov cx, 0xb0b
sub cl, 0x01
sub ch, 0x01
push cx
push 0x2e2e2e6c
push 0x6c617720
push 0x65687420
push 0x6e6f2072
push 0x65656220
mov cx, 0x666f
push cx
xor cx, cx
mov cl, 0x20
push cx
cmp bl, 0x01
jz build_v2_string_2
push 0x73
build_v2_string_2:
push 0x656c7474
mov cx, 0x6f62
push cx
xor cx, cx
mov cl, 0x20
push cx
push ax
push 0x202c646e
push 0x756f7261
push 0x20746920
push 0x73736170
push 0x202c6e77
push 0x6f642065
push 0x6e6f2065
mov cx, 0x6b61
push cx
xor cx, cx
mov cl, 0x54
push cx
xor eax, eax
mov al, 0x04
xor ebx, ebx
mov bl, 0x01
mov ecx, esp
mov edx, ebp
sub edx, esp
int 0x80
leave
ret
outro:
push ebp
mov ebp, esp
xor eax, eax
mov al, 0xb
sub al, 0x01
push ax
push 0x20217475
push 0x6f206465
push 0x73736170
push 0x20646e61
push 0x206b6e75
push 0x72642065
push 0x72276577
push 0x20776f6e
push 0x203b646e
push 0x756f7261
push 0x206d6568
push 0x74206465
push 0x73736170
push 0x20646e61
push 0x206e776f
push 0x64206d65
push 0x6874206e
push 0x656b6174
push 0x20657627
xor ax, ax
mov ax, 0x6557
push ax
xor ax, ax
mov ah, 0x0b
mov al, 0x2e
sub ah, 0x01
push ax
push 0x72656562
push 0x20666f20
push 0x73656c74
push 0x746f6220
push 0x65726f6d
push 0x206f6e20
push 0x2c6c6c61
push 0x77206568
push 0x74206e6f
push 0x20726565
push 0x6220666f
push 0x2073656c
push 0x74746f62
push 0x2065726f
push 0x6d206f4e
xor eax, eax
mov al, 0x04
xor ebx, ebx
mov bl, 0x01
mov ecx, esp
mov edx, ebp
sub edx, esp
int 0x80
leave
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment