Skip to content

Instantly share code, notes, and snippets.

@TheCurle
Last active September 9, 2020 19:38
Show Gist options
  • Save TheCurle/69e4a4364f9f04bdeff21750f0450b63 to your computer and use it in GitHub Desktop.
Save TheCurle/69e4a4364f9f04bdeff21750f0450b63 to your computer and use it in GitHub Desktop.
Weird Erythro Things
.text
.LC0:
.string "%d\n"
PrintInteger:
pushq %rbp
movq %rsp, %rbp
subq $16, %rsp
leaq .LC0(%rip), %rcx
movq $0, %rax
call printf
nop
leave
ret
.globl main
.def main; .scl 2; .type 32; .endef
main:
pushq %rbp
call __main
movq %rsp, %rbp
movq $12, %r8
movq $3, %r9
imulq %r8, %r9
movq %r9, %rdx
call PrintInteger
movq $18, %r8
movq $2, %r9
movq $4, %r10
imulq %r9, %r10
subq %r10, %r8
movq %r8, %rdx
call PrintInteger
movq $1, %r8
movq $2, %r9
addq %r8, %r9
movq $9, %r8
addq %r9, %r8
movq $5, %r9
movq $2, %r10
movq %r9, %rax
cqo
idivq %r10
movq %rax, %r9
subq %r9, %r8
movq $3, %r9
movq $5, %r10
imulq %r9, %r10
addq %r8, %r10
movq %r10, %rdx
call PrintInteger
movl $0, %eax
popq %rbp
ret
.text
.text
.globl Testings
.def Testings; .scl 2; .type 32; .endef
Testings:
pushq %rbp
movq %rsp, %rbp
subq $32, %rsp
movq $40, %r8
movl %r8d, %eax
jmp L1
L1:
popq %rbp
addq $32, %rsp
ret
.comm Result, 4, 4
.text
.globl main
.def main; .scl 2; .type 32; .endef
main:
pushq %rbp
movq %rsp, %rbp
subq $32, %rsp
call __main
movq $10, %r9
movq %r9, %rcx
call PrintInteger
movq %rax, %r10
movq $10, %r8
movq %r8, %rcx
call PrintInteger
movq %rax, %r9
movl %r9d, Result(%rip)
movzbl Result(%rip), %r8
movq %r8, %rcx
call PrintInteger
movq %rax, %r9
movq $10, %r8
movq %r8, %rcx
call PrintInteger
movq %rax, %r9
movq $10, %r9
addq %r9, %r9
movq %r9, %rcx
call PrintInteger
movq %rax, %r9
L2:
popq %rbp
addq $32, %rsp
ret
.text
.LC0:
.string "%d\n"
.globl main
.def main; .scl 2; .type 32; .endef
main:
pushq %rbp
movq %rsp, %rbp
subq $32, %rsp
call __main
.comm x, 8, 8
movq $1, %r8
movq $2, %r9
cmpq %r9, %r8
setl %r9b
andq $255, %r9
movq %r9, x(%rip)
movq x(%rip), %r8
movq %r8, %rdx
leaq .LC0(%rip), %rcx
call printf
movq $1, %r8
movq $2, %r9
cmpq %r9, %r8
setle %r9b
andq $255, %r9
movq %r9, x(%rip)
movq x(%rip), %r8
movq %r8, %rdx
leaq .LC0(%rip), %rcx
call printf
movq $1, %r8
movq $2, %r9
cmpq %r9, %r8
setg %r9b
andq $255, %r9
movq %r9, x(%rip)
movq x(%rip), %r8
movq %r8, %rdx
leaq .LC0(%rip), %rcx
call printf
movq $1, %r8
movq $2, %r9
cmpq %r9, %r8
setge %r9b
andq $255, %r9
movq %r9, x(%rip)
movq x(%rip), %r8
movq %r8, %rdx
leaq .LC0(%rip), %rcx
call printf
movq $1, %r8
movq $2, %r9
cmpq %r9, %r8
setne %r9b
andq $255, %r9
movq %r9, x(%rip)
movq x(%rip), %r8
movq %r8, %rdx
leaq .LC0(%rip), %rcx
call printf
movq $1, %r8
movq $2, %r9
cmpq %r9, %r8
sete %r9b
andq $255, %r9
movq %r9, x(%rip)
movq x(%rip), %r8
movq %r8, %rdx
leaq .LC0(%rip), %rcx
call printf
movq $18, %r8
movq $18, %r9
cmpq %r9, %r8
sete %r9b
andq $255, %r9
movq %r9, x(%rip)
movq x(%rip), %r8
movq %r8, %rdx
leaq .LC0(%rip), %rcx
call printf
movl $0, %eax
addq $32, %rsp
popq %rbp
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment