开发者

What changes I have to do to make this 16 bit assembly to 32 bit?

I asked a question about assembly language here. I got a feel that it is difficult to use 16 bits progra开发者_JS百科ms. So now I want to change it to 32 bit. Here is the code of the first program I was trying :

[org 0x0100]
mov ax, 5
mov bx, 10
add ax, bx
mov bx, 15
add ax, bx 
mov ax, 0x4c00
int 0x21

I named it to ex01.asm. I used NASM to make a COM file. The command was

nasm ex01.asm -o ex01.com -l ex01.lst

But I can't use the created COM file in Ollydbg. So if I want to change this program to work in win xp or win 7, so I can use Ollydbg, what changes I have to do and why? My thoughts :

  1. I think I have to change ORG 0x100. It is specific for COM files I think. So I want to know, what changes I should make here? Do COM file do not work on win XP and win 7? Can I have to make a EXE file instead of a COM file? I just want to understand this procedure.

  2. I have to change the second last line because it is used to tell DOS that the program is finished. What changes I have to do here and why?

  3. I forgot why the last line is used? Can anybody tell me and if required a substituion for it?


I think that, the NASM can't produce EXE directly. You will need to compile ASM into object file and then link with some linker (ld.exe from MinGW package for example).

In code you will need to create procedure instead of inline code (WinMain).

Code:

mov ax, 0x4c00 
int 0x21

will be replaced by returning from procedure (or calling function from kernel32.dll).

This can help (a little): http://en.kioskea.net/faq/1559-compiling-an-assembly-program-with-nasm

You can also look to FASM http://flatassembler.net/ which is able to build exe directly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