Can someone help me check what is worng on this Computer Science Problem? Thanks
ID: 3699875 • Letter: C
Question
Can someone help me check what is worng on this Computer Science Problem? Thanks!
# This is the starter code for the
# second Simple Machine exercise.
# You must set flag (at address 0x11)
# to 1 if number (at address 0x10)
# is negative and 0 otherwise.
#####################################
#
# Original C Code
# -----------------
# if (number < 0)
# {
# flag = 1;
# }
# else
# {
# flag = 0;
# }
#####################################
#
# Your program starts here.
0xB000 # (ADDR=0x0)
0x1010 # (ADDR=0x1)
0x9000 # (ADDR=0x2)
0x4000 # (ADDR=0x3)
0x6006 # (ADDR=0x4)
0x7009 # (ADDR=0x5)
0xB001 # (ADDR=0x6)
0x2011 # (ADDR=0x7)
0x700B # (ADDR=0x8)
0xB000 # (ADDR=0x9)
0x2011 # (ADDR=0xA)
0x0000 # (ADDR=0xB)
0x0
0x0
0x0
0x0
0xFFFF # (ADDR=0x10) number is here
0x4321 # (ADDR=0x11) flag is here
Explanation / Answer
According to the question,
You must set flag to 1 if number is negative (at address 0x11) and 0 otherwise (at address 0x10) .
You have written:
0xFFFF # (ADDR=0x10) Here,flag = 0
0x4321 # (ADDR=0x11) Here, flag = 1
But it should be:
0x2011 # (ADDR=0xA) Here,flag = 0
0x0000 # (ADDR=0xB) Here, flag = 1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.