Google

May 13, 2008

assembly program to find out the largest number from an unordered array

The program to find out the largest number from an unordered array of sixteen 8 bit numbers stored sequentially in the memory locations starting at offset 0500H in the segment 2000H


Logic: The 1st number of the array is taken in a register, say AL. The 2nd number of array is then compared with the 1st one. If the 1st one is greater than 2nd one, it is left unchanged. However, if the 2nd one is greater than 1st, 2nd number replaces the 1st one in the AL register. The procedure is repeated for every number in array and thus requires 15 iterations.



MOV CX, 0FH; Initialize counter for no. of iterations
MOV AX, 2000H; Initialize data segment
MOV DS, AX;
MOV SI, 0500H; Initialize source pointer
MOV AL, [SI]; Take 1st number in AL
BACK: INC SI;
CMP AL,[SI];
INC SI;
CMP AL,[SI];
JNC NEXT;
MOV AL,[SI];
NEXT: LOOP BACK; Repeat the procedure 15 times
HLT

You might be also interested in:

:: centigrade (celsius) to fahrenheit calculation for 8086 Assembly Language
:: Data transfer instructions of 8086 microprocessor

TCP/IP on PIC 18 series

TCP/IP stack is readly avalibe from Microchip.com
implement the tcp/ip or udp port in your projects using ENC28j60 from microchip, using SPI port

or try this

Go to www.microchip.com and search for

PIC18F97J60

It comes with ready TCP IP stack and it will help you...let me know if you need further information...

You might be also interested in:
:: 8051 based project for electrical students
:: free and open source 8086 Microprocessor Emulator
:: Invoke function

May 10, 2008

Serial Port interfacing with atmega

Here is the code to interface atmega32 and serial port.


.include"m32def.inc"
.org 0000
rjmp main


main: ldi r16,low(ramend)
out SPL,r16
ldi r16,high(ramend)
out SPH,r16

ldi r18,0x00
out UBRRH,r18
ldi r18,0x19 ;setting baud rate of 2400 for 1MHZ
out UBRRL,r18
ldi r19,0x18
out UCSRB,r19 ;enabling RX & TX bits
ldi r19,0x86
out UCSRC,r19 ;setting aychronous mode with 1 stop
;& 1start bit & no parity
again: rcall usart_rx
rcall usart_tx
rjmp again




usart_rx: sbis UCSRA,RXC
rjmp usart_rx
in r17,UDR

ret


usart_tx: sbis UCSRA,UDRE
rjmp usart_tx
out UDR,r17
ret

;*************************

and set the settings in hyper terminal as

baud rate:2400
flow control:none

;********
You might be also interested in:
:: centigrade (celsius) to fahrenheit calculation for 8086 Assembly Language
:: Data transfer instructions of 8086 microprocessor


May 8, 2008

Interfacing pic microcontroller with LCD

Here is the code to interface the pic 16F877A PROCESSOR to 16x2 LCD
this is a assembly code and it is properly working just you have to modify some of the routines as per your need.
As this is in assembly it doesn't take any space and also it use 8 bit mode.







; Program Module : Debug board
; Purpose : to show the content of data bus and adress bus
; Programmed By : Kamal Kant Singh
; Date of Start : 26th june,2007
;_________________________________________________________________________



PROCESSOR 16F877A
#include"p16F877A.inc"

__CONFIG _CP_OFF & _WDT_OFF & _XT_OSC & _PWRTE_ON & _BODEN_OFF & _LVP_OFF & _DEBUG_OFF

cblock 0x0021
a1
a2
a3 ; used in sapr
a4
a5
a6 ;for macro PRINT
l1
l2
l3
w_temp
w_temp1
endc


PRINT macro label
local endom
local next_char
clrf a6
next_char
movf a6,w
call label
iorlw 0
btfsc STATUS,Z
goto endom
call send_char
incf a6,f
goto next_char
endom
endm

COMMA macro
movlw ','
call send_char
endm



en equ 2
rs equ 0
rw equ 1



org 0x0000
goto main
org 0x0004
goto main

main
movlw .20
call delayxms
banksel ADCON1
movlw 0x06
movwf ADCON1

banksel TRISA
movlw 0xFF
movwf TRISD ; port B for data bus contents while ports C,D are for address bus contents
movwf TRISB
movwf TRISC
movlw 0x30
movwf TRISA
clrf TRISE

banksel PORTB
clrf PORTB
clrf PORTD
clrf PORTC
clrf PORTE
clrf PORTA


