I am learning assembly and working on the application turbodebugger. I have been given…
- User
I am learning assembly and working on the application turbodebugger. I have been given this example program: 2.3. Example of program in assembly language The program calculates the sum of a row of numbers at SIR address and length specified in LGSIR variable; the result will be put in SUM location. The first source program will be in the .COM type CODE SEGMENT PARA PUBLIC ‘CODE’ ASSUME CS:CODE, DS:CODE ORG 100H START: JMP ENTRY SIR DB 1,2,3,4 LGSIR DB $-SIR SUM DB 0 ENTRY: MOV CH,0 MOV CL,LGSIR ; in CX is the length’s row MOV AL,0 ; the initialization of the register where the sum is ; calculated MOV SI,0 ; the index’s initialization NEXT: ADD AL,SIR[SI] ; the add of the current element INC SI ; passing at the next element in the row LOOP NEXT ; CX decrementing and jump to next ; element if CX differs from 0 MOV SUM,AL ; end of program MOV AX,4C00h INT 21H CODE ENDS END START
And then these commands: Study the presented example. • Assemble, link and trace the given example • Use Turbo Debugger to inspect content of registers and memory (SUM location). • Rewrite the example in .EXE • Make symbolic trace and debug • Modify the code to add an array of words not bytes • Modify the code to keep the sum in a double size location than the added values
Help me understand and complete each task
- Assistant
- User
Tell me about the example program first, what does it do? Why is it written that way?
- Assistant
The example program is written in assembly language and calculates the sum of a row of numbers stored in an array located at memory address SIR, and of length specified in LGSIR variable. The result of the calculation is stored in the SUM location.
The program starts with a jump instruction to the ENTRY label, followed by the definition of the SIR, LGSIR, and SUM variables. The SIR variable is defined as an array of bytes that contains the row of numbers to be added, and the LGSIR variable is defined as the length of the row. The SUM variable is defined as a byte that will store the result of the calculation.