0

I have a silly question... I am trying to do string comparisons and first, I want to move each string into a register. I first used BYTE to declare the strings, and realized that I mismatched the size of the register to the variable. In correcting this, I ran into constant value too large. From my understanding, I am trying to pack too many bits into a DWORD variable. However, what makes this strange to me is that I was using a smaller declaration first and had no issue with that... What am I doing wrong?

str1 DWORD "Hello World!", 0
str2 DWORD 20 DUP(0)
----------------------------------
mov eax, str2
mov ebx, str1

Note : str2 is initialized the way it is for user input, my issue lies with str1

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Topher
  • 1
  • You can't move a string into a register. You can move an individual *byte* of a string into a register, or you can move a *pointer* to the string. Which is it that you want? – Nate Eldredge Nov 10 '21 at 15:50
  • Normally you want BYTE / DB arrays for strings; MASM is weird about quoted multi-character strings as operands to DWORD, same as for `DD` in [When using the MOV mnemonic to load/copy a string to a memory register in MASM, are the characters stored in reverse order?](https://stackoverflow.com/q/57427904). If you want the address in a register, use `mov eax, OFFSET str2`. The pointer is always a dword, regardless of the element width of MASM variable's type. – Peter Cordes Nov 10 '21 at 16:02

0 Answers0