标签:stack 字符串长度 包含 10个 art result sem 限制 str1
目录
data segment
str db 30,?,30 dup(?);30是限制个数,?存储实际个数
count db 0
data ends
code segment
assume cs:code,ds:data
main proc far
start:
push ds
mov ax,0
push ax
mov ax,data
mov ds,ax
lea dx,str
mov ah,0ah
int 21h
mov cl,str+1
mov ch,0
mov si,2
L3:
cmp str[si],30h
jae L1
inc count
jmp L2
L1:
cmp str[si],39h
jbe L2
inc count
L2:
inc si
loop L3
mov ah,02h
mov dl,0dh
int 21H
mov ah,02h
mov dl,0ah
int 21H
lea bx,count
mov ax,[bx]
或
mov al,count
mov ah,00h
mov bl,10
div bl;余数在ah,商在al
mov dx,ax
add dx,3030h;转化成十\个位对应的ASCII码
mov ah,2
int 21h
mov dl,dh
mov ah,2
int 21h
mov ah,4ch
int 21h
code ends
end start
code segment
org 100h
assume cs:code
main proc near
start:
mov bx,0a39h
mov si,0
mov cx,16
next:
shr bx,1
jnc l1
inc si
l1:
loop next
mov dx,si
add dx,30h
cmp dl,3ah ;看1是否超过十个
jb l2
add dl,7
l2:
mov ah,02h
int 21h
mov ax,4c00h
int 21h
main endp
code ends
end start
code segment
assume cs:code
start:
mov ah,01
int 21h
mov bl,al;存储在al中
mov ah,01
int 21h
mov bh,al
sub bx,3030h
add bl,bh
mov al,bl
mov ah,00h
mov bl,10
div bl
add ax,3030h
push ax;保护ax中数据
mov dl,al
mov ah,2
int 21h
pop ax
mov dl,ah
mov ah,2
int 21h
mov ah,4ch
int 21h
code ends
end start
例如,输入3,屏幕上将显示“333”。
code segment
assume cs:code
start:
mov ah,01h
int 21h
mov bl,al
sub al,30h
mov cl,al
mov ch,00h
mov ah,02h
mov dl,0dh
int 21h
mov ah,02h
mov dl,0ah
int 21h
L1:
mov dl,bl
mov ah,02h
int 21h
loop L1
mov ah,4ch
int 21h
code ends
end start
data segment
x dw ?
data ends
code segment
assume cs:code,ds:data
main proc far
start:
mov ax,data
mov ds,ax
mov ax,0
mov bx,1
mov cx,50
L1: add ax,bx
add bx,2
loop L1
mov x,ax
mov ah,04h
int 21h
main endp
code ends
end start
code segment
assume cs:code
start:
mov bx,1234h
mov cx,16
l1:
mov dl,30h
shl bx,1
jnc l2
inc dl
l2:
mov ah,02h
int 21h
loop l1
mov ah,4ch
int 21h
code ends
end start
data segment
x db 0,1,2,3,4,5,6,7,8,9,0ah,0bh,0ch,0dh,0eh,0fh
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov cx,16
mov si,0
l1:
mov dl,x[si]
add dl,30h
cmp dl,39h
jbe l2
add dl,7
l2:
mov ah,02h
int 21h
inc si
loop l1
mov ah,4ch
int 21h
code ends
end start
data segment
array db 33,57,65,62,90,69,85,56,53,39
min db ?
data ends
stack segment
dw 10 dup(?)
stack ends
code segment
assume cs:code,ds:data,ss:stack
start:
mov ax,data
mov ds,ax
mov al,255
mov cx,10
mov si,0
mov di,0
l1:
cmp al,array[si]
jbe l2
mov al,array[si]
l2:
inc si
loop l1
mov min,al
mov ah,0
l3:
mov bl,10
div bl
mov dl,ah
push dx
inc di
mov ah,0
cmp ax,0
jz l4
loop l3
l4:
mov cx,di
l5:
pop dx
add dl,30h
mov ah,02h
int 21h
loop l5
mov ah,4ch
int 21h
code ends
end start
data segment
string db 'aaaaaaaaaasbbbbbcccy'
len dw $-string
result db 0
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov di,0
mov cx,len
lea si,string
l1:
lodsb
cmp al,'a'
jnz l2
inc result;直接加即可
l2:
loop l1
mov al,result;直接将result传递给al
mov ah,00h
l3:
mov bl,10
div bl
mov dl,ah
push dx
inc di
mov ah,0
cmp ax,0
jz l4
loop l3
l4:
mov cx,di
l5:
pop dx
add dl,30h
mov ah,02h
int 21h
loop l5
mov ah,4ch
int 21h
code ends
end start
data segment
str1 db 'computer'
len1 dw $-str1
str2 db 'computer'
mess1 db 'MATCH$'
mess2 db 'NO MATCH$'
data ends
code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax
mov es,ax
lea si,str1
lea di,str2
cld
mov cx,len1
repe cmpsb
jz l1
lea dx,mess2
jmp l2
l1:
lea dx,mess1
l2:
mov ah,09h
int 21h
mov ah,4ch
int 21h
code ends
end start
标签:stack 字符串长度 包含 10个 art result sem 限制 str1
原文地址:https://www.cnblogs.com/lihello/p/11520790.html