Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; multi-segment executable file template.
- data segment
- ; add your data here!
- str1 db 50 dup(?)
- str2 db 50 dup(?)
- length db 0
- transformations db 0
- porakaIsti db "Isti se $"
- porakaRazlicni db "Ne se isti $"
- inputString db "Vnesi string: $"
- ends
- stack segment
- dw 128 dup(0)
- ends
- code segment
- transform proc
- pop bx
- pop si
- mov cx, 0
- workProcess:
- cmp [si], 36d
- je submitAndExit
- cmp [si], 65d
- jge toBeSure
- jmp workProcess
- toBeSure:
- cmp [si], 90d
- jg continueWithSearch
- add [si], 32d
- inc cx
- jmp continueWithSearch
- continueWithSearch:
- inc si
- jmp workProcess
- submitAndExit:
- push cx
- push bx
- ret
- transform endp
- start:
- ; set segment registers:
- mov ax, data
- mov ds, ax
- mov es, ax
- lea di, str1
- lea dx, inputString
- mov ah, 09h
- int 21h
- readFirstString:
- mov ah, 01h
- int 21h
- stosb
- inc length
- cmp al, 36d
- je setFirstString
- jmp readFirstString
- setFirstString:
- lea si, str1
- push si
- call transform
- pop cx
- add transformations, cl
- lea di, str2
- mov dl, 13d
- mov ah, 02h
- int 21h
- mov dl, 10d
- mov ah, 02h
- int 21h
- lea dx, inputString
- mov ah, 09h
- int 21h
- readSecondString:
- mov ah, 01h
- int 21h
- stosb
- dec length
- cmp al, 36d
- je setSecondString
- jmp readSecondString
- setSecondString:
- lea si, str2
- push si
- call transform
- pop cx
- add transformations, cl
- lea si, str1
- lea di, str2
- cmp length, 0
- jne notEqual
- compare:
- cmp [si], 36d
- je equal
- mov dl, [di]
- cmp [si], dl
- jne notEqual
- inc si
- inc di
- equal:
- mov dl, 13d
- mov ah, 02h
- int 21h
- mov dl, 10d
- mov ah, 02h
- int 21h
- lea dx, porakaIsti
- mov ah, 09h
- int 21h
- jmp return
- notEqual:
- mov dl, 13d
- mov ah, 02h
- int 21h
- mov dl, 10d
- mov ah, 02h
- int 21h
- lea dx, porakaRazlicni
- mov ah, 09h
- int 21h
- return:
- mov dl, transformations
- add dl, 48d
- mov ah, 02h
- int 21h
- mov ax, 4c00h ; exit to operating system.
- int 21h
- ends
- end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement