iczelion tut1[2]

[入库:2005年8月19日] [更新:2007年3月24日]

本文简介:选择自 jimgreen 的 blog

add    sp, 12                                ; the caller balances the stack framepascal calling convention is the reverse of c calling convention. it passes parameters from left to right and the callee is responsible for the stack balancing after the call.
win16 adopts pascal convention because it produces smaller codes. c convention is useful when you don't know how many parameters will be passed to the function as in the case of wsprintf(). in the case of wsprintf(), the function has no way to determine beforehand how many parameters will be pushed on the stack, so it cannot do the stack balancing.
stdcall is the hybrid of c and pascal convention. it passes parameter from right to left but the callee is responsible for stack balancing after the call.win32 platform use stdcall exclusively. except in one case: wsprintf(). you must use c calling convention with wsprintf().

.data
.data?
.const
.code
all four directives are what's called section. you don't have segments in win32, remember? but you can divide your entire address space into logical sections. the start of one section denotes the end of the previous section. there'are two groups of section: data and code. data sections are divided into 3 categories:

  • .data    this section contains initialized data of your program.
  • .data?  this section contains uninitialized data of your program. sometimes you just want to preallocate some memory but don't want to initialize it. this section is for that purpose. the advantage of uninitialized data is: it doesn't take space in the executable file. for example, if you allocate 10,000 bytes in your .data? section, your executable is not bloated up 10,000 bytes. its size stays much the same. you only tell the assembler how much space you need when the program is loaded into memory, that's all.
  • .const  this section contains declaration of constants used by your program. constants in this section can never be modified in your program. they are just *constant*.

you don't have to use all three sections in your program. declare only the section(s) you want to use.

there's only one section for code: .code. this is where your codes reside.
<label>
end <label>

本文关键:iczelion asm
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top