Assembly Language Question

Description

Please answer all questions as indicated. These questions are for an Introduction to Computer Organization course and the language that is being used is C. I have attached the exam questions below so please take a look at them!

Don't use plagiarized sources. Get Your Custom Assignment on
Assembly Language Question
From as Little as $13/Page

Unformatted Attachment Preview

1. One Byte’s Alright (20 points): Suppose a char is interpreted as a signed 8-bit integer, and an unsigned
char is interpreted as an unsigned 8-bit integer. Consider the following code snippet:
char x,y;
x=0x7F
y=~x+1;
Evaluate each of the following:
1.1 What is the value of y? (answer A-L)
A) 0b10000000
B) 0b10000001
C) 0b10000010
D) 0b01111111
E) 0b01111110
F) 0b01111101
G) 0b11111111
H) 0b11111110
I) 0b11111101
J) 0b00000000
K) 0b00000001
L) 0b00000010
1.2 What is the value of (x | y) ? (answer A-L)
A) 0b10000000
B) 0b10000001
C) 0b10000010
D) 0b01111111
E) 0b01111110
F) 0b01111101
G) 0b11111111
H) 0b11111110
I) 0b11111101
J) 0b00000000
K) 0b00000001
L) 0b00000010
1
1.3 What is the value of (x & y) ? (answer A-L)
A) 0b10000000
B) 0b10000001
C) 0b10000010
D) 0b01111111
E) 0b01111110
F) 0b01111101
G) 0b11111111
H) 0b11111110
I) 0b11111101
J) 0b00000000
K) 0b00000001
L) 0b00000010
1.4 What is the value of (x ^ y) ? (answer A-L)
A) 0b10000000
B) 0b10000001
C) 0b10000010
D) 0b01111111
E) 0b01111110
F) 0b01111101
G) 0b11111111
H) 0b11111110
I) 0b11111101
J) 0b00000000
K) 0b00000001
L) 0b00000010
2
2. C If You Can Solve This One (20 points): For the C puzzles below, determine whether each statement is
always true (e.g. true for all values of x and y). If the statement can be false, give a counter example value
for x or y that would make the statement false. Assume that x and y are signed integers and could have any
value (functions foo and bar could return any signed integer). The full context for evaluation is:
int x,y;
unsigned int ux, uy;
x = foo();
y = bar();
ux = x;
uy = y;
For example, for the puzzle
x < 0 ® -x > 0
the answer would be:
FALSE
And the counter example would be:
x = Tmin
Solve the following, writing the answer on your answer sheet:
2.1:
(x & 5) == 0x5
®
((x | (x ux
2.4:
x+y = -1
®
(~x + 1) == (y + 1)
3
3. Heavy Metal (20 points): Consider the following declaration:
char * mystery[20];
Suppose the address of mystery is 0x6012e0. Using the following memory dumps on an x86-64 machine,
what string would be printed by
printf(“%s”, mystery[6]);
MEMORY DUMP #1
(gdb) x/256xb 0x6012e0
0x6012e0: 0x62 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x6012e8: 0x68 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x6012f0: 0x6f 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x6012f8: 0x76 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601300: 0x7b 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601308: 0x82 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601310: 0x86 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601318: 0x8f 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601320: 0x96 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601328: 0x9b 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601330: 0xa4 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601338: 0xaa 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601340: 0xb3 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601348: 0xbc 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601350: 0xc5 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601358: 0xcf 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601360: 0xd4 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601368: 0xdb 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601370: 0xe3 0x08 0x40 0x00 0x00 0x00 0x00 0x00
0x601378: 0xe8 0x08 0x40 0x00 0x00 0x00 0x00 0x00
MEMORY DUMP #2
(gdb) x/256xb 0x400862
0x400862: 0x62 0x72 0x61 0x73 0x73 0x00 0x62 0x72
0x40086a: 0x6f 0x6e 0x7a 0x65 0x00 0x63 0x6f 0x70
0x400872: 0x70 0x65 0x72 0x00 0x69 0x72 0x6f 0x6e
0x40087a: 0x00 0x6e 0x69 0x63 0x6b 0x65 0x6c 0x00
0x400882: 0x74 0x69 0x6e 0x00 0x61 0x6c 0x75 0x6d
0x40088a: 0x69 0x6e 0x75 0x6d 0x00 0x73 0x69 0x6c
0x400892: 0x76 0x65 0x72 0x00 0x67 0x6f 0x6c 0x64
0x40089a: 0x00 0x74 0x69 0x74 0x61 0x6e 0x69 0x75
0x4008a2: 0x6d 0x00 0x73 0x74 0x65 0x65 0x6c 0x00
0x4008aa: 0x70 0x6c 0x61 0x74 0x69 0x6e 0x75 0x6d
0x4008b2: 0x00 0x63 0x68 0x72 0x6f 0x6d 0x69 0x75
4
0x4008ba: 0x6d 0x00 0x76 0x61 0x6e 0x61 0x64 0x69
0x4008c2: 0x75 0x6d 0x00 0x70 0x61 0x6c 0x6c 0x61
0x4008ca: 0x64 0x69 0x75 0x6d 0x00 0x7a 0x69 0x6e
0x4008d2: 0x63 0x00 0x63 0x6f 0x62 0x61 0x6c 0x74
0x4008da: 0x00 0x72 0x68 0x6f 0x64 0x69 0x75 0x6d
0x4008e2: 0x00 0x6c 0x65 0x61 0x64 0x00 0x6d 0x69
0x4008ea: 0x74 0x68 0x72 0x69 0x6c 0x00 0x01 0x1b
0x4008f2: 0x03 0x3b 0x34 0x00 0x00 0x00 0x05 0x00
0x4008fa: 0x00 0x00 0x50 0xfb 0xff 0xff 0x80 0x00
0x400902: 0x00 0x00 0xa0 0xfb 0xff 0xff 0x50 0x00
0x40090a: 0x00 0x00 0x8d 0xfc 0xff 0xff 0xa8 0x00
0x400912: 0x00 0x00 0x10 0xfd 0xff 0xff 0xc0 0x00
0x40091a: 0x00 0x00 0x80 0xfd 0xff 0xff 0x08 0x01
0x400922: 0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x00
0x40092a: 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x7a
0x400932: 0x52 0x00 0x01 0x78 0x10 0x01 0x1b 0x0c
0x40093a: 0x07 0x08 0x90 0x01 0x07 0x10 0x14 0x00
0x400942: 0x00 0x00 0x1c 0x00 0x00 0x00 0x48 0xfb
0x40094a: 0xff 0xff 0x2a 0x00 0x00 0x00 0x00 0x00
0x400952: 0x00 0x00 0x00 0x00 0x00 0x00 0x14 0x00
0x40095a: 0x00 0x00 0x00 0x00 0x00 0x00 0x01 0x7a
And here’s an ASCII table if you need it:
5
3.1 The string is: (answer A-S)
A) adamantium
B) aluminum
C) brass
D) bronze
E) chromium
F) cobalt
G) copper
H) gold
I) iron
J) nickel
K) palladium
L) platinum
M) rhodium
N) silver
O) steel
P) tin
Q) titanium
R) vanadium
S) zinc
6
4. Caverns and Chimeras (40 points): You are playing a new role playing game called Caverns and Chimeras.
There are different heroes in the game, and a group of heroes makes a “party”. You discover a leak of the
source code for an x86-64 architecture that gives you the data structure for a hero:
struct party_slot {
char shield;
short weapon;
int class;
short armor;
char snack;
short strength;
short dexterity;
short constitution;
short intelligence;
short wisdom;
short charisma;
struct party_slot * next;
};
The party_slot struct is used in a linked list that holds all of the heroes in a party. One hero per party_slot.
A “guild” is a collection of parties. The guild is defined by the struct:
struct roster {
struct party_slot * party[5];
char * party_name[5];
int party_wealth[5];
} guild;
Each party has a name (party_name) and a number of gold coins (party_wealth). There are at most 5 parties
in the guild – so the first party (index 0) would have a linked list of party_slot structs starting at
guild.party[0], the name guild.party_name[0], and party_wealth[0] gold coins.
Each hero is defined by their equipment (shield, weapon, armor, snack), their profession (class), and their
attributes (strength, dexterity, constitution, intelligence, wisdom, and charisma). The source code tells you
that the game uses a lot of “magic numbers” in its code. For example, this #define statement:
#define PALADIN 210
means that wherever the string PALADIN is in the code, it is substituted by 210 in the preprocessor of the
compiler. The game defines the following heroes:
#define PALADIN 210
#define ROGUE 212
#define WIZARD 213
#define CLERIC 215
#define BARD 216
#define BARBARIAN 218
7
The following weapons:
#define SPEAR 10
#define FAUCHARD 12
#define VOULGE 14
#define PIKE 8
#define HALBERD 6
#define GLAIVE 17
#define LANCE 13
#define RANSEUR 15
And the following snacks:
#define MUTTON 21
#define STEW 22
#define CELERY 23
#define LIMEBARK 24
#define APPLE 25
#define WAYBREAD 26
#define CHEESE 27
#define MELON 28
This function adds a hero to a specific guild index (0-4):
int add_hero (int index, int class, short weapon, short armor,
char shield, char snack, short strength, short dexterity,
short constitution, short intelligence, short wisdom,
short charisma);
Hero attributes are used to determine whether or not a hero can accomplish a specific task. For example,
function attribute_check:
int attribute_check (struct party_slot * ptr);
will check one of the six attributes (strength, dexterity, constitution, intelligence, wisdom, or charisma) to
see if it is greater than a specific value. Here is the assembly code for attribute_check:
000000000040060d :
40060d:
66 83 7f 16 0e
400612:
0f 9f c0
400615:
0f b6 c0
400618:
c3
cmpw
$0xe,0x16(%rdi)
setg
%al
movzbl %al,%eax
retq
The main monster in the game is a “chimera”, and if your hero encounters a chimera, function
handle_chimera() is invoked to see if they win or lose against the monster based on their class (profession)
and weapon – each class has to have the correct weapon to defeat the chimera:
int handle_chimera (int class, short weapon);
8
Here is the assembly code for handle_chimera:
000000000040060d :
40060d:
53
40060e:
81 ef d2 00 00 00
400614:
83 ff 08
400617:
77 51
400619:
89 ff
40061b:
ff 24 fd 48 10 40 00
400622:
66 83 fe 0a
400626:
0f 94 c3
400629:
0f b6 db
40062c:
eb 41
40062e:
66 83 fe 11
400632:
0f 94 c3
400635:
0f b6 db
400638:
eb 35
40063a:
66 83 fe 0c
40063e:
0f 94 c3
400641:
0f b6 db
400644:
eb 29
400646:
66 83 fe 06
40064a:
0f 94 c3
40064d:
0f b6 db
400650:
eb 1d
400652:
66 83 fe 0d
400656:
0f 94 c3
400659:
0f b6 db
40065c:
eb 11
40065e:
66 83 fe 0e
400662:
0f 94 c3
400665:
0f b6 db
400668:
eb 05
40066a:
bb 00 00 00 00
40066f:
85 db
400671:
74 0a
400673:
bf e0 0f 40 00
400678:
e8 43 fe ff ff
40067d:
89 d8
40067f:
5b
400680:
c3
push
%rbx
sub
$0xd2,%edi
cmp
$0x8,%edi
ja
40066a
mov
%edi,%edi
jmpq
*0x401048(,%rdi,8)
cmp
$0xa,%si
sete
%bl
movzbl %bl,%ebx
jmp
40066f
cmp
$0x11,%si
sete
%bl
movzbl %bl,%ebx
jmp
40066f
cmp
$0xc,%si
sete
%bl
movzbl %bl,%ebx
jmp
40066f
cmp
$0x6,%si
sete
%bl
movzbl %bl,%ebx
jmp
40066f
cmp
$0xd,%si
sete
%bl
movzbl %bl,%ebx
jmp
40066f
cmp
$0xe,%si
sete
%bl
movzbl %bl,%ebx
jmp
40066f
mov
$0x0,%ebx
test
%ebx,%ebx
je
40067d
mov
$0x400fe0,%edi
callq 4004c0
mov
%ebx,%eax
pop
%rbx
retq
The following gdb interaction and four memory dumps will help you:
(gdb) print &guild
$1 = ( *) 0x602080
9
MEMORY DUMP #1
0x602080: 0xa0 0x30 0x60 0x00 0x00 0x00 0x00 0x00
0x602088: 0x60 0x31 0x60 0x00 0x00 0x00 0x00 0x00
0x602090: 0x20 0x32 0x60 0x00 0x00 0x00 0x00 0x00
0x602098: 0xe0 0x32 0x60 0x00 0x00 0x00 0x00 0x00
0x6020a0: 0xa0 0x33 0x60 0x00 0x00 0x00 0x00 0x00
0x6020a8: 0x70 0x0f 0x40 0x00 0x00 0x00 0x00 0x00
0x6020b0: 0x7a 0x0f 0x40 0x00 0x00 0x00 0x00 0x00
0x6020b8: 0x83 0x0f 0x40 0x00 0x00 0x00 0x00 0x00
0x6020c0: 0x8c 0x0f 0x40 0x00 0x00 0x00 0x00 0x00
0x6020c8: 0x95 0x0f 0x40 0x00 0x00 0x00 0x00 0x00
0x6020d0: 0x00 0x04 0x00 0x00 0x00 0x01 0x00 0x00
0x6020d8: 0x40 0x00 0x00 0x00 0x80 0x00 0x00 0x00
0x6020e0: 0x00 0x02 0x00 0x00 0x00 0x00 0x00 0x00
0x6020e8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6020f0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6020f8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
MEMORY DUMP #2
0x400f70: 0x50 0x49 0x4e 0x45 0x41 0x50 0x50 0x4c
0x400f78: 0x45 0x00 0x47 0x4e 0x41 0x53 0x48 0x45
0x400f80: 0x52 0x53 0x00 0x57 0x4f 0x4c 0x46 0x50
0x400f88: 0x41 0x43 0x4b 0x00 0x4f 0x52 0x43 0x53
0x400f90: 0x42 0x41 0x4e 0x45 0x00 0x53 0x59 0x4c
0x400f98: 0x56 0x41 0x4e 0x53 0x00 0x43 0x48 0x45
0x400fa0: 0x43 0x4b 0x20 0x25 0x64 0x20 0x25 0x64
0x400fa8: 0x20 0x25 0x64 0x20 0x25 0x64 0x0a 0x00
0x400fb0: 0x4f 0x4e 0x57 0x41 0x52 0x44 0x21 0x00
0x400fb8: 0x01 0x1b 0x03 0x3b 0x5c 0x00 0x00 0x00
0x400fc0: 0x0a 0x00 0x00 0x00 0xf8 0xf4 0xff 0xff
0x400fc8: 0xa8 0x00 0x00 0x00 0x68 0xf5 0xff 0xff
0x400fd0: 0x78 0x00 0x00 0x00 0x55 0xf6 0xff 0xff
0x400fd8: 0xd0 0x00 0x00 0x00 0x61 0xf6 0xff 0xff
10
MEMORY DUMP #3
0x401048: 0x22 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401050: 0x6a 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401058: 0x2e 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401060: 0x3a 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401068: 0x6a 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401070: 0x46 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401078: 0x52 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401080: 0x6a 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401088: 0x5e 0x06 0x40 0x00 0x00 0x00 0x00 0x00
0x401090: 0x01 0x1b 0x03 0x3b 0x64 0x00 0x00 0x00
MEMORY DUMP #4
0x603000: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603008: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603010: 0x03 0x00 0x06 0x00 0xd2 0x00 0x00 0x00
0x603018: 0x28 0x00 0x18 0x00 0x10 0x00 0x0a 0x00
0x603020: 0x0e 0x00 0x0c 0x00 0x0d 0x00 0x12 0x00
0x603028: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603030: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603038: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603040: 0x00 0x00 0x08 0x00 0xd4 0x00 0x00 0x00
0x603048: 0x2b 0x00 0x1c 0x00 0x0b 0x00 0x11 0x00
0x603050: 0x0d 0x00 0x0e 0x00 0x0c 0x00 0x08 0x00
0x603058: 0x10 0x30 0x60 0x00 0x00 0x00 0x00 0x00
0x603060: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603068: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603070: 0x00 0x00 0x0d 0x00 0xd5 0x00 0x00 0x00
0x603078: 0x2c 0x00 0x19 0x00 0x06 0x00 0x0e 0x00
0x603080: 0x08 0x00 0x12 0x00 0x0e 0x00 0x0a 0x00
0x603088: 0x40 0x30 0x60 0x00 0x00 0x00 0x00 0x00
0x603090: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603098: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6030a0: 0x05 0x00 0x0e 0x00 0xd7 0x00 0x00 0x00
0x6030a8: 0x2a 0x00 0x1b 0x00 0x0e 0x00 0x0c 0x00
0x6030b0: 0x10 0x00 0x0a 0x00 0x11 0x00 0x0e 0x00
0x6030b8: 0x70 0x30 0x60 0x00 0x00 0x00 0x00 0x00
0x6030c0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6030c8: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6030d0: 0x03 0x00 0x06 0x00 0xd2 0x00 0x00 0x00
0x6030d8: 0x28 0x00 0x16 0x00 0x10 0x00 0x0a 0x00
0x6030e0: 0x0e 0x00 0x0c 0x00 0x0d 0x00 0x11 0x00
0x6030e8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6030f0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6030f8: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603100: 0x00 0x00 0x08 0x00 0xd4 0x00 0x00 0x00
0x603108: 0x2b 0x00 0x1c 0x00 0x0b 0x00 0x11 0x00
11
0x603110: 0x0d 0x00 0x0e 0x00 0x0c 0x00 0x08 0x00
0x603118: 0xd0 0x30 0x60 0x00 0x00 0x00 0x00 0x00
0x603120: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603128: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603130: 0x00 0x00 0x0d 0x00 0xd5 0x00 0x00 0x00
0x603138: 0x2c 0x00 0x19 0x00 0x06 0x00 0x0e 0x00
0x603140: 0x08 0x00 0x12 0x00 0x0e 0x00 0x0a 0x00
0x603148: 0x00 0x31 0x60 0x00 0x00 0x00 0x00 0x00
0x603150: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603158: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603160: 0x05 0x00 0x0e 0x00 0xd7 0x00 0x00 0x00
0x603168: 0x2a 0x00 0x1b 0x00 0x0e 0x00 0x0c 0x00
0x603170: 0x10 0x00 0x0a 0x00 0x11 0x00 0x0e 0x00
0x603178: 0x30 0x31 0x60 0x00 0x00 0x00 0x00 0x00
0x603180: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603188: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603190: 0x03 0x00 0x06 0x00 0xd2 0x00 0x00 0x00
0x603198: 0x28 0x00 0x17 0x00 0x10 0x00 0x0a 0x00
0x6031a0: 0x0e 0x00 0x0c 0x00 0x0d 0x00 0x13 0x00
0x6031a8: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6031b0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6031b8: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6031c0: 0x00 0x00 0x08 0x00 0xd4 0x00 0x00 0x00
0x6031c8: 0x2b 0x00 0x1c 0x00 0x0b 0x00 0x11 0x00
0x6031d0: 0x0d 0x00 0x0e 0x00 0x0c 0x00 0x08 0x00
0x6031d8: 0x90 0x31 0x60 0x00 0x00 0x00 0x00 0x00
0x6031e0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6031e8: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6031f0: 0x00 0x00 0x0d 0x00 0xd5 0x00 0x00 0x00
0x6031f8: 0x2c 0x00 0x19 0x00 0x06 0x00 0x0e 0x00
0x603200: 0x08 0x00 0x12 0x00 0x0e 0x00 0x0a 0x00
0x603208: 0xc0 0x31 0x60 0x00 0x00 0x00 0x00 0x00
0x603210: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603218: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603220: 0x05 0x00 0x0e 0x00 0xd7 0x00 0x00 0x00
0x603228: 0x2a 0x00 0x1b 0x00 0x0e 0x00 0x0c 0x00
0x603230: 0x10 0x00 0x0a 0x00 0x11 0x00 0x0e 0x00
0x603238: 0xf0 0x31 0x60 0x00 0x00 0x00 0x00 0x00
0x603240: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603248: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603250: 0x03 0x00 0x06 0x00 0xd2 0x00 0x00 0x00
0x603258: 0x28 0x00 0x15 0x00 0x12 0x00 0x0a 0x00
0x603260: 0x0e 0x00 0x0c 0x00 0x0d 0x00 0x10 0x00
0x603268: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603270: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603278: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603280: 0x00 0x00 0x08 0x00 0xd4 0x00 0x00 0x00
0x603288: 0x2b 0x00 0x1c 0x00 0x0b 0x00 0x11 0x00
0x603290: 0x0d 0x00 0x0e 0x00 0x0c 0x00 0x08 0x00
12
0x603298: 0x50 0x32 0x60 0x00 0x00 0x00 0x00 0x00
0x6032a0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6032a8: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6032b0: 0x00 0x00 0x0d 0x00 0xd5 0x00 0x00 0x00
0x6032b8: 0x2c 0x00 0x19 0x00 0x06 0x00 0x0e 0x00
0x6032c0: 0x08 0x00 0x12 0x00 0x0e 0x00 0x0a 0x00
0x6032c8: 0x80 0x32 0x60 0x00 0x00 0x00 0x00 0x00
0x6032d0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6032d8: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6032e0: 0x05 0x00 0x0e 0x00 0xd7 0x00 0x00 0x00
0x6032e8: 0x2a 0x00 0x1b 0x00 0x0e 0x00 0x0c 0x00
0x6032f0: 0x10 0x00 0x0a 0x00 0x11 0x00 0x0e 0x00
0x6032f8: 0xb0 0x32 0x60 0x00 0x00 0x00 0x00 0x00
0x603300: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603308: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603310: 0x03 0x00 0x06 0x00 0xd2 0x00 0x00 0x00
0x603318: 0x28 0x00 0x1a 0x00 0x12 0x00 0x0a 0x00
0x603320: 0x0e 0x00 0x0c 0x00 0x0d 0x00 0x0f 0x00
0x603328: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603330: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603338: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603340: 0x00 0x00 0x08 0x00 0xd4 0x00 0x00 0x00
0x603348: 0x2b 0x00 0x1c 0x00 0x0b 0x00 0x11 0x00
0x603350: 0x0d 0x00 0x0e 0x00 0x0c 0x00 0x08 0x00
0x603358: 0x10 0x33 0x60 0x00 0x00 0x00 0x00 0x00
0x603360: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603368: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603370: 0x00 0x00 0x0d 0x00 0xd5 0x00 0x00 0x00
0x603378: 0x2c 0x00 0x19 0x00 0x06 0x00 0x0e 0x00
0x603380: 0x08 0x00 0x12 0x00 0x0e 0x00 0x0a 0x00
0x603388: 0x40 0x33 0x60 0x00 0x00 0x00 0x00 0x00
0x603390: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x603398: 0x31 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6033a0: 0x05 0x00 0x0e 0x00 0xd7 0x00 0x00 0x00
0x6033a8: 0x2a 0x00 0x1b 0x00 0x0e 0x00 0x0c 0x00
0x6033b0: 0x10 0x00 0x0a 0x00 0x11 0x00 0x0e 0x00
0x6033b8: 0x70 0x33 0x60 0x00 0x00 0x00 0x00 0x00
0x6033c0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x6033c8: 0x41 0x0c 0x02 0x00 0x00 0x00 0x00 0x00
0x6033d0: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
13
Using all of this information, answer the following 5 questions:
Suppose the name of your party is the Sylvans.
4.1 How many gold coins (wealth) does your party have? (answer A-N)
A) 0
B) 1
C) 2
D) 4
E) 8
F) 40
G) 64
H) 80
I) 128
J) 256
K) 512
L) 1024
M) 2048
N) 4096
4.2 What is your party’s Paladin’s (e.g. class = Paladin) favorite snack? (answer A-L)
A) Mutton
B) Stew
C) Celery
D) Limebark
E) Apple
F) Waybread
G) Cheese
H) Melon
I) Mac and Cheese
J) Peanut Butter and Jelly
K) Dragon Kebab
L) Fillet o’ Beholder
14
4.3 Which attribute does function attribute_check() access? (answer A-L)
A) Strength
B) Dexterity
C) Constitution
D) Intelligence
E) Wisdom
F) Charisma
G) Honor
H) Cholesterol
I) Blood Sugar
J) Hemoglobin
K) Riboflavin
L) Mustard
4.4 What weapon would a Bard (e.g. class = Bard) need to use to defeat the Chimera according to function
handle_chimera()? (answer A-L)
A) Spear
B) Fauchard
C) Voulge
D) Pike
E) Halberd
F) Glaive
G) Lance
H) Ranseur
I) Onomatopoeia
J) Halitosis
K) Subpoena
L) Love
15
4.5 I set a breakpoint at function add_hero() (address 0x4006dc). Based on the additional gdb interaction
that follows, can you determine the dexterity attribute of the hero that will be added? (answer A-M)
A) 8
B) 9
C) 10
D) 11
E) 12
F) 13
G) 14
H) 15
I) 16
J) 17
K) 18
L) 19
M) 20
(gdb) i r
rax
rcx
rdx
rsi
rdi
rbp
rsp
r8
r9
r10
r11
r12
r13
rip
0x400735 4196149
0x28 40
0x6 6
0xd2 210
0x0 0
0x0 0x0
0x7fffffffe110 0x7fffffffe110
0x3 3
0x18 24
0x7fffffffdca0 140737488346272
0x7ffff7a2f460 140737348039776
0x400520 4195616
0x7fffffffe240 140737488347712
0x4006dc 0x4006dc
(gdb) x/64xb $rsp
0x7fffffffe110:
0x7fffffffe118:
0x7fffffffe120:
0x7fffffffe128:
0x7fffffffe130:
0x7fffffffe138:
0x7fffffffe140:
0x7fffffffe148:
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0xb1 0x07 0x40 0x00 0x00 0x00 0x00 0x00
0x10 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x0a 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x0e 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x0c 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x0d 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x12 0x00 0x00 0x00 0x00 0x00 0x00 0x00
16
ANSWER SHEET
ALL OF YOUR ANSWERS MUST BE ON THIS SHEET
NAME: ________________________________________________________________
ID: ____________________________________________________________________
SHOW YOUR WORK CLEARLY ON THE TEST PACKET
MAKE SURE YOUR ANSWERS ARE LEGIBLE.
1.1 (answer A-L)
1.2 (answer A-L)
1.3 (answer A-L)
1.4 (answer A-L)
2.1 (answer TRUE OR FALSE)
Counterexample if false:
2.2 (answer TRUE OR FALSE)
Counterexample if false:
2.3 (answer TRUE OR FALSE)
Counterexample if false:
2.4 (answer TRUE OR FALSE)
Counterexample if false:
3.1 (answer A-S)
4.1 (answer A-N)
4.2 (answer A-L)
4.3 (answer A-L)
4.4 (answer A-L)
4.5 (answer A-M)
§

Purchase answer to see full
attachment