어셈블리 - 4장

어셈블리 - 4장

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

View Full Document Right Arrow Icon
2 진수 산술 연산 산술연산 : 4 칙 연산 기본 연산 : 덧셈
Background image of page 1

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

View Full DocumentRight Arrow Icon
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 진수
Background image of page 2
• 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
Background image of page 3

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

View Full DocumentRight Arrow Icon
반가산기와 전가산기 and carry sum xor and carry out sum xor and xor or carry in a b a b
Background image of page 4
덧셈 ( 병렬계산 ) 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 캐리의 자리 이동 ( 왼쪽 )
Background image of page 5

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

View Full DocumentRight Arrow Icon
논리연산을 사용한 덧셈 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
Background image of page 6
논리연산을 사용한 덧셈 예 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
Background image of page 7

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

View Full DocumentRight Arrow Icon
뺄셈 (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
Background image of page 8
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 캐리 발생은 무시
Background image of page 9

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

View Full DocumentRight Arrow Icon
덧셈 오버플로우 탐지 (V 비트 ) (+) + (+) (+) V = 0 (+) + (-) (+,-) V = 0 (-) + (-) (-) V = 0 (+) + (+) (-) V = 1 (-) + (-) (+) V = 1 2 n-1 - 1 -2 n-1 0 overflow
Background image of page 10
뺄셈 오버플로우 탐지 (+) - (+) (+,-) V = 0, ( , <) (-) - (-) (+,-) V = 0, ( , <) (+) - (-) (+) V = 0 (-) - (+) (-) V = 0 (+) - (-) (-) V = 1 (-) - (+) (+) V = 1 V = C out C out-1
Background image of page 11

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

View Full DocumentRight Arrow Icon
분기 명령과 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
Background image of page 12
비트 쉬프팅 (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
Background image of page 13

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

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 51

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

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

View Full Document Right Arrow Icon
Ask a homework question - tutors are online