码迷,mamicode.com
首页 > 编程语言 > 详细

汇编语言-计算总平成绩

时间:2014-05-19 18:47:36      阅读:306      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   c   code   java   

 计算总评成绩

  1. 题目:从键盘输入一同学的期中成绩、实验成绩、期末成绩和它们在总评成绩中分别占的百分比,计算得到该同学的总评成绩,并显示出来。
  2. 要求:该程序提示输入3个成绩和所占百分比。可参考如下的例子显示:

grade  1 ?     85

percent 1 ?     20

grade  2 ?     75

percent 2 ?     20

grade  3 ?     82

percent 3 ?     60

score  is :     81

总评成绩 = (期中成绩×百分比1+实验成绩×百分比2+期末成绩×百分比3)/100

bubuko.com,布布扣
 1 ; Example assembly language program -- 
 2 ; Author:  karllen
 3 ; Date:    revised 5/2014
 4 
 5 .386
 6 .MODEL FLAT
 7 
 8 ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD
 9 
10 INCLUDE io.h            ; header file for input/output
11 
12 cr      EQU     0dh     ; carriage return character
13 Lf      EQU     0ah     ; line feed
14 
15 .STACK  4096            ; reserve 4096-byte stack
16 
17 .DATA
18         promot1_1 BYTE "grade   1 ?  ",0
19         promot1_2 BYTE "percent 1 ?  ",0
20         promot2_1 BYTE "grade   2 ?  ",0
21         promot2_2 BYTE "percent 2 ?  ",0
22         promot3_1 BYTE "grade   3 ?  ",0
23         promot3_2 BYTE "percent 3 ?  ",0
24         
25         value     BYTE 11 DUP(?)
26         onec      DWORD  ?
27         twoc      DWORD  ?
28         threec    DWORD  ?
29 
30         answer    BYTE "score is: "
31         average   BYTE 11 DUP(?)            
32                   BYTE cr,Lf,0
33 .CODE
34 _start:
35         output   promot1_1    ;enter first grade and percent
36         input    value,11
37         atod     value
38         mov      onec,eax
39         mov      ebx,eax
40         output   promot1_2 
41         input    value,11
42         atod     value
43         mul      ebx          ;calculate first grade*percent
44         mov      onec,eax
45         
46         
47         output   promot2_1    ;enter second grade and percent
48         input    value,11
49         atod     value
50         mov      twoc,eax
51         mov      ebx,eax
52         output   promot2_2
53         input    value,11
54         atod     value
55         mul      ebx          ;calculate second grade*percent
56         mov      twoc,eax
57         
58        
59         output   promot3_1    ;enter the third grade and percent
60         input    value,11
61         atod     value
62         mov      threec,eax
63         mov      ebx,eax
64         output   promot3_2
65         input    value,11
66         atod     value
67         mul      ebx          ;calculate the third grade and percent
68         mov      threec,eax
69         
70         add      eax,onec     ;to calculate sum
71         add      eax,twoc
72         add      eax,threec
73         
74         mov      ebx,100
75         div      ebx          ;to calculate the average
76         
77         dtoa     average,eax
78         output   answer
79         
80         INVOKE  ExitProcess, 0  ; exit with return code 0
81 
82 PUBLIC _start                   ; make entry point public
83 
84 END                             ; end of source code
bubuko.com,布布扣

测试

bubuko.com,布布扣

 

汇编语言-计算总平成绩,布布扣,bubuko.com

汇编语言-计算总平成绩

标签:style   blog   class   c   code   java   

原文地址:http://www.cnblogs.com/Forever-Kenlen-Ja/p/3734692.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!