Friday, March 30, 2012

Display string on scrren in assembly language using 8086


assume cs:code,ds:data
data segment
org 2000h
msg db "MICROPROCESSORLAB",0DH,0AH,"$"
data ends

code segment
start:
mov ax,data
mov ds,ax
lea dx,msg
mov ah,09h
int 21h
mov ah,4ch
int 21h
code ends
end start

Thursday, March 29, 2012

Find the string for polindrome or not using 8086 program in assembly language


assume cs:code,ds:data,es:data
data segment
org 2000h
msg1 db "enter your string",0dh,0ah,"$"
msg2 db "It is palindrom",0dh,0ah,"$"
msg3 db "It is not palindrom",0dh,0ah,"$"
msg4 db "Do you wish to continue y/n",0dh,0ah,"$"
org 4000h
strg1 db 50h dup(0h)
        org 6000h
strg2 db 50h dup(0h)
data ends

code segment
start:
mov ax,data
mov ds,ax
mov es,ax
lea si,strg1
lea di,strg2
mov bx,0h
lea dx,msg1
mov ah,09h
int 21h
next_char:
mov ah,01h
        int 21h
cmp al,0dh
je rev_string
inc bx
stosb
jmp next_char
rev_string:
mov cx,bx
dec di
nxt_byte:
mov al,[di]
mov [si],al
inc si
dec di
loop nxt_byte
lea si,strg1
lea di,strg2
mov cx,bx
cld
rep cmpsb
je palin
lea dx,msg3
mov ah,09h
int 21h
jmp next
palin:
lea dx,msg2
mov ah,09h
int 21h
next:
lea dx,msg4
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'y'
je start
cmp al,'n'
je terminate
        jmp next
terminate:
mov ah,4ch
int 21h
code ends
end start


Find the factorial of a given number using 8086 program in assembly language


ASSUME  CS:CODE, DS:DATA, SS:STACK1
DATA SEGMENT
NUM DW 05H
FACT DW 0H
DATA ENDS
STACK1 SEGMENT
STK DW 100H DUP(0H)
TOP_STACK LABEL WORD
STACK1 ENDS
CODE SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        MOV AX, STACK1
        MOV SS, AX
        LEA SP, TOP_STACK
        MOV AX, NUM
        CALL FACTO1
        MOV AH, 4CH
        INT 21H
        FACTO1 PROC NEAR
        CMP AX, 01H
        JE GO
        PUSH AX
        DEC AX
        CALL FACTO1
        POP AX
        MUL FACT
        MOV FACT, AX
        RET
GO:     MOV FACT,01H
        RET
        FACTO1 ENDP
        CODE ENDS
        END START
     

Finding the number of even and odd numbers in a given series in assembly language using 8086



ASSUME  CS:CODE, DS:DATA
DATA    SEGMENT
        ORG 5000H
SERIES  DB 35H,66H,11H,12H,22H,56H,8H,2H,1H,9H
COUNT   DB 0AH
ODDCOUNT DB 00H
EVENCOUNT DB 00H
DATA    ENDS
CODE    SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        LEA SI, SERIES
        MOV CL, COUNT
NEXT:   MOV AX, [SI]
        ROR AX, 01
        JNC EVENV
        INC ODDCOUNT
        JMP OTHER
EVENV:   INC EVENCOUNT
OTHER:  INC SI
        DEC CL
        JNZ NEXT
        MOV AH, 4CH
        INT 21H
CODE    ENDS
        END START


Data transfer in reverse direction in assembly language in 8086


assume cs:code,ds:data
data segment
org 2000h
array1 db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0ah
org 4000h
array2 db 10d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov si,2000h
mov di,4009h
mov cx,10d
go:mov al,[si]
mov [di],al
inc si
dec di
dec cx
jnz go
mov ah,4ch
int 21h
code ends
end start

Addition of two numbers in assembly language using 8086


ASSUME CS:CODE, DS:DATA
DATA    SEGMENT
        ORG 3000H
        NUM1 DB 22H
        NUM2 DB 32H
        SUM DB 00H
DATA    ENDS
CODE    SEGMENT
        ASSUME CS:CODE, DS:DATA
START:  MOV AX, DATA
        MOV DS, AX
        MOV AL, NUM1
        MOV BL, NUM2
        ADD AL, BL
        MOV SUM, AL
        MOV AH, 4CH
        INT 21H
CODE ENDS
        END START

Monday, March 26, 2012

Data transfer in forward direction in assembly language using 8086


assume cs:code,ds:data
data segment
org 2000h
array1 db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0ah
org 4000h
array2 db 50d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov si,2000h
mov di,4000h
mov cx,10d
go:mov al,[si]
mov [di],al
inc si
inc di
dec cx
jnz go
mov ah,4ch
int 21h
code ends
end start

Data Over laping in assembly language using 8086


assume cs:code,ds:data
data segment
org 2000h
array db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0ah
data ends
code segment
start:mov ax,data
mov ds,ax
mov si,2009h
mov di,200eh
mov cx,10d
go:mov al,[si]
mov [di],al
dec si
dec di
dec cx
jnz go
mov ah,4ch
int 21h
code ends
end start


LCD INTERFACING using 8051/89c51 using TOPView Simulator




2 lines 16 characters, 8 bits, port line selection EN - P3.2,RS - P3.1,RW - P3.3


$MOD51
 EN EQU P3.2
RS EQU P3.1
RW EQU P3.3
ORG 0000H
MOV A,#38H
LCALL LCD_COMD
MOV A,#0EH
LCALL LCD_COMD
MOV A,#06H
LCALL LCD_COMD
MOV A,#01H
LCALL LCD_COMD
MOV A,#'E'
LCALL LCD_TEXT
MOV A,#'C'
LCALL LCD_TEXT
MOV A,#'E'
LCALL LCD_TEXT
LOOP:SJMP LOOP
LCD_COMD:CLR C
LCALL WRITE
RET
LCD_TEXT:SETB C
LCALL WRITE
RET
WRITE:SETB EN
CLR RW
MOV RS,C
MOV P1,A
CLR EN
LCALL DELAY
RET
DELAY: MOV R0,#56
LOOP2: MOV R1,#255
LOOP1: DJNZ R1,LOOP1
             DJNZ R0,LOOP2
RET
END

INTERFACING OF 2 DIGIT SEVENSEGMENT DISPLAY THROUGH 7447 In 89c51/8051 with topview simulator


NOTE: When initializing the external modules set these settings
NON Multiplexed, green or red, common cathode, BCD.
Port line selections:
Number digits -2,
Control line and port line:
CONNECT PORT1.0 TO 1.4 BITS TO DIGIT2 AND PORT 1.4 TO 1.7 TO DIGIT1

$MOD51
ORG 0000H
        SJMP MAIN
ORG 0030H
MAIN: MOV A,#00H
AGAIN:MOV P 1,A
        LCALL DELAY
       ADD A,#01
        DA A
        SJMP AGAIN
;DELAY ROUTINE
        ORG 0040H
DELAY:         MOV R2,#0FFH
UP1:    MOV R1,#0FFH
UP2:   NOP
       NOP
       NOP
        DJNZ R1,UP2
        DJNZ R2,UP1
        RET
        END

INTERFACE OF LEDS TO GET THE TOGGLE OPERATION in 8051/89c51 in topview simulator


$mod51
mov a,#0aah
repeat: mov p1,a
         cpl a
        lcall delay
        sjmp repeat
delay:mov r2,#0ffh
back:mov r1,#0ffh
up1:nop
nop
djnz r1,up1
djnz r2,back
ret
end

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...