title: Unicorn engine Invalid memory read (UC_ERR_READ_UNMAPPED)
body: <p>I'm doing picoCTF exercises and came upon basic RE/assembly one, the purpose was to basically tell the value of EAX at the end of program. I figured it would be a nice opportunity to try Unicorn/Keystone engines, so I did it. I assembled two variants of the code (to get rid of jump instructions) with keystone engine and tried to emulate it with unicorn. However, I get the "Invalid memory read (UC_ERR_READ_UNMAPPED)" exception. One of the snippets I assembled (taking into account AT&amp;T syntax):</p>
  
  <pre><code>MOV $19388,%ebx
  MOV $28571,%eax
  MOV $19079,%ecx
  IMUL %eax,%ebx
  ADD %eax,%ebx
  MOV %ebx,%eax
  SUB %ecx,%eax
  </code></pre>
  
  <p>Which resulted in the following string (saved in file "assembledopt1.txt"):</p>
  
  <pre><code>\xbb\xbc\x4b\x0\x0\xb8\x9b\x6f\x0\x0\xb9\x87\x4a\x0\x0\xf\xaf\xd8\x1\xc3\x89\xd8\x29\xc8
  </code></pre>
  
  <p>And tried to run it with this code:</p>
  
  <pre><code>#!/usr/bin/python3
  
  from unicorn import *
  from unicorn.x86_const import *
  
  with open("assembledopt1.txt", "rb") as file:
      code = file.read()
  
  addr = 0x1000000
  
  print("Emulate x86")
  
  try:
      mu = Uc(UC_ARCH_X86, UC_MODE_32)
  
      mu.mem_map(addr, 1024*1024)
  
      mu.mem_write(addr,code)
  
      mu.reg_write(UC_X86_REG_ECX, 0x0)
      mu.reg_write(UC_X86_REG_EAX, 0x0)
      mu.reg_write(UC_X86_REG_EBX, 0x0)
  
      mu.emu_start(addr, addr+len(code))
  
  
      print("Done")
  
      r_eax = mu.reg_read(UC_X86_REG_EAX)
      print("Eax: " + r_eax)
  
  except Exception as e:
      print("Err: %s" % e)
  </code></pre>
  
  <p>Which results in previously mentioned exception.<br />
  I have no idea what I'm doing wrong since my code is pretty similar to tutorial one, and hope You can help me. Great thanks in advance to anyone that pays attention to my problem!</p>