OSDev.org https://forum.osdev.org/ |
|
[SOLVED] gcc inline asm clobber list question https://forum.osdev.org/viewtopic.php?f=13&t=31200 |
Page 1 of 1 |
Author: | dchapiesky [ Wed Jan 11, 2017 11:02 am ] |
Post subject: | [SOLVED] gcc inline asm clobber list question |
for the code... Code: unsigned long b_input(unsigned char *str, unsigned long count) { unsigned long len; asm volatile ("call *0x0000000000100020" : "=c" (len) : "c"(count), "D"(str)); return len; } Should "mem" be added in the clobber list? as in: Code: unsigned long b_input(unsigned char *str, unsigned long count) { unsigned long len; asm volatile ("call *0x0000000000100020" : "=c" (len) : "c"(count), "D"(str) : "mem"); return len; } Since the call to 100020 modifies memory pointed to by str Just trying to tidy up code and your input will help. cheers |
Author: | Kevin [ Wed Jan 11, 2017 11:10 am ] |
Post subject: | Re: gcc inline asm clobber list question |
Yes, you should add "memory" to the clobber list then. |
Author: | dchapiesky [ Wed Jan 11, 2017 11:11 am ] |
Post subject: | Re: gcc inline asm clobber list question |
Thanks... I thought so but inline asm isn't my strong suite |
Author: | Octocontrabass [ Wed Jan 11, 2017 11:13 am ] |
Post subject: | Re: [SOLVED] gcc inline asm clobber list question |
You should also add "cc" to the clobber list if that function modifies any flags. Everyone seems to forget that one. |
Author: | dchapiesky [ Wed Jan 11, 2017 11:15 am ] |
Post subject: | Re: [SOLVED] gcc inline asm clobber list question |
'"cc" like carry flag? If you can clarify I need this.... |
Author: | Icee [ Wed Jan 11, 2017 11:18 am ] |
Post subject: | Re: [SOLVED] gcc inline asm clobber list question |
dchapiesky wrote: '"cc" like carry flag? If you can clarify I need this.... CC is for all condition codes, i.e. AF, PF, CF, OF, SF, ZF. Otherwise GCC is free to assume that your inline assembly snippet preserves them and might try to use previous values after the call in generated code. |
Author: | dchapiesky [ Wed Jan 11, 2017 11:21 am ] |
Post subject: | Re: [SOLVED] gcc inline asm clobber list question |
Thanks Final code: Code: unsigned long b_input(unsigned char *str, unsigned long count) { unsigned long len; asm volatile ("call *0x0000000000100020" : "=c" (len) : "c"(count), "D"(str) : "cc", "memory"); return len; } edited for typo |
Author: | Icee [ Wed Jan 11, 2017 11:23 am ] |
Post subject: | Re: [SOLVED] gcc inline asm clobber list question |
dchapiesky wrote: Thanks Also note that when calling functions from inline assembly many of the usual call convention related aspects may not hold. For instance, the direction flag (DF) may be set and the stack may be misaligned. |
Author: | dchapiesky [ Wed Jan 11, 2017 11:27 am ] |
Post subject: | Re: [SOLVED] gcc inline asm clobber list question |
Icee wrote: For instance, the direction flag (DF) may be set and the stack may be misaligned. Yah.. ran into the misaligned stack on a different call from this example. I am going to open a separate thread for another inline asm question that has been bugging me... Thank you all for your responses |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |