table of Contents
- 1, a character string input from the keyboard (not longer than 30), counting the number of digital strings Africa, and the statistical results displayed on the screen, implemented EXE format.
- 2, count the number of 16-bit binary number a 1, and the results are displayed in hexadecimal on the screen, with the COM format achieved.
- 3, the keyboard input from a two decimal numbers, and seeking thereof, and outputs the result in decimal form.
- 4, the keyboard input from a decimal digit, the number corresponding to the number displayed on the screen.
- 5, find all odd and less than 100, the variable X stored in the word.
- 6, the BX number in binary form is displayed on the screen.
- 7, stored in a byte array X 0 ~ F 16 hexadecimal numbers, these numbers set displayed on the screen in hexadecimal form.
- 8, selected from the byte array contains an array of unsigned 10 in a minimum number stored in the variable MIN, and the number displayed in decimal form.
- 9, the start address is stored is provided in the storage space of a string STRING (a string which has been stored in memory without having to enter, and the string length is not more than 99), the number of characters in the string count of "A", and the results are displayed on the screen.
- 10, comparing the two strings of equal length, if the same, then the output Match !, If different, the output No Match!
1, a character string input from the keyboard (not longer than 30), counting the number of digital strings Africa, and the statistical results displayed on the screen, implemented EXE format.
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
2, count the number of 16-bit binary number a 1, and the results are displayed in hexadecimal on the screen, with the COM format achieved.
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
3, the keyboard input from a two decimal numbers, and seeking thereof, and outputs the result in decimal form.
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
4, the keyboard input from a decimal digit, the number corresponding to the number displayed on the screen.
For example, input 3, the screen will display "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
5, find all odd and less than 100, the variable X stored in the word.
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
6, the BX number in binary form is displayed on the screen.
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
7, stored in a byte array X 0 ~ F 16 hexadecimal numbers, these numbers set displayed on the screen in hexadecimal form.
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
8, selected from the byte array contains an array of unsigned 10 in a minimum number stored in the variable MIN, and the number displayed in decimal form.
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
9, the start address is stored is provided in the storage space of a string STRING (a string which has been stored in memory without having to enter, and the string length is not more than 99), the number of characters in the string count of "A", and the results are displayed on the screen.
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
10, comparing the two strings of equal length, if the same, then the output Match !, If different, the output No Match!
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