RampantAndroid
Diamond Member
I've been trying to write some assembly programs up in linux using GCC...I'm unsure of how to start them off, so I just wrote a quick C file and compiled it to an assembly file and used that as a template...
This code below compiles fine, but gives segmentation faults....any help is appreciated!
Thanks!
.file "Lab8.s"
.version "1.00"
.section .rodata
.text
.align 4
.globl main
.type main,@function
main:
jmp .T1
A: .long 1
B: .long 255
.T1:
mov B,%eax
cmp %eax,A
JE .Done
dec %eax
mov %eax,B
jmp .T1
.Done:
jmp .T2
.T2:
leave
ret
.size main, .-main
This code below compiles fine, but gives segmentation faults....any help is appreciated!
Thanks!
.file "Lab8.s"
.version "1.00"
.section .rodata
.text
.align 4
.globl main
.type main,@function
main:
jmp .T1
A: .long 1
B: .long 255
.T1:
mov B,%eax
cmp %eax,A
JE .Done
dec %eax
mov %eax,B
jmp .T1
.Done:
jmp .T2
.T2:
leave
ret
.size main, .-main