I am trying to add several pixels together in order to do a blurr filter in NASM. I've managed to add three pixels with the value of 00 + d3 + d8 (0 + 211 + 216). When I try to add one more pixel, with the value of 0, the program cannot print the value of the variable blurr.
Update:
It seems that adding to the variable sum can be done at max three times, since if I comment out another add, the value will be printed in my output file.
blurrTopRow:
;from 0 - 251 there will be no pixels above the active pixel
;set ah to 0 to be sure that no other values changes the byte
;save byte in al, ax should be [0000](ah) value(al)
mov ah, byte 0
mov al, byte [info + 0]
;store sum all pixels in sum, divition will be done here
add [sum], ax
;add pixel beside it (1)
;mov ah, byte 0
mov al, byte [info + 1]
;add the value to sum
;add [sum], ax If i add this value, the program stops working
;add the pixels below the first pixel
;move data to the first 8-bits
mov ah, 0
mov al, byte [info + 251]
add [sum], ax
;set the last 8-bits in the 16-bit register (ax) to 0
;to avoid messing up the value
mov ah, 0
mov al, byte [info + 252]
add [sum], ax
;devide the digit with 4
mov eax, 0
mov ax, [sum]
mov ebp, 4
mov edx, 0
idiv ebp
mov [blurr], al
ret
I believe this is due to some byte error or effective addressing that I do not understand yet. If you want to see all my code, you can find it in pastebin
For the moment, I am super confused why adding a 0 in my sum breaks the program, especially when I've already done this in the code above.
best
Seb