; lcd operation
movlw 0x02
call send_cmd
call init_lcd
;entrance
movlw 0x82
call send_cmd
PRINT eklavya
check_again
movlw 0xC0
call send_cmd
PRINT address
call print_add
movlw 0xca
call send_cmd
PRINT dat
call print_dat
movlw 0xC5
call send_cmd


goto check_again




goto endop






init_lcd
movlw 0x28
call send_cmd
movlw 0x0c
call send_cmd
movlw 0x06
call send_cmd
;movlw 0x1c
;call send_cmd
return





send_cmd
movwf w_temp1
movlw 0x05
call delayxms
swapf w_temp1,w
bcf PORTE,rs
bcf PORTE,rw
movwf PORTA
bsf PORTE,en
nop
nop
bcf PORTE,en
movf w_temp1,w
movwf PORTA
bsf PORTE,en
nop
nop
bcf PORTE,en
movlw 0x03
call delayxms
return

send_char
movwf w_temp1
movlw 0x05
call delayxms
swapf w_temp1,w
bsf PORTE,rs
bcf PORTE,rw
movwf PORTA
bsf PORTE,en
nop
nop
bcf PORTE,en
movf w_temp1,w
movwf PORTA
bsf PORTE,en
nop
nop
bcf PORTE,en
movlw 0x03
call delayxms
return
print_add
movf PORTC,w
call sapr
call asc2
call send_char
movf a3,w
call asc2
call send_char
movf PORTD,w
call sapr
call asc2
call send_char
movf a3,w
call asc2
call send_char
return

print_dat
movf PORTB,w
call sapr
call asc2
call send_char
movf a3,w
call asc2
call send_char
return


sapr
movwf w_temp
andlw 0x0F
movwf a3
swapf w_temp,w
andlw 0x0F
return


delay3xms
movwf w_temp1
call delayxms
movf w_temp1,w
call delayxms
movf w_temp1,w
call delayxms
return


delayxms
movwf l1
up
call delay1ms
decfsz l1,f
goto up
return

delay1ms
movlw .62
movwf l2
delay4us
nop
decfsz l2,f
goto delay4us
return


asc2
addwf PCL,f
retlw '0'
retlw '1'
retlw '2'
retlw '3'
retlw '4'
retlw '5'
retlw '6'
retlw '7'
retlw '8'
retlw '9'
retlw 'A'
retlw 'B'
retlw 'C'
retlw 'D'
retlw 'E'
retlw 'F'

address
addwf PCL,f
retlw 'A'
retlw 'D'
retlw 'D'
retlw ':'
retlw 0

dat
addwf PCL,f
retlw 'D'
retlw 'T'
retlw ':'
retlw 0

eklavya
addwf PCL,f
retlw ' '
retlw 'E'
retlw 'k'
retlw 'l'
retlw 'a'
retlw 'v'
retlw 'y'
retlw 'a'
retlw ' '
retlw '1'
retlw '.'
retlw '0'
retlw ' '
retlw 0



endop
goto endop
end

You might be also interested in:
:: 8051 based project for electrical students
:: free and open source 8086 Microprocessor Emulator
:: Invoke function

Apr 28, 2008

8085 Microprocessor simulator for linux

GNUsim8085



it is a graphical simulator, assembler and debugger for the Intel 8085 microprocessor in Linux.

you can download this software for this link https://sourceforge.net/project/platformdownload.php?group_id=86462


here is the screen shot of the software


this software is also available for windows the download page for it is here

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

Apr 3, 2008

Data transfer instructions of 8086 microprocessor

General purpose byte or word transfer instructions

MOV
copy byte or word from specified source to specified destination

PUSH
copy specified word to top of stack.

POP
copy word form top of stack to specified location

PUSHA
copy all registers to stack

POPA
copy words from stack to all registers.

XCHG
Exchange bytes or exchange words

XLAT
translate a byte in AL using a table in memory.

These are I/O port transfer instructions

IN
copy a byte or word from specific port to accumulator

OUT
copy a byte or word from accumulator to specific port

Special address transfer Instructions

LEA
load effective address of operand into specified register

LDS
load DS register and other specified register from memory

LES
load ES register and other specified register from memory

Flag transfer instructions

LAHF
load AH with the low byte of flag register

SAHF
store AH register to low byte of flag register

PUSHF
copy flag register to top of stack

POPF
copy word to top of stack to flag register

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