3 Replies - 1485 Views - Last Post: 29 March 2013 - 09:55 AM

#1 THX  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 29-March 13

why does this assembly code break?

Posted 29 March 2013 - 07:56 AM

why does this code break every time it hits, mov [eax], ebx?

; 

.386
.model flat
.stack 4096
.data



.code
_start:

mov eax, 2  
mov ebx, 7D12Eh
mov [eax], ebx
mov eax, 4
mov ebx, 568923h
mov [eax], ebx
mov  ebx, 3 
mov [eax], ebx


ret
 
PUBLIC _start
end



Is This A Good Question/Topic? 0
  • +

Replies To: why does this assembly code break?

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 9089
  • View blog
  • Posts: 34,142
  • Joined: 12-June 08

Re: why does this assembly code break?

Posted 29 March 2013 - 07:59 AM

_moving_ this to the assembly forum.
Was This Post Helpful? 0
  • +
  • -

#3 THX  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 29-March 13

Re: why does this assembly code break?

Posted 29 March 2013 - 08:31 AM

View Postmodi123_1, on 29 March 2013 - 07:59 AM, said:

_moving_ this to the assembly forum.

Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,279
  • Joined: 28-March 11

Re: why does this assembly code break?

Posted 29 March 2013 - 09:55 AM

1. what are you trying to do?
2. what do you think you are doing?

when you add brackets around a register, the register becomes a pointer. You moved 2 into eax, so when you do:
mov [eax], ebx, you are telling the cpu to move the value in ebx to the address - 2 which there is no such address.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1