MPMC Programs
MPMC Programs
MPMC Programs
By samba
Only for reference
By samba
Only for reference
By samba
Only for reference
in AX and BL.
By samba
Only for reference
RESULT:
Inputs: 34H, 12H
Outputs:
Addition: 46h
Subtraction: DEH
Multiplication: 03A8H
By samba
Only for reference
By samba
Only for reference
By samba
Only for reference
address.
RESULT:
Inputs: 5678H, 1234H
Outputs:
Addition: 68ACH
Subtraction: 4444H
Multiplication: 06260060H
By samba
Only for reference
32-Bit Addition
ADDRESS OPCODE LABEL MNEMONIC OPERANDS COMMENTS
By samba
Only for reference
BX to 300A
address.
RESULT:
Inputs: 12345678H,87654321 H
Output:
Addition: 99999999H
By samba
Only for reference
32-Bit Subtraction
ADDRESS OPCODE LABEL MNEMONIC OPERANDS COMMENTS
By samba
Only for reference
BX to 300A
address.
RESULT:
Inputs: 56781234H,12345678H
Output:
Subtraction: 4443BBBCH
By samba
Only for reference
2016 F4 HLT
Halt the program
By samba
Only for reference
Factorial of a number
ADDRESS OPCODE LABEL MNEMONIC OPERANDS COMMENTS
Multiply data in
200D F7E1 L2: MUL CX CX,AX.
RESULT
INPUT 04H
OUTPUT 18H
By samba
Only for reference
MASM PROGRAMS
By samba
Only for reference
By samba
Only for reference
sub al,num2
adc ah,00h
mov diff,al
mov brw,ah
xor ah,ah
mov al,num1
mul num2
mov pro,ax
xor ah,ah
mov al,num1
div num2
mov quo,al
mov rem,ah
mov ax,4ch
int 21h
end start
end
RESULT:
INPUTS: 87H, 66H
OUTPUTS: Sum-0EDH
Carry-00H
Diff-21H
Brw-0H
Pro-35CAH
Quo-01H
Rem-21H
By samba
Only for reference
By samba
Only for reference
xor bx,bx
sub ax,b
jnb l1
dec bx
l1: mov diff,ax
mov brw,bx
mov ax,4ch
int 21h
end start
end
RESULT:
INPUTS: 1287H, 5666H
OUTPUTS: Sum-68EDh
Carry-0000H
Diff-BC21H
Brw-0001H
Pro1-0BBCAH
Pro2-0640H
Quo-0004H
Rem-043DFH
By samba
Only for reference
By samba
Only for reference
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: 22223000H, 1111F222H
OUTPUTS: sum1 -2222H
sum2 -3334H
car - 0000H
Subtraction
.dosseg
.model small
.stack 100h
.data
a1 dw 3000h
a2 dw 2222h
b1 dw 0f222h
b2 dw 1111h
diff1 dw ?
diff2 dw ?
brw db ?
.code
mov ds,ax
By samba
Only for reference
mov bl,00h
mov ax,a1
sub ax,b1
mov diff1,ax
mov ax,a2
sbb ax,b2
jnb l2
dec bl
mov brw,bl
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: 22223000H, 1111F22
diff2 -1110H
brw -0000H
By samba
Only for reference
Signed Multiplication
.dosseg
.model small
.stack 100h
.data
a1 db -2h
b1 db -6h
a2 dw -2370h
b2 dw 2307h
pro dw ?
pro1 dw ?
pro2 dw ?
.code
mov ds,ax
mov al,a1
mov ah,00h
imul b1
mov pro,ax
xor dx,dx
mov ax,a2
imul b2
mov pro1,ax
mov pro2, dx
By samba
Only for reference
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: - 2H,-6H, -2370H, 2307H
OUTPUTS: Pro-0CH
Pro1-0B7F0H
Pro2-0FB26H
Signed Division
.dosseg
.model small
.stack 100h
.data
x1 db -64h
x2 db -08h
y1 dw -7856h
y2 dw -1234h
q1 db ?
rem1 db ?
q2 dw ?
rem2 dw ?
.code
By samba
Only for reference
mov ds,ax
mov ah,00h
mov al,x1
idiv x2
mov q1,al
mov rem1,ah
xor dx,dx
mov ax,y1
idiv y2
mov q2,ax
mov rem2,dx
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: - 64H,-08H, -7856H, -1234H
OUTPUTS: q1-000CH
Rem1-0FFA4H
q2- 0006H
Rem2-99EEH
By samba
Only for reference
.model small
.stack 100h
.data
num1 db 01h,02h,03h,04h,05h
num2 db 06h,07h,08h,09h,0Ah
sum db ?
cary db ?
.code
mov ds,ax
mov cl,05h
xor ax,ax
xor dl,dl
xor bx,bx
mov dl,[bx]
adc al,dl
mov [di],al
inc si
By samba
Only for reference
inc bl
inc di
loop l2
adc ah,00h
mov cary,ah
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: num1- 01H,02H,03H,04H,05H
num2- 06H,07H,08H,09H,0AH
OUTPUTS: sum-07H,09H,0BH,0DH,0FH
Cary-00H
By samba
Only for reference
.dosseg
.model small
.stack 100h
.data
num1 dw -0003h,1230h,0159h,2579h
cnt db 04h
post dw ?
negt dw ?
.code
mov ds,ax
mov cl,cnt
mov bx,0000h
mov dx,0000h
shl ax,01h
jc l1
inc bx
jmp l2
l1: inc dx
By samba
Only for reference
dec cl
jnz again
mov negt,dx
mov post,bx
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: - 0003H,1230H,0159H,2579H
OUTPUTS: post-03H
negt- 01H
By samba
Only for reference
.model small
.stack 100h
.data
num1 dw 2357h,0A59h,0C322h,0957h
cnt db 04h
oddf dw ?
evenf dw ?
.code
mov ds,ax
mov cl,cnt
mov bx,0000h
mov dx,0000h
ror ax,01
jc l1
inc bx
jmp l2
l1: inc dx
dec cl
By samba
Only for reference
jnz l3
mov oddf,dx
mov evenf,bx
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: 2357H,0A59H,0C322H,0957H
OUTPUTS: oddf-03H
Evenf-01H
By samba
Only for reference
.model small
.stack 100h
.data
num1 dw 005Eh,007Dh,0002h,0010h
cnt dw 0004h
.code
mov ds,ax
mov dx,cnt-1
cmp ax,[si+2]
jl l1
xchg [si+2],ax
xchg [si],ax
loop l2
dec dx
jnz l3
mov ah,4ch
By samba
Only for reference
int 21h
end start
end
RESULT:
INPUTS: 005EH, 007DH, 0002H, 0010H
.model small
.stack 100h
.data
res dw ?
.code
mov ds,ax
mov al,"9"
mov bl,"9"
add al,bl
AAA
add ax,3030h
mov res,ax
By samba
Only for reference
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: 09H,09H
OUTPUTS: res-3138H
Subtraction
.dosseg
.model small
.stack 100h
.data
res dw ?
.code
mov ds,ax
xor ax,ax
xor bx,bx
mov al,"9"
mov bl,"4"
sub al,bl
AAS
add ax,3030h
By samba
Only for reference
mov res,ax
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: 09H,04H
OUTPUTS: res-3035H
Multiplication
.dosseg
.model small
.stack 100h
.data
res db ?
.code
mov ds,ax
xor ax,ax
xor bx,bx
mov al,"2"
mov bl,"3"
mul bl
AAM
By samba
Only for reference
add ax,3030h
mov res,al
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: 02H,03H
OUTPUTS: res-3036H
Division
.dosseg
.model small
.stack 100h
.data
quo db ?
rem db ?
.code
mov ds,ax
xor ax,ax
xor bx,bx
mov al,"4"
mov bl,"2"
By samba
Only for reference
div bl
AAD
add ax,3030h
mov quo,al
mov rem,ah
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: 04H,02H
OUTPUTS: res-3032H
By samba
Only for reference
.model small
.stack 100h
.data
a db 98h
res db ?
.code
mov ds,ax
mov cl,04h
mov al,a
mov bl,0F0h
and al,bl
ror al,cl
mov[di],al
mov al,a
mov bl,0Fh
and al,bl
mov [di+1],al
mov ah,4ch
int 21h
By samba
Only for reference
end start
end
RESULT:
INPUTS: 98H
OUTPUTS: 0908H
.model small
.stack 100h
.data
a db 98h
res db ?
.code
mov ds,ax
mov cl,04h
mov al,a
mov bl,0F0h
and al,bl
ror al,cl
add al,30h
mov [di],al
By samba
Only for reference
mov al,a
mov bl,0Fh
and al,bl
add al,30h
mov [di+1],al
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: 98H
OUTPUTS: 3938H
By samba
Only for reference
By samba
Only for reference
RESULT:
INPUTS: arr1- 59H,27H,03H,56H
OUTPUTS: arr2- 59H,27H,03H,56H
Length of a string
.dosseg
.model small
.stack 100h
.data
string1 db "usha$"
stringlen db ?
.code
start: mov ax,@data
mov ds,ax
mov cl,00h
mov si,offset string1
mov al,"$"
l2: cmp al,[si]
je l1
inc cl
inc si
jmp l2
l1: mov stringlen,cl
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: "usha$"
OUTPUTS: 04H
By samba
Only for reference
Reverse of a string
.dosseg
.model small
.stack 100h
.data
string1 db "usha$"
stringlen db ?
.code
mov ds,ax
mov cl,00h
mov al,"$"
je l1
inc cl
inc si
jmp l2
dec si
shr cl,01h
xchg al,[si]
By samba
Only for reference
mov [bx],al
inc bl
dec si
loop l3
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: "usha$"
OUTPUTS: ahsu
.model small
.stack 100h
.data
string1 db "madam$"
mes1 db "palindrome$"
mes2 db "notpalindrome$"
.code
mov ds,ax
mov cl,00h
By samba
Only for reference
mov al,"$"
l: mov al,[si]
cmp al,"$"
jz l1
inc cl
inc si
jmp l
l1: dec si
shr cl,01h
cmp ah,[si]
jnz l2
inc bx
dec si
loop l3
jmp last
int 21h
mov ah,4ch
int 21h
end start
By samba
Only for reference
end
RESULT:
INPUTS: "madam$"
OUTPUTS: palindrome
.model small
.stack 100h
.data
st1 db "rama$"
st2 db "ram$"
mes1 db "equal$"
mes2 db "notequal$"
.code
mov ds,ax
mov cl,00h
xor dl,dl
l: mov dh,[si]
cmp dh,"$"
By samba
Only for reference
jz l1
inc dl
inc si
jmp l
cmp ch,"$"
jz l2
inc bx
inc cl
jmp l1
jnz nope
cmp al,[bx]
jnz nope
inc si
inc bx
loop l3
jmp last
By samba
Only for reference
int 21h
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: “rama$",”ram$”
.model small
.stack 100h
.data
string1 db "god$"
.code
mov ds,ax
mov cl,00h
mov al,"$"
je l1
By samba
Only for reference
inc cl
inc si
jmp l2
l1: dec si
mov bh,03h
sub cl,bh
add cl,01h
mov [si+1],dl
dec si
loop l3
mov al,"o"
mov [si+1],al
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: "god$"
OUTPUTS: good
By samba
Only for reference
.model small
.stack 100h
.data
string1 db "life$"
.code
mov ds,ax
mov cl,00h
mov al,"$"
je l1
inc cl
inc si
jmp l2
sub cl,bl
mov bh,cl
l4: dec si
loop l4
mov bh,cl
By samba
Only for reference
mov [si-1],al
inc si
loop l3
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: "life$"
OUTPUTS: lie
.dosseg
.model small
.stack 100h
.data
a db ?
.code
mov ds,ax
mov ah,01h
int 21h
By samba
Only for reference
mov a,al
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: a
OUTPUTS: a
.dosseg
.model small
.stack 100h
.data
a db ?
.code
mov ds,ax
mov ah,07h
int 21h
mov a,al
By samba
Only for reference
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: a
OUTPUTS: a(It will take the character but it won’t be echoed on monitor)
.model small
.stack 100h
.data
a db "u"
.code
mov ds,ax
mov dl,a
mov ah,02h
int 21h
mov ah,4ch
int 21h
end start
By samba
Only for reference
end
RESULT:
INPUTS: u
OUTPUTS: u
.model small
.stack 100h
.data
sr db "mpmc$"
.code
mov ds,ax
LEA dx,sr
mov ah,09h
int 21h
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: "mpmc$"
OUTPUTS: mpmc
By samba
Only for reference
.model small
.stack 100h
.data
sr db ?
.code
mov ds,ax
LEA dx,sr
mov ah,0Ah
int 21h
mov ah,4ch
int 21h
end start
end
RESULT:
INPUTS: “josh$”
OUTPUTS: josh
By samba
Only for reference
4. 8279-Keyboard display
6. 8251/8253-USART
By samba
Only for reference
8255(PPI)-1
To configure port A, port B as output ports
ADDRESS OPCODE LABEL MNEMONIC OPERANDS
2000 B0 80 MOV AL,80H
2015 F4 HLT
By samba
Only for reference
8255(PPI)-2
To configure port A as output and port B as
input port to find the complement of a number
2009 EC IN DX,0080H
By samba
Only for reference
8255(PPI)-3
To configure port A as output and port B as input
port to find the factorial of a number
ADDRESS OPCODE LABEL MNEMONIC OPERANDS
2000 B0 82 MOV AL,82H
2009 EC IN AL,DX
2017 43 INC BX
2018 E2 FB LOOP L2
201E EB E6 JMP L1
2021 F4 HLT
By samba
Only for reference
8279-Keyboard display
PROGRAM TO DISPLAY THE VALUE OF THE KEY PRESSED
IN THE DISPLAY FIELD USING ENCODE METHOD
ORG 2000H
MOVW SI,#3000
MOVB AL,#00
OUTB DX,AL
MOVB AL,#90
OUTB DX,AL
MOVW CX,#08
OUTB DX,AL
LOOP 200F
MOVW DX,#82
INB AL,DX
ANDB AL,#07
JZ 2017
MOVW SI,#3000
OUTB DX,AL
MOVW DX,#80
By samba
Only for reference
INB AL,DX
ANDB AL,#1F
MOVB AH,#00
MOVW CX,AX
ADDW SI,CX
MOVW DX,#82
MOVW DX,#80
MOVB AL,#F3
OUTB DX,AL
MOVW DX,#82
MOVB AL,#95
OUTB DX,AL
MOVW DX,#80
MOVB AL,[SI]
OUTB DX,AL
JMP 2017
ORG 3000H
LOOP: DB 0F3H,60H,0B5H,0F4H,66H
DB 0D6H,0D7H,70H,0F7H,76H
DB 77H,0C7H,93H,0E5H,97H
DB 17H,00H,76H,77H,0C7H
DB 93H,0E5H,97H,17H,00H
By samba
Only for reference
ORG 2000H
MOVW ES, AX
MOVW SS, AX
ES
ES
ES
ES
ES
ES
ES
By samba
Only for reference
ES
ES
ES
ES
ES
ES
ES
ES
ES
EE
By samba
Only for reference
OUTB DX
JMP 20A8
DB 0A ,0A
By samba
Only for reference
DB 0D
ASC ’INTERRUPT - ‘
DB 00
ASC ‘OCCURRED ! ‘
DB 00
CLI
CS
MOVW AX,DX
CALLS FE00:1B55
CALLS FE00:1B50
CS
MOVW AX, DX
CALLS FE00:1B55
INT3
CLI
CS
MOVW AX,DX
By samba
Only for reference
CALLS FE00:1B55
CALLS FE00:1B50
CS
MOVW AX,DX
CALLS FE00:1B55
INT3
CLI
CS
MOVW AX,DX
CALLS FE00:1B55
CALLS FE00:1B50
CS
MOVW AX,DX
CALLS FE00:1B55
INT3
CLI
CS
By samba
Only for reference
MOVW AX,DX
CALLS FE00:1B55
CALLS FE00:1B50
CS
MOVW AX,DX
CALLS FE00:1B55
INT3
CLI
CS
MOVW AX,DX
CALLS FE00:1B55
CALLS FE00:1B50
CS
MOVW AX,DX
CALLS FE00:1B55
INT3
CLI
CS
By samba
Only for reference
MOVW AX,DX
CALLS FE00:1B55
CALLS FE00:1B50
CS
MOVW AX,DX
CALLS FE00:1B55
INT3
CLI
CS
MOVW AX,DX
CALLS FE00:1B55
CALLS FE00:1B50
CS
MOVW AX,DX
CALLS FE00:1B55
INT3
CLI
CS
By samba
Only for reference
MOVW AX,DX
CALLS FE00:1B55
CALLS FE00:1B50
CS
MOVW AX,DX
CALLS FE00:1B55
INT3
RESULT:
Input: Interrupt 3(set the dip switch in interfacing kit)
By samba
Only for reference
8251/8253-USART
TO DISPLAY "WELCOME TO GSAS STUDY CARD"
FOR 9600 BAUD.
ORG 2000H
MOV AL,36
MOV DX,0086
OUT DX,AL
MOV AL,0A
OUT DX,AL
MOV AL,00
OUT DX,AL
MOV SP,3000
OUT DX,AL
OUT DX,AL
OUT DX,AL
OUT DX,AL
CALL 304A
By samba
Only for reference
OUT DX,AL
CALL 304A
MOV AL,CE
OUT DX,AL
CALL 304A
MOV AL,27
OUT DX,AL
CALL 304A
MOV SI,3100
IN AL,DX
AND AL,81
CMP AL,81
JNE 3031
MOV AL,[SI]
INC SI
CMP AL,00
JE 3049
MOV DX,0090
OUT DX,AL
JMP 3031
INT 03
ORG 2100H
DB 0A,0A
DB 0A,0A
By samba
Only for reference
DB 0A,0A
DB 0A,0A
DB 20,20
DB 20,20
DB 20,20
DB 20,20
RESULT:
Output: WELCOME TO GSAS STUDY CARD (displayed on the monitor)
By samba
Only for reference
4. Timer program
By samba
Only for reference
Mov dptr,#1000h
Mov r0,#0ah
Mov a,#00h
Mov r1,a
Mov p0,a
Inc r1
Mov a,r1
Dec r0
Cjne r0,#00h,loop
Org 1000h
Db 23h,44h,98h,65h,03h,93h,82h,04h,00h,07h
End
RESULT:
Output : 23h,44h,98h,65h,03h,93h,82h,04h,00h,07h is written into port0
By samba
Only for reference
mov a,p0
mov r0,a
mov r1,#60h
loop: mov a,p0
mov @r1,a
inc r1
dec r0
cjne r0,#00h,loop
end
RESULT:
Given input: 33h, 04h, 06h
By samba
Only for reference
RESULT:
Expected output: NEEHA
By samba
Only for reference
Timer program
Setb tr0
Mov tmod,#06h
Clr tr0
Setb tr0
Mov tmod,#04h
Clr tr0
Setb tr0
Mov tmod,#05h
Clr tr0
Setb tr0
Mov tmod,#07h
Clr tr0
Setb tr0
Mov tmod,#00h
Clr tr0
End
RESULT:
00000110: 8 bit counter mode
By samba
Only for reference
**********************************************************************************/
#include <REG51xD2.H>
#include "lcd.h"
main()
while(1)
By samba
Only for reference
P0=0x0ff;
P1=0x0ff;
scanline */
t = ~t;
t >>=1;
By samba
Only for reference
t = k>>4;
t +=0x30;
t = k & 0x0f;
if(t > 9)
t+=0x37;
else
t+=0x30;
RESULT:
Input: 06(key pressed in the keyboard)
By samba
Only for reference
Object : To demonstrate how to generate square wave using ESA Dual DAC interface.
Output: Generates the square wave with 2.5v amplitude. User can change the amplitude and
*****************************************************************************/
#include <REG51xD2.H>
#include "lcd.h"
for(;x>0;x--);
main()
/*`````````````````````````````````````````````111 */
By samba
Only for reference
while(1)
fre = 100;
P1=on;
delay(fre);
P1 = off;
delay(fre);
RESULT:
OUTPUT: Square wave is displayed on CRO
By samba
Only for reference
Object : To demonstrate how to generate a triangular wave form using ESA Dual DAC
interface.
*******************************************************************/
#include <REG51xD2.H>
#include "lcd.h"
main()
while(1)
P1 = i;
P0 = i; }
{P0 = i;
P1 = i;}
RESULT:
OUTPUT: Triangular wave is displayed on CRO
By samba
Only for reference
Object : To display the Digital value for the given Analog input
Connections : Connect the Interface and MCB51 board through 26 pin connector
working procedure :
On interface card move the nob of the variable register VR1 to set
the analog input signal . Press the STC key on the interface, To start
************************************************************************************/
#include <at89c51xd2.h>
#include <stdio.h>
void delay()
int l;
for (l=0;l<=0xfff;l++);
void main()
P1=0X00;
TMOD |= 0x20;
By samba
Only for reference
TH1 = 0xe6;
TR1 = 1;
while(1)
delay();
for(j=0x00;j<=0xff;j++)
if((k=P2&0x01)==0)
delay();
if(j>=0x0ff)
j=0x0ff;
RESULT:
Input: Analog value(kept in interfacing board using potentiometer)
Output: Digital value(displayed in the interfacing board using LEDs and also displayed on
monitor)
By samba