1、的功能,写出堆栈最满时各单元的地址及内容. 6.4题的程序=STACK SEGMENT AT 500HDW 128 DUP(?STACK ENDSCODE SEGMENT ;MAIN PROC FAR ;MAIN PART OF PROGRAMCODE,SS:STACKSTART: ;STARTING EXECUTION ADDRESSMOV AX,STACKSUB AX,AXMAIN PART OF PROGRAM GOES HEREMOV AX,4321HCALL HTOARETRETURN TO DOSMAIN ENDP ;END OF MAIN PART OF PROGRAMHTOA
2、PROC NEAR ;DEFINE SUBPROCEDURE HTOACMP AX,15JLE B1PUSH BPMOV BP,SPMOV BX,BP+2AND BX,000FHMOV BP+2,BXPOP BPMOV CL,4SHR AX,CLB1:ADD AL,30HCMP AL,3AHJL PRINTITADD AL,07HPRINTIT:MOV DL,ALMOV AH,2INT 21HHTOA ENDP ;END OF SUBPROCEDURECODE ENDS ;END START ;5.下面是6.5题的程序清单,请在清单中填入此程序执行过程中的堆栈变化.0000 STACKSG S
3、EGMENT0000 20 . DW 32 DUP(?0040 STACKSG ENDS CODESG SEGMENT PARA CODE BEGIN PROC FAR ASSUME CS:CODESG,SS:STACKSG0000 1E PUSH DS0001 2B C0 SUB AX,AX0003 50 PUSH AX0004 E8 0008 R CALL P100007 CB RET0008 BEGIN ENDP B10 PROC0008 E8 000C R CALL C10000B C3000C B10 ENDP C10 PROC000C C3000D C10 ENDP CODESG
4、ENDS END BEGIN6.写一段子程序SKIPLINES,完成输出空行的功能.空行的行数在AX寄存器中.SKIPLINES PROC NEAR PUSH CX PUSH DX MOV CX,AX NEXT: MOV AH,2 MOV DL,0AH INT 21H MOV AH,2 MOV DL,0DH LOOP NEXT POP DX POP CX RET SKIPLINES ENDP7.设有10个学生的成绩分别是76,69,81,90,73,88,99,63,100和80分.试编制一个子程序统计60-69,70-79,80-89,90-99和100分的人数并分别存放到S6,S7,S8,
5、S9和S10单元中.DSEG SEGMENT NUM DW 76,69,84,90,73,88,99,63,100,80 N DW 10 S6 DW 0 S7 DW 0 S8 DW 0 S9 DW 0 S10 DW 0 DSEG ENDS CODE SEGMENT MAIN PROC FAR CODE, DS:DSEG PUSH DS SUB AX, AX PUSH AX MOV AX, DSEG MOV DS, AX CALL SUB1 MAIN ENDP SUB1 PROC NEAR PUSH BX PUSH SI MOV SI, 0 MOV CX, N NEXT:MOV AX, NUMS
6、I MOV BX, 10 DIV BL MOV BL, AL CBW SUB BX, 6 SAL BX, 1 INC S6BX ADD SI,2 POP SI POP BX POP AX SUB1 ENDP CODE ENDS END START (解法二)datasg segmentgrade db 76,69,84,90,73,88,99,63,100,80s6 db 0s7s8s9s10mess6 db 6069:$mess7 db 7079:mess8 db 8089:mess9 db 9099:mess10 db 100:datasg endscodesg segmentmain p
7、roc far assume cs:codesg,ds:datasgstart: push ds sub ax,ax push ax mov ax,datasg mov ds,ax call sub1 lea dx,mess6 call dispstr mov dl,s6 call dispscore call crlf lea dx,mess7 mov dl,s7 call dispscore lea dx,mess8 mov dl,s8 lea dx,mess9 mov dl,s9 call dispscore lea dx,mess10 mov dl,s10 ret endpsub1 p
8、roc near mov cx,10 mov si,0loop1: mov al,gradesi cmp al,60 jl next5 cmp al,70 jge next1 inc s6 jmp short next5next1: cmp al,80 jge next2 inc s7next2: cmp al,90 jge next3 inc s8next3: cmp al,100 jg next5 je next4 inc s9next4: inc s10next5: inc si loop loop1dispstr proc near mov ah,9 int 21hdispstr en
9、dpdispscore proc near add dl,30h mov ah,2dispscore endpcrlf proc near mov dl,0dh mov dl,0ahcrlf endpcodesg endsend start8.编写一个有主程序和子程序结构的程序模块.子程序的参数是一个N字节数组的首地址TABLE,数N及字符CHAR.要求在N字节数组中查找字符CHAR,并记录该字符的出现次数.;主程序则要求从键盘接收一串字符以建立字节数组TABLE,并逐个显示从键盘输入的每个字符CHAR以及它在TABLE数组中出现的次数.(为简化起见,假设出现次数=15,可以用十六进制形式显示
10、出来)DATA SEGMENT MAXLEN DB 40 N DB ?TABLE DB 40 DUP (?) CHAR DB A 查找字符EVEN _ADDR DW 3 DUP(?DATA ENDS DATA MOV AX, 0 MOV AX, DATA LEA DX, MAXLEN MOV AH, 0AH INT 21H 从键盘接收字符串 MOV _ADDR, OFFSET TABLE MOV _ADDR+2, OFFSET N MOV _ADDR+4, OFFSET CHAR MOV BX, OFFSET _ADDR ; 通过地址表传送变量地址 CALL COUNT 计算CHAR的出现次数
11、 CALL DISPLAY ; 显示 MAIN ENDPCOUNT PROC NEAR ; COUNT子程序 PUSH DI MOV DI, BX MOV SI, BX+2 MOV CL, BYTE PTRSI MOV CH, 0 MOV SI, BX+4 MOV AL, BYTE PTRSI MOV BX, 0 AGAIN:CMP AL, BYTE PTRDI JNE L1 INC BX L1: INC DI LOOP AGAIN POP DI COUNT ENDP DISPLAY PROC NEAR ; DISPLAY子程序 CALL CRLF 显示回车和换行 MOV DL, CHAR M
12、OV AH, 2 MOV DL, 20H MOV AL, BL AND AL, 0FH ADD AL, 30H CMP AL, 3AH JL PRINT ADD AL, 7 PRINT:MOV DL, AL CALL CRLF DISPLAY ENDP CRLF PROC NEAR ; CRLF子程序 MOV DL, 0DH MOV DL, 0AH CRLF ENDP END START9.编写一个子程序嵌套结构的程序模块,分别从键盘输入姓名及8个字符的电话号码,并以一定的格式显示出来.主程序TELIST:(1)显示提示符INPUT NAME:(2)调用子程序INPUT_NAME输入姓名:(3
13、)显示提示符INPUT A TELEPHONE NUMBER:(4)调用子程序INPHONE输入电话号码;(5)调用子程序PRINTLINE显示姓名及电话号码;子程序INPUT_NAME:(1)调用键盘输入子程序GETCHAR,把输入的姓名存放在INBUF缓冲区中;(2)把INBUF中的姓名移入输出行OUTNAME;子程序INPHONE:(1)调用键盘输入子程序GETCHAR,把输入的8位电话号码存放在INBUF缓冲区中;(2)把INBUF中的号码移入输出行OUTPHONE.子程序PRINTLINE:显示姓名及电话号码,格式为:NAME TEL* *=编写一个子程序嵌套结构的程序模块,分别从键
14、盘输入姓名及8个字符的电话号码,并以一定的格式显示出来(解法一)data segment No_of_name db 20 No_of_phone db 8 inbuf db 20 dup(? outname db 20 dup(?), outphone db 8 dup(? message1 db please input name:, message2 db please input a telephone number: message3 db NAME,16 dup(20h),TEL.,13,10, errormessage1 db you should input 8 numbers
15、! errormessage2 db you input a wrong number! flag db ?data endsprog segmentmain proc farprog,ds:data mov ax,data mov flag,0 lea dx,message1 mov ah,09 call input_name lea dx,message2 call inphone cmp flag,1 je exit call printlineexit:main endpinput_name proc near push dx push cx mov cx,0 mov cl,No_of
16、_name call getchar mov ax,0 mov al,No_of_name sub ax,cx mov cx,ax mov al,inbufsi mov outnamesi,al loop next1 pop cx pop dx pop axinput_name endpinphone proc near mov cl,No_of_phone cmp cx,0 jnz error1 mov cl,No_of_phone cmp al,30h error2 cmp al,39h ja mov outphonesi,al loop next2 jmp exit2error1: le
17、a dx,errormessage1 mov flag,1error2: lea dx,errormessage2exit2:inphone endpgetchar proc near mov di,0rotate: mov ah,01 cmp al,0dh exit1 mov inbufdi,al inc di loop rotateexit1:getchar endpprintline proc near lea dx,message3lea dx,outnamemov ah,09int 21hlea dx,outphoneprintline endpprog endsend main从键盘输入姓名及8个字符的电话号码,并以一定的格式显示出来datarea segmentinbuf label bytename parameter list:maxn
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1