Lecture13 Lecture Today ID: 829295
Download Pdf The PPT/PDF document "Special Bit Instructions" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
1 Lecture13: Lecture : Special Bit Ins
Lecture13: Lecture : Special Bit Instructions Todays Goals Lbit tdbit litti L an d i Branch on bit instructions Bit Manipulate Instructions BSET(M (M)+(mm)) Set or clear bits in a memory byt
2 e BSET + Set to 1 bits in a mem
e BSET + Set to 1 bits in a memory locationBCLR ( M ( M ) · ( mm ()()) Clear to 0 bits in a memory locationNote that Thlbddti ey can on l y e use d on d a t Use AND andOR instructions
3 for setting/clearing bits on registers.
for setting/clearing bits on registers.Therefore, two operands are needed. 1 :theaddress : immediate mask valueIn the mask byte,1 means to affect the bit 0thbit 0 means preserve th e 0,X,$81 ;$
4 81 = ; BCLR0,Y, $33; $33 = %00110011
81 = ; BCLR0,Y, $33; $33 = %00110011 Bit Test Instructions BITA ((A) (M)) Test bits · (M)) Test bits without alterin g the value of the re g ister. BITB ((B) · (M)) Test bits without altering
5 the value of the register. Examples Exa
the value of the register. Examples Examples BITA#$44 ; $44 = %01000100Tests the bit 6 and 2 of register A. UpdatesZandNbitsofCCRaccordingly Updates Z N bits of .Note that Likecompa
6 risoninstructionstheresultisdiscardedCCR
risoninstructionstheresultisdiscardedCCRbits Like bits are affected by the instructions. Bit Condition Branch Instructions Makebranchdecisionsbasedonthevalueofbits BRCLR, BRSET
7 Perform bitwise logical AND on the cont
Perform bitwise logical AND on the contents of the specified memory location and the mask supplied with the instruction. BRCLR:branchif(M) ·(mm)=0 [ifselectedbit(s)clear] BRCLR: · = 0
8 BRSET: branch if (M) · (mm) = 0[i
BRSET: branch if (M) · (mm) = 0[if selected bit(s) set] El E here brclr$66,$80,hereldd$70 Note: The first operand is an address. loop inc count Examples Tthbilihtithtfftithbit Two door sport ca
9 r T urn on th e ca bi n ti ng o th
r T urn on th e ca bi n ti ng o th er BSET$00, %00000010; $02 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 $0000GBOXDLEFTDRGHTDTRNKD-GBOXLCBNLTRNKL Examples Tffthlblihtdtklihtithtffti Two door sport car T ur
10 n o ff e g l ove an d t g ti othe
n o ff e g l ove an d t g ti other bits BCLR$00, %00000101; $05 7 6 5 4 3 2 1 0 7 6 5 4 3 2 1 0 $0000GBOXDLEFTDRGHTDTRNKD-GBOXLCBNLTRNKL Examples Tthbilihtifithdi(thbitit) Two door sport car T
11 urn on th e ca bi n s open ( = i s
urn on th e ca bi n s open ( = i s se t) LDAA$00BITA#%01100000; #$60 B NE BRASKIPCBNLON:BSET$00, %00000010; $02 $0000GBOXDLEFTDRGHTDTRNKD-GBOXLCBNLTRNKL Examples Tffthbilihtifbthdld Two door sport
12 car T urn o ff e ca bi n b o
car T urn o ff e ca bi n b o d oors are c l ose BRCLR$00, %01100000, CBNLOFFBRASKIP 00, %00000010 SKIP: $0000GBOXDLEFTDRGHTDTRNKD-GBOXLCBNLTRNKL Examples Tthbi lihtif bthd Two door sport ca
13 r T urn on th e ca bi n b o d
r T urn on th e ca bi n b o d oors are open BRSET#%01100000CBNLONBRASKIP 00, %00000010 ; $02 SKIP: $0000GBOXDLEFTDRGHTDTRNKD-GBOXLCBNLTRNKL Questions? Wrap-up What weve learned What to Come