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!
- pkey db "press any key...$"
- vnesiString db "vnesi string:$"
- string1 db ?
- string2 db ?
- string1Size db 0
- string2Size db 0
- stringSize db 0
- nextInstruction dw 0
- ends
- stack segment
- dw 128 dup(0)
- ends
- code segment
- transform proc
- pop dx ; next instruction is popped
- mov nextInstruction, dx
- pop ax ; size of the string
- mov stringSize, al
- pop bx ; effective address of the string
- mov ch, 0d
- mov cl, stringSize
- dec cx ; not to read the last '$'
- tr:
- cmp [bx], 65d
- jle smallLetter
- cmp [bx], 90
- jge smallLetter
- add [bx], 32d
- smallLetter:
- inc bx
- loop tr
- mov dx, nextInstruction
- push dx
- ret
- transform endp
- ;;;;
- ;;;;
- ;;;;
- enterString proc
- pop dx ; this is next instruction
- mov nextInstruction, dx
- mov ax, nextInstruction
- pop bx ; this is effective address of the string
- mov cx, 50d
- inputS:
- mov ah, 1h
- int 21h
- cmp al, 36d
- je stringEntered
- mov ah, 0d
- mov [bx], ax
- inc bx
- inc stringSize
- loop inputS
- stringEntered:
- mov ah, 0d
- mov [bx], al
- mov ax, dx
- mov dx, nextInstruction
- push dx ;return next instruction
- ret
- enterString endp
- start:
- ; set segment registers:
- mov ax, data
- mov ds, ax
- mov es, ax
- ; add your code here
- lea dx, vnesiString
- mov ah, 9
- int 21h
- mov bx, OFFSET string1
- push bx
- call enterString
- mov al, stringSize
- mov string1Size, al
- mov stringSize, 0d
- lea dx, vnesiString
- mov ah, 9
- int 21h
- mov bx, OFFSET string2
- push bx
- call enterString
- mov al, stringSize
- mov string2Size, al
- mov stringSize, 0d
- ; here we have entered 2 strings
- mov al, string1Size
- mov dl, string2Size
- mov bx, OFFSET string1
- mov ah, 0d
- mov al, string1Size
- push bx
- push ax
- call transform
- ; test
- mov dl, 10d
- mov ah, 2h
- int 21h
- lea dx, string1
- mov ah, 9
- 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