www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Convert gcc assembly to ldc one

reply drug <drug2004 bk.ru> writes:
Hello!

Could you help to port this code:
```
__asm__ __volatile__ (
	"990: nop\n"                                                 \
	".pushsection .note.stapsdt,\"?\",\"note\"\n"                \
	".balign 4\n"                                                \
	".4byte 992f-991f, 994f-993f, 3\n"                           \
	"991: .asciz \"stapsdt\"\n"                                  \
	"992: .balign 4\n"                                           \
	"993: .8byte 990b\n"                                         \
	".8byte _.stapsdt.base\n"                                    \
	".8byte 0\n"                                                 \
	".asciz \"myapp\"\n"                                         \
	".asciz \"func_call\"\n"                                     \
	".asciz \"%n[_SDT_S1] %[_SDT_A1] %n[_SDT_S2] %[_SDT_A2]\"\n" \
	"994: .balign 4\n"                                           \
	".popsection\n"
	:: [_SDT_S1] "n" (4),
	   [_SDT_A1] "nor" ((a)),
	   [_SDT_S2] "n" (4),
	   [_SDT_A2] "nor" ((b))
);
```

I failed to find what is the ldc analog to gnu assembler InputOperands. 
What I need is converting ((a)) expression to `-4(%rbp)` string and 
((b)) expression to `-8(%rbp)`
Oct 24 2019
parent drug <drug2004 bk.ru> writes:
On 10/24/19 2:13 PM, drug wrote:
 Hello!
 
 Could you help to port this code:
 ```
 __asm__ __volatile__ (
      "990: nop\n"                                      
 Â Â Â Â Â Â Â Â Â  \
      ".pushsection
.note.stapsdt,\"?\",\"note\"\n"                \
      ".balign 4\n"                                     
 Â Â Â Â Â Â Â Â Â  \
      ".4byte 992f-991f, 994f-993f,
3\n"                           \
      "991: .asciz
\"stapsdt\"\n"                       
 Â Â Â Â Â Â Â Â Â  \
      "992: .balign
4\n"                                
 Â Â Â Â Â Â Â Â Â  \
      "993: .8byte
990b\n"                              
 Â Â Â Â Â Â Â Â Â  \
      ".8byte _.stapsdt.base\n"                         
 Â Â Â Â Â Â Â Â Â  \
      ".8byte 0\n"                                      
 Â Â Â Â Â Â Â Â Â  \
      ".asciz \"myapp\"\n"                              
 Â Â Â Â Â Â Â Â Â  \
      ".asciz \"func_call\"\n"                          
 Â Â Â Â Â Â Â Â Â  \
      ".asciz \"%n[_SDT_S1] %[_SDT_A1] %n[_SDT_S2] %[_SDT_A2]\"\n" \
      "994: .balign
4\n"                                
 Â Â Â Â Â Â Â Â Â  \
      ".popsection\n"
      :: [_SDT_S1] "n" (4),
         [_SDT_A1] "nor" ((a)),
         [_SDT_S2] "n" (4),
         [_SDT_A2] "nor" ((b))
 );
 ```
 
 I failed to find what is the ldc analog to gnu assembler InputOperands. 
 What I need is converting ((a)) expression to `-4(%rbp)` string and 
 ((b)) expression to `-8(%rbp)`
The answer is: ``` __asm ( `990: nop .pushsection .note.stapsdt,"?","note" .balign 4 .4byte 992f-991f, 994f-993f, 3 991: .asciz "stapsdt" 992: .balign 4 993: .8byte 990b .8byte _.stapsdt.base .8byte 0 .asciz "myapp" .asciz "func_call" .asciz "${0:n} ${1} ${2:n} ${3}" 994: .balign 4 .popsection`, "n, r, n, r", 4, a, 4, b); ``` https://godbolt.org/z/TUejUr
Oct 25 2019