首页 > 代码库 > 汇编语言-计算总平成绩
汇编语言-计算总平成绩
计算总评成绩
- 题目:从键盘输入一同学的期中成绩、实验成绩、期末成绩和它们在总评成绩中分别占的百分比,计算得到该同学的总评成绩,并显示出来。
- 要求:该程序提示输入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
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
测试
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。