How Do I Correct Errors in My TASM Code for Calculating Averages?

  • Thread starter nuubik
  • Start date
In summary, the conversation is about a programming assignment that involves finding negative elements in columns and calculating their average values using the index addressing method. The code provided has some errors and the person is seeking help in fixing them. They are also recommended to use a debugger to monitor their code and registers.
  • #1
nuubik
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.
 
Physics news on Phys.org
  • #2
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
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 to How Do I Correct Errors in My TASM Code for Calculating Averages?

What is TASM/Turbo Assembly?

TASM/Turbo Assembly is a popular assembly language used for programming in the 16-bit DOS environment. It is commonly used for creating low-level programs and operating systems.

What are some common errors that occur when using TASM/Turbo Assembly?

Some common errors that occur when using TASM/Turbo Assembly include syntax errors, linker errors, and runtime errors. These errors can be caused by typos, incorrect use of assembly language instructions, or incompatible code.

How can I fix TASM/Turbo Assembly errors?

To fix TASM/Turbo Assembly errors, you can start by carefully reviewing your code for any typos or syntax errors. You can also consult the TASM user manual for guidance on proper assembly language usage. Additionally, using a debugger or stepping through your code line by line can help identify and fix errors.

Are there any online resources for troubleshooting TASM/Turbo Assembly errors?

Yes, there are several online forums and communities dedicated to TASM/Turbo Assembly where users can ask for help and troubleshoot errors together. Additionally, there are various tutorials and guides available online for learning and troubleshooting TASM/Turbo Assembly.

Is TASM/Turbo Assembly still relevant in modern programming?

While TASM/Turbo Assembly may not be as widely used as it once was, it is still relevant in certain fields such as reverse engineering and low-level programming. It can also be a useful skill to have in understanding computer architecture and learning other assembly languages.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
20
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
3K
  • Programming and Computer Science
Replies
4
Views
4K
  • Electrical Engineering
Replies
5
Views
2K
  • Programming and Computer Science
Replies
7
Views
7K
  • Programming and Computer Science
Replies
11
Views
4K
Back
Top