1

I have some numeric constants in my data definition and would like to be able to use them inside my strings without having to embed them at runtime. Is this possible in MASM?

.data

LOWER_BOUND = 50
UPPER_BOUND = 100

promptMessage  BYTE  "Please enter a number between ", LOWER_BOUND, " and ", UPPER_BOUND, ".",10,13,0

I am using the Irvine library.

1
  • NASM can stringify constants at assemble time with its preprocessor: Nasm: Convert integer to string using preprocessor. (Which you can then use in the list of operands to db). I don't know if MASM can do the same, or if so how. You could do something like BYTE (LOWER_BOUND/10)%10 + '0', LOWER_BOUND%10 + '0' to do it explicitly for a 2-digit number, or any other fixed width with leading zeros, but variable-width needs something conditional. Commented Nov 20, 2022 at 2:58

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.