0

I am taking my first assembly programming class and my instructor wants us to find out how based addressing mode works. So here is some code that I wrote to try and do that. Only problem is that I must not understand it because I keep getting a segmentation fault. I commented on the lines to try and show what I THINK they are doing. Can someone please correct my misunderstanding.

Thanks!

.text
.global _start
L0: .int 0x99999999
L1: .int 0x12345678
L2: .int 0x11111111
_start:
movl $L1, %eax   #Stores the address of what L1 "pionts to" in regester eax
movb $0, 2(%eax)  #Stores 0 in the location eax has in it +2 memory locations
              #So 0 should be stored in the same place as L1+2
checkHere:


movl $1,%eax
movl $0,%ebx
int $0x80
Carl Norum
  • 219,201
  • 40
  • 422
  • 469
  • syscall 1h is exit() by the way, what is your intention in _start? Also, be wary of addressing below the beginning of ELF paged address space. – zetavolt Feb 23 '13 at 21:14

1 Answers1

1

.text is readonly. Put your data in .data and it should work.

Frank Kotler
  • 3,079
  • 2
  • 14
  • 9