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
862 views
in Technique[技术] by (71.8m points)

x86 - How to represent octal numbers in Assembly?

For example for hexadecimal numbers we can use 0x98398 or 8790h.

How can octal numeric constants be written? Does this work?

mov eax, 70o
See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

NASM supports 70o, 70q, 0o70, and 0q70 for octal.

I'd recommend the 0q70 version, to avoid the risk of future (human) readers mistaking the lower-case-o for a zero. I'm not a fan of the trailing suffix style for hex, either, because it's easy to miss. It helps to use the opposite case from the rest of the constant, but a leading 0x or 0q is clearer. (And for hex, avoids the need for a leading 0 to make it a numeric constant instead of a symbol name.)

As for hex-constant support, it will certainly vary by assembler, so just check your assembler manual. e.g. most DOS/Windows-only assemblers don't support 0xDEADBEEF, only 0DEADBEEFh style, so I'd guess they have fewer options for octal, too.

See the tag wiki for links to various assembler manuals (and lots of other useful resources and guides).


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

...