实验4 8086标志寄存器及中断
实验任务1:
(1)源码:
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
(2)不能。因为add指令可能会修改CF标志位,而inc不会改变CF标志位,所以这里不能用add来替换inc。
(3)前:

后:

实验任务2:
(1)源码:
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
(2)截图:

(3)
line11-18:接收输入字符串,遇到“#”则跳转到next。
line20-22:输出换行
line24-30:打印出字符串
实验任务3:
(1)源码:
assume cs:code, ds:data data segment x dw 91,792,8536,65521,2021 len equ $ - x data ends stack segment db 16 dup(0) stack ends code segment start: mov ax,data mov ds,ax mov si,0 mov cx,len/2 s: mov ax,[si] call printNumber call printSpace add si,2 loop s mov ah,4ch int 21h printNumber: mov bx,10 mov dx,0 mov di,0 push cx s1: div bx push dx inc di mov dx,0 cmp ax,0 je next jmp s1 next: mov ah,2 mov cx,di s2: pop dx or dl,30H int 21h loop s2 pop cx ret printSpace: mov dl,' ' mov ah,2 int 21h ret code ends end start
(2)

实验任务4
(1)源码:
assume cs:code, ds:data data segment str db "assembly language, it's not difficult but tedious" len equ $ - str data ends code segment start: mov ax, data mov ds, ax mov cx, len mov si, 0 call strupr mov ah, 4ch int 21h strupr: mov al, [si] and al, 223 mov [si], al inc si loop strupr ret code ends end start
(2)前:

后:

实验任务5
(1)源码:
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
(2)

(3)输入7时输出yes,输入其他数字输出no
实验任务6
(1)

(2)
中断就是计算机在执行正常程序过程中,当出现某种异常事件或某种外部请求时,处理器就暂停执行当前的程序,而转去执行对异常事件或者外部请求的处理操作。当处理完毕后,CPU再返回到被暂停执行的程序,继续执行。
浙公网安备 33010602011771号