Experiment task 1:
Task 1-1
task1_1.asm source code:
assume ds:data, cs:code, ss:stack data segment db 16 dup(0) data ends stack segment db 16 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 16 mov ah, 4ch int 21h code ends end start
Question answer:
1) In debug, execute until the end of line17 and before line19, and record this time: register (DS)= 076A, register (SS) yes= 076B, register (CS)= 076C
2) Assuming that the segment address of the code segment is X after the program is loaded, the segment address of the data segment is X X-2 , The segment address of stack is X-1.
Task 1-2
task1_2.asm source code:
assume ds:data, cs:code, ss:stack data segment db 4 dup(0) data ends stack segment db 8 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 8 mov ah, 4ch int 21h code ends end start
task1_2. Screenshot of observing the values of registers DS, CS and SS at the end of debugging to line17 and before line19:
Question answer
1) In debug, execute until the end of line17 and before line19. Record this time: register (DS) = 076A, register (SS) = 076B, register (CS) = 076C
2) Assuming that the segment address of the code segment is X after the program is loaded, the segment address of the data segment is X-2 and the segment address of the stack is X-1
Task 1-3
task1_3.asm source code:
assume ds:data, cs:code, ss:stack data segment db 20 dup(0) data ends stack segment db 20 dup(0) stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 20 mov ah, 4ch int 21h code ends end start
task1_ 3. Screenshot of register DS, CS and SS values after ASM debugging to the end of line17 and before line19:
Question answer
1) In debug, execute until the end of line17 and before line19. Record this time: register (DS) = 076A, register (SS) = 076C, register (CS) = 076E
2) Assuming that the segment address of the code segment is X after the program is loaded, the segment address of the data segment is X-4 and the segment address of the stack is X-2.
Tasks 1-4
Task task1_4.asm source code:
assume ds:data, cs:code, ss:stack code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 20 mov ah, 4ch int 21h code ends data segment db 20 dup(0) data ends stack segment db 20 dup(0) stack ends end start
task1_ 4. Screenshot of register DS, CS and SS values after ASM debugging to the end of line17 and before line19:
Question answer:
1) In debug, execute until the end of line17 and before line19, and record this time: register (DS)= 076C, register (SS)= 076E, register (CS)= 076A
2) Assuming that the segment address of the code segment is X after the program is loaded, the segment address of the data segment is X X+2, the segment address of stack is X+4.
Tasks 1-5
Based on the practice and observation of the above four experimental tasks, summarize and answer:
1) For the segment defined below, after the program is loaded, the actual memory space allocated to the segment is [N/16]*16 words (rounded up).
xxx segment db N dup(0) xxx ends
2) If the program Task1_ 1.asm, task1_ 2.asm, task1_ 3.asm, task1_ 4. In ASM, if the pseudo instruction end start is changed to end, which program can still be executed correctly. The reasons are analyzed and explained in combination with the conclusions obtained from practical observation.
task1_4.asm can operate normally. When the code has end start, the program will execute from the position marked with start, otherwise it will execute from the beginning.
Experiment task 2:
assume cs:code code segment start: mov ax,0b800h mov ds,ax mov bx,0f00h mov ax,0403h mov cx,80 s: mov ds:[bx],ax add bx,2 loop s mov ah, 4ch int 21h code ends end start
Experiment task 3:
Complete source code:
assume cs:code data1 segment db 50, 48, 50, 50, 0, 48, 49, 0, 48, 49 ; ten numbers data1 ends data2 segment db 0, 0, 0, 0, 47, 0, 0, 47, 0, 0 ; ten numbers data2 ends data3 segment db 16 dup(0) data3 ends code segment start: mov bx, 0 mov cx, 10 s:mov dx, 0 mov ax, data1 mov ds, ax add dx, [bx] mov ax, data2 mov ds, ax add dx, [bx] mov ax, data3 mov ds, ax mov [bx], dx inc bx loop s mov ah, 4ch int 21h code ends end start
Screenshot of loading, disassembling and debugging in debug:
The debug command and screenshot of the original value of the memory space data corresponding to the logical segments data1, data2 and data3 before the data is added in turn:
After adding in sequence, view the debug command and screenshot of the original value of memory space data corresponding to logical segments data1, data2 and data3:
Experiment task 4:
Complete source code:
assume cs:code data1 segment dw 2, 0, 4, 9, 2, 0, 1, 9 data1 ends data2 segment dw 8 dup(?) data2 ends stack segment dw 8 dup(?) stack ends code segment start: mov ax,data1 mov ds,ax mov bx,0 mov sp,10h mov cx,8 s0: push [bx] add bx,2h loop s0 mov cx,8 mov bx,0 s1: pop [bx+10h] add bx,2h loop s1 mov ah, 4ch int 21h code ends end start
Screenshot of loading, disassembling and debugging in debug:
After the program is executed, use the d command to view a screenshot of the memory space corresponding to the data segment data2:
Experiment task 5:
task5.asm source code:
assume cs:code, ds:data data segment db 'Nuist' db 2,3,4,5,6 data ends code segment start: mov ax, data mov ds, ax mov ax, 0b800H mov es, ax mov cx, 5 mov si, 0 mov di, 0f00h s: mov al, [si] and al, 0dfh mov es:[di], al mov al, [5+si] mov es:[di+1], al inc si add di, 2 loop s mov ah, 4ch int 21h code ends end start
Screenshot of operation results:
Use the debug tool to debug the program, and use the g command to execute it once before the program returns (i.e. after ine25 and before line27):
What is the function of line19 in the source code?
A: change the sixth bit of al to 0 to complete the case conversion.
What is the purpose of the byte data in the data segment line4 in the source code?
A: set different colors of words.
Experiment task 6:
task6.asm source code:
assume cs:code, ds:data data segment db 'Pink Floyd ' db 'JOAN Baez ' db 'NEIL Young ' db 'Joan Lennon ' dw 0 data ends code segment start: mov ax,data mov ds,ax mov bx,0 mov cx,4 s0: mov ds:[40h],cx mov si,0 mov cx,4 s: mov al,[bx+si] or al,00100000b mov [bx+si],al inc si loop s add bx,16 mov cx,ds:[40h] loop s0 mov ah, 4ch int 21h code ends end start
Screenshot of loading, disassembling and debugging in debug:
Before the program exits, use the d command to view a screenshot of the memory space corresponding to the data segment data:
Experimental task 7
task7.asm source code:
assume cs:code, ds:data, es:table data segment db '1975', '1976', '1977', '1978', '1979' dd 16, 22, 382, 1356, 2390 dw 3, 7, 9, 13, 28 data ends table segment db 5 dup( 16 dup(' ') ) ; table ends code segment start: mov ax,data mov ds,ax mov ax,table mov es,ax mov bx,0 mov si,0 mov di,0 mov cx,5 s0: mov ax,[bx+si] mov es:[di],ax add si,2h mov ax,[bx+si] mov es:[di+2h],ax add si,2h add di,10h loop s0 mov di,0 mov si,0 mov bx,20 mov cx,5 s1: mov ax,[bx+si] mov es:[di+5h],ax add si,2h mov ax,[bx+si] mov es:[di+7h],ax add si,2h add di,10h loop s1 mov di,0 mov si,0 mov bx,40 mov cx,5 s2: mov ax,[bx+si] mov es:[di+10],ax add si,2 add di,10h loop s2 mov cx,5 mov di,0 s3: mov ax,es:[di+5] mov dx,es:[di+7] div word ptr es:[di+10] mov es:[di+13],ax add di,10h loop s3 mov ah, 4ch int 21h code ends end start
Debug the screenshot and view the screenshot of the original data information of the table segment:
Run debug until the program exits, use the d command to view the screenshot of the memory space corresponding to the table segment, and confirm whether the information is structurally written to the specified memory as required: