Num dw 001h, 3880h
        mov dx, num
        mov ax, num+2
        mov bx,8
        idiv bx

after converting to 32 bit... is this correct?

Large dw 001h, 3880h  <----- i am not sure if this line is correct... any help?
        mov edx, num
        mov eax, num+2
        mov ebx,8
        idiv ebx
Posted on 2011-12-05 22:43:46 by Legend
Replace it with

Large dd 001h, 3880h  <----- i am not sure if this line is correct... any help?


Also look at this line:

mov eax, num+2

This line means grab 4 bytes from offset num plus 2. You sure you want that?
Posted on 2011-12-06 08:42:18 by JimmyClif
The original code seems to be doing 32-bit division using 16-bit instructions. One solution if you must preserve the original data structure is this:
mov eax, dword
rol eax, 16 ; To fix the unfortunate big endian placement of the words
mov ebx, 8
cdq
idiv ebx
; Although you could forget about the last three instructions and just use sal eax, 3
If you fix the data structure by either using "large dw 3880h, 001h" or just "large dd 13880h" you can skip rol instruction.
Posted on 2011-12-06 10:56:04 by LocoDelAssembly
Large dd 001h, 3880h
mov edx, num
mov eax, num+2
mov ebx,8
idiv ebx

is this a good answer? i changed dw to dd
Posted on 2011-12-07 00:41:40 by Legend
changing it to DD makes ..

mov eax, num+2

bad...
dd = dword (4), not word (2) :)
Posted on 2011-12-07 04:42:50 by evlncrn8
Large dd 001h, 3880h
mov eax, dword
mov ebx, 8
cdq
idiv ebx

@LocoDelAssembly is this what you are talking about?
Posted on 2011-12-08 18:08:52 by Legend
No, with that code you are computing 1 div 8. (I'm assuming that either you would use "mov eax, dword" or "num dd 001h, 3880h".)

My "mov eax, dword" is exploiting the fact that both words are adjacent, but if you still prefer to access them individually, then replace it with:
movsx eax,    ; move with sign extension
movzx edx, ; move with zero extension
shl eax, 16
or eax, edx
The code above assumes you preserve the original big endian order of the words (words means data defined with dw, not dd)
Posted on 2011-12-08 21:21:31 by LocoDelAssembly
num dd 001h, 3880h
movsx eax,  
movzx edx,
shl eax, 16
or eax, edx

well i want to access them individually... is above code a solution ?
Posted on 2011-12-08 23:14:04 by Legend
Yes. However, I think you are over complicating the code. Are you aware of what the original 16-bit code is doing?
Posted on 2011-12-09 08:33:07 by LocoDelAssembly
No, it's not a solution, because there is data in the codestream, and no entrypoint to the code that bypasses it! Haha!
Posted on 2011-12-12 00:55:21 by Homer