任务一
assume cs:code, ds:data data segment x db 1, 9, 3 len1 equ $ - x y dw 1, 9, 3 len2 equ $ - y data ends code segment start: mov ax, data mov ds, ax mov si, offset x mov cx, len1 mov ah, 2 s1:mov dl, [si] or dl, 30h int 21h mov dl, ' ' int 21h inc si loop s1 mov ah, 2 mov dl, 0ah int 21h mov si, offset y mov cx, len2/2 mov ah, 2 s2:mov dx, [si] or dl, 30h int 21h mov dl, ' ' int 21h add si, 2 loop s2 mov ah, 4ch int 21h code ends end start
(1)
程序运行到loop s1时,指令寄存器IP=001B指向下一条指令,而001B+00F2=010D,高位舍弃,即IP指向000D
(2)
位移量是:16,Loop指令结束地址为:0039,s1指令开始地址为0029,001B-000D=16
or dl, 30h命令占三个字节,其他指令各占两个字节,一共16字节。
任务二
assume cs:code, ds:data data segment dw 200h, 0h, 230h, 0h data ends stack segment db 16 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov word ptr ds:[0], offset s1 mov word ptr ds:[2], offset s2 mov ds:[4], cs mov ax, stack mov ss, ax mov sp, 16 call word ptr ds:[0] s1: pop ax call dword ptr ds:[2] s2: pop bx pop cx mov ah, 4ch int 21h code ends end start
(1)
ax为s1的偏移地址0021,bx为s2的偏移地址0026,cx为cs即076C。
(2)
由图可以看出AX=s1的偏移量 BX=s2的偏移量,CX则是code段的段地址
任务三
assume cs:code ds:data
data segment
x db 99, 72, 85, 63, 89, 97, 55
len equ $- x
data ends
code segment
start:
mov bx,0
mov ax,data
mov ds,ax
mov cx,len
s:
call printNumber
call printSpace
loop s
mov ah,4ch
int 21h
printNumber:
mov al,[bx]
inc bx
mov ah,0
mov dl,10
div dl
OR al,30h
OR ah,30h
mov dh,ah
mov ah,2
mov dl,al
int 21h
mov ah,2
mov dl,dh
int 21h
ret
printSpace:
mov ah,2
mov dl,' '
int 21h
ret
code ends
end start
任务四:
assume cs:code, ds:data
data segment
str db 'try'
len equ $ - str
data ends
code segment
start:
mov cx,len
mov ax,data
mov ds,ax
mov si,0
mov bl,2
mov bh,0
call printStr
mov cx,len
mov si,0
mov bl,4
mov bh,24
call printStr
mov ah,4ch
int 21h
printStr:
mov dl,bh
mov dh,0
mov ax,160
mul dx
mov di,ax
mov ax,0b800h
mov es,ax
mov ah,bl
s:
mov al,ds:[si]
inc si
mov es:[di],ax
add di,2
loop s
ret
code ends
end start
任务五
assume cs:code,ds:data data segment stu_no db '201983290170' len=$ - stu_no data ends code segment start: mov ax,data mov ds,ax mov di,0 mov ax,0b800h mov es,ax mov si,0 mov bl,0 mov bh,23 mov cx,1920 s: mov es:[si],bx add si,2 loop s mov cx,34 mov bl,45 s1: mov es:[si],bx add si,2 loop s1 mov cx,12 s2: mov bl,ds:[di] inc di mov es:[si],bx add si,2 loop s2 mov cx,34 mov bl,45 s3: mov es:[si],bx add si,2 loop s3 mov ah,4ch int 21h code ends end start