4, Experimental conclusion
1. Experimental task 1
Contents of this part:
Give the program task1.asm source code, and run screenshots
task1.asm source code:
Operation screenshot:
Answer question ①
① line27, when the assembly instruction loop s1 jumps, it jumps according to the displacement. Check the machine through debug disassembly
What is the jump displacement of the code? (the displacement value is answered in decimal) from the perspective of CPU, it is explained
How to calculate the offset address of the instruction after the jump label s1.
debug disassembly:
line27 machine code: E2F2
Jump displacement: - 14 (0Dh - 1Bh = 13 - 27 = -14)
1. After executing machine code E2F2, CS:IP points to the instruction at label s1
2. The CPU reads the instruction at label s1 and enters the instruction buffer
3.(IP) = (IP) + the length of the instruction at label s1 to obtain the offset address of the instruction after s1
Answer question ②
② line44. When the assembly instruction loop s2 jumps, it jumps according to the displacement. Check the machine through debug disassembly
What is the jump displacement of the code? (the displacement value is answered in decimal) from the perspective of CPU, it is explained
How to calculate the offset address of the instruction after the jump label s2.
debug disassembly:
line44 machine code: E2F0
Jump displacement: - 16 (29h - 39h = -10h )
1. After executing machine code E2F0, CS:IP points to the instruction at label s2
2. The CPU reads the instruction at label s2 and enters the instruction buffer
3.(IP) = (IP) + the length of the instruction at label s2 to obtain the offset address of the instruction after s2
Question ③
③ Attach the disassembly screenshot of debugging observation in debug during the above analysis
Debugging screenshot of question ①:
Screenshot of debugging in question ②:
2. Experimental task 2
Contents of this part:
The program task2.asm source code is given
① According to the jump principle of call instruction, it is analyzed theoretically that the register (ax) before the program execution to exit (line31)=
? register (bx) =? Register (cx) =?
(ax) = offset s1
(bx) = offset s2
(cx) = cs
② Assemble and link the source program to get the executable program task2.exe. Use debug to debug, observe and verify debugging
Whether the results are consistent with the theoretical analysis results.
The debugging results are consistent with the theoretical analysis results.
3. Experimental task 3
Contents of this part:
The program source code task3.asm is given
1 data segment 2 x db 99, 72, 85, 63, 89, 97, 55 3 len equ $- x 4 data ends 5 6 code segment 7 start: 8 mov ax,data 9 mov ds,ax 10 11 mov di,0 ;Point to first data 12 mov cx,7 13 14 s: mov ah,0 ;Set the high position to 0 15 mov al,[di] 16 mov bl,10 ;Divisor 10(decimal system) 17 18 call printNumber 19 call printSpace 20 inc di 21 22 loop s 23 24 mov ah,4ch 25 int 21h 26 27 printNumber: 28 div bl 29 mov bx,ax 30 31 mov ah,2 32 33 or bl,00110000b ;bl merchant 34 mov dl,bl 35 int 21h 36 37 or bh,00110000b ;bh remainder 38 mov dl,bh 39 int 21h 40 ret 41 42 printSpace: 43 mov ah,2 44 mov dl,' ' 45 int 21h 46 ret 47 48 49 code ends 50 end start
Screenshot of running test
4. Experimental task 4
Contents of this part:
The program source code task4.asm is given
1 assume ds:data, cs:code 2 data segment 3 x db 'try' 4 len equ $ - x 5 data ends 6 7 code segment 8 start: 9 mov ax,data 10 mov ds,ax 11 12 mov si,0 ;Point to data 13 mov di,0 ;First line of screen 14 mov cx,len 15 16 s: mov bl,[si] ;Low storage data 17 mov bh,02 ;Green characters on black background 18 call printStr 19 inc si 20 loop s 21 22 mov si,0 23 mov di,0F00h ;Last line of screen 24 mov cx,len 25 26 s1: mov bl,[si] 27 mov bh,04 ;Scarlet letter on black background 28 call printStr 29 inc si 30 loop s1 31 32 mov ah,4ch 33 int 21h 34 35 36 printStr: 37 mov ax,0b800h 38 mov es,ax 39 40 mov es:[di],bx 41 add di,2 42 ret 43 44 code ends 45 end start
Screenshot of running test
5. Experimental task 5
Contents of this part:
The program source code task5.asm is given
1 assume ds:data, cs:code 2 data segment 3 stu_no db '201983290103' 4 len = $ - stu_no 5 data ends 6 7 code segment 8 start: 9 mov ax,data 10 mov ds,ax 11 12 mov ax,0b800h 13 mov es,ax ;Set display buffer 14 mov di,0 ;point data data 15 mov cx,2000 ;80×25 All characters in the screen 16 mov si,0 ;Traverse the entire screen 17 18 mov bh,00010111b ;Set white on blue 19 mov bl,0 ;eliminate bl Cluttered information in 20 s: call print 21 loop s 22 23 mov cx,80 24 mov si,0f00h ;Points to the first character of the last line 25 mov bl,'-' ;Set the last line to all'-' 26 s1: call print 27 loop s1 28 29 mov cx,len 30 mov si,0f44h 31 32 s2: mov bl,[di] 33 call print 34 inc di 35 loop s2 36 mov ah,4ch 37 int 21h 38 print: 39 mov es:[si],bx 40 add si,2 41 ret 42 43 44 code ends 45 end start
Screenshot of running test