Google

Jun 30, 2008

A subroutine program in assembly language

A subroutine based program in assembly language.

this is the MAIN PROGRAM

LXI SP 2400H
LXI H,2000H
LXI B,1020H
CALL SUB
HLT

this is the subroutine
SUB: PUSH B
PUSH H
LXI B,4080H
LXI H,4090H
DAD B
SHLD 2200H
POPH
POPB
RET

this subroutine is some thing like functions in c program language. here the main function is calling the subroutine SUB in the last but one line then the flow of the execution of the program is transfered to the subroutine once the program flow is reached to the end of the subroutine i.e RET statement then the execution will be going to the main program.


You might be also interested in:

:: free and open source 8086 Microprocessor Emulator
:: Invoke function

Jun 28, 2008

whether given number is palindrome or not

This is assembly language program for finding a given number is palindrome or not

Example:
3000 – AD
3001 – B5

AD = 10101101
B5 = 10110101 (D7=1; D6=0; D5=1; D4=1; D3=0; D2=1; D1=0; D0=1)

AD and B5 are palindrome

Algorithm
1. Take the 2nd value B5
2. The binary equivalent of it (10110101), is cut into bits n each bit is put in address ranging from 8001 to 8008 in the reverse order. That is, D0 is put in 8001; D1 in 8002 and so on—until D7 in 8008
3. This is done by rotating 10110101 right thro carry
4. Thus the carry values are stored into the addresses (8001 – 8008)
5. Hence we get, 8001 – 00000001
8002 – 00000000
8003 – 00000001
8004 – 00000000
8005 – 00000001
8006 – 00000001
8007 – 00000000
8008 – 00000001
6. Each of these values hafta b shifted so as to get 10000000 of 8001
00000000 of 8002
00100000 of 8003
00000000 of 8004
00001000 of 8005
00000100 of 8006
00000000 of 8007
00000001 of 8008
7. Add the values present in 8001 to 8008 n store it in the register C. Hence in register C, we have the value AD after rotating B5)
8. Get the 1st value from 3000 n store it in accumulator (register A)
9. Subtract A and C registers
10. If the numbers are palindrome, 01h gets stored in memory 4000
11. If the numbers r not palindrome, 02h is stored in memory 4001
12. end

the program

Label Mnemonics

MVI H, 08h
MVI L, 01h
MVI C, 08h
LDA 3001
rotate: RAR
JC one
JNC zero
one: MVI M, 01h
JMP next
Zero: MVI M, 00h
Next: INC L
DCR C
JNZ rotate
MVI L, 00h
Inc: INC L
MOV D, L
MOV A, L
SUI 09h
JZ fini
MOV A, M
Hey: RRC
DCR D
JZ inc
JNZ hey
Fini: MVI L, 00h
MVI C, 00h
Other: INC L
MOV A, M
MOV B, A
INC L
MOV A, M
ADD B
ADD C
MOV C, A
MOV A, L
SUI 08h
JNZ other
MVI H, 30h
MVI L, 00h
MOV A,M
SUB C
JZ palin
JNZ nopalin
Palin: MVI A, 01h
STA 4000
JMP over
Nopalin: MVI A, 02h
STA 4001
Over: HLT

You might be also interested in:

:: Assembly Language Programs to compute an expression
:: Interfacing Analog-to-Digital converter to 8086 using 8255
:: Interfacing Digital-To-Analog converter to 8086 using 8255
:: Temperature Control system using 8086

Jun 26, 2008

seperate the digits of hexa decimal number assembly language program

seperate the digits of a hexa decimal numbers and store in different locations

first get the packed BCD number and mask the lower nibble then move to the required position in the number and adjust the higher BCD digit as a lower digit then store the partial result now get the orignal BCD number and mask the higher nibble store the result and stop the program

LDA 2200H
ANI F0H
RRC
RRC
RRC
RRC
STA 2300H
LDA 2200H
ANI 0FH
STA 2301H
HLT

You might be also interested in:

:: Assembly Language Source Codes
:: why there are two ground pins in 8086
:: Program to display ASCII characters on the display unit

Jun 25, 2008

assambley Language program for swapping two numbers

swap the two numbers
the following program will swap the two numbers
eg; 23 will be changed to 32

LDA 2000H
MOV B,A
LDA 2200H
STA 2000H
MOV A,B
STA 2200H
HLT
the algorithm of the program is simple just copy the fist number in to register B and second number in to register A while storing store them in the reverse way that id first store the contents in the A first and then store the contents in register B

Jun 23, 2008

Adding the 4 four most significant bit to a hexa no

this is the program to add 4 most significant bit to a hexa decimal number

first get most significant BCD Digit
then move to the location by RLC command
store the temporary number in C
get the lower BCD digit and add it
store the result and stop the program.

LDA 2201H
RLC
RLC
RLC
RLC
MOV C,A
LDA 2200H
ADD C
STA 2300H
HLT

Jun 21, 2008

once (1's) and twos (2's) complement of a number

1's complement of the number

LDA 2200H
CMA
STA 2300H
HLT
cma will give 1's complement of a number


2's complement of a number


LDA 2200H
CMA
ADI 01H
STA 2300H
HLT
here first the once's complent of the number is determined and then one is added to it

You might be also interested in:

