IV. EXPERIMENTAL CONCLUSIONS
1. Experimental Task 1
Give the program task1.asm source code, and run a screenshot
1 assume cs:code, ds:data 2 3 data segment 4 x db 1, 9, 3 ;x Initial value is 0 (offset address) 5 len1 equ $ - x ; symbolic constants, $The offset address for the next data item, in this example, is 3 6 7 y dw 1, 9, 3 ;y Is 3 8 len2 equ $ - y ; symbolic constants, $The offset address for the next data item, in this example, is 9 9 data ends 10 11 code segment 12 start: 13 mov ax, data 14 mov ds, ax 15 16 mov si, offset x ; Take Symbols x Corresponding offset address 0 -> si 17 mov cx, len1 ; From Symbol x Number of consecutive byte data items to start with -> cx 18 mov ah, 2 19 s1:mov dl, [si] 20 or dl, 30h 21 int 21h 22 23 mov dl, ' ' 24 int 21h 25 26 inc si 27 loop s1 28 29 mov ah, 2 30 mov dl, 0ah 31 int 21h 32 33 mov si, offset y 34 mov cx, len2/2 35 mov ah, 2 36 s2:mov dx, [si] 37 or dl, 30h 38 int 21h 39 40 mov dl, ' ' 41 int 21h 42 43 add si, 2 44 loop s2 45 46 mov ah, 4ch 47 int 21h 48 code ends 49 end start
Answer Questions 1
(1) line27, the assembly instruction loop s1 jumps according to the amount of displacement. Through debug disassembly, look at its machine code and analyze how much displacement it jumps? (Displacement values are answered in decimal numbers) From the perspective of the CPU, how to calculate the offset address of the instruction following the jump label s1.
Machine code: F2 (h) --> 11110010 (b) --> 00001110 (b) --> -12 (d decimal) (complement --> source code)
Calculation of displacement: d(h) - 19(h) -->13-25= -12 (d decimal)
The CPU subtracts the current offset address from the target offset address and calculates the offset address of the instruction following the jump label s1.
Answer Questions 2
(2) line44, the assembly instruction loop s2 jumps according to the amount of displacement. Through debug disassembly, look at its machine code and analyze how much displacement it jumps? (Displacement values are answered in decimal numbers) From the perspective of the CPU, how to calculate the offset address of the instruction following the jump label s2.
Displacement: F0(h)
Question 3
(3) Disassembly screenshots of debugging observations in debug when the above analysis is attached
2. Experimental Task 2
Give program task2.asm source code
1 assume cs:code, ds:data 2 3 data segment 4 dw 200h, 0h, 230h, 0h 5 data ends 6 7 stack segment 8 db 16 dup(0) 9 stack ends 10 11 code segment 12 start: 13 mov ax, data 14 mov ds, ax 15 16 mov word ptr ds:[0], offset s1 17 mov word ptr ds:[2], offset s2 18 mov ds:[4], cs 19 20 mov ax, stack 21 mov ss, ax 22 mov sp, 16 23 24 call word ptr ds:[0] 25 s1: pop ax 26 27 call dword ptr ds:[2] 28 s2: pop bx 29 pop cx 30 31 mov ah, 4ch 32 int 21h 33 code ends 34 end start
Given analysis, debugging, validation, register (ax) =? (bx) =? (cx) =? Attach a screenshot of the debug results interface.
(1) According to the jump principle of call instruction, theoretical analysis is made first. Register (ax) =? Register (bx) =? Register (cx) = before program execution (line31)?
Register (ax)= Offset address of S1 Register (bx)= Offset address of S2 Register (cx)= Segment Address for S2
(2) Assemble and link the source program to get the executable task2.exe. Debug with debug to observe and verify whether the results of debugging are consistent with the results of theoretical analysis.
Agreement.
3. Experimental Task 3
Give program source task3.asm
1 assume cs:code, ds:data 2 3 data segment 4 x db 99, 72, 85, 63, 89, 97, 55 5 len equ $- x 6 data ends 7 8 code segment 9 main: 10 mov ax, data 11 mov ds, ax 12 13 mov cx, len 14 mov si, offset x 15 print: 16 mov al, [si] 17 mov ah, 0 18 call printNumber 19 call printSpace 20 inc si 21 loop print 22 23 mov ah, 4ch 24 int 21h 25 26 ;Function: Output a two-digit number in decimal form 27 ;Entry parameter: register ax(Data to be output --> ax) 28 ;Export parameters: none 29 printNumber: 30 mov bl, 10 31 div bl 32 mov bx, ax 33 34 mov ah, 2 35 36 mov dl, bl ; Printer(10 position) 37 or dl, 30h 38 int 21h 39 40 mov dl, bh ; Print Remainder(Bits) 41 or dl, 30h 42 int 21h 43 ret 44 45 printSpace: 46 mov ah, 2 47 mov dl, ' ' 48 int 21h 49 ret 50 51 code ends 52 end main
Run Test Screenshot
4. Experimental Task 4
Give program source task4.asm
1 assume cs:code 2 data segment 3 str db 'try' 4 len equ $ - str 5 data ends 6 code segment 7 main: 8 mov ax, 0b800h 9 mov es, ax 10 11 first_print: 12 mov ax, data 13 mov ds, ax 14 mov si, offset str 15 mov cx, len 16 mov bl, 00000010b ; Green on Black 17 mov bh, 0 ; Line 0 18 call printStr 19 20 second_print: 21 mov si, offset str 22 mov cx, len 23 mov bl, 00000100b ; Red on Black 24 mov bh, 24 ; Line 24 25 call printStr 26 27 mov ah, 4ch 28 int 21h 29 30 ; Entry parameters: 31 ; Address of first character in string --> ds:si(Where the segment address of the string is -> ds, Offset Address for String Start Address -> si) 32 ; String Length --> cx 33 ; String color --> bl 34 ; Specify Row --> bh (Value:0 ~24) 35 printStr: 36 push bp 37 push di 38 39 mov ah, 0 40 mov al, 160 41 mul bh 42 mov bp, ax 43 mov di, si 44 printChar: 45 mov al, ds:[si] 46 mov es:[bp+di], al ; character 47 mov es:[bp+di+1], bl ; colour 48 inc si 49 inc di 50 inc di 51 loop printChar 52 53 pop bp 54 pop di 55 ret 56 code ends 57 end main
Run Test Screenshot
5. Experimental Task 5
Give program source task5.asm
1 assume cs:code, ds:data 2 data segment 3 stu_no db '201983290357' 4 len = $ - stu_no 5 data ends 6 7 code segment 8 main: 9 call print_blue_screen 10 call print_stu_no 11 12 mov ah, 4ch 13 int 21h 14 print_blue_screen: 15 push ax 16 push es 17 push si 18 19 mov ax, 0b800h 20 mov es, ax 21 mov cx, 2000 22 mov si, 1 23 single_blue: 24 mov byte ptr es:[si], 00010000b 25 inc si 26 inc si 27 loop single_blue 28 29 pop si 30 pop es 31 pop ax 32 ret 33 34 print_stu_no: 35 push ax 36 push es 37 push si 38 push ds 39 push di 40 prefix: 41 mov ax, 0b800h 42 mov es, ax 43 mov cx, 34 44 mov si, 3840 ; si Store offset address for each video output 45 call print_dash 46 content: 47 mov ax, data 48 mov ds, ax 49 mov cx, len 50 mov di, 0 ; di Deposit data Offset address for each character in 51 single_no: 52 mov al, ds:[di] 53 inc di 54 mov byte ptr es:[si], al 55 inc si 56 mov byte ptr es:[si], 00010111b 57 inc si 58 loop single_no 59 postfix: 60 mov cx, 34 61 call print_dash 62 63 pop di 64 pop ds 65 pop si 66 pop es 67 pop ax 68 ret 69 70 ; input parameter: 71 ; Base address shown si 72 ; Output Length cx 73 ; output: 74 ; Base address after iteration si 75 print_dash: 76 single_dash: 77 mov byte ptr es:[si], '-' 78 inc si 79 mov byte ptr es:[si], 00010111b 80 inc si 81 loop single_dash 82 ret 83 84 code ends 85 end main
Run Test Screenshot
V. EXPERIMENTAL SUMMARY
1. Symbol constant, $refers to the offset address of the next data item.
2.EQU is an equivalent command:
COUNT EQU 100; Make the COUNT value 100 and allocate 0 bytes to the variable in the memory;
COUNT DB 100; It should be an offset address with count value of 100.
3. The OFFSET operator returns the offset of the data label. This offset is in bytes and represents the distance between the data label and the starting address of the data segment.