1. Experimental Task 1
Tasks 1-1
task1_1.asm source
assume ds:data, cs:code, ss:stack data segment db 16 dup(0) ; Reserve 16 byte cells with initial values of 0 data ends stack segment db 16 dup(0) ;Reserve 16 byte cells with initial values of 0 stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 16 ; Set top of stack mov ah, 4ch int 21h code ends end start
Debug to end of line17, before line19:
Question Answer
1. Before the end of line17 and line19 in debug, record this time: Register (DS) = u 076A_u, Register (SS) =u 076B_u, Register (CS) = u 076C_u
(2) Assuming that the segment address of the code segment is X after the program loads, the segment address of the data segment is X-2 and the segment address of the stack is X-1.
Tasks 1-2
For program task1_2.asm to assemble, connect, debug, track debugging, answer questions based on the results.
task1_2.asm
assume ds:data, cs:code, ss:stack data segment db 4 dup(0) ; Reserve 4 byte cells with initial values of 0 data ends stack segment db 8 dup(0) ; Reserve 8 byte units with initial values of 0 stack ends code segment start: mov ax, data mov ds, ax mov ax, stack mov ss, ax mov sp, 8 ; Set top of stack mov ah, 4ch int 21h code ends end start
Post-Execution Screenshot:
(1) In debug, before the end of line17 and line19, record this time: Register (DS) = _ 076A_, Register (SS) = u 076B_u, Register (CS) = _076C_u_
(2) Assuming that the segment address of the code segment is X after loading the program, the segment address of the data segment is u X-2_u, The segment address of the stack is u X-1_u.
Tasks 1-3
For program task1_3.asm to assemble, connect, debug, track debugging, answer questions based on the results.
task1_3.asm
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
Post-Execution Screenshot:
(1) In debug, before the end of line17 and line19, record this time: Register (DS) = _076A_, Register (SS) = u 076C_u, Register (CS) = u 076E_u
(2) Assuming that the segment address of the code segment is X after loading the program, the segment address of the data segment is u X-4_u, The segment address of the stack is u X-2_u.
Tasks 1-4
task1_4.asm source
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
Execution Screenshot:
(1) Before the end of line9 and line11 in debug, record this time: Register (DS) = u 076C_u, Register (SS) = u 076E_u, Register (CS) = u 076A_u
(2) Assume that after loading the program, the segment address of the code segment is u X_u, Then, the segment address of the data segment is u X+2_u, The segment address of the stack is u X+4_u.
Tasks 1-5
Based on the practice and observation of the above four experimental tasks, summarize and answer:
(1) For a segment defined below, the amount of memory space actually allocated to that segment after loading is u ceil(N/16)*16_u.
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, the pseudo-directive end start is changed to end, which program can still execute correctly? Combined with the conclusions obtained from practical observation, the reasons are analyzed and explained.
A: task1_4.asm can be executed correctly. Replace end start with end, the program does not specify a start location, task1_1. task1_2. task1_3 The entrance to the program is to include data segments, which will cause errors in data execution; Only task1_4 The entry to the program is a code snippet.
2. Experimental Task 2
Write an assembly source program to fill hexadecimal data 03 04 successively in 160 bytes from memory unit b800:0f00 to b800:0f9f.
Program source code:
assume ds:data, cs:code data segment db 80 dup(03,04) data ends code segment start: mov ax, data mov ds, ax mov ax,0b8f0h mov es,ax mov bx,0 mov cx,80 s: mov ax,[bx] mov es:[bx],ax add bx,2 loop s mov ah,4ch int 21h code ends end start
Execution Screenshot:
3. Experimental Task 3
Complete source program:
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 mov dx,0 s: mov dx,0 mov ax,data1 mov ds,ax add dl,[bx] mov ax,data2 mov ds,ax add dl,[bx] mov ax,data3 mov ds,ax mov [bx],dl inc bx loop s mov ax,4c00h int 21h code ends end start
Load, disassemble, debug screenshots in debug:
Before adding data items in turn, view debug commands and screenshots of the original values of the memory space data corresponding to logical segments data1, data2, and data3:
After adding them up, look at the debug command and screenshots of the original values of the memory space data corresponding to logical segments data1, data2, and data3:
4. Experimental Task 4
The code snippet for the 8086 assembly source program task4.asm is known below.
assume cs:code
data1 segment
dw 2, 0, 4, 9, 2, 0, 1, 9
data1 endsdata2 segment
dw 8 dup(?)
data2 endscode segment
start:
mov ax,data1
mov ds,axmov ax,data2
mov ss,ax
mov sp,10hmov cx,8
mov bx,0
s:
push ds:[bx]
add bx,2
loop smov ah, 4ch
int 21h
code ends
end start
Requirement:
(1) Completion, which stores the 8-word data in logical segment data1 in reverse order in logical segment b.
(2) After assembly and connection, load the program in debug, run until the line15 program exits, use the d command to check the memory space corresponding to data segment data2, and confirm whether the title requirement is met.
Disassembly Screenshot:
Use the d command to view a snapshot of the memory space corresponding to data segment data2:
Visible, the title requirements have been achieved.
5. Experimental Task 5
Use any text editor to enter the assembly source program task5.asm.
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
Execution Screenshot:
Debug the program using the debug tool and use the g command to execute one time until the program returns (i.e., after ine25 and before line27):
What does line19 do in source code?
A: Change lowercase letters to uppercase letters
What is the purpose of the byte data of data segment line4 in the source code?
A: Set the font color.
6. Experimental Task 6
The code snippet for the 8086 assembly source program task6.asm is known below.
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 mov cx,4 s: mov al,[bx] or al,20h mov [bx],al add bx,16 loop s mov ah, 4ch int 21h code ends end start
Requirement:
1. Complete the program by uppercase->lowercase the first word of each line in the data segment.
(2) Load the program in debug, disassemble, and check the memory space of the data segment with the d command before line13 exits to make sure that the first word on each line is capitalized - > lowercase.
Load, disassemble, debug screenshots in debug:
Before the program exits, use the d command to view a screenshot of the memory space corresponding to the data segment:
7. Experimental Task 7
These data are already defined in the logical segment data of the program task7.asm (line4-6).
task7.asm
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 endstable segment
db 5 dup( 16 dup(' ') ) ;
table endscode segment
start:
mov ax,data
mov ds,ax
mov ax,table
mov es,axmov si,0
mov di,0
mov bx,0
mov cx,5
mov sp,0s: mov ax,[si]
mov es:[di],ax
mov ax,[si+2]
mov es:[di+2],axmov ax,[bx+20]
mov es:[di+5],0
mov es:[di+7],axmov ax,[bx+30]
mov es:[di+10],ax
mov ax,es:[di+7]
mov dl,es:[di+10]
div dl
mov es:[di+13],axadd si,4
add di,16
add bx,2loop s
mov ah, 4ch
int 21h
code ends
end start
View a screenshot of the table segment's raw data information:
Before running in debug until the program exits, use the d command to view a snapshot of the table segment's memory space to confirm that the information is structurally written to the specified space as required