-
TASM/turbo assambly
I had to write program which finds all negative elements in columns and calculates their average values and i had to do this with index addressing method. My code below:
Code:
.model tiny
.code
.startup
Org 100h
Jmp Short Start
Vector Dw 2, -7, -1, 16, -15
N Equ 5
Start:
Xor Bx, Bx
Xor Dx, Dx
Xor Si, Si
Mov Cx, N
Dec Cx
S:
Mov Ax, Vector[Bx]
Add Bx, 2
Cmp Ax, 0
Jge _next
Inc Si
Add Dx, Ax
_next:
Dec Cx
Loop S
AVG:
Mov Ax, Dx
Cwd
Idiv Si
Could someone help me fix my errors? I would be very thankful.
-
-
Not to hijack the thread, but TASM is very outdated...might want to learn The Netwide Assembler: NASM instead. It's cross-platform and will write 16, 32, and 64 bit programs.
-
What the heck is with these two lines:
Code:
Cmp Ax, 0
Jge _next
You're skipping all non-negative values? Why is this comparison even here?