flat assembler
Message board for the users of flat assembler.
Index
> Main > Putting 2 strings together |
Author |
|
flaith 26 Jun 2005, 07:23
you can also use windows api "lstrcat" in kernel32 !
_________________ Je suis sur de 'rien', mais je ne suis pas sur du 'tout'. |
|||
26 Jun 2005, 07:23 |
|
Vasilev Vjacheslav 26 Jun 2005, 13:28
Code: szFormat db "%s%s",0 szText1 db "line1",0 szText2 db "line2",0 ... szBuffer rb 1024 ... cinvoke wsprintf,szBuffer,szFormat,szText1,szText2 as said flaith it is better to use lstrcat |
|||
26 Jun 2005, 13:28 |
|
shaolin007 26 Jun 2005, 13:37
Another way is to use c function strcat(). Just import it like the strcmp() in previous post.
Code: cinvoke strcmp, string 1, string 2 String2 is added to string1. |
|||
26 Jun 2005, 13:37 |
|
Matrix 26 Jun 2005, 15:14
Hy, i just wrote these, they work...
Code: macro bdisplay .__stringvar002 { mov si,.__stringvar002 mov bl,10 call bwritestring } org 100h push es push ds pop es ;testing strcat0b bdisplay _strcat0b bdisplay _string1 bdisplay _plusstring bdisplay _string2 bdisplay _equalstring mov di,_string1 mov si,_string2 call strcat0b bdisplay si call bendline ;testing stradd0b bdisplay _stradd0b bdisplay _string1 bdisplay _plusstring bdisplay _string2 bdisplay _equalstring mov di,_string1 mov si,_string2 call stradd0b bdisplay si call bendline ;testing strcat0b now with modified string1 bdisplay _strcat0b bdisplay _string1 bdisplay _plusstring bdisplay _string2 bdisplay _equalstring mov di,_string1 mov si,_string2 call strcat0b bdisplay si call bendline xor ax,ax ; waitkey int 16h pop es int 20h _string1: db 'Flat',0 times 128 db 0 ; we resetve bytes for proc stradd _string2: db 'assembler',0 _plusstring: db ' + ',0 _equalstring: db ' = ',0 _strcat0b: db ' strcat0b: ',13,10,0 _stradd0b: db ' stradd0b: ',13,10,0 bwritestring: ; Writes a 0 terminated string to screen ( string is at ds:si ) push ax bx mov bx,7 ; use video page 0, normal white mov ah,$e localloop: lodsb or al,al jnz next_char pop bx ax ret next_char: int 10h jmp localloop bendline: ; ends the line ( adds y loc = 1 x loc = 0 ) push ax bx ; returns: AX = 0xE0A ; BX = 7 mov bx,7 mov ax,$E0D int 10h mov al,$A int 10h pop bx ax ret ;------------------------------------------------------------ strcat0b: ; append string, 0 terminated: input: es:di = string1, ds:si=string2, output: ds:si=string1+string2+#0 xor ebx,ebx mov bx,.tmpstr .copy01: mov al,[es:di] or al,al jz .copy02 mov [ebx],al inc di inc ebx jmp .copy01 .copy02: lodsb mov [ebx],al inc ebx or al,al jz .done2 jmp .copy02 .done2: mov si,.tmpstr ret .tmpstr: times 256 db 0 stradd0b: ; append string2 onto string1 end, 0 terminated: input: es:di = string1, ds:si=string2, output: string1 with string2 apended at ds:si ; (reserve bytes at the end of string1!) mov bx,di .getend01: mov al,[es:di] or al,al jz .copy02 inc di jmp .getend01 .copy02: lodsb stosb or al,al jz .done2 jmp .copy02 .done2: mov si,bx ret |
|||
26 Jun 2005, 15:14 |
|
Christopher D 26 Jun 2005, 17:34
Thanks
|
|||
26 Jun 2005, 17:34 |
|
Kain 26 Jun 2005, 17:56
Here is another approach.
Code: format PE CONSOLE include 'win32ax.inc' .data src db 'a man from Kent',0 srclen dd $-src dest db 'There once was ',0 buffer rb 30 destlen dd buffer-dest-1 ;extra -1 to skip destination zero terminated byte strm db 'Message',0 .code start: mov esi, src ; source address in esi mov ecx, [srclen] ; length of source in ecx inc ecx ; include the 0 termination byte mov edi, dest ; destination in edi add edi, [destlen] ; start at end of destination rep movsb push 0 push strm push dest push 0 call [MessageBox] push 0 call [ExitProcess] .end start If you do use something like this, make sure the destination buffer can hold all the bytes. |
|||
26 Jun 2005, 17:56 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.