DSEG SEGMENT
STRING1 DB ?I AM A STUDENT.? STRING2 DB ?I AM A STUDENT!?
YES DB ?MATCH?,0DH,0AH,?$? NO DB ?NO MATCH?,0DH,0AH,?$?
DSEG ENDS
CSEG SEGMENT MAIN PROC FAR
ASSUME CS:CSEG, DS:DSEG,ES:DSEG
START: PUSH DS SUB AX, AX
PUSH AX
MOV AX, DSEG MOV ES, AX MOV DS, AX
BEGIN: LEA SI, STRI NG1 LEA DI, STRING2
MOV EX, STRING2-STRING1 REPE COMPSB JNE DISPNO MOV AH,09 LEA DX,YES INT 21H DISPNO: MOV AH,09 LEA DX,NO INT 21 MAIN ENDP CSEG ENDS
END START
11、编写程序,计算S=(a+b)—2*(a AND b)
DATA SEGMENT
a DW x b DW y S DW ? DATA ENDS
STACK SEGMENT PARA STACK DW 20H DUP(0) STACK ENDS
17
COSEG SEGMENT
PROC1 PROC FAR
ASSUME CS:COSEG,DS:DATA,SS:STACK START: PUSH DS MOV AX,0 PUSH AX
MOV AX,DATA
MOV DS,AX MOV DX,a MOV BX,a
AND BX,b SHL BX,1 SUB DX,BX MOV S,DX
RET
PROC1 ENDP COSEG ENDS
END START
12、编制一个能循环显示十条新闻标题的控制程序,每条新闻的地址转换表NEWS放在数据区中。
DSEG SEGMENT
NEW1 DB ?NEW1?,0DH,0AH,?$? NEW2 DB ?NEW2?,0DH,0AH,?$? NEW3 DB ?NEW2?,0DH,0AH,?$? . . .
NEW10 DB ?NEW2?,0DH,0AH,?$?
NEWS DW NEW1,NEW2,…NEW10 DSEG ENDS CSEG SEGMENT MAIN PROC FAR
ASSUME CS:CSEG,DS:DSEG START: PUSH DS
SUB AX,AX PUSH AX
MOV AX,DSEG MOV DS,AX
18
BEGIN: MOV CX,10
LEA BX,NEWS DISP: MOV DX,[BX]
ADD BX,2 MOV AH,09 INT 21H LOOP DISP JMP BEGIN
MAIN ENDP CSEG ENDS
END START
13、把0~100(十进制)之间的30个数,存入以GRAD为首地址的30字数组中,GRADE+i表示学号为i+1的学生成绩。另一个数组RANK为30个学生的名次表,其中RANK+i 的内容是学号为i+1的学生的名次。编写程序,根据GRAD中的学生成绩,将排列的名次填入RANK数组中。
DSEG SEGMENT
GRADE DW 30 DUP(?) RANK DW 30 DUP(0)
DSEG ENDS
CSEG SEGMENT
MAIN PROC FAR
ASSUME CS:CSEG,DS:DSEG
START: PUSH DS
SUB AX,AX PUSH AX
MOV AX,DSEG MOV DS,AX
BEGIN: MOV DI,0
MOV CX,30
LOOP1: PUSH CX
MOV CX,30 MOV SI,0
MOV AX,GRADE[DI] MOV DX,0
LOOP2: CMP GRAD[SI],AX
JBE GOON INC DX
GOON : ADD SI,2
LOOP LOOP2
19
POP CX INC DX
MOV RANK[DI],DX ADD DI,2
LOOP LOOP1 RET
MAIN ENDP CSEG ENDS
END START
14、编制一程序,寻找一数组中第一个零。把第一零在数组中的相对偏移量送INDEX单元中,若无零数,则送全‘0’到INDEX单元中。
DSEG SEGMENT
ADDR DW 30 DUP(?) INDEX DW ?
DSEG ENDS
CSEG SEGMENT
MAIN PROC FAR
ASSUME CS:CSEG,DS:DSEG
START: PUSH DS
SUB AX,AX PUSH AX
MOV AX,DSEG MOV DS,AX
BEGIN: MOV DI,0
MOV CX,30
LOP: MOV AX,ADDR[DI]
CMP GRAD[DI],0 JNE GOON
MOV INDEX,DI
GOON : ADD DI,2
LOOP LOP RET
MAIN ENDP CSEG ENDS
END START
15、十进制100字数组的首地址为MEM,要求编写程序删除数组中所有为零的项,并将后续项向前压缩,最后将数组中的剩余部分补上零。
20