Google

Dec 22, 2008

Our Blog statistics

We have compiled and published over hundred assembly language programs and tutorials over the past one year now on this blog and we would like to thank our blog subscribers and our loyal visitors for the support, feedback and response.

We intend to bring you more tutorials and source codes related to microprocessors and microcontrollers in the future. Following is the summary of the traffic details our blog received







If you have any feedback, queries or comments you can reach us at kpac.ltd [at] gmail [dot] com

Dec 17, 2008

program to find the sum of squares of n numbers

program to find the sum of squares of n numbers

initially we load the si and di registers and we move contents of si to that of cl and then we continue to increment si and move si to al and multiply the current result with al. Then we move contents of si to that of bl and we multiply bl and add the result in ax to that of di.

the code can be analyzed as follows

mov si,2000
mov di,4000
mov cl, [si]
inc si
mov dx,0
l1 mov ah,00
mov l,[si]
add dx,ax
inc si
loop l1
Mov [di],dx
int a5

Dec 14, 2008

program to find the sum of cubes of n numbers

program to find the sum of cubes of n numbers

initially we load the si and di registers and we initalize ax and cx registers to zero. we move ax to content of di and move contents of si to cl. the we continue to increment si and move si to al and multiply the current result with al. Then we move contents of si to that of bl and we multiply bl and add the result in ax to that of di and we repeat this till the loop ends

the code can be analyzed as follows

mov si,2000
mov di,4000
mov ax,0
mov cx,0
mov [di],ax
mov cl,[si]
inc si
mov al,[si]
mul al
mov bl,[si]
mul bl
add [di], ax
loop continue
int a5

Dec 11, 2008

program to find the largest between two numbers

following program is to find the largest between two numbers

For the execution of this program we load si and di registers with initial address and move ah to 0 and we move the contents of si to al and we compare the contents of di with that of al register.

then we user jump if carry with DOWN label and move the contents of al to that of di and halt the program

code:

MOV SI, 2000
MOV DI,4000
MOV AH,00
MOV AL,[SI]
CMP AL,[SI]
CMP AL,[DI]
JC DOWN
MOV [DI], AL
DOWN INT A5

code ends

Dec 8, 2008

program to perform fibonacci series

following program is perform fibonacci series

In order to perform the fibonacci series, that is 1,1,2,3,5,8,13 .....
We initalize SI to 2000 and CX to 0, then we initilaize AX and BX registers. Then we increment SI Register by 1 and we move the contents of AL into SI register. Then we decrement cs by one and move the contents of BL o that of si and decrement CS. Then we add al and the bl registers.

Move al with contents of si +01 and move si with BL, then we increment si by one and repeat until cx=0 and we halt the program

CODE:

MOV SI,2000
MOV CX,0000
MOV CL,[SI]
MOV AX,0000
MOV BX,00
INC SI
MOV [SI], AL
DEC CX
INC SI
MOV [SI],BL
DEC CX
AGAIN ADD AL,BL
MOV [SI+01],AL
MOV BL,[SI]
INC SI
LOOP AGAIN
INT A5

----
code ends

Dec 5, 2008

program to convert ASCII to packed BCD numbers

Following program is for conversion of ASCII to packed BCD numbers

For execution of this program, we load the 1st ASCII digit into BL and the second ASCII number into the second AL. Then we mask the upper 4 bits of 1st digit and load CL for 4 rotate required. ROtate BL 4 bit position and combine nibbles, result in AL and finally we HALT the program.

CODE:

MOV BL,35H
MOV AL,39H
AND BL,0F
AND AL,0F
MOV CL,04
ROL BL,CL
OR AL,BL
INT A5

OUTPUT: 59 Packed BCD Number

Dec 2, 2008

program to find the product of numbers in an array

This program is to find the product of numbers in an array:

We initalize the registers, then we move the size of the array to a counter and reduce its size bu one. SI is incremented to point to the 1st number of the array and move the 1st number into accumularot.

The 2nd number is moved into BL,, we multiply both the numbers abd this is continued till the numbers in the list, exhaust and finally the result is stored in AX.

Code:

MOV SI, 2000
MOV DI,4000
MOV AX,O
MOV BX,0
MOV CX,0
MOV CL,[SI]
SUB CL,[SI]
INC SI
MOV AL,[SI]
AGAIN: INC SI
MOV BL, [SI]
MUL BL
LOOP AGAIN
MOV [DI],AX
INT A5

Thus the program for product of numbers in an array can be executed using the above code.