Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
865 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 Answer

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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...