How to get the body of a function/asm statement in hexadecimal

Ali Çehreli acehreli at yahoo.com
Sun Jan 29 21:59:40 UTC 2023


On 1/29/23 13:45, Ruby the Roobster wrote:

 > Of course, function pointers cannot be dereferenced.

Since you want to see the bytes, just cast it to ubyte*. The following 
function dumps its own bytes:

import std;

void main() {
     enum end = 0xc3;
     for (auto p = cast(ubyte*)&_Dmain; true; ++p) {
         writefln!" %02x"(*p);
         if (*p == end) {
             break;
         }
     }
}

(It can be written more elegantly as a range expression.)

 > Furthermore, I would like to be able to do the same for an `asm` 
statement.

I don't know how to get the address of asm blocks.

Ali



More information about the Digitalmars-d-learn mailing list