Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

assembly - NASM TO GAS: counterpart of resw in GAS

I am tasked to convert my assembly program which uses NASM to GAS. Unfortunately there are lots of mismatched statements. I have converted some of them but I am still having trouble on how to convert this statement

min resw 1
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You could try:

.lcomm min, 2

or

.comm min, 2

to put aside space for two bytes (one word) in the bss section. The point of the bss section is that the loader will allocate space and set the content to zero on load, but it won't take up space in your file on disk.

.lcomm is if you only need to refer to min from inside the file where you use .lcomm. comm is if you need to refer to min from other files (so the linker will make it available to other files).

If you prefer to use the data section, which will put the zeros in your file and take up space on disk, then this, placed in the data section, should work:

min:
    .fill 2

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...