用汇编语言
发布网友
发布时间:2022-04-23 15:57
我来回答
共1个回答
热心网友
时间:2023-10-18 09:31
CODE SEGMENT
ASSUME CS:CODE
BARRAY DB 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100
N EQU $-BARRAY
OSUM DW 0
ESUM DW 0
START: PUSH CS
POP DS
PUSH CS
POP ES
LEA SI,BARRAY
MOV CX,N
CLD
@1:
LODSB
CBW
MOV BX,AX
CALL ONENUM
TEST AX,1
JE @2
ADD OSUM,BX
JMP @3
@2:
ADD ESUM,BX
@3:
LOOP @1
MOV AH,4CH
INT 21H
;============================
ONENUM:
PUSH BX
PUSH CX
MOV BX,0
MOV CX,8
@ONENUM1:
ROR AL,1
JNC @ONENUM2
INC BX
@ONENUM2:
LOOP @ONENUM1
MOV AX,BX
POP CX
POP BX
RET
;==============================
CODE ENDS
END START