views:

302

answers:

1
INCLUDE Irvine16.inc

.data
    byteArray BYTE 6 DUP(?)
    listSize = ($ - byteArray)
    aSum  WORD 0
    soffset = 0
.code
main PROC
    mov  ax, @data
    mov  ds, ax
    mov  cx, listSize
Loop1:
    mov  ax, 0
    movzx ax, [byteArray + soffset]
    add  aSum, ax
    soffset = soffset + 1
    loop Loop1
    exit
main ENDP
END main

The error I'm getting is error "A2074:cannot access label through segment registers"

I'm trying to use the soffset to loop through the byteArray.

A: 

I'm not sure what's in Irvine16.inc, but I bet it is saying .model small,... at some point.

If you add

ASSUME DS:_DATA

then your error messages will go away, although I doubt if that's enough to make the program run.


Ok, I've got an idea. I think you should switch to the 32-bit examples. That's a flat model where the segment registers are set up by the OS and not used by programs. I just downloaded the irvine examples and the sample project, which happens to be 32-bits did assemble and run.

In the wierd and twisted world that is x86 machine code, the 16-bit model is quite a bit more complex than the 32-bit model, at least from the point of view of a user program.

DigitalRoss
I have to agree with Crashworks and JS, regarding soffset. As it happens, that is a valid statement in most assemblers, but it will not do what I think you think it will do.
DigitalRoss
This is homework for an assembly class that specifically requires that I use the 16-bit examples.
chustar
Ahh, OK. Well, step 1 has gotta be: get an unmodified example working.
DigitalRoss