Sunday, April 8, 2012

Program to sort numbers in ascending order using 8086 (unsigned numbers)

assume cs:code,ds:data
data segment
org 2000h
series db 81h,82h,93h,95h,10h,56h,33h,99h,13h,44h
count dw 10d
data ends
code segment
start:mov ax,data
mov ds,ax
mov dx,count
dec dx
go:mov cx,dx
lea si,series
nxt_byte:mov al,[si]
cmp al,[si+1]
jb next
xchg al,[si+1]
xchg al,[si]
next:inc si
loop nxt_byte
dec dx
jnz go
mov ah,4ch
int 21h
code ends
end start

Program to find the number of numbers having 5th bit as one in a series using 8086

assume cs:code,ds:data
data segment
org 2000h
series db 56h,32h,45h,11h,32h,87h,97h,65h,55h,88h
numcount db 00h
data ends
code segment
start:mov ax,data
mov ds,ax
mov si,2000
mov cx,0ah
go:mov ax,[si]
test ax,10h
jz next
inc numcount
next:inc si
dec cx
jnz go
mov ah,4ch
int 21h
code ends
end start

Saturday, April 7, 2012

Different types of SIGNALING Schemes using MATLAB

clc
clear all
close all
n=input('enter the number of bits')
m=mod(randperm(n),2)            %binary data
t=['the binary data is      ',num2str(m)]
c=input('enter your choice 1.unipolar nrz 2.polar nrz 3.unipolar rz 4.manchester')
switch c
    case 1
for i=1:1:n
s((i-1)*100+1:i*100)=m(i)
end
    case 2
        for i=1:1:n
            if m(i)==1
                m(i)=1
            else
                m(i)=-1
            end
        end
        for i=1:1:n
s((i-1)*100+1:i*100)=m(i)
        end
    case 3
        for i=1:1:n
    s(1+100*(i-1):50*((2*i)-1))=m(i)
    s(1+50*((2*i)-1):100*i)=0
        end
    case 4
        for i=1:1:n
            if m(i)==1
                m(i)=1
            else
                m(i)=-1
            end
        end
        for i=1:1:n
    s(1+100*(i-1):50*((2*i)-1))=m(i)
    s(1+50*((2*i)-1):100*i)=-m(i)
        end
    otherwise
disp('invalid choice')
end
plot(s)
gtext(t)
switch c
    case 1
        gtext('unipolar nrz signaling')
    case 2
        gtext('polar nrz signaling')
    case 3
        gtext('unipolar rz signaling')
    otherwise
        gtaxt('manchester signaling')
end

Thursday, April 5, 2012

Frequency Shift Keying using MATLAB




clc
clear all
close all
m=input('enter the binary sequency')
l=length(m)
t=[0.01:0.01:l]
for i=1:1:l
a((i-1)*100+1:i*100)=m(i)
end
% the fsk can be written as sum of two asks having different frequencies  
% generating the ASK Signal for the inputed sequence with high frequency
f1=a.*(sin(2*pi*5*t))
f2=not(a).*sin(2*pi*t)
fsk=f1+f2
figure(1)
plot(f1)
title('ASk signal')
figure(2)
plot(f2)
title('ask signal')
figure(3)
plot(fsk)
title('frequency shift keying signal')
figure(4)
hold on
plot(f1,'black')
plot(f2,'red')
helg=legend('high frequency signal','low frequency signal')
hold off

YOU MAY LIKE1. Amplitude Shift keying              
2. Phase Shift Keying                  
3. Hybrid Shift Keying                  

Sunday, April 1, 2012

Division of two numbers using 8086 in assembly language

assume cs:code,ds:data
data segment
org 2000h
num1 dw 8345h
num2 dw 2346h
rem dw 2d dup(0h)
quo dw 2d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,num1
idiv num2
mov quo,ax
mov rem,dx
mov ah,4ch
int 21h
code ends
end start

Finding the product of two numbers using 8086 program in assembly language

assume cs:code,ds:data
data segment
org 2000h
num1 dw 1234h
num2 dw 2345h
product dw 2d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,num1
mul num2
mov product,ax
mov product+2,dx
mov ah,4ch
int 21h
code ends
end start

