Representations in bases assembly language 8086

64 Views Asked by At

The following values are given:

x db 128;a db -128 and for y will be the same value like x only dw, b the same like y only -128 and for z dd and c dd -128. Show which are the representations of x,a,y,b,z,c in base 2 and 16 (sign and unsigned). Explain why. And look about what I've done:

I have done this:

   (128)in base 2 = 10000000(i have used . to view better)
   (-128)in base 2 db = also with 10000000
   dw: 128 in base 2 = 0000000001000000
   128 is = 1111111111000000
   dd : 128 in base 2 = 00000000000000000000000001000000
   128 in base 2 = 11111111111111111111111111000000

It is good how I resolve? And here it comes to problem. I didn't know how to transform in base 16 all of numbers sign and unsigned, db, dw and dd. Some ideas?

1

There are 1 best solutions below

0
On

128 is = 1111111111000000

That's not correct. The 16-bit number 128 would be 0000000010000000. If you meant -128 then that would be 1111111110000000 (note that there's one 1 less than in your version).

I didn't know how to transform in base 16

Just take your binary representations and map each group of four bits to a hexadecimal digit:

Base2  Base16
-------------
0000    0
0001    1
0010    2
0011    3
0100    4
0101    5
0110    6
0111    7
1000    8
1001    9
1010    A
1011    B
1100    C
1101    D
1110    E
1111    F

So for example, 10000000 equals 0x80, 01111111 equals 0x7F, and so on.