Mr.Grease
Mr.Grease

Reputation: 197

Emu8086 assembly adder

I'm trying to write an assembly program that adds the numbers (initialized as nums) which are smaller than A0H. However when I run this program it fails to add ANY of the numbers. Any help would be appreciated.

     PAGE 60,132
TITLE COOLADDER

    .MODEL SMALL
    .STACK 64     


    .DATA
NUMS DB 01H,01H,01H,01H,0A1H,0A1H
SUM DB ?
CC DB ?

    .CODE
MAIN PROC FAR
MOV AX,@DATA
MOV DS,AX
MOV CX,6
MOV BX,OFFSET NUMS    
MOV AL,0

AGAIN:  
MOV DI,0A0H      
CMP DI,[BX]
JNA RES

ADD AL,[BX]   
MOV CC,AL
RES:  
INC BX
DEC CX
JNZ AGAIN
MOV SUM,AL
MOV AH,4CH
INT 21H


MAIN ENDP
     END MAIN

Upvotes: 2

Views: 678

Answers (1)

Fifoernik
Fifoernik

Reputation: 9899

The data was defined as bytes but you are comparing as words!

Change this:

MOV DL,0A0H      
CMP DL,[BX]

Upvotes: 2

Related Questions