Board index » delphi » Refering to variables in assembler?

Refering to variables in assembler?

I have a problem using the assembler in Delphi. I want to change a value in a array of integers
but don't know how to refer to it. I have tried the following where I want to access the second
number in the array but without success.

        var     num: array[0..9] Of Integer;
        ...
        ...
        asm
                mov     num+1,12345
        end

If you know what I am doing wrong, what I should do or if you can come up with some hint, please let me know.

- Cristian

 

Re:Refering to variables in assembler?


Quote
Cristian Almstrand (Christian.Almstr...@Elektro.Ing.HB.SE) wrote:

: I have a problem using the assembler in Delphi. I want to change a value in a array of integers
: but don't know how to refer to it. I have tried the following where I want to access the second
: number in the array but without success.

:       var     num: array[0..9] Of Integer;
:       ...
:       ...
:       asm
:               mov     num+1,12345
:       end

I think you should use current code (it works in TP, i think it works on
Delphi too) : (there is surely simpler, but it works)

asm
        push  ds
        pop   es
        lea   di, num
        inc   di                        (*add  di, 2*)
        inc   di
        mov  ax, 12345
        stosw
end;

Try also :
        lea  di, num
        mov  ds:[di+2], 12345
Maybe it works ... (it is a long that I did not acces array in asm ...)

: If you know what I am doing wrong, what I should do or if you can come up with some hint, please let me know.

: - Cristian

Hope this will help,
                                        F.

--
Fabrice.Pre...@Linux.univ-compiegne.fr
WWW : Http://linux.univ-compiegne.fr/~premel/index.html

Re:Refering to variables in assembler?


In article <1995Nov16.064612.26...@gdunix.gd.chalmers.se>,

Quote
Cristian Almstrand <Christian.Almstr...@Elektro.Ing.HB.SE> wrote:
>I have a problem using the assembler in Delphi. I want to change a value in a array of integers
>but don't know how to refer to it. I have tried the following where I want to access the second
>number in the array but without success.

>    var     num: array[0..9] Of Integer;
>    asm
>            mov     num+1,12345
>    end

asm
        lea     bx,num
        mov     word ptr [bx+2],12345
end;

Quote
>- Cristian

--TCA of NewOrder  /  newor...@carina.unm.edu  /  http://www.nmt.edu/~surface
Programmer for Stranger Than Fiction Games, Inc.  
Project WallyWorld:  A cross between Super Mario World, Rainbow Islands,
Gods, and Pyros.

Re:Refering to variables in assembler?


Quote
On Thu, 16 Nov 1995 06:42:30 GMT, you wrote:
>I have a problem using the assembler in Delphi. I want to change a value in a array of integers
>but don't know how to refer to it. I have tried the following where I want to access the second
>number in the array but without success.
>    var     num: array[0..9] Of Integer;
>    ...
>    ...
>    asm
>            mov     num+1,12345
>    end
>If you know what I am doing wrong, what I should do or if you can come up with some hint, please let me know.

Assuming your 'num' is in the DATA-Segment, this works
        asm     Mov     Si, Offset Num
                Mov     Bx, Index_to_Access
                Shl     Bx, 1
                Mov     [Si+Bx], 12345
        end;

or this:
        asm     Mov     Num.Word[1], 21345
        end;

or this:
        asm     Mov     [(Offset Num) + 2], 12345
        end;

or this:
        asm     Lea     Si, Num
                Mov     Si.Word[1], 12345
        end;

or...

   - Robert Beicht -

---------------------------------------------------------------------
--- Robert Beicht     e-Mail: bei...@lrz.fh-muenchen.de           ---
---               Compuserve: 100551,2212                         ---
---------------------------------------------------------------------
---                      WWW: http://www.lrz-muenchen.de/~p7003ot ---
---------------------------------------------------------------------

Re:Refering to variables in assembler?


Quote
On Thu, 16 Nov 1995 06:42:30 GMT, you wrote:
>I have a problem using the assembler in Delphi. I want to change a value in a array of integers
>but don't know how to refer to it. I have tried the following where I want to access the second
>number in the array but without success.
>    var     num: array[0..9] Of Integer;
>    ...
>    ...
>    asm
>            mov     num+1,12345
>    end
>If you know what I am doing wrong, what I should do or if you can come up with some hint, please let me know.

Assuming your 'num' is in the DATA-Segment, this works
        asm     Mov     Si, Offset Num
                Mov     Bx, Index_to_Access
                Shl     Bx, 1
                Mov     [Si+Bx], 12345
        end;

or this:
        asm     Mov     Num.Word[1], 21345
        end;

or this:
        asm     Mov     [(Offset Num) + 2], 12345
        end;

or this:
        asm     Lea     Si, Num
                Mov     Si.Word[1], 12345
        end;

or...

   - Robert Beicht -

---------------------------------------------------------------------
--- Robert Beicht     e-Mail: bei...@lrz.fh-muenchen.de           ---
---               Compuserve: 100551,2212                         ---
---------------------------------------------------------------------
---                      WWW: http://www.lrz-muenchen.de/~p7003ot ---
---------------------------------------------------------------------

Other Threads