首页
社区
课程
招聘
Intel汇编学习中求助
发表于: 2010-8-9 09:15 3767

Intel汇编学习中求助

2010-8-9 09:15
3767
小弟近来在学习Intel汇编程序设计遇见一个问题:考虑之后,没有正确的答案写下来 求教各位大侠,小弟不胜感激:
代码如下:
TITLE Integer Summation Program
INCLUDE Irvine32.inc
EXTREN PromptForInteger@0:PROC
EXTREN ArraySum@0:PROC,Display Sum@0:PROC
ArraySum   EQU ArraySum@0
PromptForIntegers  EQU PromptForIntegers@0
Display  EQU DisplaySum@0
Count=3;
.data
Prompt1 BYTE "Enter a signed integer:",0
Prompt2 BYTE "The sum of the integer",0
array DWORD Count Dup(?)
sum   DWORD ?
.code
main PROC
       call  clrscr
;promptForIntegers(addr prompt1,addr array,Count)
       push Count
       push OFFSET array
       push OFFSET Propt1
       call   PromptForIntegers
;sum=AaarySum(addr array,Count)
      push  Count
      push  OFFSET array
      call    ArraySum
    mov     sum,   eax
;DisplaySum(addr prompt2,sum)
      push sum
      push OFFSET Prompt2
      call    DisplaySum
      call    crlf
      exit
main ENDP
ENDP main
我的问题有两个:
第一:Count 应该是作为输入的整数的个数。但是在上面的代码中我并没有看见有关Count声明为何类型啊,只有Count=3,请教高手们这是什么意思!
第二:EXTREN PromptForInteger@0:PROC中为啥为0,书上在讲述EXTREN中这样说国@n,n为
函数的参数个人*4,显然三个过程模块均不为0,这里为啥为零呢?
小弟的问题可能比较幼稚,希望能得到大家的帮助谢谢!

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (7)
雪    币: 59
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
我看的不是这种书。
或许count的类型是默认类型。dd类型的
第二个 @0上面只是出现在声明中。
楼下接力!!
2010-8-20 00:05
0
雪    币: 452
活跃值: (72)
能力值: ( LV9,RANK:330 )
在线值:
发帖
回帖
粉丝
3
count is not a variable
count is a constant, like #define count 3 in c/c++
in asm, there are 2 ways to define a constant: using "equ" or "="
if you use "=", you can redefine it later.
if you use "equ", you cannot.

For the 2nd question, did you convert the code from C? C uses cdecl, but masm uses stdcall. That maybe the reason
2010-8-20 00:11
0
雪    币: 401
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
=和EQU都可以定义一个变量,不过两者是有区别的,请自行摆渡,我就不复制粘贴了。至于类型,自然是32bit,汇编里才不管是整型还是字符型,你给指定了值之后爱把它当啥类型它就是啥类型。
第二个问题……书上没写@0吧?是lz自己加上的?
2010-8-20 00:13
0
雪    币: 59
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
3楼英语真好,还有就是你说用=后可以在后面定义。但是楼主通篇都没有定义count啊。
2010-8-20 00:40
0
雪    币: 401
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
6
额,难道我打字这么慢么,我回复的时候还是只到2L的,我居然到了4L了,杯具。
2010-8-20 01:09
0
雪    币: 452
活跃值: (72)
能力值: ( LV9,RANK:330 )
在线值:
发帖
回帖
粉丝
7
constant in MASM32 is not always 32bit by default
If I remember correctly, inMASM32 v8, it is 32bit, but in v9 and v10, it is 64bit
If I use a constant macro (a macro that returns a constant) in v9 and v10, I have to convert the result to DWORD

And, constant is not variable.
EQU and = define constant, not variable
At compile time, constant is converted to immidiate value
Variable is converted to the address, and takes memory at runtime.
2010-8-20 01:15
0
雪    币: 401
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
8
omg,好吧,我承认我口误了,是常量,不是变量,囧。
至于编译器默认的数据位数,我倒是真没在意过,都是直接** DWORD xx的。
2010-8-20 01:31
0
游客
登录 | 注册 方可回帖
返回
//