1. Experimental task 1
(1) Give the program task1.asm source code, and run screenshots
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
(2)
Answer question ①
① line27, when the assembly instruction loop s1 jumps, it jumps according to the displacement. Check the machine code through debug disassembly and analyze the jump displacement? (the displacement value is answered in decimal) from the perspective of the CPU, explain how to calculate the offset address of the instruction after the jump label s1.
The displacement is 12 The function of loop label is to cycle jmp short when cx is not less than 0. It is based on the last byte F2 of this instruction. F2 is the complement of - 14, which is the displacement transferred
Answer question ②
② line44. When the assembly instruction loop s2 jumps, it jumps according to the displacement. Check the machine code through debug disassembly and analyze the jump displacement? (the displacement value is answered in decimal) from the perspective of the CPU, explain how to calculate the offset address of the instruction after the jump label s2.
The displacement is 14 The function of loop label is to cycle jmp short when cx is not less than 0. It is based on the last byte F0 of this instruction. F0 is the complement of - 16, which is the displacement of transfer
Question ③
③ Attach the disassembly screenshot of debugging observation in debug during the above analysis
2. Experimental task 2
(1) The program task2.asm source code is given
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
(2)
After analysis, debugging and verification, register (ax) =? (bx) = (cx) =? Attach the screenshot of the debugging result interface.
① According to the jump principle of call instruction, it is analyzed theoretically that before the program executes to exit (line31), register (ax) = 0021h, register (bx) = 0026h, register (cx) = 076ch
② Assemble and link the source program to get the executable program task2.exe. Use debug to observe and verify whether the debugging results are consistent with the theoretical analysis results.
Theoretical analysis: ds:[0] put the offset address of s1 into the stack, and then put it out of the stack into ax. ds:[2] put the offset address of s2 into the stack, and then press the segment address of s2 into the stack, and then put the segment address out into bx, and the offset address into cx. Verify that it is correct.
3. Experimental task 3
(1) The program source code task3.asm is given
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 ax,data mov ds,ax mov cx,len mov si,offset x s: mov ah,0 mov al,[si] mov bl,10 div bl call printNumber call printSpace inc si loop s mov ah,4ch int 21h printNumber: mov bx,ax mov ah,2 mov dl,bl add dl,30h int 21h mov dl,bh add dl,30h int 21h ret printSpace: mov ah,2 mov dl,' ' int 21h ret code ends end start
(2) Screenshot of running test
4. Experimental task 4
(1) The program source code task4.asm is given
assume cs:code ds:data data segment str db 'try' len equ $ - str data ends code segment start: mov ax,data mov ds,ax mov si,offset str mov bh,0 mov bl,2 call printStr mov si,offset str mov bh,24 mov bl,4 call printStr mov ah,4ch int 21h printStr: mov cx,len mov ax,0b800h mov es,ax mov al,0a0h mul bh mov di,ax s:mov al,ds:[si] mov ah,bl mov es:[di],ax inc si add di,2 loop s ret code ends end start
(2) Screenshot of running test
5. Experimental task 5
(1) The program source code task5.asm is given
assume cs:code ds:data data segment stu_no db '201983290119' len = $ - stu_no data ends code segment start: mov ax,data mov ds,ax mov bx,0 mov ax,0b800h mov es,ax mov cx,80 mov si,0f00h mov dl,'-' s1: mov es:[si],dl;Fill the last row with all- add si,2 loop s1 mov cx,len mov si,0f44h s2: mov dl,ds:[bx];Fill the student number from the last line of 68 bytes mov es:[si],dl add si,2 inc bx loop s2 mov cx,2000 mov si,1 mov dl,17h s3: mov es:[si],dl;Fill all in blue add si,2 loop s3 mov ax,4c00h int 21h code ends end start
(2) Screenshot of running test