;輸入不超過65535的10進位制數,將其以16位2進位制數的形式顯示補碼 (neg指令意義的補碼) ; 非數學意義上的補碼 CODE SEGMENT ASSUME CS:CODE ORG 100H START: JMP BBB X DW 0 MSG1 DB 10,13,"please input a number:","$" MSG2 DB 10,13,16 DUP(0),"$" BBB: PUSH CS POP DS PUSH CS POP ES LEA DX,MSG1 MOV AH,9 INT 21H LEA BX,X MOV AX,0 PUSH AX AGAIN1: MOV AH,1 INT 21H CMP AL,13 JE LINE0 SUB AL,30H MOV AH,0 MOV SI,AX POP AX MOV CL,10 MOV CH,0 MUL CX ADD AX,SI PUSH AX JMP AGAIN1 LINE0: POP AX NEG AX ;;;;;;;;;;;;;;;;;;;;;;;;;; MOV X,AX ;================= LEA DI,MSG2 INC DI INC DI MOV CX,16 MOV AX,X AGAIN2: ROL AX,1 JC @1 MOV BYTE PTR[DI],30H JMP @2 @1: MOV BYTE PTR[DI],31H @2: INC DI LOOP AGAIN2 ;============== LEA DX,MSG2 MOV AH,9 INT 21H MOV AH,8 INT 21H MOV AH,4CH INT 21H CODE ENDS END START
;輸入不超過65535的10進位制數,將其以16位2進位制數的形式顯示補碼 (neg指令意義的補碼) ; 非數學意義上的補碼 CODE SEGMENT ASSUME CS:CODE ORG 100H START: JMP BBB X DW 0 MSG1 DB 10,13,"please input a number:","$" MSG2 DB 10,13,16 DUP(0),"$" BBB: PUSH CS POP DS PUSH CS POP ES LEA DX,MSG1 MOV AH,9 INT 21H LEA BX,X MOV AX,0 PUSH AX AGAIN1: MOV AH,1 INT 21H CMP AL,13 JE LINE0 SUB AL,30H MOV AH,0 MOV SI,AX POP AX MOV CL,10 MOV CH,0 MUL CX ADD AX,SI PUSH AX JMP AGAIN1 LINE0: POP AX NEG AX ;;;;;;;;;;;;;;;;;;;;;;;;;; MOV X,AX ;================= LEA DI,MSG2 INC DI INC DI MOV CX,16 MOV AX,X AGAIN2: ROL AX,1 JC @1 MOV BYTE PTR[DI],30H JMP @2 @1: MOV BYTE PTR[DI],31H @2: INC DI LOOP AGAIN2 ;============== LEA DX,MSG2 MOV AH,9 INT 21H MOV AH,8 INT 21H MOV AH,4CH INT 21H CODE ENDS END START