1、 LOOP SSS MOV CX,0XXX: MOV DX,0 MOV BX,10 DIV BX INC CX PUSH DX CMP AX,0 JA XXX MOV AH,02HSSSS: POP DX ADD DL,30H INT 21H LOOP SSSSMOV AH,4CHCODE ENDSEND START2 p进制bx(入口)转换MOV CX,0POP AX MOV BX,7 ;进制的入口参数 ADD AL,37H JMP XXXX QQQ: ADD AL,30HXXXX: MOV DL,AL3 x的n次方DATA SEGMENTX DB 80H DUP(0)Y DB 80H DU
2、P(0)DATA ENDSSTACK SEGMENTDW 20H DUP(0)CODE,DS:DATA,SS:STACK MOV AX,DATA ;该程序实现了首位是0则吧输出的功能 MOV DS,AX ;局限是两个数必须是个位数 MOV AH,01H ;并且输入时两个数之间没有空格检测 MOV X,AH SUB AL,30H MOV Y,AL MOV AH,01H MOV BL,AL MOV AL,Y MOV CL,Y MUL CL INC X CMP BL,X JNE XXX PUSH AX MOV DL,0DH MOV DL,0AH POP AXXX: JA XX MOV AH,4CH
3、CODE ENDS END START4 y与x的选择输出MOV AH,0MOV BL,ALCMP AL,3JE S1CMP AL,4JE S2CMP AL,5JE S3CMP AL,6JE S4JNA S5CMP AL,7JNB S5S1:MUL BLADD AL,BLJMP SSSS2:SUB AL,BLS3:S4:MUL BXMOV CL,2DIV CLS5:MOV DL,0DH MOV DL,65H MOV DL,72H MOV DL,6FH JMP XX MOV CL,16 DIV CL POP AX ;也可以mov dl,ah 效果一样 MOV CL,8 SHR AX,CL CMP
4、 AL,9 JNA QQQ MOV AH,4CH END START 5 跟踪数据段MOV AX,DATA MOV DS,AX MOV SI,OFFSET XWW: CMP AL,3DH JE ZZ CMP AL,3AH JB YY SUB AL,37H MOV SI,AL INC SI JMP WWYY:ZZ: DEC SI ;这是要注意的 MOV AH,SI DEC SI6九九乘法表DW 30H DUP(0)CODE SEGMENT ASSUME CS:CODE MOV CX,101H QQ: INC CL MOV DL,20H ;输出空格 MOV AH,02H INT 21H MOV D
5、L,CH MOV DL,2AH MOV DL,CL MOV DL,3DH MOV AL,CH MOV BL,CL MOV AH,0 MUL BL MOV BL,0AH DIV BL ADD DL,30H CMP DL,30H JE KKK JMP RR KKK:乘之后结果首位是0RR: POP AX MOV DL,AH CMP CH,CL JA QQ MOV AH,02H ;回车换行 CMP CH,9 JE EE INC CH MOV CL,1 JMP WW EE:7 逆向输出DW 80H DUP(0) MOV AX,DATA MOV BX,OFFSET X CMP AL,0DH JE QQQ
6、 MOV BX,AL JMP XXX DEC BX MOV DL,BX MOV CX,BX INC CX CMP CX,OFFSET X JNE QQ MOV AX,4C00H8 去掉空格并反向输出DATA CMP BX,20H JE QQ9四位二进制数转换为压缩的bcd码 MOV CX,4 JB XXX JMP QQ SUB AL,30H LOOP XX MOV AL,BX MOV DH,8 XOR AH,AH DIV DH PUSH AX MOV AL,AH MOV DH,4 MOV DH,2 ADD AH,30H MOV DL,AH LOOP QQQ10 星星输出STACK1 INC A
7、L MOV BL,AL MOV BH,AL MOV CX,AX MOV DH,1 DEC CL MOV X,CL 定义两个段xx和qq是两种运算,不过在第一层循环里 MOV CL,X JMP BBAA:BB: INC CL CMP BL,CL JE SSSS MOV DL,20H JMP AA INC BL INC DH DEC X CMP BH,DH JNE XX 11 字符串的比较X DB 50H DUP(0)Y DB 50H DUP(0)Z DB CHAR1CHAR2A DB CHAR1B DB CHAR1=CHAR2 INC CH MOV SI,OFFSET Y JE WWWWWW:
8、JA AA JB BB MOV DL,CH CMP DL,0 ;两个数的长度要是一样,则每一项进行比较,从高位首项开始 JE CC DEC DL MOV CH,BX MOV CL,SI JMP SSS LEA DI,ZA1: CMP DH,11 MOV DL,DI MOV AH,2 INC DI JMP A1 LEA DI,AB1: JMP B1CC: LEA DI,B C1: JMP C1 ;12两个循环实现向量相乘 VA DB 1,3,5,7,9 VB DB 2,4,6,8,10 COUNT EQU $-VB RESULT DB COUNT*COUNT DUP(0) DATA ENDSST
9、ACK SEGMENT PARA STACK DW 40H DUP(0) STACK ENDS START: LEA SI,VA LEA DI,VB LEA BP,RESULT PUSH BP MOV CX,COUNT LOP1: PUSH CX PUSH DI MOV AL,SI LOP2: MUL BYTE PTR DI MOV BP,AX ADD BP,1 LOOP LOP2 POP DI POP CX LOOP LOP1 MOV CX,25 POP BP LOP3: MOV AX,BP MOV BL,0AH KKK: RR: LOOP LOP3 ;13求阶乘 DATA SEGMENT
10、RES DW ? STACK1 SEGMENT PARA STACK DW 20H DUP(0) ;8的阶乘就不行了,寄存器的位数有限 STACK1 ENDS CODE SEGMENT CALL STDIN 回车换行 MOV BX,1 CALL FACT MOV RES,BX MOV AX,BX ;想让它输出 MOV CX,0 XXX: JA XXX SSS: LOOP SSS STDIN PROC MOV AH,1 CMP AL,30H JL STDIN CMP AL,37H JG STDIN AND AL,0FH RET STDIN ENDP FACT PROC JG NEXT1 NEXT1:CMP AX,1 JG NEXT2 NEXT2: MUL BX MOV BX,AX DEC AX CMP AL,1 JA NEXT2 FACT ENDP14 十进制多字节加法器X DB 20H DUP(0)Y DB 20H DUP(0)Z DB 20H DUP(0) MOV BP,OFFSET X MOV DI,OFFSET Z CMP AL,2BH ;是加号就跳 JE WW MOV BP,AL INC BP CMP AL,3DH ;是等于号就跳 JE AA SUB A
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1