Eee MP & MC Lab Manual
Eee MP & MC Lab Manual
INTRODUCTION TO MASM/TASM
ASSEMBLY LANGUAGE PROGRAMMING USING MASM SOFTWARE:
The programs are written using assembly language in editor then compile it. The complier
converts assembly language statements into machine language statements/checks for errors.
Then execute the compiled program.
There are different soft wares developed by different companies for assembly language
programming, they are:
MERITS OF MASM:
Path setting
Suppose it display path as Z:\>
Then type MOUNT C C:\ MASM then drive c is mounted as local directory C:\MASM\
INPUT I port
QUIT Q
REGISTER R [register]
UNASSEMBLE U [range]
FLOW CHART:
START
Initialize DS
AL Data1
BL Data2
AL AL+BL
Data Memory AL
AL Data1
AL AL-BL
Data Memory AL
AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 3
Data Memory AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.
AL Data1
AX AL*BL
Data Memory AX
AL Data1
AH 00H
AX AX / BL
Data Memory AX
STOP
Exp No:
Date:
ABSTRACT: Assembly language program to perform all arithmetic operations on 8-bit data
PORTS USED: None
REGISTERS USED: AX, BL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load the given data to registers AL& BL
Step 4: Perform addition and Store the result
Step 5: Repeat step 3
Step 6: Perform subtraction and Store the result
Step 7: Repeat step 3
Step 8: Perform multiplication and Store the result
Step 9: Repeat step 3
Step 10: Perform division and Store the result
Step 11: stop.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 EQU 04H
N2 EQU 06H
RESULT DB 06H DUP (00)
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
MOV AL, N1
MOV BL, N2
ADD AL, BL
MOV [RESULT], AL
MOV AL, N1
SUB AL, BL
MOV [RESULT+1], AL
MOV AL, N1
MUL BL
MOV [RESULT+2], AL
MOV [RESULT+3], AH
MOV AL, N1
MOV AH, 00H
DIV BL
MOV [RESULT+4], AL
MOV [RESULT+5], AH
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
SI 5000H
AX Data1
BX Data2
AX AX+BX
[SI] AX
AX Data1
AX AX-BX
[SI+2] AX
AX Data1
AX, DX AX*BX
[SI+4] AX, DX
AX Data1
DX 0000H
AX, DX DX: AX / BX
[SI+8] AX, DX
STOP
AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 8
Data Memory AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.
Exp No:
Date:
2. ARITHMETIC OPERATIONS ON 16BIT DATA
ABSTRACT: Assembly language program to perform all arithmetic operations on 16bit data
PORTS USED: None
REGISTERS USED: AX, BX, SI
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Initialize SI with some memory location
Step 4: Load the given data to registers AX & BX
Step 5: Perform addition and Store the result
Step 6: Repeat step 4
Step 7: Perform subtraction and Store the result
Step 8: Repeat step 4
Step 9: Perform multiplication and Store the result
Step 10: Repeat step 4
Step 11: Perform division and Store the result
Step 12: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 EQU 8888H
N2 EQU 4444H
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
MOV SI, 5000H
MOV AX, N1
MOV BX, N2
ADD AX, BX
MOV [SI], AX
MOV AX, N1
SUB AX, BX
MOV [SI+2], AX
MOV AX, N1
MUL BX
MOV [SI+4], AX
MOV [SI+6], DX
MOV AX, N1
MOV DX, 0000H
DIV BX
MOV [SI+8], AX
MOV [SI+0AH], DX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
Initialize Data1, Data2
CX COUNT
BX COUNT-1
AL Data1 [BX]
Data memory AL
BX BX-1
CX CX-1
NO
CX=
0 YES
CX COUNT
BX COUNT-1
AL Data1 [BX]
Data memory AL
BX BX-1
CX CX-1
NO
CX=
YES
0
STOP
AL Data1[bx]+Data2[bx]
AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 12
Data
Datamemory
Memory AL
AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.
Exp No:
Date:
3. MULTIBYTE ADDITION AND SUBTRACTION
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 DB 33H, 33H, 33H
N2 DB 11H, 11H, 11H
COUNT EQU 0003H
SUM DB 03H DUP (00)
DIFF DB 03H DUP (00)
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
MOV DS, AX
MOV CX, COUNT
MOV BX, 0002H
CLC
BACK: MOV AL, N1 [BX]
ADC AL, N2 [BX]
MOV SUM [BX], AL
DEC BX
LOOP BACK
MOV CX, COUNT
MOV BX, 0002H
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
CLC
BACK1: MOV AL, N1 [BX]
SBB AL, N2 [BX]
MOV DIFF [BX], AL
DEC BX
LOOP BACK1
MOV AH, 4CH
INT 21H
CODE ENDS
END START
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
AL Data1
BL Data2
AL 2`S Complement of AL
AX AL*BL
Data memory AX
AL Data1
AL 2`S Complement of AL
AX signed AL
AX AX/BL
Data memory AX
STOP
AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 16
Data Memory AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.
Decrement
Exp No: CX, if CX
Date: not equal
4. SIGNED to OPERATIONS
Zero ON 8 BIT DATA
jump to
ABSTRACT: Assembly language program to perform signed operations
step12
PORT USED: None
REGISTERS USED: AL, BL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load AL with first number
Step 4: Do 2’s compliment of AL
Step 5: Load BL with second number
Step 6: Perform signed Multiplication
Step 7: Store the result in data memory
Step 8: Load AL with first number
Step 9: Repeat step 4
Step 10: Convert AL to AX
Step 11: Perform signed division
Step 12: Store the result in data memory
Step 13: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 DB 08H
N2 DB 04H
RESULT DW 02 DUP (00)
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
XOR AX, AX
MOV AL, N1
NEG AL
MOV BL, N2
IMUL BL
MOV [RESULT], AX
MOV AL, N1
NEG AL
CBW
IDIV BL
MOV [RESULT+2], AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
AL ASCII 1
BL ASCII 2
AL AL+BL
ASCII Adjustment after addition
Data Memory AX
AL ASCII 1
AL AL-BL
ASCII Adjustment after subtraction
Data Memory AX
AL Data1
BL Data2
AX AL*BL
ASCII Adjustment after Multiplication
Data Memory AX
STOP
AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 20
Data Memory AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.
Exp No:
Date:
5. ASCII ARITHMETIC OPERATIONS
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N1 DB ‘8’
N2 DB ‘4’
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
MOV DS, AX
MOV SI, 5000H
XOR AX, AX
MOV AL, N1
MOV BL, N2
ADD AL, BL
AAA
MOV [SI], AX
MOV AL, N1
MOV AH, 00
SUB AL, BL
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
AL BCD Num
CL 04H
AH AL
AL ALAND 0FH
AH AH AND F0H
AH Rotate AH by CL
times
AL AL OR 30H
AH AH OR 30H
Data Memory AX
STOP
Exp No:
Date:
6. BCD TO ASCII CONVERSION
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
BCD DB 17H
ASCII DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
MOV DS, AX
MOV AL, BCD
MOV CL, 04
MOV AH, AL
AND AL, 0FH
AND AH, 0F0H
ROR AH, CL
OR AL, 30H
OR AH, 30H
MOV ASCII, AX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
AL ASCII 1
BL ASCII 2
CL 04H
AL AL AND 0FH
BL BL AND 0FH
AL rotate AL by CL times
AL AL OR BL
Data Memory AL
STOP
Exp No:
Date:
7. ASCII TO BCD CONVERSION
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
ASCII1 DB ‘1’
ASCII2 DB ‘7’
BCD DB ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
MOV DS, AX
MOV CL, 04H
MOV AL, ASCII1
MOV BL, ASCII2
AND AL, 0FH
AND BL, 0FH
ROR AL, CL
OR AL, BL
MOV BCD, AL
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
CX COUNT
SI address of LIST
DX 0000H
AL [SI]
YES NO
CF=1
DL DL+1
DH DH+1
SI SI +1
SI SI+1
CX CX-1
NO
CX=0
YES
Data memory DX
STOP
Exp No:
Date:
8. NUMBER OF POSITIVE AND NEGATIVE NUMBERS
ABSTRACT: Assembly language program to count number of positive and negative numbers
PORT USED: None
REGISTERS USED: SI, DX, CX, AL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load CX register with count value
Step 4: Initialize DX with 0000h
Step 5: Load SI with offset list
Step 6: Copy the contents from memory location SI to AL
Step 7: Rotate left the content of AL
Step 8: Jump to step13 if carry
Step 9: Increment DL
Step 10: Increment SI
Step 11: Decrement CX and jump to step6 if no zero
Step 12: Jump to step16
Step 13: Increment DH
Step 14: Increment SI
Step 15: Decrement CX and jump to step6 if no zero
Step 16: Store the result to the data memory
Step 17: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB 0FFH, 0DDH, 04H, 05H, 98H
RESULT DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
LEA SI, LIST
MOV CX, 0005H
MOV DX, 0000H
BACK: MOV AL, [SI]
ROL AL, 01H
JC NEGATIVE
INC DL
INC SI
LOOP BACK
JMP EXIT
NEGATIVE: INC DH
INC SI
LOOP BACK
EXIT: MOV [RESULT], DX
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
CX COUNT
SI Offset LIST
DX 0000H
AL [SI]
AL Cir right AL
NO
YES
CF=1
DH DH+1 DL DL+1
SI SI+1 SI SI +1
CX CX-1
NO
CX=0
YES
Data memory DX
STOP
AL Data1[bx]+Data2[bx]
AL AL*BL
ADITYA COLLEGE OF ENGINEERING & TECHNOLOGY Page 36
Data
Datamemory
Memory AL
AL
MICROPROCESSORS & MICROCONTROLLERS LAB RECORD ECE Dept.
Exp No:
Date:
9. NUMBER OF ODD AND EVEN NUMBERS
ABSTRACT: Assembly language program to count number of odd and even numbers
PORT USED: None
REGISTERS USED: AL, CX, DL, DH, SI
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment
Step 3: Load CX register with count
Step 4: Initialize DX with 0000
Step 5: Load SI with offset list
Step 6: Copy the contents from memory location SI to AL
Step 7: Rotate right the content of AL
Step 8: Jump to step13 if carry
Step 9: Increment DL
Step 10: Increment SI
Step 11: Decrement CX and jump to step6 if no zero
Step 12: Jump to step16
Step 13: Increment DH
Step 14: Increment SI
Step 15: Decrement CX and jump to step6 if no zero
Step 16: Store the result to the data memory
Step 17: Stop
PROGRAM:-
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB 05H,01H,03H,04H,08H,02H
COUNT DW 0006H
RESULT DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV CX, COUNT
MOV DX, 0000H
MOV SI, OFFSET LIST
BACK: MOV AL, [SI]
ROR AL, 01H
JC ODD
INC DL
INC SI
LOOP BACK
JMP EXIT
ODD: INC DH
INC SI
LOOP BACK
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
AL Packed BCD
Num
CL 04H
BL AL
AL AL*0FH
BL BL *F0H
BL Cir BL by CL times
STOP
Exp No:
Date:
10. PACKED BCD TO UNPACKED BCD CONVERSION
ABSTRACT: Write a program to convert packed BCD number into Unpacked BCD number.
REGISTERS USED: AL, BL
PORTS USED: None.
ALOGARITHM:
Step 1: Start
Step 2: Initialize the data segment
Step 3: Copy packed number into AL register
Step 4: Copy packed number into BL register
Step 5: Initialize the count CX with 04h
Step 6: Perform AND operation on AL with 0Fh
Step 7: Perform AND operation on BL with 0F0h
Step 8: Rotate right without carry operation on BL by CL times
Step 9: Move the result data memory
Step 10: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
N EQU 29H
RESULT DB 02H DUP (0)
DATA ENDS
CODE SEGMENT
ORG 2000H
START:
MOV AX, DATA
MOV DS, AX
MOV AL, N
MOV BL, N
MOV CL, 04H
AND AL, 0FH
AND BL, 0F0H
ROR BL, CL
MOV [RESULT], BL
MOV [RESULT+1], AL
MOV AH, 4CH
INT 21h
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS, ES
SI Offset string
DI Memory location
CX Count
ES: DI DS: SI
CX CX-1
SI SI+1
DI DI+1
NO
CX=
0
YES
STOP
Exp No
Date:
11. TRANSFER BLOCK OF DATA
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATA
DATA SEGMENT
LIST DB ‘ADITYA’
COUNT EQU 06H
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV CX, COUNT
MOV DI, 5000H
LEA SI, LIST
CLD
REP MOVSB
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOWCHART:
START
Initialize DS, ES
SI Offset string
BX 0002H
CX Count
DI Count-1
CX AX
AX AX/BL
CX AX
AL [SI]
AL [DI]
NO [SI] AL
SI SI+1
DI DI+1
CX CX-1
NO
CX=
0 YES
STOP
Exp No:
Date:
12. REVERSAL OF GIVEN STRING
ABSTRACT: Assembly language program to reverse a given string
PORT USED: None
REGISTERS USED: AX, BL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment & extra segment
Step 3: Load CX register with count
Step 4: Copy the contents from CX to AX
Step 5: Load SI with offset list
Step 6: Initialize DI with (count-1)
Step 7: Initialize BL with 02
Step 8: Perform division with BL
Step 9: Copy the contents from AX to CX
Step 10: Move the contents from memory location SI to AL
Step 11: Exchange the contents of AL with [DI]
Step 12: Move the contents from memory location AL to SI
Step 13: Increment SI
Step 14: Decrement DI
Step 15: Decrement CX and jump to step10 if no zero
Step 16: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB ‘MICRO PROCESSOR’
COUNT EQU ($-LIST)
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV CX, COUNT
MOV AX, CX
MOV SI, OFFSET LIST
MOV DI, (COUNT-1)
MOV BL, 02H
DIV BL
MOV AH, 00H
MOV CX, AX
BACK: MOV AL, [SI]
XCHG AL, [DI]
MOV [SI], AL
INC SI
DEC DI
LOOP BACK
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
CX Count
DX Count
SI Offset list
CX DX
AL [SI]
SI SI+1
Compare AL, [SI]
YES
CF=
1 NO
[SI] AL
SI SI-1
[SI] AL
CX CX-1
NO
CX=
0 YES
DX DX-1
NO
DX=
0 YES
STOP
Exp No:
Date:
13. SORTING OF ‘N’ NUMBERS
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
LIST DB 56H, 12H, 72H, 32H
COUNT EQU 0003H
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
MOV DS, AX
MOV CX, COUNT
MOV DX, CX
AGAIN: MOV SI, OFFSET LIST
MOV CX, DX
BACK: MOV AL, [SI]
INC SI
CMP AL, [SI]
JC NEXT
XCHG [SI], AL
DEC SI
MOV [SI], AL
INC SI
NEXT: LOOP BACK
DEC DX
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
JNZ AGAIN
MOV AH, 4CH
INT 21H
CODE ENDS
END START
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS, ES
DI Offset string
DX 0000H
AL NULL
Character
YES
ZF=
NO
0
DX DX+1
DI DI+1
Data memory DX
STOP
Exp No:
Date:
PROGRAM:
ASSUME CS: CODE, ES: DATA
DATA SEGMENT
LIST DB ‘ADITYA$’
LEN DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
MOV ES, AX
MOV AL,’$’
LEA DI, LIST
MOV DX, 0000H
CLD
BACK: SCASB
JE EXIT
INC DX
JMP BACK
EXIT: MOV LEN, DX
MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS, ES
SI Offset string1
DI Offset String2
AX Length1
BX Length2
Compare AX, BX
NO
ZF=
0 YES
CX AX
NO
ZF=0
YES
Data memory ‘Yes’
STOP
Exp No:
Date:
15. COMPARISON OF TWO STRINGS
ABSTRACT: Assembly language program to compare two strings.
PORT USED: None
REGISTERS USED: AX, BL
ALGORITHM:
Step 1: Start
Step 2: Initialize data segment & extra segment
Step 3: Load AX with length of String 1
Step 4: Load BX with length of String 2
Step 5: Compare AX with BX
Step 6: Jump step14 if not equal
Step 7: Copy the contents from AX to CX
Step 8: Load SI with first location of string 1
Step 9: Load DI with first location of string 2
Step 10: Repeat comparing string byte until count equals to zero
Step 11: jump to step 14 if not equal
Step 12: Store the result to the data memory
Step 13: Jump to step 15
Step 14: Store another result to the data memory
Step 15: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA, ES: DATA
DATA SEGMENT
LIST1 DB ‘ADITYA’
LEN1 EQU ($-LIST1)
LIST2 DB ‘ADITYA’
LEN2 EQU ($-LIST2)
RESULT DW ?
DATA ENDS
CODE SEGMENT
ORG 1000H
START:
MOV AX, DATA
MOV DS, AX
MOV ES, AX
MOV AX.LEN1
MOV BX, LEN2
CMP AX, BX
JNE EXIT
MOV CX, AX
MOV SI, OFFSET LIST1
MOV DI, OFFSET LIST2
CLD
REP CMPSB
JNE EXIT
MOV RESULT, 5555H
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
JMP NEXT
EXIT: MOV RESULT, 0FFFFH
NEXT: MOV AH, 4CH
INT 21H
CODE ENDS
END START
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
AL 13H
AH 00H
Interrupt 10H
AH 00H
Interrupt 10H
YES
ZF=
0 NO
BL 0FH
AH 14
Interrupt 10H
STOP
Exp No:
Date:
16. READING KEYBOARD BUFFERED WITH ECHO
ABSTRACT: To Read the Keyboard Buffered with Echo.
REGISTERS USED: AH, AL, SI
PORTS USED: None.
ALGORITHM:
Step 1: Start.
Step 2: Load the number 13h into AL register
Step 3: Initialize the AH register with 00h
Step 4: Display interrupt
Step 5: Initialize the AH register with 00h
Step 6: Key board Interrupt
Step 7: Compare the data in AL register with character ‘q’
Step 8: If equal to zero go to step 12
Step 9: Move the number 0Fh into BL register
Step 10: Move the number 14 into AH register
Step 11: Keyboard Interrupt
Step 12: Load the number 4C in AH register.
Step 13: Stop
PROGRAM:
ASSUME CS: CODE
CODE SEGMENT
ORG 1000H
START: MOV AH, 00H
MOV Al, 13H
INT 10H
BACK: MOV AH, 00H
INT 16H
CMP AL, ‘q’
JE EXIT
MOV BL, 0FH
MOV AH, 14
INT 10H
JMP BACK
EXIT: MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCLATIONS;
RESULT:
FLOW CHART:
START
Initialize DS, CS
SI 2000H
AH 00H
Interrupt 16H
YES
ZF=
0 NO
[SI] AL
[SI] [SI+1]
STOP
Exp No:
Date:
17. READING KEYBOARD BUFFERED WITHOUT ECHO
ABSTRACT: To read the string or character from keyboard without ECHO by using BIOS
Commands.
REGISTERS USED: AH, AL, SI
PORTS USED: None.
ALGORITHM:
Step 1: Start
Step 2: Initialize SI with Offset Result.
Step 3: Initialize AH with 00h
Step 4: Keyboard Interrupt
Step 5: Compare AL with character q
Step 6: Copy the contents AL into SI register
Step 7: If equal to zero go to step 10
Step 8: Increment SI
Step 9: Go to step 3 without condition
Step 10: Terminate the program
Step 11: Stop
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
ORG 3000H
RESULT DB 50H DUP (0)
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV SI, OFFSET RESULT
BACK: MOV AH, 00H
INT 16H
CMP AL, ‘q’
MOV [SI], AL
JE EXIT
INC SI
JMP BACK
EXIT: MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
FLOW CHART:
START
Initialize DS
SI Offset Text
AL 13h
AH 00H
Interrupt 10H
AL Text [SI]
Compare AL, ‘q’
YES
ZF=
0 NO
BL 0FH
AH 14
Interrupt 10H
[SI] [SI+1]
STOP
Exp No:
Date:
18. DISPLAY STRING BY USING DOS & BIOS COMMANDS
ABSTRACT: To display the string character by using BIOS commands.
REGISTER USED: AL, AH, SI.
PORTS USED: None
ALGORITHM:
Step 1: Start
Step 2: Set the screen in Graphic mode
Step 3: Initialize AH with 00h
Step 4: Set the keyboard display mode.
Step 5: Initialize SI with 0000h.
Step 6: Copy the contents SI into AL register.
Step 7: Compare AL register with null character ‘!’
Step 8: If equal go to step 11.
Step 9: Move the number 14 into AH register.
Step 10: Move the number 05h into BL register.
Step 11: Set keyboard display mode.
Step 12: Go to step 6.
Step 13: Terminate the program.
Step 14: Stop.
PROGRAM:
ASSUME CS: CODE, DS: DATA
DATA SEGMENT
TEXT DB ‘ADITYA MICROPROCESSORS LAB!'
DATA ENDS
CODE SEGMENT
ORG 1000H
START: MOV AX, DATA
MOV DS, AX
MOV AH, 00H
MOV AL, 13H
INT 10H
MOV SI, 00H
BACK: MOV AL, TEXT [SI]
CMP AL, ‘!'
JE EXIT
MOV BL, 05H
MOV AH, 14
INT 10H
INC SI
JMP BACK
EXIT: MOV AH, 4CH
INT 21H
CODE ENDS
END START
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
RESULT:
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
MANUAL CALCULATIONS:
Exp No:
Date:
RESULT:
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
RESULT:
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
ALGORITHM:
Step 1: Start
Step 2: Initialize the BL register as 00H.
Step 3: Move the contents of BL to AL.
Step 4: Write the AL value in Port.
Step 5: Increment the BL value and check if it is not zero go to step 2.
Step 6: Initialize the BL register as 0FFH.
Step 7: Move the contents of BL to AL.
Step 8: Write the AL value in Port.
Step 9: Decrement the BL register and check if it is not zero go to step 6.
Step 10: Go to step 2.
.
PROGRAM:
RESULT:
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
Exp No:
Date:
20. KEYBOARD INTERFACING
AIM: To display a string through interfacing 8279.
REGISTERS USED: AX, BX, CX, DX, SI
PORTS USED: command port, data port
CONNECTIONS: 8279 study card P1 to J2 of ESA 86/88 study card adapter.
ALGORITHM:
Step 1: Start
Step 2: Initialize keyboard and display mode in display mode by transferring 10H.
Step 3: Initialize clear display RAM with 0CCH.
Step 4: Initialize write display RAM with 90H
Step 5: Initialize CX with 10H.
Step 6: .Load SI with 1000H.
Step 7:.Move the content of SI to AL.
Step 8: Write AL onto C0H address location.
Step 9: Increment SI.
Step 10: Go to step 13.
Step 11: Go to step 7 if CX is not equal to 0.
Step 12: Jump to step 2.
Step 13: Load DX with 0A0FFH.
Step 14: .Decrement DX.
Step 15: If DX is not equal to zero then goto step 14. .
Step 16: Return to main program.
Step 17: Stop.
PROGRAM:
AGAIN: MOV AL, 10H
OUT 0C2, AL
MOV AL, 0CCH
OUT 0C2, AL
MOV AL, 90H
OUT 0C2, AL
MOV CX, 10H
MOV SI, 1000H
NEXT: MOV AL, [SI]
OUT 0C0, AL
INC SI
CALL DELAY
LOOP NEXT
JMP AGAIN
MANUAL CALCULATIONS:
RESULT:
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
Exp No:
Date:
MOV A, #55H
MOV P1, A
HLT: SJMP HLT
RESULT:
CODE TABLE:
Physical Address
Label Hex Code Mnemonic Comments
Segment Offset
Operands
Address Address
Exp No:
Date:
22. SERIAL COMMUNICATION
PROGRAM:
AGAIN: MOV R0, #06H
MOV DPTR, #4150H
MOV SCON, #50H
MOV TMOD, #20H
MOV TH1, #0FDH
SETB 8EH
NEXT: MOVX A,@DPTR
MOV SBUF, A
HERE: JNB 99H, HERE
CLR T1
INC DPTR
DJNZ R0, NEXT
SJMP AGAIN
RESULT:
MANUAL CALCULATIONS:
2.Go to file & open new file,type the program & save as file name.c.Go to Project – Open
Project and browse for saved file and open it.
6.Make sure that the oscillator frequency is 12MHz. Put tick mark on “use on chip ROM”. Go
to output, put tick mark on “create HEX file”. Click ok.
7.Build the target as illustrated in the figure below,check whether HEX file is created or not.
Having successfully built the target, we are now ready to start the debug session and run the
simulator.
First start a debug session.
PROLOAD:
Proload is a software which accepts only hex files. Once the machine code is
converted into hex code, that hex code has to be dumped into the microcontroller placed in
the programmer kit and this is done by the Proload. Programmer kit contains a
microcontroller on it other than the one which is to be programmed. This microcontroller has
a program in it written in such a way that it accepts the hex file from the keil compiler and
dumps this hex file into the microcontroller which is to be programmed. As this programmer
kit requires power supply to be operated, this power supply is given from the power supply
circuit designed above. It should be noted that this programmer kit contains a power supply
section in the board itself but in order to switch on that power supply, a source is required.
Thus this is accomplished from the power supply board with an output of 12volts or from an
adapter connected to 230 V AC.
4. Now place the microcontroller in the GIF socket provided in the programmer kit.
5. Click on the Proload icon in the PC. A window appears providing the information like
Hardware model, com port, device type, Flash size etc. Click on browse option to
select the hex file to be dumped into the microcontroller and then click on “Auto
program” to program the microcontroller with that particular hex file.
6. The status of the microcontroller can be seen in the small status window in the bottom
of the page.
7. After this process is completed, remove the microcontroller from the programmer kit
and place it in your system board. Now the system board behaves according to the
program written in the microcontroller.
Exp No:
Date:
PROGRAM:
# include <reg51.h>
Sfr DACDATA = 0X90;
Void main ()
{
Unsigned char WAVEVALUE [12] = {128,192,238,255,238,192,128,64,17,0,17,64}
Unsigned char X;
While(1)
{
for (x=0; x<12;x++)
{
DACDATA = WAVEVALUE[x];
}
}
}
RESULT:
Exp No:
Date:
AIM: To read a key from interfaced keypad & display the same on Alphanumeric LCD
panel.
Ports used: PORT 0, PORT 1, PORT 2.
PROGRAM:
include<reg51.h>
#define port P1
#define dataport P2 // Dataport for lcd
#define key P0 // Port for keypad
#define sec 100
sbit rs = port^1;
sbit rw = port^2;
sbit en = port^3;
sbit col1=key^4;
sbit col2=key^5;
sbit col3=key^6;
sbit row1=key^0;
sbit row2=key^1;
sbit row3=key^2;
sbit row4=key^3;
rw=0;
en=1;
delay(1);
en=0;
return;
}
case 9:lcd("9");
break;
case 0:lcd("0");
break;
case 11:lcd("*");
break;
case 12:lcd("#");
break;
}
}
void main()
{
col1=col2=col3=1; //Input Port
while(1)
{
row1=row2=row3=row4=0;
if(col1==0)
check_col1();
else
if(col2==0)
check_col2();
else
if(col3==0)
check_col3();
}
}
RESULT: