0

I just started learning assembly and I got to arrays. When I try to get the register bx to hold place 2 for example in the array

IDEAL 
MODEL small
STACK 100h
DATASEG

    array db 5 dup(45)



CODESEG
start:
    mov ax, @data
    mov bx, offset array; here
    mov ax, bx
    add ah, al
    mov al, [bx+2]
    add ah, al
    mov ax, 0




exit:
    mov ax, 4c00h
    int 21h
END start   

But it doesn't work for me. If anyone know why this doesn't work as I intend it to please comment.

Thanks.

P.S. Can someone please also explain to me how to make an array without using dupe i.e: array db 1,2,3,4 (this only contains 1)

shnap
  • 175
  • 1
  • 1
  • 10
  • 2
    You didn't move `ax` into `ds`. – Erik Eidt Jan 13 '20 at 17:45
  • Should I move use `mov ds,ax` because the data is there? – shnap Jan 13 '20 at 18:02
  • DS is the data segment register. It has to point to the data segment. If you have multiple data segments, you can switch between them by putting the address of the current data segment there. Also see [What is the value of segment registers in 8086?](https://stackoverflow.com/q/18837627/1305969). – zx485 Jan 13 '20 at 18:55

0 Answers0