Experiment 2 compilation and debugging of assembly source program of multiple logic segments

Experimental task 1

  • Task 1-1
    • To program task1_1.asm assembles and connects, loads and tracks debugging with debug, and answers questions based on the results.

      ① ds=076A ss=076B 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.

  • Task 1-2
    • To program task1_2.asm assembles and connects, loads and tracks debugging with debug, and answers questions based on the results.

      ① ds=076A ss=076B 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.

  • Task 1-3
    • To program task1_3.asm assembles and connects, loads and tracks debugging with debug, and answers questions based on the results.

      ① ds=076A ss=076C 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.

  • Tasks 1-4
    • To program task1_4.asm assembles and connects, loads and tracks debugging with debug, and answers questions based on the results.

      ① ds=076C ss=076E 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.

  • Tasks 1-5
    • Based on the practice and observation of the above four experimental tasks, summarize and answer:
      ① For the segment defined below, after the program is loaded, the actual memory space allocated to the segment is rounded up by N/16
      ② After end start is changed to end




      task1_4 can be executed normally, because its code segment is defined in the front, and if the previous end start is removed, it is clear that the program entry is start. After removal, the first three file data segment definitions cannot be found in front of the code segment

Experiment task 2

Write an assembly source program to realize 160 consecutive bytes to memory units b800:0f00 ~ b800:0f9f, and fill hexadecimal data 03 and 04 repeatedly in turn.

  • code
    assume cs:code
    
    code segment
    start:
    	mov ax,0b800h
    	mov ds,ax
    	mov bx,0f00h
    	mov cx,160
    	mov ax,0403h
    	s:mov [bx],ax
    	inc bx
    	inc bx
    	loop s
    	mov ax,4c00h
    	int 21h
    code ends
    end start
    

Experimental task 3

  • code
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,10
	mov bx,0
	s: mov dx,0
	mov ax,data1
	mov ds,ax
	add dx,[bx]
	mov ax,data2
	mov ds,ax
	add dx,[bx]
	mov ax,data3
	mov ds,ax
	mov [bx],dx
	inc bx
	loop s
	mov ax,4c00h
	int 21h
code ends
end start



Experimental task 4

code:

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
	mov cx,8
	mov ax,data2
	mov ss,ax
	mov sp,16
	mov bx,0
	s:
	push [bx]
	add bx,2
	loop s
    
    mov ah, 4ch
    int 21h
code ends
end start


Experimental task 5

  • The function and operation of Line19 will change the sixth position 0 from low order to uppercase,

  • It can be seen that the five byte units of Line4 control the color of the font

Experimental task 6

code

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,4
	mov bx,0
	s:
	mov al,[bx]
	or al,00100000B
	mov [bx],al
	mov al,[bx+16]
	or al,00100000B
	mov [bx+16],al
	mov al,[bx+32]
	or al,00100000B
	mov [bx+32],al
	mov al,[bx+48]
	or al,00100000B
	mov [bx+48],al
	inc bx
	loop s

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

Experimental task 7

code

assume cs:code, ds:data, es:table

data segment
    db '1975', '1976', '1977', '1978', '1979' 
    dw  16, 22, 382, 1356, 2390
    dw  3, 7, 9, 13, 28 
data ends

table segment
    db 5 dup( 16 dup(' ') )  ;
table ends

code segment
start:
	mov ax,data
	mov ds,ax
	mov cx,5
	mov ax,table
	mov es,ax
	mov di,0
	mov bx,0
	c1:
	mov ax,[bx]
	mov es:[di],ax
	add bx,2
	mov ax,[bx]
	add di,2
	mov es:[di],ax
	add bx,2
	add di,14
	loop c1

	mov cx,5
	mov di,5
	c2:
	mov ax,[bx]
	mov es:[di],ax
	add bx,2
	add di,16
	loop c2
	
	mov cx,5
	mov di,8	
	c3:
	mov ax,[bx]
	mov es:[di],ax
	add bx,2
	add di,16
	loop c3

	mov cx,5
	mov di,5
	
	c4:
	mov ax,es:[di]
	mov dl,es:[di+3]
	div dl
	mov es:[di+6],al
	add di,16
	loop c4

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

Information of the initial logical segment

After execution

You can see that the contents of the corresponding columns have been copied to the table

Posted by idris on Thu, 11 Nov 2021 09:56:02 -0800