MP Lab Observation
MP Lab Observation
ECE Dept.
CONTENTS
Page no.
1. Microprocessor 8086 Programming 2.1 Introduction to MASM and TASM 2.2 Arithmetic operations a) Arithmetic Operations on 8 bit data b) Arithmetic Operations on 16 bit data c) Multibyte addition and subtraction d) Signed Operations on 8 bit data e) ASCII Arithmetic Operations 6 11 16 21 26 3
2.3 Logic Operations a) BCD to ASCII Conversion b) ASCII to BCD Conversion. c) Positive & negative count in an array d) Even & odd count in an array e) Packed BCD to Unpacked BCD Conversion 31 35 39 44 49
2.4 String Operations a) Move Block of Data b) Reversal of given String c) Sorting of N numbers d) Length of given String e) Comparison of two Strings 52 55 60 66 71
2.5 DOS/BIOS Programming a) Reading Keyboard buffered with echo b) Reading Keyboard buffered with out echo c) Display String by using BIOS Commands 76 79 82
ECE Dept.
Page no.
3. Interfacing with 8086 3.1. Digital to Analog Converters 3.2. Keyboard Display Interfacing (8279) 85 97
ECE Dept.
INTRODUCTION TO MASM/TASM
ASSEMBLY LANGUAGE PROGRAMMING USING MASM SOFTWARE:
This software used to write a program (8086, Pentium processors etc.) 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: 1. produces binary code 2. Referring data items by their names rather than by their address. HOW TO ENTER INTO MASM EDITOR: Click Start on the desktop. Then select Run Then it Shows inbox Then type Command (CMD) which enters you into DOS prompt Path setting Suppose it display path as C:\ DOCUME-\ADMIN> Then type CD\ i.e.; C:\DOCUME\\ADMIN>CD\ Then the path is C :\> Then type CD MASM Then the path is C: MASM> Then type edit i.e.; C: MASM>edit Then you enter into MASM text editor.
ECE Dept.
or
C: MASM filename.ASM, , ;
Then link this file using C: MASM>LINK filename.OBJ or C: MASM>LINK filename.OBJ , , ; i.e link the program in assembly with DOS then debug to create exe file
DEBUG COMMANDS:
ASSEMBLE COMPARE A [address] C range address ; Assembly the instructions at a particular address ; Compare two memory ranges
MICROPROCESSORS LAB OBSERVATION DUMP ENTER D [range] E address [list] ; Display contents of memory
ECE Dept.
at specific Location FILL GO HEX INPUT LOAD MOVE NAME OUTPUT PROCEED QUIT Q R [register] S range list T [=address] [value] F range list ; Fill in a range of memory
G [=address] [addresses] ; Execute a program in memory H value1 value2 I port L [address] [drive] [first sector] [number] M range address N [pathname] [arg list] O port byte P [=address] [number] ; Add and subtract two Hex values
UNASSEMBLE U [range] WRITE W [address] [drive] [first sector] [number] XA [#pages] XD [handle]
ALLOCATE expanded memory DEALLOCATE expanded memory MAP expanded memory pages
ECE Dept.
ECE Dept.
AL
AL+BL AL
Data Memory
AL
Data1
AL
AL-BL AL
Data Memory
AL
Data1
AL AH
Data1 00H
AX AX / BL Data Memory AX
STOP
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
ECE Dept.
ECE Dept.
10
ECE Dept.
11
ECE Dept.
AX [SI]
AX+BX AX
AX
Data1
AX [SI+2]
AX-BX AX
AX
Data1
AX, DX [SI+4]
AX*BX AX, DX
AX DX
Data1 0000H
AX, DX [SI+8]
DX AX / BX AX,DX
STOP
12
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
13
ECE Dept.
MANUAL CALCULATIONS:
14
ECE Dept.
RESULT:
15
ECE Dept.
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 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
16
ECE Dept.
FLOW CHART:
START
Initialize DS Initialize Data1, Data2 CX COUNT BX COUNT-1
AL
Data1 [bx]
AL
BX CX NO
BX-1 CX-1
CX=0
YES CX BX AL COUNT COUNT-1 Data1 [bx]
AL
AL
BX CX
BX-1 CX-1
NO
CX=0
YES
STOP
17
ECE Dept.
CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments
18
ECE Dept.
MANUAL CALCULATIONS:
19
ECE Dept.
20
ECE Dept.
21
ECE Dept.
AL
AL
Data1
AL
STOP
22
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
23
ECE Dept.
24
ECE Dept.
25
ECE Dept.
26
ECE Dept.
AL BL
Data1 Data2
STOP 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 SUB AL, BL AAS MOV [SI+2], AX MOV AL, 08H
27
MICROPROCESSORS LAB OBSERVATION MOV BL, 04H MUL BL AAM MOV [SI+4], AX AAD DIV BL MOV [SI+6], AX MOV AH, 4CH INT 21H CODE ENDS END START
ECE Dept.
CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments
28
ECE Dept.
MANUAL CALCULATIONS:
29
ECE Dept.
30
ECE Dept.
Al AL AH
AH AL .0FH AH .F0H
AH
Cir AH by CL times
AL AH Data Memory
AL+30h AH+30h AX
STOP
31
ECE Dept.
CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments
32
ECE Dept.
33
ECE Dept.
RESULT:
34
ECE Dept.
AL BL
AL .0FH BL .0FH
AL AL
Data Memory
STOP
35
ECE Dept.
DS: DATA
CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments
36
ECE Dept.
37
ECE Dept.
38
ECE Dept.
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 MOV AH, 4CH INT 21H CODE ENDS
39
ECE Dept.
AL
[SI]
AL
Cir left AL NO
YES
CF=1
DH SI
DH+1 SI+1
DL SI
DL+1 SI +1
CX
CX-1
NO
CX=0
YES YES Data memory DX
STOP
40
ECE Dept.
CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments
41
ECE Dept.
MANUAL CALCULATIONS:
42
ECE Dept.
43
ECE Dept.
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 EXIT: MOV [RESULT], DX MOV AH, 4CH INT 21H CODE ENDS END START
44
ECE Dept.
FLOW CHART:
START
AL
[SI]
AL YES
Cir right AL NO
CF=1
DH SI
DH+1 SI+1
DL SI
DL+1 SI +1
CX NO
CX-1
CX=0
YES Data memory DX
STOP
45
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
46
ECE Dept.
47
ECE Dept.
48
ECE Dept.
49
ECE Dept.
BL AL BL
AL AL .0FH BL .F0H
BL
Cir BL by CL times
Data Memory
AL, BL
50
ECE Dept.
RESULT:
51
ECE Dept.
FLOW CHART:
START
ES: DI CX SI DI
NO
CX=0
YES
STOP
52
MICROPROCESSORS LAB OBSERVATION 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 Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
53
ECE Dept.
MANUAL CALCULATIONS:
RESULT:
54
ECE Dept.
55
ECE Dept.
START
CX AX, DX CX
AX AX/BX AX
AL AL NO [SI]
[SI] [DI] AL
SI DI CX
NO
CX=0
YES
STOP
56
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
57
ECE Dept.
58
ECE Dept.
59
ECE Dept.
PROGRAM:
ASSUME CS: CODE, DS: DATA DATA SEGMENT LIST DB 56H, 12H, 72,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 JNZ AGAIN MOV AH, 4CH INT 21H CODE ENDS END START
60
ECE Dept.
CF=1
YES NO [SI ] SI [SI] AL SI-1 AL
CX
CX-1
NO
NO
DX=0 YES
STOP
61
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Label Segment Address Offset Address Hex Code Mnemonic operand
ECE Dept.
Comments
62
ECE Dept.
63
ECE Dept.
64
ECE Dept.
65
ECE Dept.
PROGRAM: ASSUME CS: CODE, DS: DATA, ES: DATA DATA SEGMENT LIST DB ADITYA$ LEN DB ? DATA ENDS CODE SEGMENT ORG 1000H START: MOV AX, DATA MOV DS, AX 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
66
ECE Dept.
FLOW CHART:
START
DI DX AL
YES
ZF=0
NO DX DI Data memory DX+1 DI+1 DX
STOP
67
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
68
ECE Dept.
MANUAL CALCULATIONS:
69
ECE Dept.
70
ECE Dept.
71
ECE Dept.
START
Compare AX, BX
NO
ZF=0
YES CX AX
ZF=0 YES
Data memory
Yes
Data memory
NO
STOP
72
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
73
ECE Dept.
74
ECE Dept.
75
ECE Dept.
76
ECE Dept.
START
STOP
77
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
RESULT:
78
ECE Dept.
79
ECE Dept.
STOP CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments
80
ECE Dept.
81
ECE Dept.
Step1: Start Step2: Set the screen in Graphic mode Step3: Initialize AH with 00h Step4: Set the keyboard display mode. Step5: Initialize SI with 0000h. Step6: Copy the contents SI into AL register. Step7: Compare AL register with null character ! Step8: If equal go to step 11. Step9: Move the number 14 into AH register. Step10: Move the number 05h into BL register. Step11: Set keyboard display mode. Step12: Go to step 6. Step 13: Terminate the program. Step14: Stop. PROGRAM:
ASSUME CS: CODE, DS: DATA DATA SEGMENT TEXT DB ADITYA MICROPROCESSORS LAB!' DATA ENDS CODE SEGMENT ORG 1000H START: AX, DATA MOV DS, AX MOV AL, 13H; SET the screen in graphics mode MOV AH, 00 INT 10H MOV SI, 00H BACK: MOV AL, TEXT [SI] CMP AL,'!' JE EXIT MOV AH, 14 MOV BL, 05H INT 10H INC SI JMP BACK EXIT: MOV AH, 4CH INT 21H CODE ENDS END START
82
ECE Dept.
FLOW CHART:
START
SI
Initialize DS Offset Text AL 13h AH 00H Interrupt 10H AL Text [SI] Compare AL, q
STOP
83
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
RESULT:
84
ECE Dept.
85
ECE Dept.
This program can be executed in STAND-ALONE MODE or SERIAL MODE of operation. The program starts at memory location 3000H ALGORITHM: (FOR TRIANGULAR WAVE): Step 1: Start Step 2: Initialize the control word register with all ports as simple I/O mode Step 3: Load Maximum Amplitude value to CX register. Step 4: Load 00 to AL register. Step 5: Initialize the port A address. Step 6 : Locate the contents of AL to DX register. Step 7: Increment the value in AL by one. Step 8: Locate AL contents to DX register. Step 9: Decrement the value of CX register by one and go to step 6 if CX not equal to zero. Step 10: Load 00FF to CX register. Step 11: Decrement the value of AL by one. Step 12: Locate the contents in AL register to DX register. Step 13: Decrement the value of CX by one and go to step 12 if CX not equal to zero. Step 14: Otherwise move to step 3 Step 15: Stop. PROGRAM (FOR TRIANGULAR WAVE): MOV DX, 0FFE6 MOV AL, 80 OUT DX, AL MOV DX, 0FFE0 MOV AL, 00 RPT: MOV CX, 0FF L1 : OUT DX, AL INC AL LOOP L1 MOV CX, 0FF L2 : OUT DX,AL DEC AL LOOP L2 JMP RPT
86
ECE Dept.
START
DX AL [DX] DX AL CX [DX] AL CX
Addr. Of CWR 80 AL
CX=0
NO YES CX FFH
[DX] AL CX
AL AL-1 CX-1
NO
CX=0 YES
87
ECE Dept.
CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand Comments
RESULT:
88
ECE Dept.
Step 1: Start Step 2: Initialize the control word register with all ports as simple I/O mode Step 3: Load Maximum Amplitude value to CX register. Step 4: Load 00 to AL register. Step 5: Initialize the port A address. Step 6 : Locate the contents of AL to DX register. Step 7: Increment the value in AL by one. Step 8: Locate AL contents to DX register. Step 9: Decrement the value of CX register by one and go to step 6 if CX not equal to zero.
DX AL [DX] DX AL CX [DX] AL CX
Addr. Of CWR 80 AL
CX=0
NO YES
89
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
RESULT:
90
MICROPROCESSORS LAB OBSERVATION ALGORITHM (FOR SQUARE WAVE): Step 1: Start Step 2: Initialize the control word register with all ports as simple I/O mode Step 3: Load Maximum Amplitude value to AX register. Step4: Initialize the port A address. Step 6 : Transmit the contents of AX to port A Step 7: Create Delay Step 8: Load Minimum Amplitude value to AX register. Step 9: Transmit the contents of AX to port A Step 10: Create Delay Step 11: Go to Step 3 and Repeat ALGORITHM FOR DELAY Step 1: Load the CX register with 93h Step 2: Decrement CX Step 3: Repeat Step 2 till CX is zero Step4: Return to main program PROGRAM (FOR SQUARE WAVE): MOV DX, 0FFE6 MOV AL, 80 OUT DX, AL MOV DX, 0FFE0 RPT: MOV AX, 0FF OUT DX, AX CALL DELAY MOV AX, 00 OUT DX, AX CALL DELAY JMP RPT DELAY PROGRAM: MOV CX, 1E L1: NOP NOP LOOP L1 RET
ECE Dept.
91
ECE Dept.
DX AL [DX] DX AL CX [DX] CX
Addr. Of CWR 80 AL
CX=0
NO YES CX AL [DX] CX COUNT FFH AL CX-1
NO
CX=0 YES
92
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
RESULT:
93
MICROPROCESSORS LAB OBSERVATION ALGORITHM (FOR SINE WAVE): Step 1: Start Step 2: Move the control word address 0FFE6 to register DX Step 3: Move 80 to AL register. Step 4: Locate the contents in AL register to DX register using port out. Step 5: Initialize the SI with 4000h location. Step 6: Move the number 46 into the counter CX register. Step 7: Initialize the Port A address ie. 0FFE0 Step 8: Move the contents SI into AL register. Step 9: Locate the contents in AL register to DX register using port out.. Step 10: Increment the value of SI. Step 11: Decrement the counter and go to Step 8 until CX =0 Step 12: Jump to location step 5. Step 13: Stop. PROGRAM FOR SINE WAVE: MOV DX, 0FFE6 MOV AL, 80 OUT DX, AL RPT: MOV SI, 4000 MOV CL, 46 MOV DX, 0FFE0 L1: MOV AL, [SI] OUT DX, AL INC SI LOOP L1 JMP RPT
ECE Dept.
94
ECE Dept.
HEX CODES 7F AA D1 ED FC FC ED D1 AA 7F 53 2D 10 01 07 1D 3F 8A B5 D9 F2 FE FA E7 C8 A0 74 49 25 0B 00 0B 25 49 69 95 BF E0 F7 FF F7 E0 BF 95 69 3F 1D 07 01 10 2D 53 74 A0 C8 E7 FA FE F2 D9 B5 8A 5F 36 17 04 04 17 36 5F
DX AL [DX] DX SI
Addr. Of CWR 80 AL
NO
CX=0
YES
95
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
RESULT:
96
ECE Dept.
97
ECE Dept.
PIN OUT DEFINITION 8279 A0: Selects data (0) or control/status (1) for reads and writes between micro and 8279. BD: Output that blanks the displays. CLK: Used internally for timing. Max is 3 MHz. CN/ST: Control/strobe, connected to the control key on the keyboard. CS: Chip select that enables programming, reading the keyboard, etc. DB7-DB0: Consists of bidirectional pins that connect to data bus on micro. IRQ: Interrupt request, becomes 1 when a key is pressed, data is available. OUT A3-A0/B3-B0: Outputs that sends data to the most significant/least significant nibble of display. RD (WR): Connects to micros IORC or RD signal, reads data/status registers. RESET: Connects to system RESET. RL7-RL0: Return lines are inputs used to sense key depression in the keyboard matrix. Shift: Shift connects to Shift key on keyboard. SL3-SL0: Scan line outputs scan both the keyboard and displays.
98
ECE Dept.
KEYBOARD INTERFACE OF 8279: The keyboard matrix can be any size from 2x2 to 8x8. Pins SL2-SL0 sequentially scan each column through a counting operation. o The 74LS138 drives 0s on one line at a time. o The 8279 scans RL pins synchronously with the scan. o RL pins incorporate internal pull-ups, no need for external resistor pull-ups. Unlike the 82C55, the 8279 must be programmed first.
99
Function Mode set Clock Read FIFO Read Display Write Display Display write inhibit Clear End interrupt
0 1 0 1 0 1 0 1
Selects the number of display positions, type of key scan Programs internal clk, sets scan and debounce times. Selects type of FIFO read and address of the read. Selects type of display read and address of the read. Selects type of write and the address of the write. Allows half-bytes to be blanked. Clears the display or FIFO Clears the IRQ signal to the microprocessor.
The first 3 bits of # sent to control port selects one of 8 control words. Keyboard Interface of 8279 First three bits given below select one of 8 control registers (opcode). 000DDMMM o Mode set: Opcode 000. DD sets displays mode. MMM sets keyboard mode. DD field selects either: 8- or 16-digit display Whether new data are entered to the rightmost or leftmost display position. DD Function 00 8-digit display with left entry 01 16-digit display with left entry 10 8-digit display with right entry 11 16-digit display with right entry Keyboard Interface of 8279 o MMM field: DD Function 000 Encoded keyboard with 2-key lockout 001 Decoded keyboard with 2-key lockout 010 Encoded keyboard with N-key rollover 011 Decoded keyboard with N-key rollover 100 Encoded sensor matrix 101 Decoded sensor matrix 110 Strobed keyboard, encoded display scan
o o
111 Strobed keyboard, decoded display scan Encoded: SL outputs are active-high, follow binary bit pattern 0-7 or 0-15. Decoded: SL outputs are active-low (only one low at any time). Pattern output: 1110, 1101, 1011, 0111.
100
ECE Dept.
Strobed: An active high pulse on the CN/ST input pin strobes data from the RL pins into an internal FIFO for reading by micro later. o 2-key lockout/N-key rollover: Prevents 2 keys from being recognized if pressed simultaneously/Accepts all keys pressed from 1st to last. INTERFACE OF 8279 001PPPPP o The clock command word programs the internal clock driver. o The code PPPPP divides the clock input pin (CLK) to achieve the desired operating frequency, e.g. 100KHz requires 01010 for a 1 MHz CLK input. 010Z0AAA o The read FIFO control word selects the address (AAA) of a keystroke from the FIFO buffer (000 to 111). o Z selects auto-increment for the address. 011ZAAAA o The display read control word selects the read address of one of the display RAM positions for reading through the data port. 100ZAAAA o Selects write address Z selects auto-increment so subsequent writes go to subsequent display positions. INTERFACE OF 8279 1010WWBB o The display write inhibit control word inhibits writing to either the leftmost 4 bits of the display (left W) or rightmost 4 bits. o BB works similarly except that they blank (turn off) half of the output pins. 1100CCFA o The clear control word clears the display, FIFO or both o Bit F clears FIFO and the display RAM status, and sets address pointer to 000. If CC are 00 or 01, all display RAM locations become 00000000. If CC is 10, 00100000, if CC is 11, 11111111. 1110E000 o End of Interrupt control word is issued to clear IRQ pin in sensor matrix mode. 1) Clock must be programmed first. If 3.0 MHz drives CLK input, PPPPP is programmed to 30 or 11110. 2) Keyboard type is programmed next. o The previous example illustrates an encoded keyboard, external decoder used to drive matrix. 3) Program the FIFO. Once done, a procedure is needed to read data from the keyboard. o To determine if a character has been typed, the FIFO status register is checked. o When this control port is addressed by the IN instruction, the contents of the FIFO status word is copied into register AL: Code given in text for reading keyboard. Data returned from 8279 contains raw data that need to be translated to ASCII: o Row and column number are given the rightmost 6 bits (scan/return). o This can be converted to ASCII using the XLAT instruction with an ASCII code lookup table.
101
ECE Dept.
The CT and SH indicate whether the control or shift keys were pressed. The Strobed Keyboard code is just the state of the RLx bits at the time a 1 was strobed on the strobed input pin.
ALGORITHM:
Step 1: Start Step 2: Load SI with memory location. Step 3: Move 10 to AL register. Step 4: Load CX with count. Step 5: Initialize the Command word register i.e., 0FF42 Step 6: Locate the contents in AL register to DX register using port out. Step 7: Move D3 to AL register. Step 8: Locate the contents in AL register to DX register using port out. Step 9: Move 90 to AL register. Step 10: Locate the contents in AL register to DX register using port out Step 11: Initialize the Data Register address ie. 0FF40 Step 12: Move the contents SI into AL register. Step 13: Locate the contents in AL register to DX register using port out. Step 14: Create Delay. Step 15: Increment the value of SI. Step 16: Decrement the counter and go to Step 11 until CX =0 Step 17: Jump to location step 5.
ALGORITHM FOR DELAY Step 1: Load the DX register with 0FFFFh Step 2: Decrement DX Step 3: Repeat Step 2 till DX is zero Step4: Return to main program
PROGRAM:
START: MOV SI, 2000H MOV CX, 0008H MOV AL, 10 MOV DX, 0FF42 OUT DX, AL MOV AL, 0D3 OUT DX, AL MOV AL, 90 OUT DX, AL NEXT: MOV DX, 0FF40 MOV AL, [SI] OUT DX, AL CALL DELAY INC SI LOOP NEXT JMP START DELAY PROGRAM: MOV DX, 0FFFFH BACK: DEC DX JNZ BACK RET
INPUT DATA:
Segment address Offset address 2000 DATA INPUT 00 77 F3 60 87 E6 77
102
ECE Dept.
DX
[DX] AL 90H
AL
[DX]
AL
DX
AL SI [DX]
[SI] SI+1 AL
DX
DX
DELAY
DX-1
NO
DX=0
YES
CX
CX-1
NO
CX=0
YES
103
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
RESULT:
104
ECE Dept.
It consists of two stator windings A,B and a motor having two magnetic poles N and S. when a voltage +v is applied to stator winding A, a magnetic field Fa is generated. The rotor positions itself such that its poles lock with corresponding stator poles. With the winding A excited as before ,winding b is now to Fa. the resulting magnetic field F makes an angle of 450. the rotor consequently moves through 450 in anti clockwise direction, again to cause locking of rotor poles with corresponding stator poles. While winding B has voltage +V applied to it, winding A is switched off. The rotor then moves through a further 450 in anti-clockwise direction to aligne itself with stator field Fb. with voltage +V on winding B, a voltage V is applied to winding A. then the stator magnetic field has two components Fa , Fb and their resultant F makes an angle of 1350 position.
105
ECE Dept.
In this way it can be seen that ,as the pattern of excitation of the state of winding is changed, the rotor moves successively through450 steps. And completes one full revolution in anti clock-wise direction. A practical PM stepper motor will have 1.80 step angle and 50 tooth on its rotor;there are 8 main poles on the stator, each having five tooth in the pole face. The step angle is given by A = 360 / (N * K) degrees Where N = number of rotor tooth. K = execution sequence factor. PM stepper motors have three modes of excitation i,e.. Single phase mode Two phase mode Hybrid mode Single phase mode: in this mode only one of the motor winding is excited at a time. There are four steps in the sequence, the excitation sequence factor K=2 ,so that step angle is 900. Two phase mode: Here both stators phase are excited at a time. There are four steps in the excitation sequence, K = 2 and the step angle is 900. However, the rotor positions in the two phase mode are 450 way from those in single phase mode. Hybrid mode: this is a combination of single and two phase modes. There are 8 steps in excitation sequence=2 and step angle = 450. a voltage +V is applied to a stator winding during some steps, which voltage V is applied during certain other steps. This requires a bipolar regulated power supply capable of yielding +V,-V and zero outputs and a air of SPDT switches, which is quite cumbersome. Consequently each of the two stator windings is split into two sections A1-A2 , B1-B2. these sections are wound differentially. These winding sections can now be excited from a univocal regulated power supply through switcher S1 to S4. this type of construction is called bipolar winding construction. Bipolar windingesults in reduced winding inductance and consequently improved torque stepping rate. Description: the stepper motor interfaces uses four transistor pairs (SL 100 and 2N 3055) in a Darlington pair configuration. Each Darlington pair is used to excite the particular winding of the motor connected to 4 pin connector on the interface. The inputs to these transistors are from the 8255 PPI I/O lines of the microprocessor kit or from digital I/O card plugged in the PC. port A lower nibble PA0 , PA1, PA2 , PA3 are the four lines brought out to the 26 pin FRC male connector(J1) on the interface module. The freewheeling diodes across each winding protect transistors from switching transients. Theory: A motor used for moving things in small increments is known as stepper motor. Stepper motor rotate from one fixed position to next position rather than continuous rotation as in case of other ac or dc motor stepper motors are used in printers to advance the paper from one position to advance the paper from one position to another in steps. They are also used to position the read/write head on the desired track of a floppy disk. To rotate the shaft the stepper motor a sequence of pulses are applied to the windings in a predefined sequence. The number of pulses required for one complete rotation per pulse is given by 3600/NT. where
106
ECE Dept.
NT is the number of teeth on rotor. Generally the stepper motor is available with 10 to 300 rotation. They are available with two phases and four phase common field connections. Instead of rotating smoothly around and around as most motors, stepper motors rotate or step one fixed position to next. Common step size range from 0.90 to 300. it is stepped from one position to next by changing the currents through the fields in the motor. The two common field connections are referred to as two phase and four phase. The drive circuitry is simpler in 4 phase stepper. The figure shows a circuitry that can interface a small 4 stepper motor to four microcomputer port lines. The 7406 buffers are inverting, so. A high on ah output port pin turns on current to a winding. The purpose of clamp diodes across each winging is to save transistors from inductive kick. Resistors R1 and R2 are current limiting resistors. Typical parameters of stepper motor: 1. Operating voltage 2. Current rating 3. Step angle 12 volts 1.2 Amp 1.80 200(No. of teeth on rotor) 3 kg/cm
Working of stepper motor: Suppose that SW1 and SW2 are turned ON. Turning OFF SW2 and turning ON SW4 cause the motor to rotate one step of 1.80 clockwise. Changing to SW4 and SW3 ON will cause the motor to rotate 1.80 clockwise another. Changing SW3 and SW2 ON will cause another step. To step the motor in counter clock wise direction simply work through the switch sequence in the reverse direction. The switch pattern for changing from one step to another step in clockwise direction is simply rotated right one position. For counter clockwise direction rotated left one position ALGORITHM: Step 1: Start Step 2: move the control word address 0FFE6 to register DX Step 3: move 80 to AL register. Step 4: locate the contents in AL register to DX register using port out. Step 5:Intialize BX with 07d0 Step 6: move port A address ie.,,0FFE0 to DX register. Step 7: move 11 to AL register. Step 8: locate the contents in AL register to DX register using port out. Step 9: move 300 to CX register. Step 10: repeat step 8 until the content in CX register becomes equal to zero. Step 11: Rotate carry left through bit. Step 12: Decrement BX by one Step 13: repeat steps from 8 until the content in BX register becomes equal to zero. Step 14:Intialize BX with 07d0 Step 15: locate the contents in AL register to DX register using port out. Step 16: move 300 to CX register. Step 17: repeat step 15 until the content in CX register becomes equal to zero.
107
ECE Dept.
Step 18: Rotate carry left through bit. Step 19: Decrement BX by one Step 20: repeat steps from 15 until the content in BX register becomes equal to zero. Step 21: jump to location / step 8. PROGRAM: MOV MOV OUT RPT: MOV MOV MOV BACK: OUT MOV L1: LOOP ROL DEC JNZ MOV MOV BACK1:OUT MOV L2: LOOP ROR DEC JNZ JMP DX, 0FFE6 AL, 80 DX, AL BX,07D0 DX, 0FFE0 AL, 11 DX, AL CX, 0300 L1 AL, 01H BX BACK BX,07D0 AL, 11 DX, AL CX, 0300 L2 AL, 01H BX BACK1 RPT
108
ECE Dept.
Addr. Of CWR 80 AL
[DX]
CX
COUNT
CX
CX-1
NO
CX=0
YES Cir left AL BX-1
AL BX NO
BX=0
YES
STEPS AL COUNT
BX [DX] CX
CX NO
CX-1
CX=0
AL BX YES Cir Right AL BX-1
NO
BX=0
YES
109
MICROPROCESSORS LAB OBSERVATION CODE TABLE: Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
RESULT:
110
MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
111
MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
112
MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
113
MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
114
MICROPROCESSORS LAB OBSERVATION Physical Address Segment Address Offset Address Label Hex Code Mnemonic operand
ECE Dept.
Comments
115