&igrave;–&acute;&igrave;…ˆ&euml;&cedil;”&euml;&brvbar;&not; - 4&igrave;ž&yen;

# ì–´ì…ˆë¸”ë¦¬ - 4ìž¥

This preview shows pages 1–14. Sign up to view the full content.

2 진수 산술 연산 산술연산 : 4 칙 연산 기본 연산 : 덧셈

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Sum Carry 3 7 7 + 4 4 9 sum 6 carry 1 3 7 7 + 4 4 9 sum 2 6 carry 1 3 7 7 + 4 1 9 sum 8 2 6 carry 0 10 진수
• 2 진수 a a + b + b a b sum carry 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 sum = a xor b carry = a and b c in c in a b c out sum 0 0 0 0 0 0 0 1 0 1 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
반가산기와 전가산기 and carry sum xor and carry out sum xor and xor or carry in a b a b
덧셈 ( 병렬계산 ) 3 7 7 3 7 7 + 4 4 9 + 4 2 9 sum 7 1 6 sum 7 9 6 carry 0 1 1 carry 0 0 1 + 1 1 + 0 1 8 2 6 sum 7 0 6 carry 0 1 0 + 1 8 0 6 캐리의 자리 이동 ( 왼쪽 )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
논리연산을 사용한 덧셈 xor and 를 사용한 덧셈 ( C 루틴 ) int add ( int a, int b ) { int s; /* sum */ int c; /* carry */ s = a ^ b; /* xor operation */ while (c = (a & b) << 1) { /* shift-left after carry- a = s; decision*/ b = c; s = a ^ b; } return(s); } a + b a, b: n bits
논리연산을 사용한 덧셈 예 13 10 + 11 10 001101 (a) 001011 (b) sum 000110 (s) ( a ) carry 001001 carry<<1 01001 (c) ( b ) sum 010100 ( s ) --> ( a ) carry 000010 carry<<1 00010 ( c ) --> ( b ) sum 010000 ( s ) (a) carry 000100 carry<<1 00100 ( c ) (b) sum 011000 carry 000000

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
뺄셈 (signed number) 음수 : 2 의 보수 (2’s complement) 표현 부호 판정 : 최상위 비트 (msb), 0: 양수 , 1: 음수 뺄셈은 덧셈으로 계산 x - y = x + (-y) = x + (2 n -1-y) + 1 n: 자리개수 즉 비트수 n 비트의 정수 표현 범위 – signed: -2 n-1 ~ 2 n-1 - 1 – unsigned: 0 ~2 n -1 4 비트의 경우 2 n-1 - 1 -2 n-1 0 overflow 0 000 0 0001 1 0010 2 ... 0111 7 1 000 -8 1001 -7 .... 1 111 -1
6 - 3 n = 8 인 경우 6 – 3 = 6 + (-3) = 00000110 - 00000011 = 00000110 + [(100000000 -1- 00000011 ) +1] = 00000110 + [11111111 - 00000011 + 1] = 0 0000110 + 1 1111101 = 0 0000011 캐리 발생은 무시

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
덧셈 오버플로우 탐지 (V 비트 ) (+) + (+) (+) V = 0 (+) + (-) (+,-) V = 0 (-) + (-) (-) V = 0 (+) + (+) (-) V = 1 (-) + (-) (+) V = 1 2 n-1 - 1 -2 n-1 0 overflow
뺄셈 오버플로우 탐지 (+) - (+) (+,-) V = 0, ( , <) (-) - (-) (+,-) V = 0, ( , <) (+) - (-) (+) V = 0 (-) - (+) (-) V = 0 (+) - (-) (-) V = 1 (-) - (+) (+) V = 1 V = C out C out-1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
분기 명령과 CC 분기 명령을 처리할때의 CC 검사 cc 를 만들때 사용한 수가 signed number 인 경우 OP code CC bl N xor V= 1 ble Z or (N xor V) = 1 be Z = 1 bne Z = 0 bge N xor V = 0 bg Z or (N xor V) = 0
비트 쉬프팅 (shifting) 연산 sll: s hift l eft l ogical sra: s hift r ight a rithmetic srl: s hift r ight l ogical 명령어 형식 Op S, A, D S, D: 레지스터 A: 레지스터 또는 상수 A 의 하위 5 비트로 쉬프팅 양을 표시 0 0 sra srl sll arithmetic: 대상 정보가 수치 logical: 비수치 Shift n-bit left = multiply by 2 n

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/03/2009 for the course CS Assembly taught by Professor Park during the Fall '09 term at 홍익대학교.

### Page1 / 51

ì–´ì…ˆë¸”ë¦¬ - 4ìž¥

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online