| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1295 人关注过本帖
标题:汇编求数组中分数段
只看楼主 加入收藏
情.难言ゝ
Rank: 3Rank: 3
来 自:安徽安庆
等 级:论坛游侠
威 望:1
帖 子:74
专家分:137
注 册:2013-9-8
结帖率:83.33%
收藏
 问题点数:0 回复次数:2 
汇编求数组中分数段
程序代码:
data   segment
       score   dw   76,69,84,90,73,88,99,63,100,80
       mess    db   'the 10 students score :',13,10,'$'
       mess1   db   'the number of the score(60-69):','$'
       mess2   db   'the number of the score(70-79):','$'
       mess3   db   'the number of the score(80-89):','$'
       mess4   db   'the number of the score(90-99):','$'
       mess5   db   'the number of the score(100):','$'     
data   ends

extra  segment
       num1    dw   ?
       num2    dw   ?
       num3    dw   ?
       num4    dw   ?
       num5    dw   ?
extra  ends

code   segment
;宏定义输出指令print         
print  macro   addr
       mov     dx,addr
       mov     ah,09h
       int     21h
       endm

main   proc   far
      assume  cs:code,ds:data,es:extra
start:
       push    ds
       sub     ax,ax
       push    ax
       
       mov     ax,data
       mov     ds,ax
       
       mov     ax,extra
       mov     es,ax
       
;输出这10个成绩
       print   offset mess
       mov     cx,10
       mov     si,offset score
next1:
       print   si
       add     si,2
       loop    next1
       
       call    crlf
       call    son
       
;输出num1、num2、num3、num4、num5的值
       mov     cx,5
       mov     si,offset  mess1
       mov     di,offset  num1 
result:
       print   si
       print   di
       
       call    crlf
       add     si,2
       add     di,2
       loop    result
       
       ret
main   endp
;回车换行crlf
crlf   proc    far
       push    dx
       push    ax
       
       mov     ah,02h
       mov     dl,0dh
       mov     dl,0ah
       int     21h
       
       pop     ax
       pop     dx
       ret
crlf   endp

son    proc    near
       push    ax
       push    bx
       push    cx
       push    si
       push    di
       
       mov     bx,69
       mov     cx,10 
       mov     si,offset  score
       mov     di,offset  num1
;[si(score)分别与bx(69,79,89,99,109)比较
rotate:
       cmp     [si],bx
       jb      count
       cmp     bx,105
       je      next2
       add     bx,10
       jmp     rotate
count:
       ;inc     [di]
       add     di,2
next2:
       add     si,2
       loop    rotate
       
       pop     di
       pop     si
       pop     cx
       pop     bx
       pop     ax 
       ret
son    endp
code   ends
       end     main

2014-05-25 18:08
xkwy0000
Rank: 6Rank: 6
等 级:贵宾
威 望:11
帖 子:107
专家分:441
注 册:2013-2-8
收藏
得分:0 
拒绝讨论带有‘宏定义’的问题,
原因不会使用‘宏定义’
2014-06-09 15:25
xkwy0000
Rank: 6Rank: 6
等 级:贵宾
威 望:11
帖 子:107
专家分:441
注 册:2013-2-8
收藏
得分:0 
http://baike.baidu.com/view/2076445.htm?fr=aladdin
宏定义是C语言提供的三种预处理功能的其中一种,这三种预处理包括:宏定义、文件包含、条件编译。
不带参数宏定义又称为宏代换、宏替换,简称“宏”。 格式: #define 标识符 字符串
其中的标识符就是所谓的符号常量,也称为“宏名”。

print   offset mess   编译没有通过,可能 offset mess 需要是一个变量名  
2014-06-11 18:10
快速回复:汇编求数组中分数段
数据加载中...
 
   



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

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