Announcement

Collapse
No announcement yet.

How to write TO a string with ASM?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to write TO a string with ASM?

    The following code always generates a Windows "...has peformed illegal function..."
    error. It has been through MANY permutations, to no avail:

    Code:
    DEFSTR S
    DEFWRD W
    DEFINT I
     
    S = " "
     
    WSeg1 = CODESEG(Table1)
    WPtr1 = CODEPTR(Table1)
     
    WSeg2 = STRSEG(S)
    WPtr2 = STRPTR(S)
     
    ! db &H66
    ! db &H60
     
    ! mov ds, WSeg1
    ! mov si, WPtr1
     
    ! mov es, WSeg2
    ! mov di, WPtr2
     
    ! mov al, ds:[si]
    ! mov es:[di], al
     
    ! db &H66
    ! db &H61
     
    PRINT S
     
    END(0)
     
    Table1:
    ! db 084
    I have tried replacing the Table1: with a second string that had
    a letter in it. No luck. I have tried using CODEPTR32() and STRPTR32()
    with ! lds and ! les, same results. I tried using ! movsb, with
    no luck. So, I am forced to the conclusion that the error is being
    generated by the program's trying to write to illegal memory.
    Strangely enough, I have not had this problem with using ! mov
    where its destination operand was a numeric variable - it only seems
    to happen when it's a string variable.

    Any replies gratefully received.


    ------------------
    mailto:[email protected][email protected]</A>

    [This message has been edited by Clay Clear (edited February 04, 2003).]

    #2
    Disregard! I just found out that I have to use VARPTR(SEG) on the
    strings, *not* STRPTR(SEG).

    Thanks anyway to anybody who might have replied.


    ------------------
    mailto:[email protected][email protected]</A>

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