TASM/turbo assambly

  • Thread starter nuubik
  • Start date
  • #1
1
0

Homework Statement


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

.exit 0
end
Could someone help me fixing my errors? I would be very thankful.
 

Answers and Replies

  • #2
rcgldr
Homework Helper
8,770
569
Note that loop decrements cx. You don't need the dec cx instruction. Is there a debugger you can use to step through the code one instruction at a time so you can monitor the registers (these also let you view chunks of memory)?
 
  • #3
35,287
7,140
The name of the debugger is tdebug.exe that comes with Turbo. It's pretty easy to use. If you're writing assembly code, it's pretty much essential to use a debugger.
 

Related Threads on TASM/turbo assambly

  • Last Post
Replies
5
Views
3K
  • Last Post
Replies
1
Views
4K
  • Last Post
Replies
1
Views
2K
  • Last Post
Replies
0
Views
2K
  • Last Post
Replies
2
Views
3K
Replies
1
Views
950
  • Last Post
Replies
1
Views
4K
Replies
0
Views
793
Replies
1
Views
4K
Top