;============================================================================== ;file :add.asm ;author :Andre Long ;due :April 24, 2006 ;description :This subprogram will use arrays to add numbers ;============================================================================== ;Procedures To INCLUDE Pcmac.inc ;macros EXTRN NEWLINE:FAR ;display a new line EXTRN GETDEC$:FAR ;gets 16-bit decimal number EXTRN PUTDEC$:FAR ;display 16-bit decimal number ;============================================================================== .MODEL SMALL .586 .STACK 1000h ;============================================================================== .DATA Aray DB 72 DUP (0) Bray DB 72 DUP (0) Cray DB 72 DUP (0) carryN DB 0 endPos DW 71 nextPos DW 0 counterX DW 0 ;============================================================================== .CODE addFib proc _Begin mov ax, 0 mov bx, 0 mov si, endPos mov [Aray + si], 1 mov [Bray + si], 1 blue: cmp counterX, 25 jbe red jmp byeOuterLoop red: cmp si, 0 je resume mov al, [Aray + si] mov bl, [Bray + si] add al, bl add al, carryN cmp al, 9 jbe noCarry jmp yesCarry noCarry: mov carryN, 0 mov [Cray + si], al dec si jmp red yesCarry: mov carryN, 1 sub al, 10 mov [Cray + si], al dec si jmp red ptG: mov dl, [Bray + si] ; move BX into AX and CX into BX mov [Aray + si], dl mov dl, [Cray + si] mov [Bray + si], dl inc counterX jmp blue byeOuterLoop: resume: cmp nextPos, 72 jb see jmp go see: mov di, nextPos ;display Cray array mov al, [Cray + di] call putdec$ inc nextPos mov di, nextPos mov al, [Cray + di] jmp resume go: _Exit addFib endp end addFib