Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Created December 4, 2016 13:46
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 yohhoy/76b9e0d7c30ccd81317fecb71c734847 to your computer and use it in GitHub Desktop.
Save yohhoy/76b9e0d7c30ccd81317fecb71c734847 to your computer and use it in GitHub Desktop.
gcc 7.0(HEAD) -std=c++1z -03
#include <cstdio>
#include <string>
int main() {
using namespace std::literals::string_literals;
for (char c: "Hello"s) {
std::printf("(%d)", c);
}
}
.LC0:
.string "(%d)"
main:
pushq %rbp
pushq %rbx
subq $40, %rsp
leaq 16(%rsp), %rbx
leaq 21(%rsp), %rbp
movl $1819043144, 16(%rsp)
movq $5, 8(%rsp)
movb $111, 4(%rbx)
movq %rbx, (%rsp)
movb $0, 21(%rsp)
.L2:
movsbl (%rbx), %esi
movl $.LC0, %edi
xorl %eax, %eax
call printf
addq $1, %rbx
cmpq %rbx, %rbp
jne .L2
movq (%rsp), %rdi
leaq 16(%rsp), %rax
cmpq %rax, %rdi
je .L7
call operator delete(void*)
.L7:
addq $40, %rsp
xorl %eax, %eax
popq %rbx
popq %rbp
ret
movq (%rsp), %rdi
leaq 16(%rsp), %rdx
movq %rax, %rbx
cmpq %rdx, %rdi
je .L5
call operator delete(void*)
.L5:
movq %rbx, %rdi
call _Unwind_Resume
@yohhoy
Copy link
Author

yohhoy commented Dec 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment