1, Experimental purpose
2, Experimental conclusion
1. Experimental task 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
- 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 001B-000D and 14, which is obtained by subtracting s1 from 001B at the end of loop command - 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 0039-0029 and 16, which is obtained by subtracting s2 from 0039 at the end of loop command - Question ③
③ Attach the disassembly screenshot of debugging observation in debug during the above analysis
2. Experimental task 2
- 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
- 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) =? Register (bx) =? Register (cx) =?
② 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.
The last assignment of ax is at pop ax in line 25. At this time, the value at the top of the stack is the address of s1, and the ax value is the address of line 25
The last assignment of bx is at pop ax in line 28. At this time, the value at the top of the stack is the address of s2, so the bx value is the address of line 28
The last assignment of cx is at pop cx in line 29. At this time, the stack is empty. If you continue pop, you will put forward the last value in the data section, which is the value of cs, that is, the short address of the code section
As a result, register (ax) =0021 register (bx) = 0026 register (cx) = 076C
It is consistent with s1 position, s2 position and cs value
- After analysis, debugging and verification, register (ax) =? (bx) = (cx) =? Attach the screenshot of the debugging result interface.
3. Experimental task 3
- 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 si, offset x mov cx, len s:mov al, [si] mov ah, 0 mov bl, 10 div bl or ah, 30h or al, 30h mov bh, ah mov bl, al call s1 call s2 inc si loop s mov ah, 4ch int 21h s1: mov ah, 2 mov dl, bl int 21h mov dl, bh int 21h ret s2: mov ah, 2 mov dl, ' ' int 21h ret code ends end start
- Screenshot of running test
4. Experimental task 4
- The program source code task4.asm is given
assume cs:code, ds:data
data segment
str db 'try'
len equ $ - str
data endscode segment
start:
mov ax, data
mov ds, ax
mov ax, 0b800h
mov es, ax
mov si, offset strmov bh, 0
mov bl, 160
mov al, bh
mul bl
mov di, axmov bl, 2
mov cx, lens:call s1
inc si
loop smov si, offset str
mov bh, 24
mov bl, 160
mov al, bh
mul bl
mov di, axmov bl, 4
mov cx, lens2:call s1
inc si
loop s2mov ah, 4ch
int 21hs1:mov al, [si]
mov es:[di], al
inc di
mov es:[di], bl
inc di
retcode ends
end start - Screenshot of running test
5. Experimental task 5
- The program source code task5.asm is given
assume cs:code, ds:data data segment stu_no db '----------------------------------201983290423----------------------------------' len = $ - stu_no data ends code segment start: mov ax, data mov ds, ax mov ax, 0b800h mov es, ax mov si, offset stu_no mov ah, 00010111B mov cx, 0f00h mov al, ' ' mov di, 0 s2:call s1 loop s2 mov di, 0f00h mov cx, len s:mov al, [si] call s1 inc si loop s mov ah, 4ch int 21h s1:mov es:[di], al inc di mov es:[di], ah inc di ret code ends end start
- Screenshot of running test