Pages

Search in This Blog

Thursday, 16 February 2012

Addition of two packed BCD numbers entered through keyboard


  • Write an 8086 program that adds two packed BCD numbers input from the keyboard and computes and displays the result on the system video monitor
  • Data should be in the form 64+89= The answer 153 should appear in the next line.
Program: 
Mov dx, buffer address
Mov ah,0a
Mov si,dx
Mov byte ptr [si], 8
Int 21
Mov ah,0eh
Mov al,0ah
Int 10 ;                               BIOS service 0e line feed position cursor
sub byte ptr[si+2], 30h
sub byte ptr[si+3], 30h
sub byte ptr[si+5], 30h
sub byte ptr[si+6], 30h
Mov cl,4
Rol byte ptr [si+3],cl
Rol byte ptr [si+6],cl
Ror word ptr [si+2], cl
Ror word ptr [si+2], cl
Mov al, [si+3]
Add al, [si+6]
Daa
Mov bh,al
Jnc display
Mov al,1
Call display
Mov al,bh
Call display
Int 20
Display Subroutine:
mov bl,al ;         Save original number and al,f0 ;Force bits 0-3 low
mov cl,4 ;           Four rotates
ror al,cl ;             Rotate MSD into LSD
add al,30 ;          Convert to ASCII
mov ah,0e ;       BIOS video service 0E
int 10 ;                Display character
mov al,bl ;          Recover original number
and al,0f ;           Force bits 4-7 low
add al,30 ;          Convert to ASCII
int 10 ;                 Display character
ret ;                      Return to calling program
                                                   ;
                                                             ;Input buffer begins here

Wednesday, 15 February 2012

interfacing 7 segment display with 8086 processor


Statement: Program to interface 8086 microprocessor kit with Seven Segment Display and make any digit to Blink
Description:
In this program we interface 8086 microprocessor with Seven Segment Display and diaplay a digit.  To interface with Seven Segment Display,we must be familiar with 8255A PPI, which has three ports which can be used as I/O ports. The ports A, B and C are identified using addresses 19H, 1BH, and 1DH respectively and control register address is 1FH. We use Seven Segment Display structure using the following digit



Digit
Hexadecimal
Decimal
Binary
8
0
1
2
3
4
5
6
7
8
9
C0
F9
A4
B0
99
92
82
F8
80
90
192
249
164
176
153
146
130
248
128
144
11000000
11111001
10100100
10110000
10011001
10010010
10000010
11111000
10000000
10010000
code: 

Source program:
 MOV AL,10000000B
 OUT PPI_C, AL
STR:   MOV AL, 10011001B
 OUT PPIA,AL
 MOV CX, FFFFH
DEL:    NOP
 NOP
 NOP
 LOOP DEL
 MOV AL, 11111111B
 OUT PPIA, AL
 MOV CX, FFFFH
DEL1:    NOP
 NOP
 NOP
 LOOP DEL1
 JMP  STR
 HLT

Sunday, 12 February 2012

Traffic light programming in assembly for 8086








; Traffic ligts test 2 for
; c:\emu8086\devices\Traffic_Lights.exe

; This is just an example of how to set the lights,
; DO NOT RUN AT MAXIMUM SPEED, DO NOT USE REAL CARS.
;)


#start=Traffic_Lights.exe#

name "traffic2"

yellow_and_green equ      0000_0110b
red              equ      0000_0001b
yellow_and_red   equ      0000_0011b
green            equ      0000_0100b

all_red          equ      0010_0100_1001b

start:
nop


; 0,1,2

mov ax, green
out 4, ax

mov ax, yellow_and_green
out 4, ax

mov ax,red
out 4, ax

mov ax, yellow_and_red
out 4, ax


; 3,4,5

mov ax, green << 3
out 4, ax

mov ax, yellow_and_green << 3
out 4, ax

mov ax,red << 3
out 4, ax

mov ax, yellow_and_red << 3
out 4, ax



; 6,7,8

mov ax, green << 6
out 4, ax

mov ax, yellow_and_green << 6
out 4, ax

mov ax,red << 6
out 4, ax

mov ax, yellow_and_red << 6
out 4, ax



; 9,A,B

mov ax, green << 9
out 4, ax

mov ax, yellow_and_green << 9
out 4, ax

mov ax,red << 9
out 4, ax

mov ax, yellow_and_red << 9
out 4, ax


; all

mov ax, all_red
out 4, ax

mov ax, all_red << 1  ; all yellow
out 4, ax

mov ax, all_red << 2  ; all green :)
out 4, ax


jmp start