6、题
参考程序:
6、编写程序,从键盘上键入0—9中任一自然数N,将其立方值送显示器显示出来。 DATA SEGMENT
INPUT DB ‘please input N(0~9):$’
LFB DB ‘ 0$, 1$, 8$, 7$, 64$,125$,216$,343$,512$,729$’ N DB ? DATA ENDS Stack segment
DB 100dw(?) Stack ends Code segment
Assume cs:code,ds:data,ss:stack Main proc far Start: push ds Sub ax,ax Push ax
MOV AX,DATA MOV DS,AX
MOV AH,09H MOV DX,OFFSET INPUT INT 21H
MOV AH,01H INT 21H
MOV N,AL MOV AH,02H MOV DL,0AH INT 21H
MOV DL,N AND DL,0FH MOV CL,2 SHL DL,CL MOV DH,00H LEA BX,LFB ADD DX,BX MOV AH,09H
MOV AX,SEG LFB MOV DS,AX INT 21H RET
MIAN ENDP CODE ENDS
END STRAT 7.题
参考程序:
9
DATA SEGMENT
X DW 1234H Y DW 2345H Z DW 3456H U DW ? DATA ENDS
STACK SEGMENT STACK DB 100DUP(?) STACK ENDS CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK START:MOV AX,DATA MOV DS,AX MOV AX,X CMP AX,0 JNZ LOP1 JMP ZERO1 LOP1: MOV AX,Y CMP AX,0 JNZ LOP2 JMP ZERO2 LOP2: MOV AX,Z CMP AX,0 JNZ LOP3
JMP ZERO3 LOP3: MOV AX,X ADD AX,Y ADC,AX,Z MOV U,AX JMP EXEIT ZERO1: MOV Y,0 MOV Z,0
JMP EXEIT ZERO2: MOV X,0 MOV Z,0
JMP EXEIT ZERO3: MOV X,0 MOV Z,0
EXEIT: MOV AH,04CH INT 21H CODE ENDS
END START
8、题 参考程序:
DATA SEGMENT
INPUT DB ‘please input (0~7):$’ DATA ENDS
STACK SEGMENT STACK DB 100DUP(?) STACK ENDS
10
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK START: MOV AX,DATA MOV DS,AX MOV AH,09H
MOV DX,OFFSET INPUT INT 21H MOV AH,01H INT 21H
CMP AL,‘0’ JE P0
CMP AL,‘1’ JE P1
CMP AL,‘2’ JE P2
CMP AL,‘3’ JE P3
CMP AL,‘4’ JE P4
CMP AL,‘5’ JE P5
CMP AL,‘6’ JE P6
CMP AL,‘7’ JE P7
MOV AH,04CH INT 21H
P0: ????????. ???????? ????????. JMP AGAIN
P1: ????????.
???????? ????????. JMP AGAIN
.
. .
P7: ????????. ???????? ????????. JMP AGAIN CODE ENDS
END START
9、题
参考程序:
DATA SEGMENT
BLOCK DB D1,D2,D3,????????.,D100
11
COUNT EQU $-BLOCK DATA ENDS
STACK SEGMENT STACK DB 100DUP(?) STACK ENDS CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK START: MOV AX,DATA MOV DS,AX
MOV BX,OFFSET BLOCK MOV CX,COUNT MOV DL,00H LOP: MOV AX,[BX] CMP AX,100 JG ADD1 INC BX DEC CX JZ EXEIT JMP LOP ADD1: INC DL INC BX DEC CX JZ EXEIT JMP LOP EXEIT: MOV AH,04CH INT 21H CODE ENDS
END START 10、题
参考程序:
DATA SEGMENT BUF
D1,D2,D3,????????.,Dn COUNT EQU $-BUF DATA ENDS
STACK SEGMENT STACK DB 100DUP(?) STACK ENDS CODE SEGMENT ASSUME
CS:CODE,DS:DATA,SS:STACK START: PUSH DS SUB AX,AX PUSH AX MOV AX,DATA MOV DS,AX LEA SI,BUF MOV DX,COUNT-1 UOTSID: MOV CX,DX
PUSH SI DB
MOV AL,[SI] INSIDE: INC SI
CMP AL,[SI] JNC NEXCHG XCHG [SI],AL NEXTCHG: LOOP INSIDE POP SI DEC DX
JNZ OUTSID
RET
CODE ENDS END START
12