Task 1:
1_ 1 (1) code
1 assume ds:data, cs:code, ss:stack 2 3 data segment 4 db 16 dup(0) 5 data ends 6 7 stack segment 8 db 16 dup(0) 9 stack ends 10 code segment 11 start: 12 mov ax, data 13 mov ds, ax 14 15 mov ax, stack 16 mov ss, ax 17 mov sp, 16 18 19 mov ah, 4ch 20 int 21h 21 code ends 22 end start
(2)
DS=076A SS=076B CS=076C
data segment address: X-2 stack segment address: X-1
1_ 2 (1) code
1 assume ds:data, cs:code, ss:stack 2 3 data segment 4 db 4 dup(0) 5 data ends 6 7 stack segment 8 db 8 dup(0) 9 stack ends 10 code segment 11 start: 12 mov ax, data 13 mov ds, ax 14 15 mov ax, stack 16 mov ss, ax 17 mov sp, 8 18 19 mov ah, 4ch 20 int 21h 21 code ends 22 end start
DS=076A SS=076B CS=076C
data segment address: X-2 stack segment address: X-1
1_ 3 (1) code
1 assume ds:data, cs:code, ss:stack 2 3 data segment 4 db 20 dup(0) 5 data ends 6 7 stack segment 8 db 20 dup(0) 9 stack ends 10 code segment 11 start: 12 mov ax, data 13 mov ds, ax 14 15 mov ax, stack 16 mov ss, ax 17 mov sp, 20 18 19 mov ah, 4ch 20 int 21h 21 code ends 22 end start
DS=076A SS=076C CS=076E
data end: X-4 stack section: X-2
1_ 4 (1) code
1 assume ds:data, cs:code, ss:stack 2 code segment 3 start: 4 mov ax, data 5 mov ds, ax 6 7 mov ax, stack 8 mov ss, ax 9 mov sp, 20 10 11 mov ah, 4ch 12 int 21h 13 code ends 14 15 data segment 16 db 20 dup(0) 17 data ends 18 19 stack segment 20 db 20 dup(0) 21 stack ends 22 end start
DS=076C SS=076E CS=076A
data section: X+2 stack section: X+4
1_5 (1)
1 xxx segment 2 db N dup(0) 3 xxx ends
For the segment defined below, after the program is loaded, the actual memory space allocated to the segment is (N/16 + 1)H bytes (code segment?)
Modify Task1_ The result after end of 1 is CS = 076a and IP = 0000
Modify Task1_ The result after end of 4 is CS = 076a and IP = 0000
task1_2 and task1_3 you can imagine the results and task1_1. The conclusion is that only task1_4. It can operate normally after modification
The reason is that if the pseudo instruction end start is changed to end, the code segment of the program must start from 076A and will not start from the address corresponding to start. At this time, only Task1 can be seen_ 4 in Decompilation, the corresponding memory unit stores the correct instructions
task1_1 stores the values of other segments. After decompilation, it must not be the instruction of the code segment we need. task1_2 and task1_3 the same is true
Task 2:
code
1 assume cs:code 2 code segment 3 start: 4 mov ax, 0b800h 5 mov ds, ax 6 mov bx, 0f00h 7 mov cx, 80 8 s: mov ax, 03h 9 mov [bx], ax 10 inc bx 11 mov ax, 04h 12 mov [bx], ax 13 inc bx 14 loop s 15 16 mov ax, 4c00h 17 int 21h 18 code ends 19 end start
result
Task 3:
code
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 bx, 0 19 mov cx, 10 20 s: mov ax, [bx] 21 add ax, [bx+16] 22 mov [bx+32], ax 23 inc bx 24 loop s 25 26 mov ah, 4ch 27 int 21h 28 code ends 29 end start
Before adding data items in turn, check the debug command and screenshot of the original value of memory space data corresponding to logical segments data1, data2 and data3
After adding in sequence, view the debug command and screenshot of the original value of memory space data corresponding to logical segments data1, data2 and data3
Task 4:
code
1 assume cs:code 2 3 data1 segment 4 dw 2, 0, 4, 9, 2, 0, 1, 9 5 data1 ends 6 7 data2 segment 8 dw 8 dup(?) 9 data2 ends 10 11 code segment 12 start: 13 mov ax, data1 14 mov ds, ax 15 mov bx, 14 16 mov cx, 8 17 mov si, 16 18 s: mov ax,[bx] 19 mov [si], ax 20 sub bx, 2 21 add si, 2 22 loop s 23 24 mov ah, 4ch 25 int 21h 26 code ends 27 end start
Before the program exits, use the d command to view a screenshot of the memory space corresponding to the data segment data2
Task 5:
code:
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 24 add di, 2 25 loop s 26 27 mov ah, 4ch 28 int 21h 29 code ends 30 end start
result
Use the debug tool to debug the program, and use the g command to execute the screenshot before the program returns (i.e. after ine25 and before line27)
The function of line19 in the source code is to change lowercase letters into uppercase letters
The byte data in the data segment line4 in the source code is used to set the font color
Task 6:
code
1 assume cs:code, ds:data 2 3 data segment 4 db 'Pink Floyd ' 5 db 'JOAN Baez ' 6 db 'NEIL Young ' 7 db 'Joan Lennon ' 8 data ends 9 10 code segment 11 start: 12 mov ax, data 13 mov ds, ax 14 mov bx, 0 15 mov cx, 4 16 s: mov al, [bx] 17 or al, 20h//The function core code will be uppercase and lowercase 18 mov [bx], al 19 add bx, 16 20 loop s 21 22 mov ah, 4ch 23 int 21h 24 code ends 25 end start
Before the program exits, use the d command to view a screenshot of the memory space corresponding to the data segment data
Task 7:
code
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 ;Transfer year 20 mov cx, 5 21 mov bx, 0 22 mov si, 0 23 s0: push cx 24 mov cx, 4 25 s1: mov al, [bx] 26 mov es:[si], al 27 inc si 28 inc bx 29 loop s1 30 mov byte ptr es:[si], ' ' 31 add si, 12 32 pop cx 33 loop s0 34 35 ;Transfer income 36 mov cx, 5 37 mov bx, 20 38 mov si, 5 39 s2: mov ax, [bx] 40 mov dl, 10 41 div dl 42 add ah, 48 43 mov es:[si+3], ah;1 position 44 45 mov ah, 0 46 div dl 47 add ah, 48 48 mov es:[si+2], ah;2 position 49 mov ah, 0 50 div dl 51 add ah, 48 52 mov es:[si+1], ah;3 position 53 54 mov ah, 0 55 div dl 56 add ah, 48 57 mov es:[si], ah;4 position 58 59 mov ah, 0 60 mov byte ptr es:[si+4], ' ' 61 add si, 16 62 add bx, 2 63 loop s2 64 65 ;Number of transfers 66 mov cx, 5 67 mov bx, 30 68 mov si, 10 69 s3: mov ax, [bx] 70 mov dl, 10 71 div dl 72 add ah, 48 73 mov es:[si+1], ah;1 position 74 75 mov ah, 0 76 div dl 77 add ah, 48 78 mov es:[si], ah;2 position 79 80 mov ah, 0 81 mov byte ptr es:[si+2], ' ' 82 add si, 16 83 add bx, 2 84 loop s3 85 86 ;Calculated per capita 87 mov cx, 5 88 mov bx, 20 89 mov si, 13 90 s4: mov ax, [bx] 91 mov dl, [bx+10] 92 div dl;here al There is per capita income 93 mov ah, 0 94 mov dl, 10 95 div dl 96 add ah, 48 97 mov es:[si+1], ah;1 position 98 99 mov ah, 0 100 div dl 101 add ah, 48 102 mov es:[si], ah;2 position 103 104 mov ah, 0 105 mov byte ptr es:[si+2], ' ' 106 add si, 16 107 add bx, 2 108 loop s4 109 110 mov ah, 4ch 111 int 21h 112 code ends 113 end start
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 whether the information is structurally written to the specified memory as required
It should be noted here that 1356 / 13 = 104, but only two digits are allocated to per capita income in the requirement, so the lower two digits of 04 are saved
At the same time, mov byte ptr es:[si+2], '' also note that the essence is mov es:[si+2], 20 so it must be indicated whether to store memory by byte or word
I use add ah, 48 to convert numerical values into numbers and store them in the specified memory