5天了没人解决,求大牛

和我赛跑的人 2014-05-21 10:23:12
.code
szBuffer db '0123456',256 dup(0)
start:
......
end start

这个汇编代码编译以后生产的EXE 0123456 在.text段

求C++实现这个效果代码,让常量在.text段
...全文
251 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
和我赛跑的人 2014-05-22
  • 打赏
  • 举报
回复
引用 5 楼 zhao4zhong1 的回复:
 
The _emit Pseudoinstruction
Home |  Overview |  How Do I

The _emit pseudoinstruction is similar to the DB directive of MASM. You use _emit to define a single immediate byte at the current location in the current text segment. However, _emit can define only one byte at a time, and it can only define bytes in the text segment. It uses the same syntax as the INT instruction. 

The following fragment places the given bytes into the code:

#define randasm __asm _emit 0x4A __asm _emit 0x43 __asm _emit 0x4B
 .
 .
 .
__asm {
     randasm
     }
dw dd有吗
赵4老师 2014-05-22
  • 打赏
  • 举报
回复
 
The _emit Pseudoinstruction
Home |  Overview |  How Do I

The _emit pseudoinstruction is similar to the DB directive of MASM. You use _emit to define a single immediate byte at the current location in the current text segment. However, _emit can define only one byte at a time, and it can only define bytes in the text segment. It uses the same syntax as the INT instruction. 

The following fragment places the given bytes into the code:

#define randasm __asm _emit 0x4A __asm _emit 0x43 __asm _emit 0x4B
 .
 .
 .
__asm {
     randasm
     }
Saleayas 2014-05-21
  • 打赏
  • 举报
回复
#pragma const_seg(".my_data1")
const char sz2[]= "test2";     // stored in .my_data1
和我赛跑的人 2014-05-21
  • 打赏
  • 举报
回复
引用 3 楼 Symfund 的回复:
MSDN: #pragma code_seg( [ [ { push | pop }, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] ) // pragma_directive_code_seg.cpp void func1() { // stored in .text } #pragma code_seg(".my_data1") void func2() { // stored in my_data1 } #pragma code_seg(push, r1, ".my_data2") void func3() { // stored in my_data2 } #pragma code_seg(pop, r1) // stored in my_data1 void func4() { } int main() { }
我的是把常量放到text段里
Symfund 2014-05-21
  • 打赏
  • 举报
回复
MSDN: #pragma code_seg( [ [ { push | pop }, ] [ identifier, ] ] [ "segment-name" [, "segment-class" ] ) // pragma_directive_code_seg.cpp void func1() { // stored in .text } #pragma code_seg(".my_data1") void func2() { // stored in my_data1 } #pragma code_seg(push, r1, ".my_data2") void func3() { // stored in my_data2 } #pragma code_seg(pop, r1) // stored in my_data1 void func4() { } int main() { }
和我赛跑的人 2014-05-21
  • 打赏
  • 举报
回复
引用 1 楼 Saleayas 的回复:
#pragma const_seg(".my_data1")
const char sz2[]= "test2";     // stored in .my_data1
const段, 不是我想要的 我要的是放到代码段里

3,881

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