hankec Hanke Chen

Problem 1

3 exponent 2 fraction

[-6, 7]

1/32 = 1.00 * 2^-5 = 101 00 1/16 = 1.00 * 2^-4 = 100 00 3/32 = 1.10 * 2^-6 = 110 10 1 = 1.00 * 2^0 = 000 00 11 = 1011.000 = 1.011 * 2^-3 = 011 11 = 12 12 = 1100.000 = 1.100 * 2^-3 = 011 11 = 12

[-2, 3]
1/32 = 1.00 * 2^-5 = 2^-2 * 0.001 = 000 001 = 000 00 = round to 0
1/16 = 1.00 * 2^-4 = 2^-2 * 0.01 = 000 01 = no round
3/32 = 000 10 = round to 0.1*2^-2 = 1/8
1 = 1.0 * 2^0 = 011 00 = no round
11 = 1011.000 = 1.011 * 2^3 = 110 10 = round to 12
12 = 1100.000 = 1.100 * 2^3 = 110 10 = no round

(11:48.32)

Problem 2

CNT1 = 168/struct_a byte CNT2 = 12/4 = 3 byte CNT3 = 4 byte struct_a = 24 byte

rax = (rax *3) * 8 + 12

CNT1 * sizeof(struct_a) = 168
sizeof(struct_a) = 24
CNT2 * sizeof(int) = 12
CNT2 = 3
CNT1 = 7
sizeof(struct_a) = sizeof(int) * CNT2 + CNT3 + 1
5 = CNT2 + CNT3
CNT3 = 2

(24:22.17)

Problem 3

high at = 104 100 / N = (16 + 8byte) struct_a = 12 + type_t

type_t = uint8 N = 5

(32:01.90)

Problem 4

int looped(int a[], int n) { int i; int x%edx = 0; for (i%ecx = 0; n > n && i <= 0; i++) { if (a[i]>x) x = a[i] } return x; }

remember test %rax %rax and then jle is testing whether is 0
cmp is flipped

(42:17.66)??

Problem 5

0x55683a58 0x55683a5f ? 0x003164f8

20, 8b, 04, 80

(54:56.65)??

TODO:

Problem 6

mul = 7 add = 5

7 + 5 + 7 + 7 7 + 5 + 5 + 7 7 + 7 + 5 ??

TODO:

(1:00:56.38)

Problem 7

physical: 14 bits 2 way associative 8 byte block size 2 sets Least Recent

...CT..., CI, CO CO CO

0x1 0x4

001 100 110 011

store 8 element mmm mhh hhh hhh


mhm mhm hhh hhh

store 4*4 = 16 mhhhm hhhmh hhmhh hmhhh mhhhm 6 miss

store 4*2 mhmhm hmhmh mhmhm hmhmh mhmhm 13 miss

store 2*16 mhhhh hhhhh hhhhh hmhhh hhhhh 2 miss

store 2*8 mhhhh hhhmh hhhhh hmhhh hhhhm 4 miss * 2 = 8 miss

(1:28:22.37)

Problem 8

abc, bac

213

(1:30:29.67)

Problem 9

15

11

(1:32:26.37)

Problem 10

cnt == 0 cnt == -1 cnt == 0 cnt == 1

(1:34:51.43)

Problem 11

Yes 1 2 4 3 6 5

...

P(s1) P(s1) P(s1) P(s2) P(s3) V(s2) V(s3) V(s1) V(s1) V(s1)

(1:43:52.23)

TODO:

- instruction table

Table of Content