Bunch of 9 different but unique guys, each with their own quality, good and bad.

Monday, October 09, 2006

N bit N nos ADDITION
Author:rahul
Status: PERFECT
Comment:this is just a sample prog which adds 3-64 bit nos and gives the ans. to extend the prog to n nos just type them onto to the 3rd line of prog.each 64bit no is written as 4 16 bit nos with the least significant word written first and msw lastfollowed by lsw of next no. modify count value as required.to extend the prog to n bits with every 16 bit increase increment the no.in line 13 by 1and also increment no.in line4 by 1. eg for a 80 bit no line 13 will read:mov dl,5d and line 4 as:ans dw 6 dup(0)

Prog:
.model small
.data
nos dw 9234h,0h,0h,8000h,9005h,0h,0h,0h,0h,1h,0h,80c0h
ans dw 5 dup(0)
count equ 3d
.code
start: mov ax,@data
mov ds,ax
mov si,offset nos
mov cl,count
nxtno: clc
mov di,offset ans
mov dl,4d
nxtwrd: lodsw
mov bx,[di]
adc ax,bx
mov [di],ax
inc di
inc di
dec dl
jnz nxtwrd
adc word ptr[di],0h
dec cl
jnz nxtno
mov ax,4c00h
int 21h
end start
end

0 Comments:

Post a Comment

<< Home