Task 1-1
(1) In debug, execute until the end of line17 and before line19. Record this time: register (DS) = 076A, register (SS) = 076B, register (CS) = 076C.
(2) 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-2h and the segment address of the stack is X-1h.
Task 1-2
(1) In debug, execute until the end of line17 and before line19. Record this time: register (DS) = 076A, register (SS) = 076B, register (CS) = 076C.
(2) 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-2h and the segment address of the stack is X-1h.
Task 1-3
(1) In debug, execute until the end of line17 and before 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 the program is loaded, the segment address of the data segment is X-4h and the segment address of the stack is X-2h.
Tasks 1-4
(1) In debug, execute until the end of line9 and before line11. 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 the program is loaded, the segment address of the data segment is X+2h and the segment address of the stack is X+4h.
Tasks 1-5
(1) For the segment defined below, after the program is loaded, the actual memory space allocated to the segment is 2*[N/16] B.
(2) If the program Task1_ 1.asm, task1_ 2.asm, task1_ 3.asm, task1_ 4. In ASM, if the pseudo instruction end start is changed to end, which program can still be executed correctly? The reasons are analyzed and explained in combination with the conclusions obtained from practical observation.
Answer: task1_4.asm can still run normally. It can be seen from task 1-1 that the address difference between DS and CS is 10h by default. If the start position of the program is not indicated, the program runs from DS+10h by default. Change end start to end. Use - r to view the register, and you can see that the value of CS is 076A instead of the original 076C. Use disassembly to view, and you can find that all the areas where CS starts are 0, There are no instructions to execute.
Task 2
Experiment code:
assume cs:code code segment start: mov ax,0b800h mov ds,ax mov bx,0f00h mov cx,50h;50h I.e. 80 mov ax,0403h s: mov ds:[bx],ax add bx,2 loop s mov ah,4ch int 21h code ends end start
Operation results:
Task 3
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,0ah s: mov ax,ds:[bx] add ax,ds:[bx+10h] mov ds:[bx+20h],ax inc bx loop s mov ah,4ch int 21h code ends end start
Disassembly:
Before adding:
After addition:
Task 4
Experiment code:
assume cs:code,ss:stack data1 segment dw 2, 0, 4, 9, 2, 0, 1, 9 data1 ends data2 segment dw 8 dup(?) data2 ends stack segment dw 8 dup(?) stack ends code segment start: mov ax,stack mov ss,ax mov sp,8 mov ax,data1 mov ds,ax mov bx,0 mov cx,8 s: push [bx] add bx,2 loop s mov ax,data2 mov ds,ax mov bx,0 mov cx,8 s2: pop [bx] add bx,2 loop s2 mov ah, 4ch int 21h code ends end start
Before storage:
After storage:
Task 5
Operation results:
A: the function of line19 is to convert lowercase letters into uppercase letters.
Modify line 4 to db 5 dup(2), and the operation result is:
A: the function of line4 is to set the color.
Task 6
Experiment code:
assume cs:code, ds:data, ss:stack data segment db 'Pink Floyd ' db 'JOAN Baez ' db 'NEIL Young ' db 'Joan Lennon ' data ends stack segment dw 1 dup(?) stack ends code segment start: mov ax,stack mov ss,ax mov sp,1 mov ax,data mov ds,ax mov ax,data mov es,ax mov cx,4 s: push cx mov bx,0 mov cx,4 s2: mov al,es:[bx] or al,20h mov es:[bx],al inc bx loop s2 pop cx mov ax,es inc ax mov es,ax loop s mov ah, 4ch int 21h code ends end start
Before conversion:
Disassembly:
After conversion:
Task 7
Experiment code:
assume cs:code, ds:data, es:table,ss:stack data segment db '1975', '1976', '1977', '1978', '1979' dd 16, 22, 382, 1356, 2390 dw 3, 7, 9, 13, 28 data ends table segment db 5 dup( 16 dup(' ') ) ; table ends stack segment dw 1 dup(?) stack ends code segment start: mov ax,stack mov ss,ax mov sp,1 mov ax,data mov ds,ax mov ax,table mov es,ax mov di,0;data ;1 mov bx,0;table mov si,0;table mov cx,5 year: push cx mov cx,4 year2: mov al,ds:[di] mov es:[bx+si],al inc si inc di loop year2 pop cx add bx,10h mov si,0 loop year ;2 mov bx,0 mov si,5 mov cx,5 income: push cx mov cx,4 income2: mov al,ds:[di] mov es:[bx+si],al inc si inc di loop income2 pop cx add bx,10h mov si,5 loop income ;3 mov bx,0 mov si,10 mov cx,5 num: push cx mov cx,2 num2: mov al,ds:[di] mov es:[bx+si],al inc si inc di loop num2 pop cx add bx,10h mov si,10 loop num ;4 mov bx,0 mov si,5 mov cx,5 cal: mov ax,word ptr es:[bx+si] add si,2 mov dx,word ptr es:[bx+si] add si,3 div word ptr es:[bx+si] add si,3 mov word ptr es:[bx+si],ax add bx,10h mov si,5 loop cal mov ah, 4ch int 21h code ends end start
Operation results:
After structured write: