Академический Документы
Профессиональный Документы
Культура Документы
substring
.model small
.data
buff1 db 20 dup("$")
buff2 db 20 dup("$")
len1 dw 0
len2 dw 0
.code
mov ds, ax
mov es, ax
mov ax, 0
mov cx, 0
call disp
call read
mov len1, cx
call disp
call read
mov len2, cx
inc bx
push si
repz cmpsb
jz found
pop si
inc si
dec bx
jnz next
call disp
jmp ed
call disp
int 21h
read proc
mov cx, 0
int 21h
je done
mov [si], al
inc si
inc cx
jmp nxt
done: ret
read endp
disp proc
int 21h
ret
disp endp
end
;2. password
.model small
.data
buff1 db "password$"
buff2 db 20 dup("$")
len1 dw 08h
len dw 0
.code
mov ds, ax
mov es, ax
mov ax, 0
call disp
call read
mov len, cx
jnz l1
repz cmpsb
jnz l1
call disp
jmp ed
call disp
jmp again
int 21h
read proc
mov cx, 0
int 21h
jz done
mov [si], al
inc si
inc cx
jmp next
done: ret
read endp
disp proc
int 21h
ret
disp endp
end
;3.Two string
.model small
.data
buff2 db 20 dup("$")
len1 dw 0
len2 dw 0
.code
mov ds, ax
mov es, ax
mov ax, 0
call disp
call read
mov len1, cx
call disp
call read
mov len2, cx
call disp
call displen
call disp
mov cx, 0
jnz l1
repz cmpsb
jnz l1
call disp
jmp ed
call disp
int 21h
displen proc
aam
push ax
mov dl, ah
int 21h
pop ax
mov dl, al
int 21h
ret
displen endp
read proc
mov cx, 0
int 21h
jz done
mov [si], al
inc si
inc cx
jmp next
done: ret
read endp
disp proc
int 21h
ret
disp endp
end
;5. systime
.model small
.code
call clear
call setcur
int 21h
call convert
mov dl, ":"
call dispch
call convert
call dispch
call convert
int 21h
clear proc
mov cx, 0
int 10h
ret
clear endp
setcur proc
mov bh, 00
mov dl, 30
mov dh, 12
int 10h
ret
setcur endp
convert proc
push cx
push dx
aam
push ax
mov dl, ah
int 21h
pop ax
mov dl, al
int 21h
pop dx
pop cx
ret
convert endp
dispch proc
int 21h
ret
dispch endp
end
;6. sysdate
.model small
.data
year dw 00
month db 0
day db 0
dweek db 0
msg1 db "MON$"
msg2 db "TUE$"
msg3 db "WED$"
msg4 db "THUR$"
msg5 db "FRI$"
msg6 db "SAT$"
msg7 db "SUN$"
.code
mov ds, ax
int 21h
mov year, cx
mov month, dh
mov day, dl
mov dweek, al
call convert
call pslash
call convert
call pslash
push ax
call convert
pop ax
mov al, ah
call convert
call disp
mov al, dweek
cmp al, 01
jne l1
jmp ed
jne l2
jmp ed
jne l3
jmp ed
jne l4
jmp ed
jne l5
jmp ed
jne l6
jmp ed
int 21h
convert proc
aam
push ax
mov dl, ah
int 21h
pop ax
mov dl, al
int 21h
ret
convert endp
pslash proc
int 21h
ret
pslash endp
disp proc
int 21h
ret
disp endp
end
.model small
.code
call clear
call setcur
mov ax, 00
jz l1
push ax
call dispcnt
int 21h
cmp al, 0f
jz exit
call delay
call setcur
pop ax
jmp repeat
cmp ax, 00
jz exit
push ax
call dispcnt
int 21h
cmp al, 0f
jz exit
call delay
call setcur
pop ax
jmp l1
int 21h
clear proc
mov ah, 06
mov bh, 07
mov cx, 00
int 10h
ret
clear endp
setcur proc
mov bh, 0
mov dl, 40
mov dh, 12
int 10h
ret
setcur endp
dispcnt proc
aam
push ax
mov dl, ah
int 21h
pop ax
mov dl, al
int 21h
ret
dispcnt endp
delay proc
l: dec dx
jnz l
loop l2
ret
delay endp
end
;8. name
.model small
.data
buff1 db 20 dup("$")
hex_x db 0
hex_y db 0
bcd_x dw 0
bcd_y dw 0
.code
mov ds, ax
mov es, ax
mov ax, 0
int 21h
call readstr
lea dx, msg2
call disp
call read
mov bcd_x, bx
mov hex_x, al
call disp
call read
mov bcd_y, bx
mov hex_y, al
call clear
call clear
call setcur
call disp
int 21h
clear proc
mov cx, 0
int 10h
ret
clear endp
setcur proc
mov bh, 0
int 10h
ret
setcur endp
read proc
aad ;al=[41]base16
ret
read endp
readstr proc
mov cx, 0
int 21h
jz done
mov [si], al
inc si
jmp next
done: ret
readstr endp
disp proc
mov ah, 09h
int 21h
ret
disp endp
end
;9. xy coordinates
.model small
.data
hex_x db 0
hex_y db 0
bcd_x dw 0
bcd_y dw 0
.code
mov ds, ax
mov ax, 0
call disp
call read
mov bcd_x, bx
mov hex_x, al
call disp
call read
mov bcd_y, bx
mov hex_y, al
call clear
call clear
call setcur
call dispxy
int 21h
call dispxy
int 21h
dispxy proc
push ax
mov dl, ah
int 21h
pop ax
mov dl, al
int 21h
ret
dispxy endp
clear proc
mov cx, 0
int 10h
ret
clear endp
setcur proc
mov bh, 0
int 10h
ret
setcur endp
read proc
aad ;al=[41]base16
ret
read endp
disp proc
int 21h
ret
disp endp
end
;10. modular
displ macro m
lea dx, m
int 21h
endm
.model small
.data
buff1 db 20 dup("$")
.code
include C:\Tasm\f1.mac
include C:\Tasm\f2.mac
mov ds, ax
displ msg1
mov cx, 0
next: read_ch
je done
mov [si], al
inc si
inc cx
jmp next
inc si
loop l1
int 21h
end