NCZV에서 C, V

Sireal·2024년 3월 18일
2

ARM Systems

목록 보기
1/3

NZCV에서 C, V란


xPCR에서 Negative와 Zero는 플래그 이름으로 쓰임세 바로 유추할 수 있어서 정리를 안해도 될거같다.

Carry


C Is set in one of four ways:

  • For an addition, including the comparison instruction CMN, C is set to 1 if the addition produced a carry (that is, an unsigned overflow), and to 0 otherwise.
  • For a subtraction, including the comparison instruction CMP, C is set to 0 if the subtraction produced a borrow (that is, an unsigned underflow), and to 1 otherwise.
  • For non-addition/subtractions that incorporate a shift operation, C is set to the last bit shifted out of the value by the shifter.
  • For other non-addition/subtractions, C is normally left unchanged (but see the individual instruction descriptions for any special cases).
    (ref. ARM Architecture Reference Manual)

Carry

  • 비교명령CMN(Rn -(-Rm))을 포함한 덧샘 명령어로 Carry 발생시 C는 1, 안그럼 0
  • 비교명령CMP(Rn -Rm)을 포함한 뺄셈 명령어로 Carry 발생시 C는 0, 안그럼 1.
  • 시프트 명령어를 통합하는 비 덧셈/뺄셈 일 경우, 시프트에 시프트된 마지막 비트가 C로 됨.
  • 기타 비 덧셈/뺄셈 은, C 에서 일반적으로 변경되지 않은채 유지됨. (특별한 케이스의 독립된 명령어는 설명참고)

정리

  • 덧셈, 뺄셈, 비교 연산: [Carry] [MSB] [bit] [bit] [bit] ... [LSB] [Carry]
    • 덧셈명령어(CMN포함)에서 자리올림이 일어나면 C는 1. 아니면 0.
    • 뺄셈명령어(CMP포함)에서 자리올림이 일어나면 C는 0. 아니면 1.
  • 시프트 연산: [Carry] [MSB] [bit] [bit] [bit] ... [LSB]
    • 시프트 명령어는 밀려나서 사라진 비트를 C플래그에 저장.

oVerflow


V Is set in one of two ways:

  • For an addition or subtraction, V is set to 1 if signed overflow occurred, regarding the operands and result as two's complement signed integers.
  • For non-addition/subtractions, V is normally left unchanged (but see the individual instruction descriptions for any special cases).
    (ref. ARM Architecture Reference Manual)

Overflow

  • 덧셈 혹은 뺄셈일 경우 피연산자와 결과를 2의보수 부호있는 정수로 간주하여, 부호있는 오버플로우가 일어나면 V는 1.
  • 비 덧셈 혹은 뺄셈일 경우, V는 일반적으로 변하지 않음. (특별한 케이스의 독립된 명령어는 설명참고)

정리

  • 뎃셈, 뺄셈 연산시에만 적용가능
  • 덧셈, 뺄셈 연산시 피연산자(Rn)이 2^32(0xFFFFFFFF)를 넘기면 1로 활성화 됨.
profile
달리다 넘어져도 아픔마저 즐기려하는 사람

0개의 댓글