DEMONSTRATION on MICROPROCESSOR AND MICRO-CONTROLLER LAB By Mr. P. H. Chandra Mouli Assistant Professor DEPT. OF E.C.E, VEMU IT CHITTOOR
DEMONSTRATION on
MICROPROCESSOR AND MICRO-CONTROLLER LAB
By
Mr. P. H. Chandra Mouli
Assistant Professor
DEPT. OF E.C.E, VEMU IT CHITTOOR
Topics to be discussed• Vision, Mission, POs, PSOs & PEOs
• Syllabus & Course Outcomes (COs)
• Over view of Micro Processor and Micro-Controller
• Code Composer Studio
(CCS-V6.1 using( MSP430 Controller)
• Major Equipment List
• Lab Physical View
• Dos & Don’t
• Safety Precautions
Vision, Mission, POs, PSOs & PEOs
Vision of the institute
To be a premier institute for professionaleducation producing dynamic and vibrantforce of technocrat with competent skills,innovative ideas and leadership qualities toserve the society with ethical and benevolentapproach.
Mission of the institute
Mission_1: To create a learning environment with state-of-the art infrastructure, well equipped laboratories, researchfacilities and qualified senior faculty to impart high qualitytechnical education.
Mission_2: To facilitate the learners to foster innovativeideas, inculcate competent research and consultancy skillsthrough Industry-Institute Interaction.
Mission_3: To develop hard work, honesty, leadershipqualities and sense of direction in rural youth by providingvalue based education.
Vision of the Department
To become a centre of excellence in the fieldof Electronics and Communication Engineeringand produce graduates with Technical Skills,Research & Consultancy Competencies, Life-long Learning and Professional Ethics to meetthe challenges of the Industry and evolvingSociety.
Mission of the Department
Mission_1: To enrich Technical Skills of studentsthrough Effective Teaching and Learning practicesfor exchange of ideas and dissemination ofknowledge.Mission_2: To enable the students with researchand consultancy skill sets through state-of-the artlaboratories, industry interaction and training oncore & multidisciplinary technologies.Mission_3: To develop and instill creativethinking, Life-long learning, leadership qualities,Professional Ethics and social responsibilitiesamong students by providing value basededucation.
Programme Educational Objectives ( PEOs)
PEO_1: To prepare the graduates to be able to plan,analyze and provide innovative ideas toinvestigate complex engineering problems of industryin the field of Electronics and CommunicationEngineering using contemporary design and simulationtools.PEO_2: To provide students with solid fundamentals in core and multidisciplinary domain for successful implementation of engineering products and also to pursue higher studies. PEO_3: To inculcate learners with professional and ethical attitude, effective communication skills, teamwork skills, and an ability to relate engineering issues to broader social context at work place.
Programme Outcome (POs)PO_1: Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and
an engineering specialization to the solution of complex engineering problems.PO_2: Problem analysis: Identify, formulate, review research literature, and analyze complex engineering
problems reaching substantiated conclusions using first principles of mathematics, natural sciences, andengineering sciences.
PO_3: Design/development of solutions: Design solutions for complex engineering problems and designsystem components or processes that meet the specified needs with appropriate consideration for thepublic health and safety, and the cultural, societal, and environmental considerations.
PO_4: Conduct investigations of complex problems: Use research-based knowledge and research methodsincluding design of experiments, analysis and interpretation of data, and synthesis of the information toprovide valid conclusions.
PO_5: Modern tool usage: Create, select, and apply appropriate techniques, resources, and modernengineering and IT tools including prediction and modeling to complex engineering activities with anunderstanding of the limitations.
PO_6: The engineer and society: Apply reasoning informed by the contextual knowledge to assess societal,health, safety, legal and cultural issues and the consequent responsibilities relevant to the professionalengineering practice.
PO_7: Environment and sustainability: Understand the impact of the professional engineering solutions insocietal and environmental contexts, and demonstrate the knowledge of, and need for sustainabledevelopment.
PO_8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of theengineering practice.
PO_9: Individual and team work: Function effectively as an individual, and as a member or leader in diverseteams, and in multidisciplinary settings.
PO_10: Communication: Communicate effectively on complex engineering activities with the engineeringcommunity and with society at large, such as, being able to comprehend and write effective reports anddesign documentation, make effective presentations, and give and receive clear instructions.
PO_11: Project management and finance: Demonstrate knowledge and understanding of the engineering andmanagement principles and apply these to one’s own work, as a member and leader in a team, to manageprojects and in multidisciplinary environments.
PO_12: Life-long learning: Recognize the need for, and have the preparation and ability to engage inindependent and life-long learning in the broadest context of technological change.
Programme Specific Outcome (PSOs)
PSO_1: Higher Education: Qualify in competitiveexaminations for pursuing higher education byapplying the fundamental concepts of Electronicsand Communication Engineering domains such asAnalog & Digital Electronics, Signal Processing,Communication & Networking, EmbeddedSystems, VLSI Design and Control Systems etc..
PSO_2: Employment: Get employed in alliedindustries through their proficiency in programspecific domain knowledge, specialized softwarepackages and Computer programming or becomean entrepreneur.
Syllabus & Course Outcomes (COs)
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY ANANTAPURIII B.Tech. II-Sem (ECE)
(15A04607) MICROPROCESSORS AND MICROCONTROLLERS LABORATORYPart-A: MPMC Lab
Course Outcomes:• Able to write 8086 assembly language programs• Make use of programmable peripheral devices and their interfacing in assembly
programming• Able to write 8051 assembly language programs• Develop and simulate programs using embedded C for MSP 430• Make use of MSP 430 and their Interfacing devices in CC Studio• List of Experiments:• Note: Use MASM/8086 microprocessor kit• 1. Introduction to MASM Programming.• 2. Programs using arithmetic and logical operations.• 3. Programs using string operations and Instruction prefix: Move Block, Reverse string,
sorting, • String comparison.• 4. Programs for code conversion.• 5. Multiplication and Division programs.• 6. Sorting and multi byte arithmetic.• 7. Programs using CALL and RET instructions.
Part-B: Embedded C Experiments using MSP430:
• 1. Interfacing and programming GPIO ports in C using MSP430 (blinking LEDs, push buttons).
• 2. Usage of Low Power Modes: (Use MSPEXP430FR5969 as hardware platform and
• demonstrate the low power modes and measure the active mode and standby mode current)
• 3. Interrupt programming examples through GPIOs.
• 4. PWM generation using Timer on MSP430 GPIO.
• 5. Interfacing potentiometer with MSP430.
• 6. PWM based Speed Control of Motor controlled by potentiometer connected to MSP430
• GPIO.
• 7. Using ULP advisor in Code Composer Studio on MSP430.
• 8. Low Power modes and Energy trace++:
• a. Enable Energy Trace and Energy Trace ++ modes in CCS
• b. Compute Total Energy, and Estimated lifetime of an AA battery
Part-A: MPMC Lab
• List of Experiments:
• Note: Use MASM/8086 microprocessor kit
• 1. Introduction to MASM Programming.
• 2. Programs using arithmetic and logical operations.
• 3. Programs using string operations and Instruction prefix: Move Block, Reverse string, sorting,
• String comparison.
• 4. Programs for code conversion.
• 5. Multiplication and Division programs.
• 6. Sorting and multi byte arithmetic.
Part-B: Embedded C Experiments using MSP430:
1. Interfacing and programming GPIO ports in C using MSP430 (blinking LEDs, push buttons).
2. Usage of Low Power Modes: (Use MSPEXP430FR5969 as hardware platform and
demonstrate the low power modes and measure the active mode and standby mode current)
3. Interrupt programming examples through GPIOs.
4. PWM generation using Timer on MSP430 GPIO.
5. Interfacing potentiometer with MSP430.
6. PWM based Speed Control of Motor controlled by potentiometer connected to MSP430
GPIO.
Part-C: Advanced Experiments:
• 1.Serial Communication using UART.
• 2.Finding a largest and smallest number for the given data.
VEMU INSTITUTE OF TECHNOLOGY::P.KOTHAKOTANEAR PAKALA, CHITTOOR-517112
(Approved by AICTE, New Delhi & Affiliated to JNTUA, Anantapuramu)Department of Electronics &Communication Engineering
LIST OF EXPERIMENTS TO BE CONDUCTED
WHAT is Micro Processor?
• Program controlled semiconductor device (IC) which fetches (from memory), decodes and executes instructions.
• It is used as CPU (Central Processing Unit) in computers.
First GenerationBetween 1971 – 1973
PMOS technology, non compatible with TTL4 bit processors 16 pins
8 and 16 bit processors 40 pinsDue to limitations of pins, signals are
multiplexed
Second GenerationDuring 1973NMOS technology Faster speed, Higher density, Compatible with TTL4 / 8/ 16 bit processors 40 pinsAbility to address large memory spaces and I/O portsGreater number of levels of subroutine nestingBetter interrupt handling capabilities
Intel 8085 (8 bit processor)
Third GenerationDuring 1978
HMOS technology Faster speed, Higher packing density
16 bit processors 40/ 48/ 64 pinsEasier to program
Dynamically relatable programsProcessor has multiply/ divide arithmetic
hardwareMore powerful interrupt handling
capabilitiesFlexible I/O port addressing
Intel 8086 (16 bit processor)
Fourth GenerationDuring 1980sLow power version of HMOS technology (HCMOS)32 bit processorsPhysical memory space 224 bytes = 16 MbVirtual memory space 240 bytes = 1 TbFloating point hardwareSupports increased number of addressing modes
Intel 80386
Fifth Generation Pentium
16
ARCHITECTURE OF 8086
REGISTER ORGANIZATION
Sl.No. Type Register width Name of register
1 General purpose register 16 bit AX, BX, CX, DX
8 bit AL, AH, BL, BH, CL, CH, DL, DH
2 Pointer register 16 bit SP, BP
3 Index register 16 bit SI, DI
4 Instruction Pointer 16 bit IP
5 Segment register 16 bit CS, DS, SS, ES
6 Flag (PSW) 16 bit Flag register
INSTRUCTION SET
19
ProgramA set of instructions written to solve a problem.
InstructionDirections which a microprocessor
follows to execute a task or part of a task.
Computer language
High Level Low Level
Machine Language Assembly Language
Binary bits English Alphabets ‘Mnemonics’ Assembler Mnemonics
Machine Language
1. Data Transfer Instructions
20
Instructions that are used to transfer data/ address in to registers, memory locations and I/O ports.
Generally involve two operands: Source operand and Destination operand of the same size.
Source: Register or a memory location or an immediate dataDestination : Register or a memory location.
The size should be a either a byte or a word.
A 8-bit data can only be moved to 8-bit register/ memory and a 16-bit data can be moved to 16-bit register/ memory.
1. Data Transfer Instructions
21
Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT …
MOV reg2/ mem, reg1/ mem
MOV reg2, reg1 MOV mem, reg1MOV reg2, mem
(reg2) (reg1)(mem) (reg1) (reg2) (mem)
MOV reg/ mem, data
MOV reg, dataMOV mem, data
(reg) data(mem) data
XCHG reg2/ mem, reg1
XCHG reg2, reg1XCHG mem, reg1
(reg2) (reg1)(mem) (reg1)
1. Data Transfer Instructions
22
Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT …
PUSH reg16/ mem
PUSH reg16
PUSH mem
(SP) (SP) – 2MA S = (SS) x 1610 + SP(MA S ; MA S + 1) (reg16)
(SP) (SP) – 2MA S = (SS) x 1610 + SP(MA S ; MA S + 1) (mem)
POP reg16/ mem
POP reg16
POP mem
MA S = (SS) x 1610 + SP(reg16) (MA S ; MA S + 1)(SP) (SP) + 2
MA S = (SS) x 1610 + SP(mem) (MA S ; MA S + 1)(SP) (SP) + 2
1. Data Transfer Instructions
23
Mnemonics: MOV, XCHG, PUSH, POP, IN, OUT …
IN A, [DX]
IN AL, [DX]
IN AX, [DX]
PORTaddr = (DX)(AL) (PORT)
PORTaddr = (DX)(AX) (PORT)
IN A, addr8
IN AL, addr8
IN AX, addr8
(AL) (addr8)
(AX) (addr8)
OUT [DX], A
OUT [DX], AL
OUT [DX], AX
PORTaddr = (DX)(PORT) (AL)
PORTaddr = (DX)(PORT) (AX)
OUT addr8, A
OUT addr8, AL
OUT addr8, AX
(addr8) (AL)
(addr8) (AX)
2. Arithmetic Instructions
24
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
ADD reg2/ mem, reg1/mem
ADC reg2, reg1ADC reg2, memADC mem, reg1
(reg2) (reg1) + (reg2)(reg2) (reg2) + (mem)(mem) (mem)+(reg1)
ADD reg/mem, data
ADD reg, dataADD mem, data
(reg) (reg)+ data(mem) (mem)+data
ADD A, data
ADD AL, data8ADD AX, data16
(AL) (AL) + data8(AX) (AX) +data16
2. Arithmetic Instructions
25
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
ADC reg2/ mem, reg1/mem
ADC reg2, reg1ADC reg2, memADC mem, reg1
(reg2) (reg1) + (reg2)+CF(reg2) (reg2) + (mem)+CF(mem) (mem)+(reg1)+CF
ADC reg/mem, data
ADC reg, dataADC mem, data
(reg) (reg)+ data+CF(mem) (mem)+data+CF
ADDC A, data
ADD AL, data8ADD AX, data16
(AL) (AL) + data8+CF(AX) (AX) +data16+CF
2. Arithmetic Instructions
26
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
SUB reg2/ mem, reg1/mem
SUB reg2, reg1SUB reg2, memSUB mem, reg1
(reg2) (reg1) - (reg2)(reg2) (reg2) - (mem)(mem) (mem) - (reg1)
SUB reg/mem, data
SUB reg, dataSUB mem, data
(reg) (reg) - data(mem) (mem) - data
SUB A, data
SUB AL, data8SUB AX, data16
(AL) (AL) - data8(AX) (AX) - data16
2. Arithmetic Instructions
27
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
SBB reg2/ mem, reg1/mem
SBB reg2, reg1SBB reg2, memSBB mem, reg1
(reg2) (reg1) - (reg2) - CF(reg2) (reg2) - (mem)- CF(mem) (mem) - (reg1) –CF
SBB reg/mem, data
SBB reg, dataSBB mem, data
(reg) (reg) – data - CF(mem) (mem) - data - CF
SBB A, data
SBB AL, data8SBB AX, data16
(AL) (AL) - data8 - CF(AX) (AX) - data16 - CF
2. Arithmetic Instructions
28
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
INC reg/ mem
INC reg8
INC reg16
INC mem
(reg8) (reg8) + 1
(reg16) (reg16) + 1
(mem) (mem) + 1
DEC reg/ mem
DEC reg8
DEC reg16
DEC mem
(reg8) (reg8) - 1
(reg16) (reg16) - 1
(mem) (mem) - 1
2. Arithmetic Instructions
29
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
MUL reg/ mem
MUL reg
MUL mem
For byte : (AX) (AL) x (reg8)For word : (DX)(AX) (AX) x (reg16)
For byte : (AX) (AL) x (mem8)For word : (DX)(AX) (AX) x (mem16)
IMUL reg/ mem
IMUL reg
IMUL mem
For byte : (AX) (AL) x (reg8)For word : (DX)(AX) (AX) x (reg16)
For byte : (AX) (AX) x (mem8)For word : (DX)(AX) (AX) x (mem16)
2. Arithmetic Instructions
30
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
DIV reg/ mem
DIV reg
DIV mem
For 16-bit :- 8-bit :(AL) (AX) :- (reg8) Quotient(AH) (AX) MOD(reg8) Remainder
For 32-bit :- 16-bit :(AX) (DX)(AX) :- (reg16) Quotient(DX) (DX)(AX) MOD(reg16) Remainder
For 16-bit :- 8-bit :(AL) (AX) :- (mem8) Quotient(AH) (AX) MOD(mem8) Remainder
For 32-bit :- 16-bit :(AX) (DX)(AX) :- (mem16) Quotient(DX) (DX)(AX) MOD(mem16) Remainder
2. Arithmetic Instructions
31
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
IDIV reg/ mem
IDIV reg
IDIV mem
For 16-bit :- 8-bit :(AL) (AX) :- (reg8) Quotient(AH) (AX) MOD(reg8) Remainder
For 32-bit :- 16-bit :(AX) (DX)(AX) :- (reg16) Quotient(DX) (DX)(AX) MOD(reg16) Remainder
For 16-bit :- 8-bit :(AL) (AX) :- (mem8) Quotient(AH) (AX) MOD(mem8) Remainder
For 32-bit :- 16-bit :(AX) (DX)(AX) :- (mem16) Quotient(DX) (DX)(AX) MOD(mem16) Remainder
2. Arithmetic Instructions
32
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
CMP reg2/mem, reg1/ mem
CMP reg2, reg1
CMP reg2, mem
CMP mem, reg1
Modify flags (reg2) – (reg1)
If (reg2) > (reg1) then CF=0, ZF=0, SF=0If (reg2) < (reg1) then CF=1, ZF=0, SF=1If (reg2) = (reg1) then CF=0, ZF=1, SF=0
Modify flags (reg2) – (mem)
If (reg2) > (mem) then CF=0, ZF=0, SF=0If (reg2) < (mem) then CF=1, ZF=0, SF=1If (reg2) = (mem) then CF=0, ZF=1, SF=0
Modify flags (mem) – (reg1)
If (mem) > (reg1) then CF=0, ZF=0, SF=0If (mem) < (reg1) then CF=1, ZF=0, SF=1If (mem) = (reg1) then CF=0, ZF=1, SF=0
2. Arithmetic Instructions
33
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
CMP reg/mem, data
CMP reg, data
CMP mem, data
Modify flags (reg) – (data)
If (reg) > data then CF=0, ZF=0, SF=0If (reg) < data then CF=1, ZF=0, SF=1If (reg) = data then CF=0, ZF=1, SF=0
Modify flags (mem) – (mem)
If (mem) > data then CF=0, ZF=0, SF=0If (mem) < data then CF=1, ZF=0, SF=1If (mem) = data then CF=0, ZF=1, SF=0
2. Arithmetic Instructions
34
Mnemonics: ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV, CMP…
CMP A, data
CMP AL, data8
CMP AX, data16
Modify flags (AL) – data8
If (AL) > data8 then CF=0, ZF=0, SF=0If (AL) < data8 then CF=1, ZF=0, SF=1If (AL) = data8 then CF=0, ZF=1, SF=0
Modify flags (AX) – data16
If (AX) > data16 then CF=0, ZF=0, SF=0If (mem) < data16 then CF=1, ZF=0, SF=1If (mem) = data16 then CF=0, ZF=1, SF=0
3. Logical Instructions
35
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
3. Logical Instructions
36
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
3. Logical Instructions
37
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
3. Logical Instructions
38
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
3. Logical Instructions
39
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
3. Logical Instructions
40
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
3. Logical Instructions
41
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
3. Logical Instructions
42
Mnemonics: AND, OR, XOR, TEST, SHR, SHL, RCR, RCL …
4. String Manipulation Instructions
43
String : Sequence of bytes or words
8086 instruction set includes instruction for string movement, comparison, scan, load and store.
REP instruction prefix : used to repeat execution of string instructions
String instructions end with S or SB or SW. S represents string, SB string byte and SW string word.
Offset or effective address of the source operand is stored in SI register and that of the destination operand is stored in DI register.
Depending on the status of DF, SI and DI registers are automatically updated.
DF = 0 SI and DI are incremented by 1 for byte and 2 for word.
DF = 1 SI and DI are decremented by 1 for byte and 2 for word.
4. String Manipulation Instructions
44
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
REP
REPZ/ REPE
(Repeat CMPS or SCAS until ZF = 0)
REPNZ/ REPNE
(Repeat CMPS or SCAS until ZF = 1)
While CX 0 and ZF = 1, repeat execution of string instruction and(CX) (CX) – 1
While CX 0 and ZF = 0, repeat execution of string instruction and(CX) (CX) - 1
4. String Manipulation Instructions
45
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
MOVS
MOVSB
MOVSW
MA = (DS) x 1610 + (SI)MAE = (ES) x 1610 + (DI)
(MAE) (MA)
If DF = 0, then (DI) (DI) + 1; (SI) (SI) + 1If DF = 1, then (DI) (DI) - 1; (SI) (SI) - 1
MA = (DS) x 1610 + (SI)MAE = (ES) x 1610 + (DI)
(MAE ; MAE + 1) (MA; MA + 1)
If DF = 0, then (DI) (DI) + 2; (SI) (SI) + 2If DF = 1, then (DI) (DI) - 2; (SI) (SI) - 2
4. String Manipulation Instructions
46
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
CMPS
CMPSB
CMPSW
MA = (DS) x 1610 + (SI)MAE = (ES) x 1610 + (DI)
Modify flags (MA) - (MAE)
If (MA) > (MAE), then CF = 0; ZF = 0; SF = 0If (MA) < (MAE), then CF = 1; ZF = 0; SF = 1If (MA) = (MAE), then CF = 0; ZF = 1; SF = 0
For byte operationIf DF = 0, then (DI) (DI) + 1; (SI) (SI) + 1If DF = 1, then (DI) (DI) - 1; (SI) (SI) - 1
For word operationIf DF = 0, then (DI) (DI) + 2; (SI) (SI) + 2If DF = 1, then (DI) (DI) - 2; (SI) (SI) - 2
Compare two string byte or string word
4. String Manipulation Instructions
47
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
SCAS
SCASB
SCASW
MAE = (ES) x 1610 + (DI)Modify flags (AL) - (MAE)
If (AL) > (MAE), then CF = 0; ZF = 0; SF = 0If (AL) < (MAE), then CF = 1; ZF = 0; SF = 1If (AL) = (MAE), then CF = 0; ZF = 1; SF = 0
If DF = 0, then (DI) (DI) + 1 If DF = 1, then (DI) (DI) – 1
MAE = (ES) x 1610 + (DI)Modify flags (AL) - (MAE)
If (AX) > (MAE ; MAE + 1), then CF = 0; ZF = 0; SF = 0If (AX) < (MAE ; MAE + 1), then CF = 1; ZF = 0; SF = 1If (AX) = (MAE ; MAE + 1), then CF = 0; ZF = 1; SF = 0
If DF = 0, then (DI) (DI) + 2 If DF = 1, then (DI) (DI) – 2
Scan (compare) a string byte or word with accumulator
4. String Manipulation Instructions
48
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
LODS
LODSB
LODSW
MA = (DS) x 1610 + (SI)(AL) (MA)
If DF = 0, then (SI) (SI) + 1 If DF = 1, then (SI) (SI) – 1
MA = (DS) x 1610 + (SI)(AX) (MA ; MA + 1)
If DF = 0, then (SI) (SI) + 2 If DF = 1, then (SI) (SI) – 2
Load string byte in to AL or string word in to AX
4. String Manipulation Instructions
49
Mnemonics: REP, MOVS, CMPS, SCAS, LODS, STOS
STOS
STOSB
STOSW
MAE = (ES) x 1610 + (DI)(MAE) (AL)
If DF = 0, then (DI) (DI) + 1 If DF = 1, then (DI) (DI) – 1
MAE = (ES) x 1610 + (DI)(MAE ; MAE + 1 ) (AX)
If DF = 0, then (DI) (DI) + 2 If DF = 1, then (DI) (DI) – 2
Store byte from AL or word from AX in to string
Mnemonics Explanation
STC Set CF 1
CLC Clear CF 0
CMC Complement carry CF CF/
STD Set direction flag DF 1
CLD Clear direction flag DF 0
STI Set interrupt enable flag IF 1
CLI Clear interrupt enable flag IF 0
NOP No operation
HLT Halt after interrupt is set
WAIT Wait for TEST pin active
ESC opcode mem/ reg Used to pass instruction to a coprocessor which shares the address and data bus with the 8086
LOCK Lock bus during next instruction
5. Processor Control Instructions
50
6. Control Transfer Instructions
51
Transfer the control to a specific destination or target instructionDo not affect flags
Mnemonics Explanation
CALL reg/ mem/ disp16 Call subroutine
RET Return from subroutine
JMP reg/ mem/ disp8/ disp16 Unconditional jump
8086 Unconditional transfers
6. Control Transfer Instructions
52
8086 signed conditional branch instructions
8086 unsigned conditional branch instructions
Checks flags
If conditions are true, the program control is transferred to the new memory location in the same segment by modifying the content of IP
6. Control Transfer Instructions
53
Name Alternate name
JE disp8Jump if equal
JZ disp8Jump if result is 0
JNE disp8Jump if not equal
JNZ disp8Jump if not zero
JG disp8Jump if greater
JNLE disp8Jump if not less or equal
JGE disp8Jump if greater than or equal
JNL disp8Jump if not less
JL disp8Jump if less than
JNGE disp8Jump if not greater than or equal
JLE disp8Jump if less than or equal
JNG disp8Jump if not greater
8086 signed conditional branch instructions
8086 unsigned conditional branch instructions
Name Alternate name
JE disp8Jump if equal
JZ disp8Jump if result is 0
JNE disp8Jump if not equal
JNZ disp8Jump if not zero
JA disp8Jump if above
JNBE disp8Jump if not below or equal
JAE disp8Jump if above or equal
JNB disp8Jump if not below
JB disp8Jump if below
JNAE disp8Jump if not above or equal
JBE disp8Jump if below or equal
JNA disp8Jump if not above
6. Control Transfer Instructions
54
Mnemonics Explanation
JC disp8 Jump if CF = 1
JNC disp8 Jump if CF = 0
JP disp8 Jump if PF = 1
JNP disp8 Jump if PF = 0
JO disp8 Jump if OF = 1
JNO disp8 Jump if OF = 0
JS disp8 Jump if SF = 1
JNS disp8 Jump if SF = 0
JZ disp8 Jump if result is zero, i.e, Z = 1
JNZ disp8 Jump if result is not zero, i.e, Z = 1
8086 conditional branch instructions affecting individual flags
Assemble Directives
55
Instructions to the Assembler regarding the program being executed.
Control the generation of machine codes and organization of the program; but no machine codes are generated for assembler directives.
Also called ‘pseudo instructions’
Used to :› specify the start and end of a program› attach value to variables› allocate storage locations to input/ output data› define start and end of segments, procedures, macros etc..
56
Define Byte
Define a byte type (8-bit) variable
Reserves specific amount of memory locations to each variable
Range : 00H – FFH for unsigned value; 00H – 7FH for positive value and 80H – FFH for negative value
General form : variable DB value/ values
Example:
LIST DB 7FH, 42H, 35H
Three consecutive memory locations are reserved for the variable LISTand each data specified in the instruction are stored as initial value inthe reserved memory location
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCFARNEARENDP
SHORT
MACROENDM
57
Define Word
Define a word type (16-bit) variable
Reserves two consecutive memory locations to each variable
Range : 0000H – FFFFH for unsigned value; 0000H –7FFFH for positive value and 8000H – FFFFH for negative value
General form : variable DW value/ values
Example:
ALIST DW 6512H, 0F251H, 0CDE2H
Six consecutive memory locations are reserved for the variable ALIST andeach 16-bit data specified in the instruction is stored in two consecutivememory location.
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCFARNEARENDP
SHORT
MACROENDM
58
SEGMENT : Used to indicate the beginning of a code/ data/ stack segment
ENDS : Used to indicate the end of a code/ data/ stack segment
General form:
Segnam SEGMENT
………………
Segnam ENDS
Program code orData Defining Statements
User defined name of the segment
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCFARNEARENDP
SHORT
MACROENDM
59
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCFARNEARENDP
SHORT
MACROENDM
Informs the assembler the name of the program/ data segment that should be used for a specific segment.
General form:
Segment Register
ASSUME segreg : segnam, .. , segreg : segnam
User defined name of the segment
ASSUME CS: ACODE, DS:ADATA Tells the compiler that the instructions of theprogram are stored in the segment ACODE anddata are stored in the segment ADATA
Example:
60
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCFARNEARENDP
SHORT
MACROENDM
ORG (Origin) is used to assign the starting address (Effective address) for a program/ data segment
END is used to terminate a program; statements after END will be ignored
EVEN : Informs the assembler to store program/ data segment starting from an even address
EQU (Equate) is used to attach a value to a variable
ORG 1000H Informs the assembler that the statements following ORG1000H should be stored in memory starting with effectiveaddress 1000H
LOOP EQU 10FEH Value of variable LOOP is 10FEH
_SDATA SEGMENTORG 1200HA DB 4CHEVENB DW 1052H
_SDATA ENDS
In this data segment, effective address of memory locationassigned to A will be 1200H and that of B will be 1202H and1203H.
Examples:
61
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCENDPFARNEAR
SHORT
MACROENDM
PROC Indicates the beginning of a procedure
ENDP End of procedure
FAR Intersegment call
NEAR Intrasegment call
General form
procname PROC[NEAR/ FAR]
………
RET
procname ENDP
Program statements of the procedure
Last statement of the procedure
User defined name of the procedure
62
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCENDPFARNEAR
SHORT
MACROENDM
ADD64 PROC NEAR
………
RETADD64 ENDP
The subroutine/ procedure named ADD64 is declared asNEAR and so the assembler will code the CALL and RETinstructions involved in this procedure as near call andreturn
CONVERT PROC FAR
………
RETCONVERT ENDP
The subroutine/ procedure named CONVERT is declared asFAR and so the assembler will code the CALL and RETinstructions involved in this procedure as far call and return
Examples:
63
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCENDPFARNEAR
SHORT
MACROENDM
Reserves one memory location for 8-bit signed displacement in jump instructions
JMP SHORT AHEAD The directive will reserve one memory locationfor 8-bit displacement named AHEAD
Example:
64
DB
DW
SEGMENTENDS
ASSUME
ORGENDEVENEQU
PROCENDPFARNEAR
SHORT
MACROENDM
MACRO Indicate the beginning of a macro
ENDM End of a macro
General form:
macroname MACRO[Arg1, Arg2 ...]
………
macroname ENDM
Program statementsin the macro
User defined name of the macro
INTRODUCTION TO TASM PROGRAMMING
• The Turbo Assembler (TASM) mainly PC-targeted assembler package was Borland’s offering in the X86 assembler programming tool market.
• As one would expect, TASM worked well with Borland’s high-level language compilers for the PC, such as Turbo Pascal, Turbo Basic and Turbo C.
• The effective execution of a program in assembly language we need the following
• MASM assembler
• NE (Norton’s Editor) editor (or) Edlin editor
• Linker
• Debug utility of DOS
How to use TASM:
• Install the specified TASM software on PC with DOS operating system. The program implementation and its execution are illustrated in four stages, they are
• Editing of program
• Assembling the program
• Linking the program
• Debugging and execution of the program
• C:\ tasm>edit (file name).asm
• >tasm (file name).asm
Assembling
• Turbo assembler version 3.2 copy right (C) 1988, 1992 Borland International
• Assembling file : (file name)
• Error messages : None
• Warning messages : None
• Passes : 1
• PROGRAM:
• Remaining memory : 392K
• C:\ tasm>tlink (file name).objTurbo Linking
• Turbo link version 5.1 copy right (C) 1992 Borland International the Program
•
•C:\ tasm>debug (file name).exe Debugging & Operation
• - r of the• - p Program• - q
MICROCONTROLLER
• What is a Microcontroller?
• A single chip computer or A CPU with all the peripherals like RAM, ROM, I/O Ports, Timers , ADCs etc... on the same chip. For ex: Motorola’s 6811, Intel’s 8051, Zilog’s Z8 and PIC 16X etc…
MSP-EXP430G2 LaunchPad
CCS Functional Overview
CCS MSP430G2 Procedure1. File New CCS Project 2. Type in your Project name and make the selections shown below (your dialog may look slightly different than this one). 3. If you are using the MSP430G2553, make the appropriate choices for that part. Make sure to click Empty Project (with main.c) and then click Finish. 4. If you are writing an Assembly Code, select Empty Assembly-only Project5. Code Composer will add the named project to your workspace and display it in the Project Explorer pane. Based on your template selection, it will also add a file called main.c/ main.asm and open it for edit- ing. 6. Change the include header file statement from #include <msp430.h> to #include <msp430g2553.h>7. Type in your program code in the main.c / main.asm file and save it. 8. CCS can automatically save modified source files, build the program, open the debug perspective view, connect and download it to the target (flash device), and then run the program to the beginning of the main function. To do this, click on the "Debug" . 9. When the Ultra-Low-Power Advisor (ULP Advisor) appears, click the Proceed button. 10. When the download completes, CCS is in the Debug perspective. Notice the Debug tab in the upper right-hand corner indicating that we are now in the "CCS Debug" view. 11. Click and drag the perspective tabs to the left until you can see all of both tabs. You can observe that the program has run through the C-environment initialization routine in the runtime support library and stopped at main() in main.c.
Lab Physical View
Major Equipment Details
S.No Name of the Equipment QuantityAmount
(Rs.)
1. 8086 Microprocessor Trainer Kits 13 71,782/-
2. 8051 Micro-Controller Trainer Kits 14 1,04,655/-
3. Power Supply (+/-12V) 16 19,370/-
4.Study Card Interface
(8259, 8279, 8255, 8251/8253)08 9,398/-
5.ADC, DAC, Traffic Lights, Elevator &
Stepper Motor Interface10 13,156/-
6. 16 - Bit EMB-PIC Kits 09 1,01,250/-
7.MSP-EXP430 G2553, F5529, FR5969 &
CC3100 Booster Pack23 51,810/-
8. Tiva C Series EK- TM4C123GXL 10 15,222/-
9. Sensor Hub Booster Pack 03 14,584/-
10. Stabilizer (5 KVA) 01 12,564/-
11.
PC’s
System Configuration
DELL -20Nos
Mother Board -
1280
P4 @ 2.6 GHz Processor
360GB Hard disk
2 GB RAM
HCL 15"inches Colour Monitor
HCL Keyboard, HCL mouse.
20 3,66,000/-
Total 7, 79,791/-
DOs & DON’TS
• Do not displace monitor, keyboard, mouse etc.
• Do not use personal pen drives without permission.
• Students should not attempt to repair, open, tamper or interfere with any of the computer, cabling, or other equipment in the laboratory.
Safety Precautions
• Data will be preserved using UPS Backup.
• Equipped with Fire Extinguishers.
• Students and Faculty are instructed to follow Safety Instructions Chart in the Laboratories.
• Before inserting USB Stick, the Pen drives have to be scanned for any malicious content.
• The Lab is under CC Camera surveillance.
• Keep all the Computers Updated with antivirus software.
• Make Sure the Firewalls are enabled on each and every Computer.
• Miniature Circuit Breaker’s (MCB’s).
• Students inserting USB Stick have to be scanned for any malicious content.
• Students should not attempt to repair, open, tamper or interfere with any of the computer, cabling, or other equipment in the laboratory.
• Do not displace monitor, keyboard, mouse etc.
• Do not use personal pen drives without permission.