:: Traffic light control system using 8086
:: Assembly Language Program to serve NMI
:: Interfacing Stepper Motor to 8086 using 8255

Jun 17, 2008

Find the maximum number from the list of hexa decimal numbers

The program will find the maximum number form the list of hexadecimal numbers

LDA 2200H
MOV C,A
XRAA
LXI H,2201H
BACK: CMP M
JNC SKIP
MOVE A,M
SKIP: INX H
DCR C
JNZ BACK
STA 2300H
HLT


the algorithm is as follows
  • first initialize counter C= no of numbers in the list
  • then assign the maximum value is equal to zero ( thats the minimum possible value we can assign ) A=0
  • then initialize the pointer to the list of numbers
  • compare the number with A
  • if the number is greater the then maximum number that is A then replace A with the new number if not go for the next number
  • i.e increment pointer value and decrement count C
  • if c reaches 0 then come out of loop
  • store the number in A in some memory location
  • stop the program
You might be also interested in:

:: Assembly Language Programs to compute an expression
:: Interfacing Analog-to-Digital converter to 8086 using 8255
:: Interfacing Digital-To-Analog converter to 8086 using 8255
:: Temperature Control system using 8086

Jun 16, 2008

Find the number of negative numbers from list of hexa decimal numbers

This Assembly Language program for 8086 microprocessor will calculate the number of negative numbers from the list of hexa decimal numbers


LDA 2200H
MOV C,A
MVI B,00
LXI H,2201H
BACK: MOV A,M
ANI 80H
JZ SKIP
INR B
SKIP: INX H
DCR C
JNZ BACK
MOV A,B
STA 2300H
HLT

the program works as follows
first initialize the counter for total number of numbers to search for (C)
put the initial value for negative numbers is equals to zero ( B=0)
initialize the pointer to the memory location of the data
then get the number and check the most significant bit if it is 1 then the number is negative (verify this your self )
increment B that is negative number count
increment pointer
decrement number count C
repeat the process of the total numbers
store the result and stop the program .

You might be also interested in:

:: Assembly Language Source Codes
:: why there are two ground pins in 8086
:: Program to display ASCII characters on the display unit

Jun 14, 2008

Block data transfer program for 8086 assembly language

This program will move the block of data from one location to other location in the memory.
The program will work as follows
first lets take some counter as to how may locations has to be moved
then take a pointer and point to source location with a pointer H
then take a pointer D and point to destination memory
get the byte form source pointer and then store it in the destination pointer location
increment source and destination pointer value
decrement counter
check if counter is zero if not continue
else stop the program


MVI C,AH Initialize counter
LXI H,2200H
LXI D,2300H
BACK MOV A,M
STAX D
INX H
INX D
DCR C
JNZ BACK
HLT

You might be also interested in:

:: Traffic light control system using 8086
:: Assembly Language Program to serve NMI
:: Interfacing Stepper Motor to 8086 using 8255

Jun 13, 2008

Adding two hexa-decimal numbers with carry

LDA 2200H
MOV C,A
LXI H,2201H
SUB A
MOV B,A
Back: ADD M
JNC Skip
INR B
skip INX H
DCR C
JNZ BACK
STA 2300H
MOV A,B
STA 2301H
HLT
This program will add tho hexa deciaml numbers without carry

You might be also interested in:

:: 8051 based project for electrical students
:: free and open source 8086 Microprocessor Emulator
:: Invoke function

Jun 11, 2008

How to add two Hexa decimal numbers without carry

Adding hexa-decimal numbers without carry


LDA 2200
MOV C,A
SUB A
LXI H,2201H
Back: ADDM
INT H
DCR C
JNZ Back
STA 2300H
HLT

lnitialize counter c
then make sum=0
initialize the pointer
sum = sum+data
decrement counter c
if counter is zero then repeat else
store the result
halt the program.

You might be also interested in:

:: Effective addresses
:: Floating Point Initializations
:: options available for int 21h instruction

Jun 10, 2008

How to choose a MicroController

There are numerous different microcontroller chips available in the market but narrowing, selecting and distilling the search for the desired mirocontroller is quite difficult.

We found a very interesting instructable which talks about some hints, these for hobbyists who want to gain a learning experience about " how to choose a micro controller " . The instructable explains the basic functionality of a microcontroller , its architecture , design aspects , budgeting , the variety of microcontrollers available in the market and other online reseouces

you can read the detail instructalb step-by-step here

thanks westfw
related links

digikey

alldatasheet.com

You might be also interested in:

:: TCP/IP on PIC 18 series
:: assembly program to find out the largest number from an unordered array
:: Program to find out the number of even and odd numbers from a given series
:: assembly Program to create , write and close file

Jun 8, 2008

How to add two binary numbers without carry

Adding binary numbers without carry



MOV A,L
ADD E
DDA
STA 2300H
MOV A,H
ADC D
DAA
STA 2301H
HLT

the program works as followes
first statment gets 2 digits of the number 1
second statment addes two lower digits
DDA will adjust to valid BCD
STA statment will store the result in the address 2300H
mov A,H will move the most significan digits of second number
next statment will add them
then adjust to valid BCD
then store the result to 2301
thats it the end of the program.

You might be also interested in:

:: Effective addresses
:: Floating Point Initializations
:: options available for int 21h instruction