1, Experimental purpose
1. Understand and master the assembly source program of more than 8086 logic segments
2. Understand and skillfully apply flexible addressing methods
3. Understand the essence of loop in programming language through the use of assembly instruction loop, and master its correct use in nested loop
4. Master the method of debugging 8086 assembler with debug
2, Experimental preparation
Review textbook chapters 5-8: assembly source program structure including multiple logic segments, addressing mode, assembly instruction loop, div usage
3, Experimental content
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-2 and the segment address of the stack is _X-1.
2.
① 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-2 and the segment address of the stack is _X-1.
3.
① 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-4 and the segment address of the stack is _X-2.
4.
① 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+2 and the segment address of the stack is _X+4.
5.
① For the segment defined below, after the program is loaded, the actual memory space allocated to the segment is _2*[N/16] B ([] is rounded up).
Program task1_4 can still be executed correctly. When start is not used to indicate the program entry, the program will read from the first line of code by default.
two
Three,
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 cx, 0ah mov ax, data1 mov ds, ax mov bx, 0 s: mov dl, [bx] add dl, [16+bx] mov [32+bx], dl inc bx loop s mov ah, 4ch int 21h code ends end start
Disassembly:
Before adding:
After addition:
Four,
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 bx, 0 mov ax, data1 mov ds, ax mov cx, 8 s1: push [bx] add bx, 2 loop s1 mov bx, 0 mov cx, 8 s2: pop [bx+16] add bx, 2 loop s2 mov ah, 4ch int 21h code ends end start
Disassembly:
Before loading:
Five,
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 add di, 2 loop s mov ah, 4ch int 21h code ends end start
The g command is executed once before the program returns
The function of line19 in the source code is: Convert lowercase letters to uppercase letters
In the source code, DB 2,3,4,5,6 -- > is changed to: db 5 dup(2)
The purpose of the byte data of line4 in the data section of the source code is: the function of line4 is to set the color
six
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
load:
Disassembly:
result:
Seven,
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
Commissioning screenshot:
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