Questions tagged [sign-extension]

72 questions
0
votes
1 answer

How is MOVSX instruction sign extending input in this case?

I have the following disassembly: [dest] = d5 cd e8 ca 68 movzx eax, [ebp+dest] # value of edx at this point is: F7FBB898 movsx edx, al # value of edx after this is: FFFFFFD5 # [ebp+var_E] stores 0 movzx eax, [ebp+var_E] movsx eax, al # eax…
Neon Flash
  • 3,113
  • 12
  • 58
  • 96
0
votes
1 answer

How to sign extend a two's complement number given in the program arguments in mips (assembly)

I am trying to sign extend a two's complement number that I get from the program arguments in mips. How would I do this?
0
votes
2 answers

A compilation problems in VS2015

127: int a = 2815; 00007FF78B5126EE mov dword ptr [a],0AFFh 128: 129: short c = static_cast(a); 00007FF78B5126F5 movsx ax,byte ptr [a] 00007FF78B5126FA mov word ptr [c],ax In my environment an int takes 4 byte and a…
Shawn
  • 82
  • 4
0
votes
1 answer

Convert from base 10 to an arbitrary radix with proper sign extend

I was wondering if there's a formal way to properly sign extend base-10 numbers in an arbitrary base when converting. For example, if I had -256 in base 10, how would I properly sign extend the result in base 7 (or base n) without assuming a fixed…
user3639182
  • 47
  • 1
  • 6
0
votes
1 answer

making Arithmetic in verilog (sign extension) edited

(edited) i'm working on the verilog Arithmetic project and i got stuck on the sign extension part(assuming this is the problem). i have 4bit input A, B and should have 8 bit output. for some of the process(sum, sub...) i need to use sign extend to…
Jake
  • 3
  • 2
0
votes
1 answer

Sign extend 11 bits to 32 bits

How do you sign extend an 11 bit number to a 32 bit number in C++? I have the following function, but it is not returning the proper sign-extension as expected: unsigned int signExtend11to32ui(int i) { int mask = 2047; // 0x7FF or 0000 0111 1111…
Erik P.
  • 349
  • 3
  • 13
0
votes
0 answers

Adding values without sign-extension?

I know that the CPU doesn't care about the sign bit, because of two's complement. But when using different operand sizes, then the source value gets sign extended to the destination's size. xor rax, rax add rax, byte 0xAD ; adds 0xFFFFFFFFFFFFFFAD…
Cubi73
  • 1,891
  • 3
  • 31
  • 52
0
votes
1 answer

What is happening in this Assembly code?

Background: I am doing a "binary bomb" assignment in which I must pass 6 different phases to 'defuse' the bomb. I can use a debugger to help keep track of values and step through each line of the Assembly. I am stuck on the second phase. Goal: Find…
Jay
  • 309
  • 2
  • 5
  • 11
0
votes
1 answer

C - Seemingly unsigned int being sign extended when right shift?

So I was trying to test out a super short function for getting me the integer value of certain bits x through y from an integer, but am having some trouble with the sign extension that is happening. I tried casting to an unsigned int and then…
Rohan
  • 33
  • 2
  • 5
-1
votes
2 answers

Sign Extension Implementation in C

Ok I have read a lot about sign extension but I am brand new to C as well as all the 'bitwise operators' so I am still having trouble figuring out how I should actually implement it in C. I have a function called getField that should return the…
Kyle Hobbs
  • 445
  • 1
  • 4
  • 14
-2
votes
3 answers

Sign extension, addition and subtraction binary in C

How would I go about implementing a sign extend from 16 bits to 32 bits in C code? I am supposed to be using bitwise operators. I also need to add and subtract; can anyone point me in the right direction? I did the first 4 but am confused on the…
user2306249
  • 59
  • 1
  • 5
  • 13
1 2 3 4
5