0% found this document useful (0 votes)
936 views7 pages

PFC Workshop01 2015

Here is the code of the program: #include <stdio.h> int main() { char c = 'A'; int i = 1; long l = 1000; float f = 0.5; double d = 12.809; return 0; } The memory structure of the program would be: c: address 'A' i: address 1 l: address 1000 f: address 0.5 d: address 12.809
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
936 views7 pages

PFC Workshop01 2015

Here is the code of the program: #include <stdio.h> int main() { char c = 'A'; int i = 1; long l = 1000; float f = 0.5; double d = 12.809; return 0; } The memory structure of the program would be: c: address 'A' i: address 1 l: address 1000 f: address 0.5 d: address 12.809
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Subject: PRF192- PFC

Workshop 01
Name: Đỗ Minh Hiếu
ID Student: SE162117
Class: SE1648
Objectives:
(1) Reviewing for number systems
(2) Exploring memory of a C program

Recommendations
Part 1: Students do exercises using notebooks
Part 2: Students develop programs, run them, write down their memory structure to
notebooks.

Part 1: Number systems

Exercise 1 (2 marks): Convert decimal numbers to binary ones

Decimal 4-bit Decimal 8-bit Decimal 16-bit Binary


Binary Binary

9 1001 7 0000 0111 255 0000 0000 1111 1111


7 0111 34 0010 0010 192 0000 0000 1100 0000
2 0010 125 0111 1101 188 0000 0000 1011 1100
15 1111 157 1001 1101 312 0000 0001 0011 1000
12 1100 162 1010 0010 517 0000 0010 0000 0101
11 1011 37 0010 0101 264 0000 0001 0000 1000
6 0110 66 0100 0010 543 0000 0010 0001 1111
5 0101 77 0100 1101 819 0000 0011 0011 0011
8 1000 88 0101 1000 1027 0000 0100 0000 0011
13 1101 99 0110 0011 2055 0000 1000 0000 0111
14 1110 109 0110 1101 63 0000 0000 0011 1111

Exercise 2(2 marks): Convert decimal numbers to binary and hexadecimal ones

Decimal Binary Hexa. Decimal 16-bit Binary Hexadecim


al

9 1001 9 255 0000 0000 1111 1111 00FF


127 0111 1111 7F 192 0000 0000 1100 0000 00C0
125 0111 1101 7D 188 0000 0000 1011 1100 00BC
157 1001 1101 AF 312 0000 0001 0011 1000 0138
162 1010 0010 A2 517 0000 0010 0000 0101 0205
37 0010 0101 25 264 0000 0001 0000 1000 0108
66 0100 0010 42 543 0000 0010 0001 1111 021F
77 0100 1101 4D 819 0000 0011 0011 0011 0333
88 0101 1000 58 1027 0000 0100 0000 0011 0403
99 0110 0011 63 2055 0000 1000 0000 0111 0807
109 0110 1101 6D 63 0000 0000 0011 1111 003F

Exercise 3(2 marks): Compute


(b: binary, q: octal, h: hexadecimal)

3245q + 247q = 3514q = 011 101 001 100 b

1 1 <---- carry
  3 2 4 5
+
             2 4 7
       35 14

1A7Bh + 26FE7h = 28A62 h = 0010 1000 1010 0110 0010 b


11 1 <---- carry
26FE7
+
1A7B
28 A62

1101101101b - 10110111b = 1010110110 b


1 11 11 <---- carry
1101101101
-
10110111
1010110110
3654q – 337q = 3315q = 110 110 011 101b

1 <---- carry
3654
-
337
3315

3AB7h – 1FAh = 38BD h = 0011 1000 1011 1101 b


11 <---- carry
3AB7
-
1FA
38BD
36Ah – 576q = 1EC h = 0001 1110 1100 b
576 q = 382 d =17E h
11 <---- carry
36A
-
17E
1EC
64AEh – 1001101b= 62141 q
64AE h = 25774 d = 62256 q
1001101 b = 115 q
<---- carry

62256

- 115

62141
101101111 b
+ 100111011 b
110110001 b
110001101 b
10111101000 b

1011010 b* 1011b = 1111011110 b


1011010
* 1011
1011010
1011010
0000000
1011010
1111011110
1101000b + 2AB h + 345 q = 3F8 h = 1770 q
1101000 b = 150 q = 68 h
2AB h = 1253 q
345 q = E5 h
11 <---- carry 11 <---- carry

68 150
+ 2AB + 1253
+ E5 + 345
3F8 1770

3AFh / 1Ch = 100001b Remainder 10011b = 33d Remainder 19d


3AF h = 1110101111 b = 943 d
1C h = 11100 b = 28 d

1110101111 | 11100
-11100 | ---------
--------- | 100001
10 |
101 |
1011 |
10111 |
101111 |
-11100
----------
10011
3ACh – 562q = 1000111010 b = 570 d
3AC h = 0011 1010 1100 b
562 q = 101 110 010 b
111 1 <---- carry
001110101100
-
101110010
1000111010
3FFA h / 327q =1001100b Remainder 100110b = 76d Remainder 38d
3FFA h = 0011 1111 1111 1010 b = 16378 d
327q = 011 010 111 = 215 d

11111111111010 | 11010111
-11010111 |-------------------
--------------- | 1001100
1010001
10100011
101000111
- 11010111
----------------
11100000
-11010111
--------------
10011
100110

Exercise 4 (2 marks)
1- Show binary formats of 1-byte unsigned numbers:
251d = 1111 1011b
163d = 1010 0011b
117d = 0111 0101b
2- Show binary formats of 2-byte unsigned numbers:
551d = 0000 0010 0010 0111b
160d = 0000 0000 1010 0000b
443d = 0000 0001 1011 1011b
3- Show binary formats of 1-byte signed numbers:
-51d = 11001101b
|51|d = 00110011b
Flip bit = 11001100
Add 1 = 1
-51 = 11001101b
-163d : Out of Range
-117d = 10001011b
|117|d = 01110101b
Flip bit= 10001010
Add 1 = 1
-117d = 10001011b
320d : Out of Range
4- Show the decimal values of 1-byte unsigned representations: :
01100011 b = 99d
10001111 b = 143d
11001010 b = 202d
01001100 b = 76d

Part 2: Explore memory structure of programs

Sample

c:22936 ‘A’
23
i:22936 1
16
l:2293 1000
612
f:22936 0.5
08
d:22936 12.809
00

Complete the code of following program then draw it’s memory structure
(2 marks)

You might also like