Skip to content

add Intel syntax alternatives to all gcc inline assembly#244

Open
ecm-pushbx wants to merge 1 commit intoFDOS:masterfrom
ecm-pushbx:ecm-gcc-inline-asm-intel
Open

add Intel syntax alternatives to all gcc inline assembly#244
ecm-pushbx wants to merge 1 commit intoFDOS:masterfrom
ecm-pushbx:ecm-gcc-inline-asm-intel

Conversation

@ecm-pushbx
Copy link
Copy Markdown
Contributor

Based on #225 I developed the patch in https://pushbx.org/ecm/test/20260422-generate-listings.diff (AT&T syntax) and https://pushbx.org/ecm/test/20260422-generate-listings-intel.diff (Intel syntax) to generate assembler listing files from the .c files.

This commit includes only the changes to inline assembly, as these shouldn't break anything for other users or other compilers than ia16-elf-gcc. As it turns out, gcc extended inline assembly allows to specify two variants for any snippet, one for AT&T syntax and the other for Intel syntax.

Previously discussed in https://codeberg.org/tkchia/gcc-ia16/issues/9#issuecomment-13551167

I verified that both sys.com and kgc8632.sys are byte by byte exactly identicalised matches before and after applying this commit.

@andrewbird
Copy link
Copy Markdown
Contributor

So this is interesting, why would GCC allow this and what if the two sides aren't equivalent?

@ecm-pushbx
Copy link
Copy Markdown
Contributor Author

In my case I make use of it so I can use -masm=intel despite the whole kernel not being updated to use (only) this variant. As for if they're not equivalent I'd hazard a guess that's user error.

@andrewbird
Copy link
Copy Markdown
Contributor

The use of ATT syntax is only in the GCC inline, or did I miss some other example in the kernel? It seems to me that if we switched to Intel syntax here it would be more in keeping with the rest of the assembly source in the kernel. Would anyone object to that?

@ecm-pushbx
Copy link
Copy Markdown
Contributor Author

The use of ATT syntax is only in the GCC inline, or did I miss some other example in the kernel?

If you pass -masm=intel then this switches the entire kernel (the C code) to be built as Intel syntax, whereas otherwise it uses AT&T syntax. It is only visible with -S or the listing file options.

It seems to me that if we switched to Intel syntax here it would be more in keeping with the rest of the assembly source in the kernel. Would anyone object to that?

That would require editing all makefiles to always pass -masm=intel

@andrewbird
Copy link
Copy Markdown
Contributor

I thought that it might be nice to keep just one version of the inline assembly code and also support your use case.

@ecm-pushbx
Copy link
Copy Markdown
Contributor Author

I thought that it might be nice to keep just one version of the inline assembly code and also support your use case.

I don't know how that'd be possible unfortunately. If you use -masm=intel you need either Intel inline code, or (maybe) switch explicitly to AT&T and back after the inline code.

@andrewbird
Copy link
Copy Markdown
Contributor

Okay, sorry for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants