I'm working on a project for school and can't seem to get past this one particular error.

The code that I have so far isn't finalized and most likely has some logic errors that I will need to change, but for now I'm just trying to get it to compile.

I've posted the ASM code here:
http://kyleabaker.pastebin.com/m4236f1a1

I'm getting this error for the following lines (all the same error/problem): 86, 88, 90, 92, 97, 103, 110, 118, 122, 132, 134, 135, 137, 139, 141, 154

If I could understand how to fix one of them then I'm sure I could apply it to the rest.

Basically, I have an array with roman numerals that I'm attempting to access dynamically. I can access it using nextchar(0), I can't use a variable in place of the 0 and that's what I need. Is there any way I can work around this?

I feel like I've exhausted Google with a little information, but no direction. Thanks in advanced.

Edit:
I'm using DOSBox and Masm to compile (for my class).
Posted on 2009-10-14 09:55:30 by kyleabaker
When in doubt, RTFM. This maxim will never fail or rust.

MASM interprets label1(label2) as label1+label2, not as a subscript operator. As both of labels are relocatable (not constant), this arithmetic is not possible. Besides, such addressing mode does not exist in x86 architecture, you'll need registers for indexed access.

Intel SDM and AMD ARM are freely available. They aren't too hard to comprehend and contain vast amounts of information about architecture you're trying to learn and write programs for.
Posted on 2009-10-14 11:14:33 by baldr

MASM interprets label1(label2) as label1+label2, not as a subscript operator. As both of labels are relocatable (not constant), this arithmetic is not possible. Besides, such addressing mode does not exist in x86 architecture, you'll need registers for indexed access.

I've been reading up a lot at http://www.emu8086.com/ with no luck so far.

If label1(label2) is interpreted as label1+label2, would I be able to do something like the following with the result that I expect from label1(label2)?


mov        dl, label1
add        dl, label2
cmp        dl, ';'
je          foo


...or is the logic behind that going to be interpreted differently than just selecting the nth item in label1's list?
Posted on 2009-10-14 11:21:16 by kyleabaker
No, that won't work either... and isn't what you want to do. As Balrd says, you need to use a register as an index. You've got, for example:

cmp      nextchar(currchar), 20h

"currchar" is a variable, too, and you want to use its "", not its address (offset) as an index. If "currchar" were a word-sized variable, we could just do:

mov bx, currchar ; "" for Nasm - "", not offset!

But it's a byte, so we have to do:

mov bh, 0
mov bl, currchar

now...

cmp nextchar, 20h

Will do what you want (I think). As you see, there are a lot of instances that will have to be fixed.

(if you're using Masm, why are you reading about emu8086?)

Best,
Frank

Posted on 2009-10-14 13:51:52 by fbkotler