Intel® oneAPI Base Toolkit
Support for the core tools and libraries within the base toolkit that are used to build and deploy high-performance data-centric applications.
419 Discussions

Option for assembling to flat binary format - Feature Request

cntk
Beginner
1,022 Views

Dear great minds of software engineering,

 

I've looked around for such feature at Intel documentation, but apparently I can't find it or it is not implemented (yet).

Therefore the following content in this post should be considered as a feature request for Intel compiler, or perhaps a new separate program shall be created as a part of the Base Toolkit.

An example of such feature can be found in other assemblers such as NASM, FASM and others.

For example with NASM

A very straightforward assembly code (saved in the file named input.asm

BITS 64  ; tells nasm to use 64-bit mode
mov eax, [gs:30h]
ret

 When assembled with the following command:

nasm -f bin -o output.bin input.asm

It produces an output file (named output.bin). By opening the file in Hex editor, we can see the following hex-bytes inside the file:

65 8B 04 25 30 00 00 00 C3

Great. This is the end result basically. We can see NASM achieves this by using file system to read/write and with BITS specified because by default it uses 16-bit mode.

For example with FASM

Currently FASM has some limitations (i.e. it is limited to 32-bit address space and it is also lacking macOS support out-of-box)... However I'd like to point out that it has a nice advantage, because FASM provides DLL version which can be used via FFI (foreign function interface) for interop from other programming languages. The DLL provides an exported function which can be invoked to assemble code to flat binary format in memory rather than using I/O like NASM; this of course gains performance boost.

Nonetheless, FASM can operate with files just fine, similarly to NASM:

use64  ; tells fasm to use 64-bit mode
xor eax, eax
mov eax, [gs:eax+30h]
ret

 To assemble (assuming the above snippet is saved in the file named input.asm

fasm input.asm output.bin

The above command will produce a file named output.bin with hex-bytes content:

 31 C0 65 67 8B 40 30 C3

Yet again, this is the end result basically. It is a little different compared to NASM, but works just the same...

 

I had mentioned there are also other approaches available, for example on Linux, it is not really trivial but can be achieved by using gcc & objdump commands.

Without further ado, I will wrap it up here. This feature is very useful in some areas such as embedding and AOT. For people who prefer Intel dialect, they would appreciate such a feature 

Would Intel implement this feature?

 

Thanks in advance. Stay safe.

~ cntk

0 Kudos
3 Replies
RahulV_intel
Moderator
983 Views

Hi,


Could you please elaborate more on the new features that you are looking for?

I have used objdump on the DPC++ compiled executables. It worked fine for me.


Thanks,

Rahul


0 Kudos
RahulV_intel
Moderator
972 Views

Hi @cntk,

 

Just a quick reminder to elaborate more on the additional features that you are looking for.

 

Thanks,

Rahul

 

0 Kudos
RahulV_intel
Moderator
956 Views

Hi,


I have not heard back from you, so I will go ahead and close this thread from my end. Feel free to post a new query if you require further assistance from Intel.


0 Kudos
Reply