程序代码:
SSEG SEGMENT STACK
STR DB 100 DUP(0)
SSEG ENDS
DSEG SEGMENT
S DW ? ;unsinged short s;
DSEG ENDS
CSEG SEGMENT
ASSUME SS:SSEG,DS:DSEG
ASSUME CS:CSEG
START:
MOV AX,SSEG
MOV SS,AX
MOV AX,DSEG
MOV DS,AX
MOV BX,1 ;unsigned short b = 1;
MOV AL,2 ;unsigned short a = 2;
LP: ;calculate bit2Npos
MOV AH,AL ;a |= LOBYTE(a);
MOV CL,AL ;unsigned char bit2Npos = LOBYTE(a);
INC AH
MUL AH ;a = LOBYTE(a)*(HIBYTE(a)+1);
ADD BX,AX ;b += a;
CMP BX,126
JA STOP ;if (b > 200) goto stop
MOV AL,CL
INC AL ;else a++;
JMP LP ;goto LP
STOP:
MOV S,BX ;s = b;
MOV BL,CL ;unsigned char para_b = bit2Npos;
CALL DISP ;disp(para_b);
MOV AH,4CH
INT 21H ;exit(0)
DISP PROC ;void disp(unsigned char para_b);
MOV DL,78
MOV AH,02H
INT 21H ;putchar('N');
MOV DL,61
MOV AH,02H
INT 21H ;putchar('=')
MOV CH, 2 ;unsigned char i;
L:
MOV CL, 4 ;unsigned char offset = 4;
ROL BL, CL ;#define ROL(x, s, n) ((x) >> (n)) | ((x) << ((s) - (n)))
MOV DL, BL ;unsigned char ch = para_b;
AND DL, 0FH ;ch = (LOBYTE)ROL(para_b, 8, offset);
CMP DL, 10
JB NEXT ;if (ch < 10) goto NEXT;
ADD DL, 7 ;else ch += NUMERIC; #define NUMERIC (7)
NEXT:
ADD DL, 30H ;ch += CHARACTER; #define CHARACTER (0x30)
MOV AH, 02H
INT 21H ;putchar(ch);
DEC CH
JNZ L ;while(i--);
RET ;return;
DISP ENDP
CSEG ENDS
END START
我的分析就是这样,看不懂你只有自己努力了
[
本帖最后由 zaixuexi 于 2011-12-18 21:05 编辑 ]