资源描述:
《汇编语言编程题目资料答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、5.1编写程序,从键盘接收一个小写字母,然后找出它的前导字符和后续字符,再按顺序用大写字母显示这三个字符。【解】:MAINPROCFARstart:pushdssubax,axpushaxinput:movah,7Hint21Hcmpe:cmpal,20HJEexitcmpal,61HJLinputcmpal,7AHJGinputprint:subal,01Hmovdl,almovah,02Hint21Haddal,01Hmovdl,almovah,02Hint21Haddal,01Hmovdl,almovah,02Hint21H;输出换行回车movdl,0A
2、Hmovah,02Hint21Hjmpinputexit:retMAINENDPENDstart5.2 将AX寄存器中的16位数分成4组,每组4位,然后把这4组数分别放在AL、BL、CL和DL中。【解】:DB 4 dup(?) .stack 100H .code MAIN PROC FAR start: push ds and ax,00H push ax mov ax,1234H mov cx,04H mov si,00H lop: push cx mov cl,04H rol ax,cl push ax and al,0FH mov BYTE PTR x
3、[si],al pop ax pop cx add si,2 Loop lop mov al,[X] mov bl,[X+2] mov cl,[X+4] mov dl,[X+6] print: mov ah,02H int 21H mov dl,al mov ah,02H int 21H mov dl,bl mov ah,02H int 21H mov dl,cl mov ah,02H int 21H exit: ret MAIN ENDP END start5.3 试编写一程序,要求比较两个字符串STRING1和STRING2所含字符是否相同,若相同则显示
4、MATCH,若不相同则显示NOMATCH。【解】:data segment string1 db "111111111",13,10,"$" string2 db "222222222",13,10,"$" inf1 db "match!",13,10,"$" inf2 db "no match!",13,10,"$"data endscode segmentmain proc far assume ds:data,cs:code,es:codestart: push ds mov ax,0 push
5、ax mov ax,data mov ds,ax mov es,ax lea si,string1 lea di,string2 mov cx,9 repz cmpsb jz match lea dx,inf2 jmp disp match:lea dx,inf1 disp :mov ah,09 int 21h retmain endpcode endsend start 5.4
6、 试编写一程序,要求能从键盘接收一个个位数N,然后响铃N次(响铃的ASCII码为07H)。【解】:main proc far start: push ds sub ax,ax push ax input: mov ah,01H int 21H cmp al,20H je exit cmp al,30H jle input cmp al,3AH jge input sub al,30H mov cx,ax and cx,0FFH lop: mov dl,07H mov ah,2H int 21H loop lop jmp input exit : ret mai
7、n endp end start5.5 编写程序,将一个包含有20个数据的数组M分成两个数组:正数数组P和负数数组N,并分别把这两个数组中数据的个数显示出来。【解】: DATASEGMENT BUFDB-32, 25, 36, -18, -64, 0, -3 COUNTEQU$ - BUF PLUSDB?; 存放正数 MINUSDB?; 存放负数 DATAENDS CODESEGMENT ASSUMECS:CODE,DS:DATA START:MOVAX,DATA MOVDS,AX MOVBL,0
8、; 负数个数 MOVDL,0;