The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => Topic started by: hutch-- on November 14, 2005, 11:42:36 PM

Title: Fixed version of "szappend"
Post by: hutch-- on November 14, 2005, 11:42:36 PM
I found a fault in the current library module szappend, here is its replacement. This version will be in the next masm32 image.


; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .486                      ; force 32 bit code
    .model flat, stdcall      ; memory model & calling convention
    option casemap :none      ; case sensitive

    .code

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

align 4

szappend proc string:DWORD,buffer:DWORD,location:DWORD

  ; ------------------------------------------------------
  ; string      the main buffer to append extra data to.
  ; buffer      the byte data to append to the main buffer
  ; location    current location pointer
  ; ------------------------------------------------------

    push esi

    mov eax, -1
    mov esi, string
    mov ecx, buffer
    add esi, location       ; add offset pointer to source address

  @@:
    add eax, 1
    mov dl, [ecx+eax]
    mov [esi+eax], dl
    test dl, dl
    jnz @B                  ; exit on written terminator

    add eax, location       ; return updated offset pointer

    pop esi

    ret

szappend endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end