1.实验任务1
add指令对零标志位和进位标志位都有影响
inc指令对零标志位有影响,对进位标志位没有影响
assume cs:code, ds:data data segment x dw 1020h, 2240h, 9522h, 5060h, 3359h, 6652h, 2530h, 7031h y dw 3210h, 5510h, 6066h, 5121h, 8801h, 6210h, 7119h, 3912h data ends code segment start: mov ax, data mov ds, ax mov si, offset x mov di, offset y call add128 mov ah, 4ch int 21h add128: push ax push cx push si push di sub ax, ax mov cx, 8 s: mov ax, [si] adc ax, [di] mov [si], ax inc si inc si inc di inc di loop s pop di pop si pop cx pop ax ret code ends end start
不能,因为add指令会修改CF标志位的值,会对adc指令在进行进位运算的时候产生影响,导致程序结果错误
运行之前数据段的值
运行之后数据段的值
2.实验任务2
assume cs:code, ds:data data segment str db 80 dup(?) data ends code segment start: mov ax, data mov ds, ax mov si, 0 s1: mov ah, 1 int 21h mov [si], al cmp al, '#' je next inc si jmp s1 next: mov ah, 2 mov dl, 0ah int 21h mov cx, si mov si, 0 s2: mov ah, 2 mov dl, [si] int 21h inc si loop s2 mov ah, 4ch int 21h code ends end start
问题1:汇编指令代码line11-18,实现的功能是?
11-18的功能为连续在键盘上输入字符,直到接受到字符‘#’,执行next代码
问题2:汇编指令代码line20-22,实现的功能是?
20-22的功能为输出一个空行,并且将已经输入的字符数交给cx寄存器,si寄存器修改为0,以便开始接下来的输出
问题3:汇编指令代码line24-30,实现的功能是?
24-30的功能为输出所有之前在键盘上输入的字符不包含‘#’,因为接受‘#’的时候没有执行inc指令
3.实验任务3
assume cs:code,ds:data data segment x dw 91,792,8536,65521,2021 len equ $ - x data ends code segment start: mov ax,data mov ds,ax mov si,0 mov cx,len/2 s: mov ax, word ptr[si] push cx call printNumber call printSpace pop cx inc si inc si loop s printNumber: mov bx,10 mov di,0 s1: mov dx,0 div bx push dx inc di cmp ax,0 jne s1 mov cx,di print: pop dx mov ah,2 or dl,30h int 21h loop print ret printSpace: mov ah,2 mov dl,' ' int 21h ret mov ah, 4ch int 21h code ends end start
4.实验任务4
assume cs:code,ds:data data segment str1 db "assembly language, it's not difficult but tedious" len equ $ - str1 data ends code segment start: mov ax,data mov ds,ax mov di,offset str1 mov cx,len call toUpper mov cx,len mov di,0 s: call print inc di loop s mov ah, 4ch int 21h toUpper: mov al,[di] cmp al,97 jb next cmp al,122 ja next and al,11011111b mov [di],al next: inc di loop toUpper ret print: mov dl,[di] mov ah,2 int 21h ret code ends end start
5.实验任务5
assume cs:code, ds:data data segment str1 db "yes", '$' str2 db "no", '$' data ends code segment start: mov ax, data mov ds, ax mov ah, 1 int 21h mov ah, 2 mov bh, 0 mov dh, 24 mov dl, 70 int 10h cmp al, '7' je s1 mov ah, 9 mov dx, offset str2 int 21h jmp over s1: mov ah, 9 mov dx, offset str1 int 21h over: mov ah, 4ch int 21h code ends end start
程序功能为在键盘上获取一个字符如果为字符7,则屏幕上输出yes,否则输出no
6.实验任务6
中断是由于软件的或者硬件的信号,使得cpu暂停当前的任务,转而去执行另一端子程序。软中断是由于程序中存在中断指令产生的,可以通过程序控制触发。