1、编写程序计算Z=(X*X-3*Y)/2
DATA SEGMENT
X DB 25
Y DB 32
Z DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AL,X
MUL AL
MOV BX,0
MOV BL,Y
ADD BL,BL
ADC BH,0
ADD BL,Y
ADC BH,0
SUB AX,BX
SHR AX,1
MOV Z,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
2、编写程序完成多字节相加
DATA SEGMENT
DAT1 DB 5EH,89H
DAT2 DB 40H,OABH
DAT3 DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV SI,0
MOV AL,DAT1[SI]
MOV AL,DAT2[SI]
MOV DAT3[SI],AL
INC SI
MOV AL,DAT1[SI]
ADC AL,DAT2[SI]
MOV DAT3[SI],AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
3、查表求平方和
DATA SEGMENT
TABL DB 0,1,4,9,16,25,36,49
DB 64,81,100,121,144,169,225
XD DB ?
YD DB ?
DATA ENDS
STACK SEGMENT STACK 'STACK'
STA DB 50 DUP (?)
TOP EQU LENGTH STA
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,TOP
MOV BX,OFFSET TABL
MOV AH,0
MOV AL,XD
ADD BX,AX
MOV AL,[BX]
MOV YD,AL
MOV AH,4CH
INT 21H
CODE ENDS
END START
4、源数据块和目的数据块是否有重叠来决定采用增址还是减址方式传送
DATA SEGMENT
STRG DB 1000 DUP(?)
BLOK1 EQU STRG+5
BLOK2 EQU STRG+10
BLENG EQU 100
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,ES:DATA
START: MOV AX,DATA
MOV DS,AX
MOV ES,AX
MOV CX,BLENG
MOV SI,OFFSET BLOK1
MOV DI,OFFSET BLOK2
CLD
PUSH SI
ADD SI,BLENG-1
CMP SI,DI
POP SI
JB GO
STD
ADD SI,BLENG-1
ADD DI,BLENG-1
GO: REP MOVSB
MOV AH,4CH
INT 21H
CODE ENDS
END START
5、找出最大数和最小数
DATA SEGMENT
BUF DB -2,+5,-128
DB +127,80,-70
COUN EQU $-BUF
MAX DB ?
MIN DB ?
DATA ENDS
STACK SEGMENT STACK
STR DB 64H DUP(?)
STACK ENDS
MYCODE SEGMENT
ASSUME DS:MYCODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,LENGTH STR
MOV CX,COUN-1
MOV SI,OFFSET BUF
MOV AL,[SI]
MOV BL,[SI]
INC SI
LOP: CMP AL,[SI]
JGE NEXT1
MOV AL,[SI]
NEXT1: CMP BL,[SI]
JL NEXT
MOV BL,[SI]
NEXT: INC SI
LOOP LOP
MOV MAX,AL
MOV MIN,BL
MOV AH,4CH
INT 21H
MYCODE ENDS
END START
6、三路分支结构程序
DATA SEGMENT
DATX DB -3
DATY DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AL,DATX
CMP AL,0
JGE BIGER
MOV AL,0FFH
MOV DATY,AL
JMP NEXT
BIGER: JE EQUL
MOV AL,1
MOV DATY,AL
JMP NEXT
EQUL: MOV DATY,AL
NEXT: MOV AH,4CH
INT 21H
CODE ENDS
END START
7、利用跳转实现多分支结构
DATA SEGMENT
ADRTAB DW R0,R1,R2,R3,R4,R5,R6,R7,R8,R9
TEN DB ?
DATA ENDS
STACK SEGMENT PARA STACK 'STACK'
STA DB 100 DUP(?)
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,LENGTH STA
MOV AH,01
INT 21H
COMPUT: MOV AH,0
AND AL,0FH
ADD AL,AL
MOV BX,OFFSET ADRTAB
ADD BX,AX
MOV AX,[BX]
JMP AX
R0:
R1:
R2:
R3:
R4:
R5:
R6:
R7:
R8:
R9:
MOV AH,4CH
INT 21H
CODE ENDS
END START
8、计算累加和
DATA SEGMENT
SUM DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AX,0
MOV CX,100
AGAIN: ADD AX,CX
DEC CX
JNZ AGAIN
MOV SUM,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
9、计算一个数中1的个数
DATA SEGMENT
X DW 31A0H
RESULT DW ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV CX,0
MOV AX,X
AGAIN: AND AX,AX
JZ EXIT
SHL AX,1
JNC NEXT
INC CX
NEXT: JMP AGAIN
EXIT: MOV RESULT,CX
MOV AH,4CH
INT 21H
CODE ENDS
END START
10、求一列数的累加和
DATA SEGMENT
BLOCK DW 0028H,0FF18H,1005H,7823H,0
DW 0CDABH,0FFFFH,1122H,3344H,7892H
COUN EQU ($-BLOCK)/2
SUM DW ?
DATA ENDS
STACK SEGMENT PARA STACK 'STACK'
STA DW 100 DUP(?)
TOP EQU SIZE STA
STACK ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START: MOV AX,DATA
MOV DS,AX
MOV AX,STACK
MOV SS,AX
MOV SP,TOP
MOV AX,0
MOV SI,OFFSET BLOCK
MOV CX,COUN
LOP: ADD AX,[SI]
ADD SI,2
LOOP LOP
MOV SUM,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
11、延时程序
TIMEDLY PROC
MOV BX,100
DELAY: MOV CX,5882
DELAYO: LOOP DELAYO
DEC BX
JNZ DELAY
RET
TIMEDLY ENDP
12、冒泡排序法
DATASEG SEGMENT
ARRAY DW 1234H,5437,7FFFH,0FFFFH,0AB55
DW 05FFH,7832H,0,9043H,5634
COUN EQU ($-ARRAY)/2
DATASEG ENDS
STACKSEG SEGMENT PARA STACK 'STACK'
STAPN DB 100 DUP(?)
TOP EQU LENGTH STAPN
STACKSEG ENDS
PROGRAM SEGMENT
ASSUME CS:PROGRAM,DS:DATASEG,SS:STACKSEG
START: MOV AX,DATASEG
MOV DS,AX
MOV AX,STACKSEG
MOV SS,AX
MOV AX,TOP
MOV SP,AX
MOV BL,0FFH
A1: CMP BL,0FFH
JNE A4
XOR BL,BL
MOV CX,COUN-1
XOR SI,SI
A2: MOV AX,ARRAY[SI]
CMP AX,ARRAY[SI+2]
JGE A3
XCHG ARRAY[SI+2],AX
MOV ARRAY[SI],AX
MOV BL,0FFH
A3: INC SI
INC SI
LOOP A2
JMP A1
A4: MOV AH,4CH
INT 21H
PROGRAM ENDS
END START