Skip to content

Commit

Permalink
Changed for 32-bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
jwasham committed Aug 30, 2016
1 parent 6ebfb28 commit bd729c5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 17 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ add_subdirectory(quick_sort)
add_subdirectory(graphs)
add_subdirectory(interview)
add_subdirectory(forking)
add_subdirectory(assembly)
5 changes: 5 additions & 0 deletions assembly/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.5)
project(asm1_proj)

set(SOURCE_FILES main.c)
add_executable(asm1 ${SOURCE_FILES})
2 changes: 1 addition & 1 deletion assembly/main.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <stdio.h>
/*
* Just a simple program so I can inspect the assembly code.
* gcc -O2 -S -c main.c
* gcc -m32 -S -c main.c
*/

int main(int argc, char *argv[]) {
Expand Down
40 changes: 24 additions & 16 deletions assembly/main.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,32 @@
.globl _main
.align 4, 0x90
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp2:
.cfi_def_cfa_register %rbp
leaq L_.str(%rip), %rdi
pushl %ebp
movl %esp, %ebp
pushl %esi
subl $36, %esp
calll L0$pb
L0$pb:
popl %eax
movl 12(%ebp), %ecx
movl 8(%ebp), %edx
leal L_.str-L0$pb(%eax), %eax
movl $12345, %esi ## imm = 0x3039
xorl %eax, %eax
callq _printf
movl $61453, %eax ## imm = 0xF00D
popq %rbp
retq
.cfi_endproc
movl $0, -8(%ebp)
movl %edx, -12(%ebp)
movl %ecx, -16(%ebp)
movl %eax, (%esp)
movl $12345, 4(%esp) ## imm = 0x3039
movl %esi, -20(%ebp) ## 4-byte Spill
calll _printf
movl $61453, %ecx ## imm = 0xF00D
movl %eax, -24(%ebp) ## 4-byte Spill
movl %ecx, %eax
addl $36, %esp
popl %esi
popl %ebp
retl

.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
Expand Down

0 comments on commit bd729c5

Please sign in to comment.