Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
727 views
5 pages
PSW 8051
Uploaded by
parabud wanki sungoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save PSW 8051 For Later
Download
Save
Save PSW 8051 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
727 views
5 pages
PSW 8051
Uploaded by
parabud wanki sungoh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save PSW 8051 For Later
Carousel Previous
Carousel Next
Download
Save
Save PSW 8051 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 5
Search
Fullscreen
2irzR020 8051 FLAG BITS AND THE PSW REGISTER ‘hen-how In Depth Tutorials and Information 8051 FLAG BITS AND THE PSW REGISTER Download PDF (Free) - Download PDF (Fre To View PDF, Download Here free.propafconverter.com Download PDF (Free) - Download PDF (Fre To View PDF, Download Here free. propdfconverter.com SECTION 2.6: 8051 FLAG BITS AND THE PSW REGISTER Like any other microprocessor, the 8051 has a flag register to indicate arithmetic conditions such as the carry bit. The flag register in the 8051 is called the program status word (PSW) register. In this section we discuss various bits of this register and provide some examples of how it is altered. PSW (program status word) re: The program status word (PSW) register is an 8-bit register. It is also referred to as the flag register. Although the PSW register is 8 bits wide, only 6 bits of it are used by the 8051. The two unused bits are user-definable flags. Four of the flags are called conditional flags, meaning that they indicate some conditions that result after an instruction is executed. These four are CY (carry), AC (auxiliary carry), P (parity), and OV (overflow). ‘As seen from Figure 2-4, the bits PSW.3 and PSW.4 are designated as RSO and RSI, respectively, and are used to change the bank registers. They are explained in the next section. The PSW.5 and PSW.1 bits are general- purpose status flag bits and can be used by the programmer for any purpose. In other words, they are user definable, See Figure 2-4 for the bits of the PSW register. cy | ac ] ro ] ws | wo] ov | — P cy Psw7 Cary flag AC PSWO Auiilary cary flag. Fo Psws Ayailuble to the wer for general purpose, RSI Pswa Register Bank selector bt |. RS PSW3 Register Rank selecor bit 0 ov Psw2 Overflow fla, — — Pswi Usersefinabie bi, P PSWo Parity flag Setileared by hardware each instuction eyele 40 indicate an odi/even number of 1 bits in the 2ccumulator RS1_RSO Register Bank, Address oo ¢ OOH 07 oi 1 OSH - OFH 10 2 10H. 17H rt 3 ISH FE Figure 2-4, its of the PSW Register hitpshvhatwnen-ow.com/806 t-microcontroler/8051-flag-bts-and-the-psw-regster! 182120020 6051 FLAG BITS AND THE PSW REGISTER The following is a brief explanation of four of the flag bits of the PSW register. The impact of instructions on these registers is then discussed. wiAdvertiseO:X. CY, the carry flag This flag is set whenever there is a carry out from the D7 bit. This flag bit is affected after an 8-bit addition or subtraction, It can also be set to 1 or 0 directly by an instruction such as “SETB C” and “CLR C” where “SETB * stands for “set bit carry” and “CLR C” for “clear carry”. More about these and other bit-addressable instructions will be given in Chapter 8. AC, the auxiliary carry flag If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set; otherwise, it is cleared. This flag is used by instructions that perform BCD (binary coded decimal) arithmetic. See Chapter 6 for more information, P, the parity flag The parity flag reflects the number of | s in the A (accumulator) register only. If the A register contains an odd number of Is, then P = 1. Therefore, P = 0 if A has an even number of Is. OY, the overflow flag This flag is set whenever the result of a signed number operation is too large, causing the high-order bit to overflow into the sign bit. In general, the carry flag is used to detect errors in unsigned arithmetic operations. The overflow flag is only used to detect errors in signed arithmetic operations and is discussed in detail in Chapter 6. hitpshvhatwnen-ow.com/806 t-microcontroler/8051-flag-bts-and-the-psw-regster! 2182irzR020 8051 FLAG BITS AND THE PSW REGISTER Table 2-1: Instructions That Affect Flag Bits instruction CY _OV__AC x x ADDC x x SUBB xX MUL x DIV x DA RRC x REC x SETBC 1 CLRC 0 CPLE x ANLC.bit_X ANU. fit _X. ORL C.bit_X ORLC, Ait_X MOV CINE Note: X can be 0 or I. ADD instruction and PSW ‘Next we examine the impact of the ADD instruction on the flag bits CY, AC, and P of the PSW register. Some examples should clarify their status. Although the flag bits affected by the ADD instruction are CY (carry flag), P (parity flag), AC (auxiliary carry flag), and OV (overflow flag) we will focus on flags CY, AC, and P for now. A discussion of the overflow flag is given in Chapter 6, since it relates only to signed number arithmetic. How the various flag bits are used in programming is discussed in future chapters in the context of many applications, See Examples 2-2 through 2-4 for the impact on selected flag bits as a result of the ADD instruction. hitpshvhatwnen-ow.com/806 t-microcontroler/8051-flag-bts-and-the-psw-regster! ais2irzR020 8051 FLAG BITS AND THE PSW REGISTER Example 2-2 Show the status of the CY, AC, and P flags after the addition of 38H and 2FH in the fol- lowing instructions. MOV A, #38H ADD A, #2FH jafter the addition A=67H, CY=0 Solution: 38 00111000 +2E SOLON 67 01100111 CY = 0 since there is no carry beyond the D7 bit. AC = I since there is a carry from the D3 to the D4 bit. P= since the accumulator has an odd number of Is (it has five Is). [Example 2-3 Show the status of the CY, AC, and P flags after the addition of 9CH and 64H in the fol- lowing instructions, MOV A, #9CH ADD A, #64H yafter addition A=00 and CY=1 Solution: 9c 10011100 + 1100100 100 00000000 CY = | since there is a carry beyond the D7 bit. AC = | since there is a carry from the D3 to the D4 bit. P=0 since the accumulator has an even number of Is (it has zero Is). [Example 24 ‘Show the status of the CY, AC, and P flags after the addition of 88H and 93H in the fol- lowing instructions. MOV A, #88H ADD A, #93H jafter the addition A=1BH,CY=1 Solution: 88 10001000 +B 10010011 1B 00011011 CY = | since there is a carry beyond the D7 bit. AC = 0 since there is no carry from the D3 to the D4 bit. P= 0 since the accumulator has an even number of Is (it has four 1s). hitpshvhatwnen-ow.com/806 t-microcontroler/8051-flag-bts-and-the-psw-regster! 462irzR020 8051 FLAG BITS AND THE PSW REGISTER > a © SPONSORED SEARCHES (Cheap World Flags _) C Fiag Carry Case _) (CC FanFlagsforSale )(__—‘FlagMakers_—_—«d) 051 RI Next post: ER BANKS AND STACK Previous post: 8051 DATA TYPES AND DIRECTIVES + Related Links © 8051 Microcontroller 8051 MICROCONTROI MICROCONTROLLERS AND EMBEDDED PROCESSORS OVERVIEW OF THE 8051 FAMILY 8051 ASSEMBLY LANGUAGE PROGRAMMING INSIDE THE 8051 Search WWH :: Search Google Custom Search Help Unprivileged Children | Careers ¥ Privacy Statement Copyright Information hitpshvhatwnen-ow.com/806 t-microcontroler/8051-flag-bts-and-the-psw-regster! 55
You might also like
PSW Register in 8051 Microcontroller - Program Status Word
PDF
No ratings yet
PSW Register in 8051 Microcontroller - Program Status Word
10 pages
Lecture 6 PSW Register
PDF
No ratings yet
Lecture 6 PSW Register
11 pages
WINSEM2024-25_BECE204L_TH_VL2024250504055_2024-12-21_Reference-Material-I
PDF
No ratings yet
WINSEM2024-25_BECE204L_TH_VL2024250504055_2024-12-21_Reference-Material-I
9 pages
Inter Task Communication Mechanisms
PDF
100% (1)
Inter Task Communication Mechanisms
33 pages
EEE_15EE63C_U2_S9_Sy
PDF
No ratings yet
EEE_15EE63C_U2_S9_Sy
4 pages
4-PSW and RAM organization-21-Jul-2020Material - I - 21-Jul-2020 - 3.psw - N - Ram - Org
PDF
No ratings yet
4-PSW and RAM organization-21-Jul-2020Material - I - 21-Jul-2020 - 3.psw - N - Ram - Org
14 pages
Embedded Sys - Week 4-Part 2
PDF
No ratings yet
Embedded Sys - Week 4-Part 2
12 pages
Unit 2 8086 System Bus Structures Fullunit
PDF
No ratings yet
Unit 2 8086 System Bus Structures Fullunit
36 pages
Mixed Signal Ic Design Testing-1
PDF
No ratings yet
Mixed Signal Ic Design Testing-1
256 pages
8259a Programmable Interrupt Controller
PDF
No ratings yet
8259a Programmable Interrupt Controller
42 pages
Ntroduction O Icrocontrollers: Fig. 2.1: Functional Block Diagram of A Microcontroller
PDF
No ratings yet
Ntroduction O Icrocontrollers: Fig. 2.1: Functional Block Diagram of A Microcontroller
19 pages
8051 Lab Stepper Motor Interfacing
PDF
No ratings yet
8051 Lab Stepper Motor Interfacing
5 pages
MC Merged
PDF
No ratings yet
MC Merged
506 pages
Unit 1
PDF
100% (1)
Unit 1
44 pages
8259 Interfacing With 8086
PDF
100% (1)
8259 Interfacing With 8086
4 pages
4 - Bit Arithmetic Processor, Design of A 4 Bit Shifter
PDF
No ratings yet
4 - Bit Arithmetic Processor, Design of A 4 Bit Shifter
56 pages
CH 3: 8085 Instruction Set Memory and I/O Interfacing
PDF
0% (1)
CH 3: 8085 Instruction Set Memory and I/O Interfacing
85 pages
5 PIC16F887 Microcontroller
PDF
100% (4)
5 PIC16F887 Microcontroller
40 pages
Chapter No 6 Mcqs
PDF
No ratings yet
Chapter No 6 Mcqs
9 pages
Adc0808 and 8253
PDF
No ratings yet
Adc0808 and 8253
35 pages
Project Report: Water Temperature Controller
PDF
No ratings yet
Project Report: Water Temperature Controller
13 pages
Mcq's On Embedded Systems
PDF
No ratings yet
Mcq's On Embedded Systems
106 pages
PIL Question Bank: 80386 and 8051
PDF
100% (1)
PIL Question Bank: 80386 and 8051
13 pages
PIC Microcontrollers: Chapter 4: Pic Architecture & Assembly
PDF
100% (1)
PIC Microcontrollers: Chapter 4: Pic Architecture & Assembly
35 pages
Stack Structure
PDF
No ratings yet
Stack Structure
19 pages
8051 Microcontroller Interview Questions
PDF
No ratings yet
8051 Microcontroller Interview Questions
7 pages
Flashflex Microcontroller Using The Programmable Counter Array (Pca)
PDF
No ratings yet
Flashflex Microcontroller Using The Programmable Counter Array (Pca)
17 pages
ET7102-Microcontroller Based System Design QB PDF
PDF
100% (1)
ET7102-Microcontroller Based System Design QB PDF
10 pages
Unit-I (8086) : Microprocessor and Microcontrollers
PDF
No ratings yet
Unit-I (8086) : Microprocessor and Microcontrollers
22 pages
Embedded Systems Lab 18ECL66: Demonstrate The Use of An External Interrupt To Toggle An LED On/Off
PDF
No ratings yet
Embedded Systems Lab 18ECL66: Demonstrate The Use of An External Interrupt To Toggle An LED On/Off
16 pages
Memory Interfacing PDF
PDF
No ratings yet
Memory Interfacing PDF
14 pages
Salient Features of 80586 (Pentium)
PDF
No ratings yet
Salient Features of 80586 (Pentium)
3 pages
Sorting A Series of 10 Numbers: Flowchart
PDF
No ratings yet
Sorting A Series of 10 Numbers: Flowchart
4 pages
MCQ For 4 and 5th Unit
PDF
No ratings yet
MCQ For 4 and 5th Unit
15 pages
Microcontroller MCQ
PDF
No ratings yet
Microcontroller MCQ
3 pages
Ece-Vii-dsp Algorithms & Architecture (10ec751) - Assignment
PDF
100% (1)
Ece-Vii-dsp Algorithms & Architecture (10ec751) - Assignment
9 pages
Topic:-Interfacing of 8255 and 8085
PDF
No ratings yet
Topic:-Interfacing of 8255 and 8085
37 pages
Unit Iv Pic Microcontroller
PDF
100% (1)
Unit Iv Pic Microcontroller
68 pages
Microprocessor and Microcontroller
PDF
100% (1)
Microprocessor and Microcontroller
35 pages
Embedded Systems Unit IV
PDF
No ratings yet
Embedded Systems Unit IV
11 pages
Chapter 5
PDF
0% (1)
Chapter 5
43 pages
The 80386 and 80486 Microprocessor
PDF
100% (2)
The 80386 and 80486 Microprocessor
31 pages
Exceptions Interrupts Timers
PDF
100% (1)
Exceptions Interrupts Timers
35 pages
MPMC Lab Manual 2019-20 PDF
PDF
No ratings yet
MPMC Lab Manual 2019-20 PDF
35 pages
8051 Assembly Language Programs
PDF
No ratings yet
8051 Assembly Language Programs
4 pages
8086 Memory Organization
PDF
No ratings yet
8086 Memory Organization
6 pages
Unit 4
PDF
No ratings yet
Unit 4
108 pages
8051 Question
PDF
No ratings yet
8051 Question
9 pages
Microcontrollers - UNIT I
PDF
No ratings yet
Microcontrollers - UNIT I
45 pages
UNIT V Microcontroller I - MCQs
PDF
100% (3)
UNIT V Microcontroller I - MCQs
10 pages
8051 Interfacing
PDF
No ratings yet
8051 Interfacing
6 pages
ARM Organization and Implementation: Aleksandar Milenkovic
PDF
100% (2)
ARM Organization and Implementation: Aleksandar Milenkovic
37 pages
8051 Unit 1 Notes
PDF
100% (13)
8051 Unit 1 Notes
19 pages
Assignment Questions of ES1
PDF
No ratings yet
Assignment Questions of ES1
5 pages
8086 Interview Questions:: 8086 Microprocessor
PDF
No ratings yet
8086 Interview Questions:: 8086 Microprocessor
20 pages
MPMC University Questions PDF
PDF
No ratings yet
MPMC University Questions PDF
22 pages
8051 - MCQ
PDF
No ratings yet
8051 - MCQ
5 pages
Interrupts: RST 7.5 RST 6.5 RST 5.5 1 Non-Vectored Intr 1 Non-Maskable Vectored Trap
PDF
No ratings yet
Interrupts: RST 7.5 RST 6.5 RST 5.5 1 Non-Vectored Intr 1 Non-Maskable Vectored Trap
11 pages
MP Lab Manual
PDF
100% (1)
MP Lab Manual
11 pages
Ece IV Microcontrollers 10es42 Question Paper
PDF
No ratings yet
Ece IV Microcontrollers 10es42 Question Paper
3 pages