A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing


  • 2 years ago

how can I write in assembly for 8086 instead of movsx edx,byte ptr [eax+1] ?

  • This Question is Open
  1. Patapom
    • 2 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    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+! ^^

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

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...


  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.