• anonymous
how can I write in assembly for 8086 instead of movsx edx,byte ptr [eax+1] ?
Computer Science
  • Stacey Warren - Expert
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
  • chestercat
I got my questions answered at in under 10 minutes. Go to now for free help!
  • anonymous
movsx means transfer from source to destination with sign extension. The pointer to the source is a BYTE POINTER, meaning it's going to move a byte (8 bits source) into EDX which is a DWORD (32 bits) target. If the sign bit of the source (i.e. bit #7) is set, then its going to be extended to other bytes of EDX. Here is how EDX looks like: |dw:1357493336782:dw| Let's call the source byte B If B's sign bit is cleared then EDX will look like this: 00000000 00000000 00000000 BBBBBBBB If B's sign bit is set then EDX will look like this: 11111111 11111111 11111111 BBBBBBBB Now, for the 8086 part of the question: there are many things the 8086 can't do. First, it can't access 32-bit memory pointers like EAX, only 16-bits ones like AX. Next, there is no equivalent of MOVSX. Finally, there is no 32 bits registers like EDX, only 16 bits ones like DX. I think the 8086 allows you to read/write memory using the syntax [AX+1] (i.e. adding a constant to an address in the same line) but we'll assume it can't. Assuming you don't want to emulate the behavior of a 32-bits architecture and only conform to the limitations of the 8086 architecture, then you should write something like: push ax ; We'll restore it later because we'll change it temporarily inc ax ; This is the equivalent of EAX+1 mov dl, [ax] ; Read a single byte for DS:AX (assuming DS is set correctly) ; At this point, DL contains the source byte WITHOUT sign extension ; We need to extend DL's sign bit #7 into DH, the high byte of DX mov al, dl ; The instruction we're going to use next only works on AX! cbw ; To extend the sign bit, we use the Convert Byte to Word opcode! mov dx, ax ; put back result into DX to conform to original code pop ax ; Restore original AX That should do it... I suppose your teacher only wants you to find the CBW opcode, the rest is purely cosmetic. Just get extatic about the power of modern days processors when you turn your essay in and you should get an A+! ^^

Looking for something else?

Not the answer you are looking for? Search for more explanations.