# Second Operations King Juguo of 2013290152

Posted by php_jord on Mon, 08 Nov 2021 21:08:19 +0100

(1) In debug, before the end of line17 and line19, record this time: Register (DS) = _076A_, Register (SS)=

_u 076B_u, Register (CS) = u 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 _ X-2_, The segment address of the stack is _ X-1_.

For program task1_2.asm to assemble, connect, debug, track debugging, answer questions based on the results.
(1) In debug, before the end of line17 and line19, record this time: Register (DS) = _076A_, Register (SS)=
_u 076B_u, Register (CS) = _076C_
(2) Assuming that the segment address of the code segment is X after loading the program, the segment address of the data segment is _ X-2_, The segment address of the stack is _ X-1.
For program task1_3.asm to assemble, connect, debug, track debugging, answer questions based on the results.

(1) In debug, before the end of line17 and line19, record this time: Register (DS) = _076A_, Register (SS)=

_ 076C_, Register (CS) = _076E_
(2) Assuming that the segment address of the code segment is X after loading the program, the segment address of the data segment is _ X-4_, The segment address of the stack is _ X-2_.
For program task1_4.asm to assemble, connect, debug, track debugging, answer questions based on the results.

(1) Before the end of line9 and line11 in debug, record this time: Register (DS) = _076C_, Register (SS)=

_ 076E_, Register (CS) = _076A_
(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
_X+4_.
xxx segment
db N dup(0)
xxx ends
Based on the practice and observation of the above four experimental tasks, summarize and answer:
(1) For a segment as defined above, the amount of memory space actually allocated to that segment after loading is u.
A: If N is a multiple of 16, the memory size is N bytes

Otherwise, the size of the memory space is ((N%16)+1)*16 bytes

end, which program can still execute correctly? Combined with the conclusions obtained from practical observation, the reasons are analyzed and explained.

A: task1_after modifying the pseudo directive to end 4. ASM works, and task1_1.asm, task1_2.asm, task1_3.asm is not working properly. If you don't write start, the program will use the first address of the default data segment as the program's initial address, because task1_ 4. The code snippet in ASM is written at the top, so it won't affect you.

Write an assembly source program to fill successive 160 bytes in memory unit b800:0f00 ~ b800:0f9f with hexadecimal numbers in turn
According to 03 04.
The code is as follows:
1 assume cs:code
2 code segment
3 start:
4     mov ax,0b800h
5     mov ds,ax
6     mov bx,0f00h
7     mov dx,0403h
8     mov cx,80
9
10 s:  mov ds:[bx],dx
11     inc bx
12     inc bx
13     loop s
14     mov ah,4ch
15     int 21h
16
17 code ends
18
19 end start

Run result:

(1) Programming adds logical segment data1 and logical segment data2 data in turn, and the result is saved in logical segment data3.
(2) Load, disassemble and debug in debug. Before and after data items are added, look at the three logical segments data1.
The memory space for data2, data3, confirms that after adding one by one, the result ensures the existence of logical segment data3.
The code is as follows:
1 assume cs:code
2 data1 segment
3     db 50, 48, 50, 50, 0, 48, 49, 0, 48, 49 ; ten numbers
4 data1 ends
5
6 data2 segment
7     db 0, 0, 0, 0, 47, 0, 0, 47, 0, 0       ; ten numbers
8 data2 ends
9
10 data3 segment
11     db 16 dup(0)
12 data3 ends
13
14 code segment
15 start:
16     mov ax,data1
17     mov ds,ax
18     mov ax,data2
19     mov es,ax
20     mov ax,data3
21     mov ss,ax
22     mov bx,0
23     mov cx,10
24 s:     mov ax,ds:[bx]
26     mov ss:[bx],ax
27     inc bx
28     loop s
29
30     mov ah,4ch
31     int 21h
32 code ends
33 end start
The result is shown in the figure:
Memory condition of two data segments before addition:

After adding, the memory of data segment data3 is shown as follows:

(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 program in debug, run to line15 program before exiting, use d command to view data segment data2 corresponding
Memory space to confirm that the title requirement is met.
The code is as follows:
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 ;data1 Address to ds
mov ax,data2
mov es,ax ;data2 Address to es
mov bx,0
mov cx,8
s1:    mov ax,ds:[bx]
push ax
inc bx
inc bx
loop s1

mov cx,8
mov bx,0

s2: pop ax
mov es:[bx],ax
inc bx
inc bx
loop s2

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

The results are as follows:

1 assume cs:code, ds:data
2 data segment
3         db 'Nuist'
4         db 2, 3, 4, 5, 6
5 data ends
6
7 code segment
8 start:
9         mov ax, data
10         mov ds, ax
11
12         mov ax, 0b800H
13         mov es, ax
14
15         mov cx, 5
16         mov si, 0
17         mov di, 0f00h
18 s:      mov al, [si]
19         and al, 0dfh
20         mov es:[di], al
21         mov al, [5+si]
22         mov es:[di+1], al
23         inc si
25         loop s
26
27         mov ah, 4ch
28         int 21h
29 code ends
30 end start

Read the source program, theoretically analyze the functions of the source code, especially line15-25, what is the function of the loop, and understand each finger line by line
Functions of the command.
Assemble and link programs to get executable files, run and observe the results.
Debug the program using the debug tool and observe it until the program returns, that is, after line25 and before line27
Result.
What does line19 do in source code?
Modify the values of the five byte units in line4, reassemble, link, run, and observe the results.

The results are as follows:

The purpose of line19 is to transform from lowercase (uist) to uppercase (UIST)

The effect of line24 makes characters appear different colors

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, confirming that each
The first word of the line has been capitalized - > lowercase.
The code 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 ax, data
mov ds, ax

mov cx, 64;16 bytes in a row
mov bx, 0
s: or  [bx], byte ptr 20h
inc bx
loop s

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

Experimental results:

Uppercase:

A lowercase letter:

(1) Complete the procedure to achieve the title requirements, and write the year, income, number of employees, and per capita income into the table paragraph in a structured way.
In a table, each row of data accounts for 16 bytes in the logical segment table, and each row's byte size is allocated as follows. During the period, between data
Space interval.
The code is as follows:
1 assume cs:code, ds:data, es:table
2
3 data segment
4     db '1975', '1976', '1977', '1978', '1979'
5     dw  16, 22, 382, 1356, 2390
6     dw  3, 7, 9, 13, 28
7 data ends
8
9 table segment
10     db 5 dup( 16 dup(' ') )
11 table ends
12
13 code segment
14 start:
15     mov ax,data
16     mov ds,ax
17     mov ax,table
18     mov es,ax
19     mov bx,0
20     mov si,0
21     mov cx,5
22
23 s1: mov ax,ds:[bx]
24     mov es:[si],ax
27     mov ax,ds:[bx]
28     mov es:[si],ax
31     loop s1
32
33     mov bx,20
34     mov si,5
35     mov cx,5
36 s2: mov ax,ds:[bx]
37     mov es:[si],ax
39     mov word ptr es:[si],0
42     loop s2
43
44     mov bx,30
45     mov cx,5
46     mov si,10
47  s3:mov ax,ds:[bx]
48     mov es:[si],ax
51     loop s3
52
53     mov bx,20
54     mov di,30
55     mov cx,5
56     mov si,13
57
58 s4: mov ax,ds:[bx]
59     mov dx,0
60     div word ptr ds:[di]
61     mov es:[si],ax
65     loop s4
66
67     mov ah, 4ch
68     int 21h
69
70 code ends
71 end start

Experimental results:

Before running:

After running: