内容发布更新时间 : 2024/12/23 3:43:15星期一 下面是文章的全部内容请认真阅读。
org 100h
pname db 4,?,4 dup (?) pnumb db 12,?,12 dup (?) data ends
code segment
assume cs:code, ds:data main proc far push ds sub ax,ax push ax mov ax,data mov ds,ax mov es,ax next1:
call inname call intele mov al,num dec al mov bl,16 mul bl
lea di,plist add di,ax mov dl,num add dl,30h
mov byte ptr[di],dl mov cx,3
lea si,pname+2 rep movsb mov cx,11
lea si,pnumb+2 rep movsb
cmp byte ptr num,9 jb next1 next2: call print ret main endp
inname proc near lea dx,mess1 mov ah,09
int 21h ;input name(XXX) lea dx,pname mov ah,10
int 21h ;get name
inc byte ptr num ret inname endp
intele proc near lea dx,mess2 mov ah,09
int 21h ;input phone(11) lea dx,pnumb mov ah,10
int 21h ;get phone numb ret intele endp
print proc near next3: lea dx,mess3 mov ah,09
int 21h ;input serial:(X) mov ah,1
int 21h cmp al,30h jle exit cmp al,39h jg exit sub al,30h cmp al,num jg exit pdisp: dec al mov bl,16 mul bl
lea dx,plist add dx,ax mov ah,9 int 21h jmp next3 exit: lea dx,mess4 mov ah,9 int 21h ret print endp code ends
end main
6.12对十名同学的期末考试成绩进行统计,使用结构变量定义学生成绩记录并预赋值,使用子程序A统计每个学生的总分,使用子程序B显示输出每个学生的姓名和总分,对于总分应使用子程序C把总分的数值转为字符显示。
学生成绩记录格式:
字段 类型 长度 学号, 字符型, 8字节 姓名, 字符型, 3字节 数学, 数值型, 2字节 物理, 数值型, 2字节 化学, 数值型, 2字节 语文, 数值型, 2字节 英语, 数值型, 2字节 总分, 数值型, 2字节 备用, 字符型, 3字节
为便于显示输出,问题简化为:学生成绩只设2门课,每门课分值最高为5分 参考程序: data segment stm struc
bname db 'aaaaaa$' c1 db ? c2 db ? c3 db 0 stm ends
st1 stm <'aaaaaa$',5,3,0> st2 stm <'bbb $',2,4,0> st3 stm <'ccc $',2,3,0> st4 stm <'ddd $',5,3,0> st5 stm <'eeeee $',2,4,0> st6 stm <'ffff $',2,4,0> st7 stm <'gg $',5,3,0> st8 stm <'hhh $',3,4,0> st9 stm <'iiii $',3,4,0> st10 stm <'kkk $',2,3,0> data ends code segment
assume cs:code,ds:data main proc far mov ax,data mov ds,ax call aa call bb mov ah,4ch int 21h main endp
aa proc near mov cx,10
mov bx,offset st1
k: mov al,[bx].c1 add al,[bx].c2 mov [bx].c3,al add bx,10 loop k ret aa endp bb proc near mov cx,10
mov bx,offset st1 j: mov dx,bx mov ah,9 int 21h mov dl,',' mov ah,2 int 21h
mov dl,[bx].c3 add dl,30h mov ah,2 int 21h add bx,10 call hh loop j ret bb endp hh proc near mov ah,2 mov dl,13 int 21h mov ah,2 mov dl,10 int 21h ret hh endp code ends end main