Announcement

Collapse
No announcement yet.

String constants in inline assembler

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

  • String constants in inline assembler

    As I remember Assembler, to reserve string constants are used
    DB 'string' statements.
    But reaction of compiler for ! DB 'string' is syntax error.
    I understand that it possible to write each byte through comma.
    But could be exist another way ?

    PS. Maybe I lost something, but information in PB.HLP is not enough.

  • #2
    Semen,

    You can easily use either basic dynamic strings by using StrPtr() or
    ASCIIZ strings using VarPtr(). What you need for an asm string processing
    routine is the ADDRESS of the string and usually its length.

    Code:
      MyString$ = "This is a test"
      lpStr&    = StrPtr(MyString$)
      ln&       = len(MyString$)
      
          ! mov ecx, ln&
          ! mov esi, lpStr&
      
        StStr:
          ! lodsb
          ' do something with the byte in AL
          ! dec ecx
          ! cmp ecx, 0    ; exit when zero
          ! jne StStr
    Once you have the address and the length, the rest is reasonably straight
    forward.

    Regards,

    [email protected]

    [This message has been edited by Steve Hutchesson (edited April 10, 2000).]
    hutch at movsd dot com
    The MASM Forum

    www.masm32.com

    Comment


    • #3
      Steve --
      I am not about processing.
      I want to include string array directy into code, using DB statements, like it possible to do in ordinary Assembler.
      But it's not comfortable to write ! DB 96, 97, 98, 99 instead of ! DB 'abcd'.
      But compiler doesn't accept ! DB 'abcd' (syntax error).

      ------------------

      Comment

      Working...
      X