0

I have 2 variables Index1 and Index2, a variable called Value with a number and 2 vectors Array1, and Array2.

I need to change the value at index Index1 in Array1 with Value and in Array2 to change the value at Index2 with Value

Everything i try end in an error or dosent affect the arrays at all

assembly 8086
.MODEL small
.STACK 100h
.DATA
index1 DB 9
index2 DB 4
value DB 77h
array1 DB 01h, 02h, 03h, 04h, 05h, 06h, 07h, 08h, 09h, 0Ah
array2 DB 11h, 12h, 13h, 14h, 15h, 16h, 17h, 18h, 19h, 1Ah
.CODE
Start:
mov ax,@data
mov ds,ax;
mov si, offset array1
mov AH,value
mov [si+index1],AH
mov si,0
mov si, offset array2
mov [si+index2],AH
;show array in consol
mov cx,10
mov si, offset array1
loopx:
    mov dl,[si]
    add dl,48
    mov ah,02h
    int 21h
    mov dl,32
    mov ah,02h
    int 21h
    inc si
loop loopx
mov ax,4c00h
int 21h
END Start
Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
  • 1
    x86 doesn't have memory-indirect addressing. `[si+index1]` is accessing memory with an address that's the sum of 2 addresses, index1 and array1. Load your index into a register, or *add* it to SI, like you're doing in the loop with `inc si` to loop over the array. – Peter Cordes Apr 26 '21 at 09:15
  • okay i manage to work with si an increment (ty for the comment) it but now i can change the value in the vector only if Value is a 1 digit number can u help me make it work with 2 digit number? @PeterCordes – Stefan Andrei Ghiță Apr 26 '21 at 10:27
  • [Displaying numbers with DOS](https://stackoverflow.com/q/45904075) – Peter Cordes Apr 26 '21 at 10:30

0 Answers0