《桂电汇编部分实验完整代码》由会员分享,可在线阅读,更多相关《桂电汇编部分实验完整代码(18页珍藏版)》请在金锄头文库上搜索。
1、实验三代码sseg segment stack dw 256 dup (?) sseg ends data segment msg1 db Enter keyword:,24h msg2 db Enter Sentence:,24h cr db 13,10,24h keyword db 250,?,250 dup (?) Sentence db 250,?,250 dup (?) match db Match at location:,24h match1 db of the sentence,13,10,24h nomatch db No match,13,10,24h data ends
2、code segment assume cs:code,ds:data,ss:sseg disp_hex proc near push ax push cx push dx push ax mov cl,4 ror al,cl and al,0fh add al,30h cmp al,39h jna d1 add al,7 d1: mov dl,al mov ah,2 int 21h pop ax and al,0fh add al,30h cmp al,39h jna d2 add al,7 d2: mov dl,al mov ah,2 int 21h mov dl,h mov ah,2 i
3、nt 21h pop dx pop cx pop ax ret disp_hex endp begin: mov ax,data mov ds,ax mov es,ax mov dx,offset msg1 mov ah,9 int 21h mov dx,offset keyword mov ah,0ah int 21h cmp keyword + 1,0 je quit mov dx,offset cr mov ah,9 int 21h b1: mov dx,offset msg2 mov ah,9 int 21h mov dx,offset Sentence mov ah,0ah int
4、21h mov dx,offset cr mov ah,9 int 21h mov dl,Sentence + 1 cmp dl,0 je quit mov dh,keyword + 1 mov di,offset Sentence + 2 b2: cmp dh,dl ja _nomatch mov si,offset keyword + 2 mov cl,dh mov ch,0 cld push di repe cmpsb pop di je _match inc di dec dl jmp b2 _match: mov ax,di sub ax,offset Sentence + 2 in
5、c ax push ax mov dx,offset match mov ah,9 int 21h pop ax call disp_hex mov dx,offset match1 mov ah,9 int 21h jmp b1 _nomatch: mov dx,offset nomatch mov ah,9 int 21h jmp b1 quit: mov ah,4ch int 21h code ends end begin /传递DATAS SEGMENTSTR1 DB ASDFG STR2 DB 100 DUP(?)DATAS ENDSSTACKS SEGMENT ;此处输入堆栈段代码
6、STACKS ENDSCODES SEGMENTASSUME CS:CODES,DS:DATAS,SS:STACKSSTART: MOV AX,DATAS MOV DS,AX LEA BX,STR1 LEA SI,STR2 MOV CX,100LOP:MOV BL,BX MOV SI,AL INC BX INC SI LOOP LOP MOV AH,4CH INT 21HCODES ENDS END START循环程序1CODE SEGMENTASSUME CS:CODESTART: MOV AH,02h MOV CX,15 MOV BL,10HLOO1: MOV BH,16LOOP2: MO
7、V DL,BL INT 21H MOV DL,20h INT 21H INC BL DEC BH CMP BH,0 JNE LOOP2 MOV DL,0ah INT 21H MOV DL,0dh INT 21H LOOP LOO1EXIT: MOV AH,4CH INT 21HCODE ENDS END START循环程序2 sseg segment stack dw 256 dup (?) sseg ends data segment msg1 db Enter keyword:,24h msg2 db Enter Sentence:,24h cr db 13,10,24h keyword
8、db 250,?,250 dup (?) Sentence db 250,?,250 dup (?) match db Match at location:,24h match1 db of the sentence,13,10,24h nomatch db No match,13,10,24h data ends code segment assume cs:code,ds:data,ss:sseg disp_hex proc near push ax push cx push dx push ax mov cl,4 ror al,cl and al,0fh add al,30h cmp a
9、l,39h jna d1 add al,7 d1: mov dl,al mov ah,2 int 21h pop ax and al,0fh add al,30h cmp al,39h jna d2 add al,7 d2: mov dl,al mov ah,2 int 21h mov dl,h mov ah,2 int 21h pop dx pop cx pop ax ret disp_hex endp begin: mov ax,data mov ds,ax mov es,ax mov dx,offset msg1 mov ah,9 int 21h mov dx,offset keyword mov ah,0ah int 21h cmp keyword + 1,0 je quit mov dx,offset cr mov ah,9 int 21h b1: mov dx,offset msg2 mov ah,9 int 21h mov dx,offset Sentence mov ah,0ah int 21h mov dx,offset cr mov ah,9 int 21h mov dl,Sentence + 1 cmp dl,0 je quit m