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

assembly - How do I write letter-initiated hexadecimal numbers in masm code?

I am currently editing several macros consisting of MASM code. They all look similar to this:

Primary MACRO
Key 0Bh,'0'
Key 29h,15h
Key 03h,'2'
Key 06h,'5'
Key 0Ch,'+'
Key 0Dh,'′'
Key 1Bh,'¨'
Key 2Bh,27h
Key 35h,'-'
Key 34h,'.'
Key 33h,','
Key 56h,'<'
ENDM

I have noticed that I can write hexadecimal numbers which are initiated by (begin with) character 0-9 in the following format: 02h, 12h, 5Ah, etc. However, if I try to write letter-initiated hexadecimal numbers in the same way (that is, like ABh, CAh, DFh, etc.), I get an error. I have tried the format 0xBA, 0xFE, etc., but it doesn't work either.

Can anyone tell me the correct format to use for writing letter-initiated hexadecimal numbers in this case?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

The correct format for hex AB is 0ABh.

The reason you need to start it with a digit is so the assembler can easily distinguish it from a label or symbol such as ABh.

And don't worry about the fact it has three digits. It doesn't magically turn into a twelve-bit number because of that, the number of bits used will depend on the addressing modes you're using.


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

...