Computers and Technology
09.10.2021 23:17
244
295
8
Solved by an expert

Find out if you can declare a variable of type dword and assign it a negative value.

Find out if you can declare a variable of type dword and assign it a negative value. what does this tell you about the assembler's type checking?
Show Answers
myg21
myg21
5,0(30 marks)

Ah, I see that the db, dw, and dd are for positive values only. How can I define a negative ones?" Well, you can assign the variables as negative values, too. However, assembler will convert them to the corresponding positive value. For example: If you assign -1 to a db variable, assembler will convert them to positive 255 integer. "How can it be? It will certainly confuse my calculation then." Nope. In fact, the converted negative values will behave similarly as if they are not flipped. Trust me. ;-) The only thing you need to beware of is just when you want to print the contents of that variable out to the screen and to distinguish the negative values from the positive ones.

To distinguish negatives from positives, usually programmers likes to divide the variable ranges into two roughly equal parts. For bytes, if the value is between 0 and 127, it is considered as positive, the rest (128-255) are considered negative. This scheme also perpetuates in dividing words and double-words. It's not hard at all, you just remember which variables are considered negative and treat them accordingly. You may find it cumbersome at first, though.

Now, the next question would be on how can we find the corresponding positive values for each negative numbers. Before we start, I just remind you that 1 byte equals to 8 bits. So 2 bytes is 16 bits, 4 bytes is 32 bits. I assume that you are able to convert a decimal number to binary and vice versa. I also assume that you're capable in doing binary digit addition.

To find the corresponding positive value, you first ignore the negative sign, then convert that number into binary. Remember the variable type you are in. If it is a byte, the resulting binary number must be 8 digits. Likewise, a word must be 16 digits and a double must be 32 digits. If the result digit is less than that, pad it with zeroes. Then, flip all digits in the binary number (i.e. from 0 to 1 or from 1 to 0). After that, increase that binary by one. Convert the result back to decimal. Voila! That's the corresponding positive value.

For example, you want to convert -5 byte to its corresponding positive value. Ignore the negative and convert 5 to binary. It's 101, right? Since we're dealing with bytes, we must have 8 digits. The result 101 is just 3 digits, so we must pad it with zeroes. Therefore, we now have 00000101. Then, we flip the digits from 0 to 1 or 1 to 0. So, we now have 11111010. The next step is to increase that number by 1: 11111010 + 1 = 11111011. Then we convert this number back to decimal: 251. Ta da! So, -5 is 251 in positive representation.

Hmm, if you find that this calculation is cumbersome... uh... Well, you have to live with that if you'd like to learn assembly. Moreover, you need to be familiar with hexadecimal numbers too. You would need to learn some converting operations and do some arithmetic between decimal, binary and hexadecimal. If you're kinda awkward, you can always employ calculators. If you do it over and over again, you probably do the calculations by heart quickly (and amaze your friends ;-).

 

thuzar
thuzar
4,7(94 marks)

I have found and attached a spreadsheet (cities.xlsx) that matches this question.

First we remember the VLOOKUP sintax:

=VLOOKUP (lookup_value, table_array, col_index_num, [range_lookup])

We need to look up the City Type (B13),

compare it to the City/COL range (A7:B10),

and return the COL percentage (2nd column of City/COL)

so the VLOOKUP function on cell F13 has to be:

=VLOOKUP(B13,$A$7:$B$10,2)

Next, to multiply the result by the Total Base Lodging (B5):

=VLOOKUP(B13,$A$7:$B$10,2) *$B$5

Finally que copy the formula to the F14:F18 cells

Notice the use of $  to make cells static and avoid errors while copying the formulas to different cells.

I have attached the completed spreadsheet as "cities final.xlsx"

Popular Questions about the subject: Computers and Technology

You are trying to apply the same style to several different elements...
Computers and Technology
20.02.2023 21:19
Device driver issues can come up if you and if this happens...
Computers and Technology
03.07.2020 06:42
Direction: Choose the letter of the correct answer. 1. It is a substance...
Computers and Technology
17.02.2020 18:25
Where can I see my followers...
Computers and Technology
20.02.2021 03:21
Egy téglalap alakú rácsháló minden pontjáról ismerjük, hogy ott...
Computers and Technology
08.10.2020 12:30
The number of individual networking addresses required for the internet...
Computers and Technology
15.05.2020 17:53
Perform online research and learn about the elements of a presentation...
Computers and Technology
03.03.2022 13:35
Me ! as a wave travels through a medium, it displaces particles...
Computers and Technology
20.10.2021 12:51
You need to invest in a the periodic maintenance of your computer....
Computers and Technology
23.11.2020 19:26
Find the current though a 12-ohm resistive circuit when 24 volts...
Computers and Technology
09.03.2021 11:34

New questions by subject

While Abbie is jogging, she moves forward 85 cm every second. How...
Mathematics
19.10.2020 02:49
Use the picture to tell if it is accurate , precise , or both?...
Biology
12.05.2023 04:11
Explain ten challenge in the use of l.c.t...
Computers and Technology
19.07.2021 22:26
2 What combination of keys turns the value in a cell into a percentage?...
Computers and Technology
31.05.2022 18:47
#
#
#
#
# #

We expand our knowledge with many expert answers