# 4, Experimental conclusion

```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
```

(2)task1_1. Screenshot after debugging to the end of line17 and before line19: ① 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__ X-2__， The segment address of stack is
X-1.

```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
```

(2)task1_2. Screenshot of observing the values of registers DS, CS and SS at the end of debugging to line17 and before line19: ① In debug, it will be executed until the end of line17 and before line19. At this time, record: 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__ X-2__， The segment address of stack is
X-1.

```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
```

(2)task1_3. Screenshot of observing the values of registers DS, CS and SS at the end of debugging to line17 and before line19: ① In debug, it will be executed until the end of line17 and before line19. At this time, record: 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_ X-4___， The segment address of stack is
x-2__.

```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
```

(2)task1_4. Screenshot of observing the values of registers DS, CS and SS at the end of debugging to line17 and before line19: ① 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__ X+2__， Segment address of stack
Yes__ X+4__.

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 16*Math.ceil(N/16).

```xxx segment
db N dup(0)
xxx ends
```

end, which program can still execute correctly? The reasons are analyzed and explained in combination with the conclusions obtained from practical observation.
task1_4.asm can run normally, because if start is not specified, it will run from the beginning of the program code by default, and Task1_ 1~1_ The code header of 3 is not a program segment. If it is executed directly from the header, an error will occur.

• end start indicates that the entry of the program is at the label start.

Write an assembly source program to realize 160 consecutive bytes to memory units b800:0f00 ~ b800:0f9f, and fill hexadecimal numbers repeatedly in turn
According to 03 04.
(1) Assembly source code:

```assume cs:code
code segment
start:mov ax,0b800h
mov ds,ax
mov bx,0f00h
mov cx,80
mov dx,0403h
s:mov ds:[bx],dx
loop s

mov ah,4ch
int 21h
code ends
end start
```

(2) Screenshot of operation results: It is known that the 8086 assembly source program task3.asm code fragment is as follows.

```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:
; ×××
code ends
end start
```

requirement:
① 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, view the three logical segments data1 respectively,
Confirm that the memory space corresponding to data2 and data3 is added one by one to ensure that the result exists in the logical segment data3.
(1) Complete assembly 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 ax,data1
mov ds,ax
mov bx,0
mov cx,10
s:mov ax,ds:[bx]
mov ds:[bx+20h],ax
inc bx
loop s

mov ah,4ch
int 21h

code ends
end start
```

It is required to check the original value of memory space data corresponding to logical segments data1, data2 and data3 before adding data items in turn
debug command and screenshot:

And, after adding in turn, view the debug command and the original value of the memory space data corresponding to the logical segments data1, data2 and data3
Screenshot:  It is known that the 8086 assembly source program task4.asm code fragment is as follows.
requirement:
① 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 view the data corresponding to data segment data2
Memory space, confirm whether the subject requirements are met.

(1) Complete assembly 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

code segment
start:
mov ax,data1
mov ds,ax
mov ax,data2
mov ss,ax
mov sp,16   ;8 Word
mov bx,0
mov cx,8
s :push ds:[bx]
loop s
mov ah, 4ch
int 21h
code ends
end start
```

(2) Load, disassemble and debug screenshots in debug It is required to give a screenshot of the memory space corresponding to data segment data2 by using the d command before the program exits.

• Before storage: • Before the program exits, use the d command to view the memory space corresponding to data segment data2: 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
loop s

mov ah, 4ch
int 21h
code ends
end start
```

(2) Screenshot of operation results: (3) Use the debug tool to debug the program, and use the g command to execute it once before the program returns (i.e. after the execution of ine25 and line27)
Screenshot before execution: (4) What is the function of line19 in the source code?
AL and DF(1101 1111): clear the third digit on the left to 0.
(5) What is the purpose of the byte data in the data segment line4 in the source code?
Operation results after modifying line4 to db 5 dup(2): Result after modification to db 5 dup(5): db is a pseudo instruction that defines the type of variable as byte type, that is, each variable occupies a storage unit
db 2,3,4,5,6 is used to allocate a storage unit for each number after db.

It is known that the 8086 assembly source program task6.asm code fragment is as follows.

```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 ah, 4ch
int 21h
code ends
end start
```

requirement:
① Complete the program and change the first word of each line in the data section from uppercase to lowercase.
② Load the program in debug, disassemble it, and check the memory space corresponding to the data segment with the d command before exiting line13, and confirm that each
The first word of the line has been changed from uppercase - > lowercase.

```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:or [bx],byte ptr 00100000b
loop s
mov ah, 4ch
int 21h
code ends
end start
``` It is required to give a screenshot of the memory space corresponding to the data segment data by using the d command before the program exits. requirement:
① Complete the program, realize the title requirements, and write the year, income, number of employees and per capita income into the table section in a structured way.
In the table, each row of data occupies 16 bytes in the logical segment table, and the byte size of each data is allocated as follows. Interim, between data
Space spacing.

```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 cx,5
mov si,0
mov bx,0
s: mov ax,[si]
mov es:[bx],ax
mov ax,[si+2]
mov es:[bx+2],ax
loop s   ;particular year

mov cx,5
mov si,20
mov bx,5
s1:mov ax,[si]
mov es:[bx],ax
mov ax,0
mov es:[bx+2],ax
loop s1;  ;income

mov cx,5
mov si,30
mov bx,10
s2:mov ax,[si]
mov es:[bx],ax
loop s2   ;Number of employees

mov cx,5
mov si,5
s3:mov ax,es:[si]
mov bl,es:[si+5]
div bl
mov es:[si+8],al
loop s3   ;Per capita income
mov ah, 4ch
int 21h
code ends
end start
```

(2) Commissioning screenshot: (3) View the screenshot of the original data information of the table segment: Run in debug until the program exits, use the d command to view the screenshot of the memory space corresponding to the table segment, and confirm that the information is
No structured write to specified memory as required It can be seen from the d command in the figure above that the information has been structurally written to the specified memory as required.

Posted by jrmontg on Sat, 06 Nov 2021 02:43:23 -0700