Test 1
Use a text editor to write code as follows:
assume cs:code, ds:data
data segment
db 'Nuist'
db 5 dup(2)
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
After running, you can see the green NUIST under the seat

Use the debug tool to disassemble and get

Let the program run to 0027

After modifying the parameters of db 5 dup(2), it is found that nuist with different colors appears, indicating that this data segment controls the color of the output characters

Test 2
The code is written as follows:
assume cs:code, ds:data
data segment
db 23, 50, 66, 71, 35
data ends
code segment
start: mov ax, data
mov ds, ax
mov dl,10
mov cx, 5
mov si, 0
s: mov ax,0
mov al, [si]
div dl
mov bx,ax
mov ah,2
mov dl,bl
or dl,48
int 21h
mov dl,bh
or dl,48
int 21h
mov dl,32
int 21h
inc si
loop s
mov ah, 4ch
int 21h
code ends
end start
Run to get results

Test 3
The code is written as follows:
assume cs:code, ds:data, ss:stack
data segment
dw 0123h, 0456h, 0789h, 0abch, 0defh, 0fedh, 0cbah, 0987h
data ends
stack segment
dw 0, 0, 0, 0, 0, 0, 0, 0
stack ends
code segment
start: mov ax,stack
mov ss, ax
mov sp,16
mov ax, data
mov ds, ax
push ds:[0]
push ds:[2]
pop ds:[2]
pop ds:[0]
mov ax,4c00h
int 21h
code ends
end start
Answer the following questions:
- The CPU executes the program. Before the program returns, the data in the data section is: 23 01 56 04 89 07 bc 0a ef 0d ed 0f ba 0c 87 09
- The CPU executes the program. Before the program returns, cs = 076ch, ss = 076bh, ds = 076ah
- After the program is loaded, the address of the code section is x, the address of the data section is X-2, and the address of the stack section is X-1
Test 4
The code is written as follows:
assume cs:code, ds:data, ss:stack
data segment
dw 0123h, 0456h
data ends
stack segment
dw 0, 0
stack ends
code segment
start: mov ax,stack
mov ss, ax
mov sp,16
mov ax, data
mov ds, ax
push ds:[0]
push ds:[2]
pop ds:[2]
pop ds:[0]
mov ax,4c00h
int 21h
code ends
end start
Answer the following questions:
- The CPU executes the program. Before the program returns, the data in the data section is: 23 01 56 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- The CPU executes the program. Before the program returns, cs = 076ch, ss = 076bh, ds = 076ah
- After the program is loaded, the address of the code section is x, the address of the data section is X-2, and the address of the stack section is X-1
- For the segment defined below, if the data in the segment accounts for N bytes, the actual space occupied by the segment after the program is loaded is ((N-1)/16+1)*16 bytes
name segment
...
name ends
Test 5
The written code is as follows:
assume cs:code, ds:data, ss:stack
code segment
start: mov ax,stack
mov ss, ax
mov sp,16
mov ax, data
mov ds, ax
push ds:[0]
push ds:[2]
pop ds:[2]
pop ds:[0]
mov ax,4c00h
int 21h
code ends
data segment
dw 0123h, 0456h
data ends
stack segment
dw 0,0
stack ends
end start
Answer the following questions:
- The CPU executes the program. Before the program returns, the data in the data section is: 23 01 56 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
- The CPU executes the program. Before the program returns, cs = 076ah, ss = 076eh, ds = 076dh
- After the program is loaded, the address of the code section is X, the address of the data section is X+3, and the address of the stack section is X+4
Test 6
According to the experiment, answer the question "if the last pseudo instruction" end start "in questions (1), (2) and (3) is changed to" end "(that is, the entry of the program is not specified), which program can still be executed correctly? Please explain why. "
- Only the program in task5 (i.e. (3)) can run normally, because the program is executed from the beginning by default, the code segment of (3) is right in front and can be executed, while the data segments of (1) and (2) cannot be executed in front, and an error will occur.
Test 7
The writing code is as follows
assume cs:code
a segment
db 1,2,3,4,5,6,7,8
a ends
b segment
db 1,2,3,4,5,6,7,8
b ends
c1 segment ; In the integrated software environment, please change the segment name here from c→Change to c1 Or other name
db 8 dup(0)
c1 ends
code segment
start:
mov ax,a
mov ds,ax
mov ax,b
mov es,ax
mov ax,c1
mov ss,ax
mov sp,8
mov cx,4
mov bx,6
s:
mov ax,[bx]
add ax,es:[bx]
push ax
sub bx,2
loop s
mov ah, 4ch
int 21h
code ends
end start
Use the debug tool to check that the data of segment C is 02 04 06 08 0a 0c 0e 10.

Test 8
The writing code is as follows
assume cs:code
a segment
dw 1,2,3,4,5,6,7,8,9,0ah,0bh,0ch,0dh,0eh,0fh,0ffh
a ends
b segment
dw 8 dup(0)
b ends
code segment
start:
mov ax,a
mov ds,ax
mov ax,b
mov ss,ax
mov sp,16
mov cx,8
mov bx,0
s:
push [bx]
add bx,2
loop s
mov ah, 4ch
int 21h
code ends
end start
Use the debug tool to view segment B data as 08 00 07 00 06 00 05 00 04 00 03 00 02 00 01 00.
