News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

mem shift, pls help ?

Started by mimime, March 21, 2007, 09:31:35 PM

Previous topic - Next topic

mimime

I have stored some data on [SI]
how do I shift to the next memory location up or down ?
sorry it might be a simple silly question but I really don't know how

MichaelW

If I understand the question correctly:

.data
    b0 db 0
    b1 db 1
    b2 db 2
    w0 dw 0
    w1 dw 1
    w2 dw 2
.code
    ; index + displacement
    mov si, OFFSET b1
    mov al, [si]        ; al <- 1
    mov al, [si+1]      ; al <- 2
    mov al, [si-1]      ; al <- 0

    mov si, OFFSET w1
    mov ax, [si]        ; ax <- 1
    mov ax, [si+2]      ; ax <- 2
    mov ax, [si-2]      ; ax <- 0

    ; index + base
    mov si, OFFSET b0
    xor bx, bx
    mov al, [si+bx]     ; al <- 0
    inc bx
    mov al, [si+bx]     ; al <- 1
    inc bx
    mov al, [si+bx]     ; al <- 2

    ; index + base + displacement
    mov si, OFFSET b0
    mov bx, 1
    mov al, [si+bx]     ; al <- 1
    mov al, [si+bx+1]   ; al <- 2
    mov al, [si+bx-1]   ; al <- 0


Using a 32-bit register to store an index, you can also specify a scaling factor of 1, 2, 4, or 8, for example:

mov ax, [ebx+2][ecx*2]



eschew obfuscation