assume is the preprocessor directive . and we are using two segment registers one is code segment and second is the data segment register.
data segment contains the all initialization s like the starting address of the program. and the variables used and the data type of those variables. product dw 2d dup(0h) specifies the processor to load the variable memory location with the zeros.
next code segment contains the executable code which performs the desired action. the result of the multiplication is stored in the ax register automatically. mov ax,data loads the startin address of the data segment in the ax register. mov ds,ax set thememory location as the variable ds. load the  number one into the ax register. and then directly multiply the content of the ax with num2. the result is stored in the ax register. then move the result into the variable product. at the endint 21h is the interrupt to the processor.

finding the sum of two numbers using 8086 in assembly language

assume cs:code,ds:data
data segment
org 2000h
num1 dw 1234h
num2 dw 2345h
sum db 2d dup(0h)
carry db 1d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,num1
mov bx,num2
add al,bl
daa
mov sum,al
mov al,ah
adc al,bh
daa
mov sum+1,al
mov bl,0h
adc bl,0h
mov carry,bl
mov ah,4ch
int 21h
code ends
end start


Assembly language program to find the sum of numbers in a given series using 8086

assume cs:code,ds:data
data segment
org 2000h
series dw 1234h,2345h,0abcdh,103fh,5555h
sum dw 00h
carry dw 00h
data ends
code segment
start:mov ax,data
mov ds,ax
mov ax,00h
mov bx,00h
mov cx,05h
mov si,2000h
go:add ax,[si]
adc bx,00h
inc si
inc si
dec cx
jnz go
mov sum,ax
mov carry,bx
mov ah,4ch
int 21h
code ends
end start

Assembly language program to find the number of ones in a given number using 8086

assume cs:code,ds:data
data segment
org 2000h
num dw 4567h
onecount db 01d dup(0h)
data ends
code segment
start:mov ax,data
mov ds,ax
mov cx,16d
mov ax,num
go:ror ax,01
jnc next
inc onecount
next:dec cx
jnz go
mov ah,4ch
int 21h
code ends
end start

Assembly language program to find maximum and minimum number in a series using 8086

assume cs:code,ds:data
data segment
org 2000h
series db 12h,11h,09h,05h,23h,99h,86h
count dw 07h
max db 00h
min db 00h
data ends
code segment
start:mov ax,data
mov ds,ax
mov cx,count
lea si,series
mov al,[si]
mov bl,al
go:inc si
cmp [si],al
jl min_val
mov al,[si]
jmp nxtp
min_val:cmp [si],bl
jg nxtp
mov bl,[si]
nxtp:loop go
mov max,al
mov min,bl
mov ah,4ch
int 21h
code ends
end start

Assembly language program to convert binary number to BCD using 8086 using procedures

ASSUME  CS:CODE, DS:DATA, SS:STACK1
DATA    SEGMENT
SERIES  DB 74H,29H,4AH,3BH
BCD_OUT DW 04H DUP(0H)
BCD     EQU 04H
DATA    ENDS
STACK1 SEGMENT
BALARAM DW 40H DUP(0H)
TOP_STACK LABEL WORD
STACK1 ENDS
CODE SEGMENT
START:  MOV AX, DATA
        MOV DS, AX
        MOV AX, STACK1
        MOV SS, AX
        LEA SI, SERIES
        LEA DI, BCD_OUT
        LEA SP, TOP_STACK
        MOV CH, BCD
        CALL BIN_BCD
        MOV AH, 4CH
        INT 21H
BIN_BCD PROC NEAR
PUSHF
PUSH AX
PUSH BX
PUSH CX
NXT_VALUE: MOV AL, [SI]
           MOV AH, 0H
           MOV CL, 64H
           DIV CL
           MOV BH, AL
           MOV AL, AH
           MOV AH, 0H
           MOV CL, 0AH
           DIV CL
           MOV CL, 04H
           ROR AL, CL
           MOV BL, AH
           ADD BL, AL
           MOV [DI], AX
           INC SI
           ADD DI, 02
           DEC CH
           JNZ NXT_VALUE
           POP CX
           POP BX
           POP AX
           POPF
           RET
           BIN_BCD ENDP
           CODE ENDS
           END START


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...