Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

TITLE A 1 4 SPRED ( EXE ) Spreadsheet arithmetic . MODEL SMALL . STACK 6 4 ; - - - - - - -

TITLE A14SPRED (EXE) Spreadsheet arithmetic
.MODEL SMALL
.STACK 64
; -----------------------------------------------
.DATA
SPRD_TBL DW 05,03,06,04,10,00 ;Data rows
DW 04,05,01,09,06,00
DW 06,02,00,10,11,00
DW 10,07,03,05,02,00
DW 00,00,00,00,00,00 ;Total row
COUNT DB ?
COLS EQU 12 ;6 cols X 2 bytes
ROWS EQU 10 ;5 rows X 2 bytes
NOCOLS EQU 06 ;No. of columns
NOROWS EQU 05 ;No. of rows
COLTOT EQU NOCOLS*(NOROWS-1)*2 ;6 cols X 4 rows X 2
.386 ; ------------------------------------------------
.CODE
A10MAIN PROC FAR
MOV AX ,@data ;Initialize
MOV DS,AX ; segment
MOV ES,AX ; registers
CALL B10HORZL ;Call horizontal addition
CALL C10VERTL ;Call vertical addition
MOV AX,4C00H ;End processing
INT 21H
A10MAIN ENDP
; Add horizontal totals (rows):
B10HORZL PROC NEAR
PUSHA ;Preserve registers
MOV COUNT,NOROWS-1 ;Count to add row cells
LEA DI,SPRD_TBL ;Initialize table
LEA SI,SPRD_TBL ; addresses
ADD SI,ROWS
B10: MOV CX,NOCOLS-1 ;Count for columns
B20: MOV AX,[DI] ;Get amount from cell
ADD [SI],AX ;Add it to row total
ADD DI,02 ;Next cell in row
LOOP B20 ;Repeat thru all cells in row ADD DI,02 ;First cell in next row
ADD SI,COLS ;Next row total
DEC COUNT ;Repeat thru all rows
JNZ B10
POPA ;Restore registers
RET
B10HORZL ENDP
; Add vertical totals (columns):
C10VERTL PROC NEAR
PUSHA ;Preserve registers
MOV COUNT,NOCOLS-1 ;Count to add column cells
MOV BX,00
LEA SI,[SPRD_TBL+COLTOT] ;Initialize column total
C10: LEA DI,SPRD_TBL ;Initialize top cell
ADD DI,BX
MOV CX,NOROWS-1 ;Count for rows
C20: MOV AX,[DI] ;Get amount from cell
ADD [SI],AX ;Add it to column total
ADD DI,COLS ;Next cell in column
LOOP C20 ;Repeat thru all cells in column
ADD BX,02 ;Next cell in row
ADD SI,02 ;Next column total
DEC COUNT ;Repeat thru all cols
JNZ C10
POPA ;Restore registers
RET
C10VERTL ENDP
END A10MAIN
Revise the program: A14SPRED (EXE) Spreadsheet arithmetic so that it adds the totals of
(a) at the right of each row (vertically)
(b) at the bottom of each column (horizontally).
(c) Display the spreadsheet on the screen.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions