Table 2.2. Condition codes Code Encoding Meaning (when set by CMP) EQ 0b0000 Equ
ID: 3854550 • Letter: T
Question
Table 2.2. Condition codes Code Encoding Meaning (when set by CMP) EQ 0b0000 Equal to NE Ob0001 Not equal to CS 0b0010 Carry set (identical to HS) HS 0b0010 Greater than, equal to (unsigned) (identical to CS). Greater than, equal to, or unordered (identical to CS), C = 1 CC 0b0011 Carry clear (identical to LO) LO 0b0011 Unsigned less than (identical to CC). MI 0b0100 PL 0b0101 Positive or zero. VS Ob0110 VC 0b0111 HI 0b1000 Greater than (unsigned) LS 0b1001 Less than or equal to (unsigned) GE 0b1010 LT GT 0b1100 Greater than (signed) LE 0b1101 Less than or equal to (signed) AL 0b1110 NV Condition flags Meaning (when set by FCMP) Equal to. Unordered, or not equal to Greater than, equal to, or unordered (identical to HS). C = 1 z=0 Less than (identical to LO). Less than (identical to CC) Less than. Greater than, equal to, or unordered Unordered. (At least one argument was NaN) Not unordered. (No argument was NaN) Greater than or unordered Less than or equal to Greater than or equal to. Less than or unordered Greater than Less than, equal to or unordered Default. Always executed Always executed c=0 c=0 Minus, Negative Signed overflow V=0 (c = 1) &6(z = 0) (C = 0) 11 (Z = 1) No signed overflow Greater than or equal to (signed) Less than (signed) 0b1011 Always Any 0b1111 Always executed AnyExplanation / Answer
Code:-
MOV X0,A
MOV #0,R7
CMP
B.NE CASE2
CASE1:
ADD X1,X1,#1
B END_SWITCH
CASE2:
MOV #1,R7
MOV X0,A
CMP
B.NE DEFAULT
SUB X1,X1,#1
B END_SWITCH
DEFAULT:
B END_SWITCH
END_SWITCH
Explanation:-
First,X value is taken into accumulator and compared with value 0.If it matches, then case0 will be executed and ultimately will be branched to last line of switch statement (END_SWITCH).
But,when the value doesn't be equal to 0 then control jumps to CASE1 where the value of X will be checked with 1 ,and if the value matches then case1 will be executed and ultimately will be branched to last line of switch statement (END_SWITCH).
Butmhere also if it doesn't matches then the control will be jumped to DEFAULT .(Same as like switch statement)
Here,first the value is checked with case constant if it matches then following statement will be executed otherwise control is branched to next condition
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.