I am getting following assembler error when I try to assemble my code:
Error: invalid operands (*UND* and *UND* sections) for `-' when setting `UPPER_CONVERSION'
I am using following command to assemble:
as -32 toupper.s -o toupper.o
My code (I am referring the lower to upper conversion code from this book):
.section .text ###CONSTANTS## #The lower boundary of our search .equ LOWERCASE_A, ’a’ #The upper boundary of our search .equ LOWERCASE_Z, ’z’ #Conversion between upper and lower case .equ UPPER_CONVERSION, ’A’ - ’a’ ## error on this line
See the first version of this question for the full code which uses $UPPER_CONVERSION
as an immediate. But the above is an MCVE which produces the assembler error message, and thus isn't usable as a way to define UPPER_CONVERSION = 65 - 97 = -32
I saw this question, I tried the solution, but I think it is not related (I may be wrong here).
You have some non-ASCII quote characters in your source code:
pasting your ’A’ - ’a’
into hd
(aka hexdump -C
) on GNU/Linux shows this:
00000000 e2 80 99 41 e2 80 99 20 2d 20 e2 80 99 61 e2 80 |...A... - ...a..|
00000010 99 0a |..|
So the problem is that your quote marks are 3-byte UTF-8 sequences, not ASCII single quotes.
Re-typing it as
.equ UPPER_CONVERSION, 'A' - 'a'
results in a file that assembles just fine. (Containing only that one line. I didn't try your entire file.)