Hi I have this program that counts the values of a table. All values are initial at 1.
I use the assembler masm 6.11
The problem I have is that the program does not go through the loop 10 times after the first iteration, it exits. I don see what is wrong can someone see the problem?
Thank youCode:; ; register usage: BX= pointer to table. ; CX= counter ; AX= current partial sum ; ; ; TITLE ADDTABLE .MODEL SMALL ;conventions- small model ; ; stack initialization ; .stack 100H ; Allocate 256 bytes stack ; ; ; Local data ; .DATA COUNTER DW 10 ;length of table TABLE DW 100 DUP(1) ;Reserve storage for table RESULT DW ? ;sum of entries ; ; Code Segment ; ; .CODE START: MOV AX, @DATA ;Load segment register MOV DS, AX ;Into DS register ; ; Initialization area ; MOV BX, OFFSET TABLE ; initialize PTR to top of table MOV CX, COUNTER ; initialize counter to # of entries XOR AX,AX ; clear current sum ; ; Loop to add table entries ; ADDLOP: ADD AX,WORD PTR [BX] ; ADD NEXT ENTRY INC BX ;Point to next entry by incrementing INC BX LOOPNZ ADDLOP ;If not, add next entry ; ; DONE, store sum and Exit ; MOV RESULT, AX ;store SUM MOV AX, 4C00H ;InA and call DOS ; END START




Reply With Quote