1. Experimental task 1
Task 1.1:
To program task1_1.asm assembles and connects, loads and tracks debugging with debug, and answers questions based on the results. task1_1.asm
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
① In debug, execute until the end of line17 and before line19. Record this time: register (DS) = 076A, register (SS) = 076B, register (CS) = 0031.
② Assuming that the segment address of the code segment is X after the program is loaded, the segment address of the data segment is - 20H and the segment address of the stack is X-10H.
Task 1.2:
To program task1_2.asm assembles and connects, loads and tracks debugging with debug, and answers questions based on the results.
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
① In debug, execute until the end of line17 and before line19. Record this time: register (DS) = 076A, register (SS) = 076B, register (CS) = 076C
② 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:
To program task1_3.asm assembles and connects, loads and tracks debugging with debug, and answers questions based on the results.
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
① In debug, execute until the end of line17 and before line19. Record this time: register (DS) =076A, register (SS) = 076C, register (CS) =076E
② 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.
Task 1.4:
To program task1_4.asm assembles and connects, loads and tracks debugging with debug, and answers questions based on the results.
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
① In debug, execute until the end of line9 and before line11. Record this time: register (DS) = 076C, register (SS) =076E, register (CS) =076A
② 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+4.
Task 1.5
1. Based on the practice and observation of the above four experimental tasks, summarize and answer: ① for the segment defined below, after the program is loaded, the actual memory space allocated to the segment is ((N+15)/16)*16.
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 can be executed, others cannot be executed. The instruction end start indicates the end and entry of the program. If the program entry is not specified, it will be executed from the first line of code, only Task1_ The first line of 4 is a code line, and the others are data lines, which are not executable.
Experimental task 2
Write an assembly source program to realize 160 consecutive bytes to memory units b800:0f00 ~ b800:0f9f, and fill hexadecimal data 03 and 04 repeatedly in turn.
assume cs:code code segment mov ax,0b800h mov ds,ax mov bx,0f00h mov cx,160 s: mov ax,0304h mov [bx],al inc bx loop s mov ax,4c00h int 21h code ends end
Experimental task 3
① The programming adds the data of logical segment data1 and logical segment data2 in turn, and the results are saved in logical segment data3. ② Load, disassemble and debug in debug. Before and after the data items are added in turn, check the memory space corresponding to the three logical segments data1, data2 and data3 respectively. After adding them one by one, ensure that the results exist in the logical segment data3.
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 ax,data1 mov ds,ax mov ax,data2 mov es,ax mov bx,0 mov cx,10 s: mov al,[bx] add es:[bx],al inc bx loop s mov ax,data3 mov ds,ax mov bx,0 mov cx,10s0: mov al,es:[bx] mov [bx],al inc bx loop s0 mov ax,4c00h int 21h code ends end start
Before adding:
After addition
It can be seen from the figure that the data in 076A and 076B are added and incorporated into 076C, that is, data1 and data2 are added and put into data3
Experimental task 4
Requirements: ① complete the program to store the eight word data in logical segment data1 in reverse order in logical segment b. ② After assembly and connection, load the program in debug and run it to line15. Before the program exits, use the d command to check the memory space corresponding to data segment data2 to confirm whether the subject requirements are met.
assume cs:code data1 segment dw 2, 0, 4, 9, 2, 0, 1, 9 data1 ends data2 segment dw 8 dup(?) data2 ends code segment start: mov ax, data1 mov ds, ax mov ax, data2 mov ss, ax mov sp, 16 mov bx, 0 mov cx, 8 s:push [bx] add bx, 2 loop s mov ah, 4ch int 21h code ends end start
Before execution
After execution
Experiment task 5
Read the source program, theoretically analyze the functions of the source code, especially line15-25, what are the functions realized by the loop, and understand the functions of each instruction line by line. Assemble and link the program to get the executable file, run and observe the results. Use the debug tool to debug the program and observe the results before the program returns, that is, after line25 and before line27.
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
Operation results
Use the debug tool to debug after line25 and before line27
The function of line19 in the source code is
Change all letters to uppercase
Modify the value of 5 byte units in line4, reassemble, link, run and observe the results.
The numerical value here is used to modify the font color
Experimental task 6
It is known that the 8086 assembly source program task6.asm code fragment is as follows. task6.asm
assume cs:code, ds:data data segment db 'Pink Floyd ' db 'JOAN Baez ' db 'NEIL Young ' db 'Joan Lennon ' data ends code segment start: mov ax, data mov ds, ax mov bx, 0 s: or byte ptr [bx], 20h or byte ptr [bx+1], 20h or byte ptr [bx+2], 20h or byte ptr [bx+3], 20h add bx, 16 loop s mov ah, 4ch int 21h code ends end start
results of enforcement
Experimental task 7
assume cs:code, ds:data, es:table data segment db '1975', '1976', '1977', '1978', '1979' dw 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 bp,0 mov si,20 mov cx,5 s: mov ax,ds:[bx] mov es:[bp],ax mov ax,ds:[bx+2] mov es:[bp+2],ax mov ax,ds:[si] mov es:[bp+5],ax mov word ptr es:[bp+7],0 mov ax,ds:[si+10] mov es:[bp+10],ax mov ax,ds:[si] mov dl,ds:[si+10] div dl mov es:[bp+13],al mov byte ptr es:[bp+14],0 add bx,4 add bp,16 add si,2 loop s mov ah, 4ch int 21h code ends end start
Screenshot of table before execution:
Screenshot of table after execution: