Compilation and debugging of assembly source program for multiple logic segments
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.
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 1:
View register value
Use the U command to view the disassembly code, find the memory address of mov ah,4ch, and use the G command to quickly execute before this command.
(DS)=076C
(SS)=076D
(CS)=076E
Question 2:
Assuming that the CODE segment address is X after the program is loaded, the data segment address is X-2 and the stack segment address is X-1
Since the memory space occupied by the program is continuous, and the segment size accounts for an integer multiple of 16 bytes, according to the code of task1-1.ASM, data is next to the segment prefix, stack is next to data, and code is next to stack. -
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
Question 1:
Repeat the operation of question 1 in task1-1 to view the register value
(DS)=076C
(SS)=076D
(CS)=076E
Question 2:
Assuming that the CODE segment address is X after the program is loaded, the data segment address is X-2 and the stack segment address is X-1
Since the memory space occupied by the program is continuous, and the segment size accounts for an integer multiple of 16 bytes, according to the code of task1-2.ASM, data is next to the program segment prefix, stack is next to data, and code is next to stack. -
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
Question 1:
Repeat the operations of task1-1 and task1-2, and the results are as follows
(DS)=076C
(SS)=076E
(CS)=0770
Question 2:
Assuming that the CODE segment address is X after the program is loaded, the data segment address is x-4 and the stack segment address is X-2
Since the memory space occupied by the program is continuous, and the segment size accounts for an integer multiple of 16 bytes, according to the code of task1-3.ASM, data is next to the program segment prefix, stack is next to data, and code is next to stack. -
Tasks 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
Question 1:
Repeat the operation to view the register value
(DS)=076E
(SS)=0770
(CS)=076C
Question 2:
Assuming that the CODE segment address is X after the program is loaded, the data segment address is x + 2 and the stack segment address is X+4
Since the memory space occupied by the program is continuous, and the segment size accounts for an integer multiple of 16 bytes, if the code according to task1-4.ASM is next to the program segment prefix, data is next to code, and stack is next to data. -
Tasks 1-5
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 \ (Ceil(N/16) \).xxx segment db N dup(0) xxx ends