Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22015

Using lodsb to move a byte into another address using inline c [duplicate]

$
0
0

I'm learning inline assembly in c and I'm trying to load a byte into another variable so I can eventually get into working with strings.

My current code took a pretty simple approach with my comments showing my logic below:

char load = 't', ret;

asm volatile(
  "mov $1, %%esi;"  /* move arg 1 (load) into %esi */
  "lodsb;"          /* load one bite from %esi into %eax */
  : "=a" (ret)      /* ret in %eax */
  : "S" (load)      /* load in %esi */
);

However, my output gives me a seg fault. Any assistance would be appreciated, thanks!


Viewing all articles
Browse latest Browse all 22015

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>