Skip to content

Instantly share code, notes, and snippets.

@doug65536
Created March 27, 2024 22:33
Show Gist options
  • Save doug65536/2b6305c84a5ef819ea7408d49eeffbca to your computer and use it in GitHub Desktop.
Save doug65536/2b6305c84a5ef819ea7408d49eeffbca to your computer and use it in GitHub Desktop.
extern int external;
int global;
int init_global = 42;
short other();
int main(int argc, char **argv)
{
int x = 4;
int y;
y = argc * x;
return y;
}
.bss
# Global variable of type int
.global global
.balign 4
global:
.space 4
.data
# Global variable of type int
.global init_global
.balign 4
init_global:
.int 42
.text
.global main
main:
push %rbp
mov %rsp,%rbp
add $ -16,%rsp
mov %edi,-4(%rbp)
mov %rsi,-16(%rbp)
mov $ 4,%eax
push %rax
mov -4(%rbp),%eax
push %rax
pop %r10
imul %rax,%r10
mov %r10,%rax
mov %eax,-24(%rbp)
jmp .L2
.L2:
leave
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment