20230125 아스키코드와 2’s complement
아스키코드
숫자는 hex 30부터 시작한다.
즉, 숫자 0 = 30h
20h는 space다.
byte vs word vs dword vs qword
- byte = 8 bits
- word = 16 bits
- dword = doubleword = 32 bits
- qword = quadword = 64 bits
10진수 2’s complement
- 양수면 그냥 2진수로 변환
- 음수면 i) (1’s complement) 0은 1로 1은 0으로 바꾸기, ii) (add 1) 1 더하기
매번 10진수를 2’s complement해라 라는 문제를 풀 때마다 구글링하면 나오는 2’s complement 계산기를 사용해서 답이 맞는지 확인해보려고 하면,
무조건 양수는 음수로 음수는 양수로 바꾸는 답을 보여줘서 혼란이 온다. 구글링이 정답은 아니라는 것을 보여주는 대표적 예시,,,,
결론은 내가 맞다. 양수면 그냥 2진수로 변환해야한다.
(The 2’s complement representation for a nonnegative number is almost identical to the unsigned representation, that is, you represent the number in binary with enough leading zeros to fill up the desired length.
There is one additional restriction - for a positive number, the leftmost bit must be zero. (Introduction to 80x86 Assembly Language and Computer Architecture, Richard C.Detmer, 11pg))
Leave a comment