小白求助,简单的两道编程题
1.以ARRAY为首地址的内存单元中,存放10个8位的带符号数(-11,22,33,-22,55,45,-33,-77,66,-47),统计数组中大于等于0的数的个数,并将结果存入RESULT字节单元中。2.统计数字69的二进制数据中1的个数,并将结果存入RESULT字节单元中。
DATA SEGMENT ARRAY DW -11,22,33,-22,55,45,-33,-77,66,-47 RESULT DW ? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START:MOV AX,DATA MOV DS,AX LEA SI,ARRAY MOV BX,0 MOV CX,10 L1: TEST WORD PTR[SI],8000H JNZ NEXT; 为负数,跳转next INC BX INC SI LOOP L1 JMP EXIT NEXT:INC SI LOOP L1 EXIT:MOV AH,4CH MOV RESULT BX INT 21H CODE ENDS END START
DATA SEGMENT RESULT DW ? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV AL,69 XOR AH,AH MOV CX,8 L1: SAL AL,1 ADC AH,0 LOOP L1 EXIT: MOV RESULT,AH MOV AH,4CH MOV RESULT BX INT 21H CODE ENDS END START
DATA SEGMENT ARRAY DW -11,22,33,-22,55,45,-33,-77,66,-47 RESULT DW ? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START:MOV AX,DATA MOV DS,AX LEA SI,ARRAY MOV BX,0 MOV CX,10 L1: TEST WORD PTR[SI],8000H JNZ NEXT; 为负数,跳转next INC BX NEXT:ADD SI,2 LOOP L1 EXIT:MOV AH,4CH MOV RESULT,BX INT 21H CODE ENDS END START
DATA SEGMENT RESULT DW ? DATA ENDS CODE SEGMENT ASSUME CS:CODE,DS:DATA START: MOV AX,DATA MOV DS,AX MOV AL,69 MOV BX,0 MOV CX,8 L1: SAL AL,1 ADC BX,0 LOOP L1 EXIT: MOV AH,4CH MOV RESULT,BX INT 21H CODE ENDS END START