17 Kasım 2016 Perşembe

Bir string içerisinde yer alan başka bir alt stringi arayıp bulan ve değiştiren assembly Kodu/ search substring in main string assembly code


Merhabalar Arkadaşlar.

Assembly dilinde bir string içerisinde yer alan başka bir alt stringi arayan ve bulduğunda da verilen string ile değiştiren assembly kodunu paylaşıyorum




        call procTextFindLength ;Store it in DH
        call procTextReplLength ;Store it in DL
       
        mov si, offset textWhole       
again:  mov di, offset textFind
        mov bx, si              ;Address storing for possible match      
        mov cl, dh
        repe
        cmpsb      
        jnz asdf
        call procReplace                      
asdf:   cmp [si], '$'
        je finish
        jmp again
finish: hlt

proc procReplace
        mov di, bx
        mov si, offset textRepl       
        cmp dh, dl
        ja tFBig
        jb tRBig
eqllng: mov cl, dl              ;or mov cl, dh
        repe
        movsb                   ;move 1 byte from si to di; si++, di++ since DF=0
        mov si, di      
        ret

tFBig:  nop                     ;TODO
tRBig:  nop                     ;TODO
        ret      
       
proc procTextFindLength
        mov si, offset textFind
agnPF:  lodsb
        cmp al,'$'
        je endPF
        inc dh
        jmp agnPF   
endPF:  ret

proc procTextReplLength
        mov si, offset textRepl
agnPR:  lodsb
        cmp al,'$'
        je endPR
        inc dl
        jmp agnPR   
endPR:  ret

textFind  db 'de$'
textRepl  db '  $'
textWhole db 'bu-bir-deneme-metnidir-deneme-de-bir-metindir$'

Hiç yorum yok:

Yorum Gönder

DataTable To List Object - C#

Merhaba Arkadaşlar , Daha önce kullandığım kısa bir kod parçasını sizinlede paylaşmak istedim.  Elimizde bulunan bir Datatable ı nasıl ...

Popüler Yayınlar