1. Experimental task 1
Task 1-1:
For task1_1.asm assembly and connection:
Load with debug:
Since the debug runs to the end of line 17, before line 19, use the u command to find the storage location of the corresponding command of line 19, and then use the g command to directly go to that command, as follows:
As can be seen from the figure:
① At this time, DS=076Ah, SS=076Bh, CS=076Ch.
② Assuming that the code segment address is x, the data segment address is X-2 and the stack segment address is X-1.
Task 1-2:
The basic operation steps are consistent with task 1-1, and the final debug result is obtained:
As can be seen from the figure:
① At this time, DS=076Ah, SS=076Bh, CS=076Ch.
② Assuming that the code segment address is x, the data segment address is X-2 and the stack segment address is X-1.
Task 1-3
The basic operation steps are consistent with task 1-1, and the final debug result is obtained:
As can be seen from the figure:
① At this time, DS=076Ah, SS=076Ch, CS=076Eh.
② Assuming that the code segment address is x, the data segment address is X-4 and the stack segment address is X-2.
Tasks 1-4
The basic operation steps are consistent with task 1-1, and the final debug result is obtained:
As can be seen from the figure:
① At this time, DS=076Ch, SS=076Eh, CS=076Ah.
② Assuming that the code segment address is X, the data segment address is X+2 and the stack segment address is X+4.
Tasks 1-5:
① The memory space allocated to this segment is rounded up to (N/16).
② After the pseudo instruction end start is changed to end:
task1_1 screenshot:
task1_2 screenshot:
task1_3 screenshot:
task1_4 screenshot:
According to the screenshot, only Task1_ 4. The ASM program can still be executed correctly. This is because of task 1_ 1 to task 1_ 3 defines data segments first and then code segments, while task 1_ 4 is to define code segments first and then data segments. end start tells the program that the code starts from start. After writing end, the program will compile from the first line. Because task 1_ 4 code snippet is written in front, and compiling from the first line is not affected.
2. Experimental task 2
Experiment code:
assume cs:code code segment mov ax, 0b800h mov ds, ax mov bx, 0f00h mov cx, 160 s: mov ax, 0403h mov [bx], ax add bx, 2h loop s mov ax,4c00h int 21h code ends end
Screenshot of experimental results:
3. Experimental task 3
Experiment code:
code segment start: mov bx, 0 mov cx, 10 s: mov dx, 0 ;register dx Save data 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
Screenshot of experimental effect:
Loading, disassembly and debugging:
Execute to end after debugging:
Memory space corresponding to logical segment data1:
Memory space corresponding to logical segment data2:
Memory space corresponding to logical segment data3:
It can be seen from the display of each corresponding memory space that the guarantee of the result exists in the logical segment data3.
4. Test task 4
Experiment code:
code segment start: mov ax, data2 mov ss, ax mov sp, 10h mov ax, data1 mov ds, ax mov dx, 0 mov cx, 8 s:push [bx] add bx, 2 loop s mov ah, 4ch int 21h code ends end start
Screenshot of experimental effect:
debug loader after assembly and connection:
data1 memory cells are stored as follows:
data2 memory cells are stored as follows:
According to the storage contents of data1 and data2, data2 does store the eight word data of data1 in reverse order.
5. Experimental task 5
Screenshot of experimental effect:
Run debug to line 27. The screenshot of the result is as follows:
The function of line 19 in the source code: and operate al and df h (i.e. 1101 1111), that is, al changes from the third digit on the left to 0, so as to realize the operation of changing lowercase letters into uppercase letters.
Change the of line4 to db 5 dup(2), and the result screenshot is as follows:
Change the of line4 to db 5 dup(5), and the result screenshot is as follows:
Thus, the function of line4 is to change the font color.
6. Experimental task 6
Experiment code:
code segment start: mov ax, data mov ds,ax mov bx, 0 mov cx, 4 s0:push cx mov si, 0 mov cx, 4 s1:or byte ptr [bx+si], 00100000b inc si loop s1 add bx, 10h pop cx loop s0 mov ah, 4ch int 21h code ends end start
Screenshot of experimental effect:
debug process, g execute, d view:
According to the screenshot, the first word in each line has changed from uppercase to lowercase.
7. Experimental task 7
Experiment code:
code segment start: mov ax, data mov ds, ax mov ax, table mov es, ax mov bx, 0 ;Year of existence mov si, 0 mov cx, 5 s0:mov ax, [si] mov es:[bx], ax mov ax, [si+2] mov es:[bx+2], ax add si, 4 add bx, 10h loop s0 mov bx, 0 ;Deposit income mov si, 14h mov cx, 5 s1:mov ax, [si] mov es:[bx+5], ax mov ax, 0 mov es:[bx+5+2], ax add si, 2 add bx, 10h loop s1 mov bx, 0 ;Number of employees saved mov si, 1eh mov cx, 5 s2:mov ax,[si] mov es:[bx+0ah], ax add si, 2 add bx, 10h loop s2 mov bx, 0 ;Seeking quotient mov cx, 5 s3:mov ax, es:[bx+5] mov dx, es:[bx+5+2] div word ptr es:[bx+0ah] mov es:[bx+0dh], ax add bx, 10h loop s3 mov ah, 4ch int 21h code ends end start
Screenshot of experimental effect:
(for the case where the income is only two bytes, I save the high bit 00 and fill it with four bytes)
8. Experimental summary
In this experiment, I fully realized the cumbersome nature of assembly language and further understood the specification of assembly language code writing. For example, in experiment task 2, I repeatedly encountered severe error. Later, I found that it was mov ax, b800h, and 0 was not added before b800h.
It is stipulated in the assembly language that the literal writing of numerical values does not start with a letter. If it starts with a letter, it is considered not a number but a symbol. b800 is considered a symbol and must be added with 0 to make the assembler think it is a value. At the same time, I also know how to realize secondary circulation and other methods.
Experiment 8 is also the result of repeated cyclic output. At the same time, it also finds out the number of bits and bytes of each data.