| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 991 人关注过本帖
标题:求助--------为什么会这样?
只看楼主 加入收藏
mjkbmykwolf
Rank: 1
来 自:武汉
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-10-31
收藏
 问题点数:0 回复次数:9 
求助--------为什么会这样?
我编的一个分类统计字符个数的汇编程序,代码如下:
  ; Assembly  language  program-
; Author:
; Data:


.386
.MODEL FLAT


ExitProcess  PROTO  NEAR32  stdcall, dwExitCode:DWORD

INCLUDE io.h                            ;header   file  for  input/out

cr          EQU       0dh                ;carriage  return  character
LF         EQU       0Ah                ;line  feed

.STACK     4096                         ;reserve   4096-byte stack

.DATA                                      ;reserve   storage  for  data
;**************************************************
prompt1   byte   cr,Lf,"Please input the string(less than eighty) :"
string    byte   80 dup(?)
prompt2   byte   cr,Lf,"The sum of the letter is :"
letterof  byte   ?
          byte   cr,Lf,0
prompt3   byte   cr,Lf,"The sum of the number is :"
numof     byte   ?
          byte   cr,Lf,0
prompt4   byte   cr,Lf,"The sum of the other is :"
otherof   byte   ?
          byte   cr,Lf,0



;**************************************************
.CODE
_start:                                     ;start  of main  program  code
;**************************************************
startofall:
   output   prompt1           ;输出提示语句
   mov      letterof,0
   mov      numof,0
   mov      otherof,0
   input    string,78
   mov      esi,0
numberif:
   mov      eax,string[esi]
   cmp      esi,78
   je       endfile
   cmp      eax,00h
   je       endfile
   cmp      eax,30h
   jl       otherof
   cmp      eax,39h
   jg       letterif1
   inc      numof
   jmp      numberif
letterif1:
   cmp      eax,41h
   jl       otherif
   cmp      eax,5Ah
   jg       letterif2
   inc      letterof
   jmp      numberif
letterif2:
   cmp      eax,61h
   jl       otherif
   cmp      eax,7Ah
   jg       otherif
   inc      letterif
   jmp      numberif
otherif:
   inc      otherof
   jmp      numberif
endfile:   
   output   prompt2
   output   prompt3
   output   ptompt4
   
   

endof:  invoke   exitprocess,0              ;come out
;**************************************************
PUBLIC _start                         ;make entry point public  

END                                       ;end  of  source  code

但是当我运行的时候怎么老是弹出一个对话框说:
     0x00401083指令饮用的0x0080805a内存。该内存不能为read。
     不调试请按确定,调试请按取消

到底是哪里的问题呀?
希望大家多多指点。  
谢谢了。
搜索更多相关主题的帖子: character reserve return file 统计 
2008-10-31 14:40
ONEPROBLEM
Rank: 6Rank: 6
来 自:广西 南宁
等 级:贵宾
威 望:21
帖 子:1569
专家分:349
注 册:2008-7-11
收藏
得分:0 
请用反汇编工具,查找对应的指令.
2008-10-31 15:52
mjkbmykwolf
Rank: 1
来 自:武汉
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-10-31
收藏
得分:0 
回复 2# 的帖子
谢谢
2008-10-31 23:16
cnhanxiao
Rank: 2
等 级:新手上路
威 望:4
帖 子:124
专家分:0
注 册:2008-10-17
收藏
得分:0 
output函数语法是?
对这种“高级”汇编语言不熟悉,感觉output函数使用上有问题,再有,一般字符串应该有结束标识,如DOS下用“$”,win32下用“0”,试试:
prompt1   byte   cr,Lf,"Please input the string(less than eighty) :",0
...

还有绑架成版主的?拒绝做版主——对不起啊!
2008-11-01 00:29
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:0 
程序代码:
;MASMPlus 代码模板 - 控制台程序

.586
.model flat, stdcall
option casemap :none

include windows.inc
include user32.inc
include kernel32.inc
include masm32.inc
include gdi32.inc


includelib gdi32.lib
includelib user32.lib
includelib kernel32.lib
includelib masm32.lib
include macro.asm


.data
    ;lpMsg        db "Hello World!",0
    prompt1 db 0dh,0ah,'Please input the string(less than eighty) :',0
    string db 80 dup(?)
    prompt2 db 0dh,0ah,'The sum of the letter is :0',0
    prompt3 db 0dh,0ah,'The sum of the number is :0',0
    prompt4 db 0dh,0ah,'The sum of the other is :0',0
    letterof dd [prompt2+28]
    numberof dd [prompt3+28]
    otherof dd [prompt4+27]

.data?
    buffer    db MAX_PATH dup(?)
    
.CODE
START:
    invoke StdOut,offset prompt1        ;输出提示语句
    invoke StdIn,offset string,78d
    dec eax
    dec eax
    dec eax
    mov ecx,eax
numberif:
    mov al,BYTE ptr [string+ecx]
    inc ecx
    je endfile
    dec ecx
    cmp al,00h
    je  endfile
    cmp al,30h
    jl  otherif
    cmp al,39h
    jg  letterif1
    mov esi,DWORD ptr [numberof]
    inc BYTE ptr [esi]
    dec ecx
    jmp numberif
letterif1:
    cmp al,41h
    jl  otherif
    cmp al,5Ah
    jg  letterif2
    mov esi,DWORD ptr [letterof]
    inc BYTE ptr [esi]
    dec ecx
    jmp numberif
letterif2:
    cmp al,61h
    jl  otherif
    cmp al,7Ah
    jg  otherif
    mov esi,DWORD ptr [letterof]
    inc BYTE ptr [esi]
    dec ecx
    jmp numberif
otherif:
    mov esi,DWORD ptr [otherof]
    inc BYTE ptr [esi]
    dec ecx
    jmp numberif
endfile:     
    invoke StdOut,offset prompt2
    invoke StdOut,CTXT(0dh,0ah)
    invoke StdOut,offset prompt3
    invoke StdOut,CTXT(0dh,0ah)
    invoke StdOut,offset prompt4
    invoke StdOut,CTXT(0dh,0ah)

    ;invoke locate,2,2            ;设定输出文本的坐标
    ;invoke StdOut,offset lpMsg
    
    ;暂停显示,回车键关闭
    invoke StdIn,addr buffer,sizeof buffer
    invoke ExitProcess,0
    
end START
2008-11-01 09:45
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:0 
本来很简单的程序 让我改来改去改的这么复杂……

算法有点问题 数大了就不行了

用到了指针……

改程序比写难多了
2008-11-01 09:47
mjkbmykwolf
Rank: 1
来 自:武汉
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-10-31
收藏
得分:0 
回复 4# 的帖子
output  变量名   
 这个应该是没有问题的
2008-11-01 17:24
mjkbmykwolf
Rank: 1
来 自:武汉
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-10-31
收藏
得分:0 
回复 6# 的帖子
呵呵,我用的是386的.386和586的语法应该是一样的吧!貌似,但好多东西还没有学到.
2008-11-01 17:27
cnhanxiao
Rank: 2
等 级:新手上路
威 望:4
帖 子:124
专家分:0
注 册:2008-10-17
收藏
得分:0 
回复 8# 的帖子
不知你的编译系统。
你先试试在数据段每行字符串后加上—— ,0
试试。不然output不知道在哪里停顿。

还有绑架成版主的?拒绝做版主——对不起啊!
2008-11-01 17:31
mjkbmykwolf
Rank: 1
来 自:武汉
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-10-31
收藏
得分:0 
我试了一下,是在prompt1后面少加了一个  ,和 0 .谢谢大家的支持.
2008-11-01 17:45
快速回复:求助--------为什么会这样?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.024659 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved