Compilation and debugging of assembler for multiple logic segments in Experiment 2

Experiment task 1:

Task 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. (memory is allocated at 16 bytes at a time.)

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-0002h and the segment address of the stack is x-0001h.

Task 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. (memory is allocated at 16 bytes at a time.)

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-0002h,   The segment address of stack is x-0001h.

Tasks 1-3:

  

In debug, execute until the end of line17 and before line19. Record this time: register (DS) = 076A, register (SS) =076C,   Register (CS) =076E. (the segment size is an integral multiple of 16 bytes, but 16 bytes is not enough, so 32 bytes are allocated.)

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-0004h,   The segment address of stack is x-0002h.

Tasks 1-4:

  

① in debug, execute until the end of line9 and before line11. Record this time: register (DS) = 076C, register (SS) =076E, register (CS) = O76A

② 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+0002h and the segment address of the stack is x+0004h

Tasks 1-5:

① round up according to the result of data modulus 16 as the memory space of the whole segment.

  ②task1_4 can operate normally. Because after using end start, the program will be executed from the place of start. If end start is not used, it will be executed from the beginning, and errors will occur except 4.

 

 

Experiment task 2:

 

assume cs:code
code segment
start:
mov ax,0b800h
mov ds,ax
mov bx,0f00h
mov cx,80
s:
mov ds:[bx],0403h
inc bx
inc bx
loop s

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

 

 

Experiment task 3:

 

Data in data1 before addition:

 

Data in data2 before addition:

 

 

 

Data in data3 before addition:

 

 

 

Data in data1 after addition:

 

Data in data2 after addition:

 

Data in data3 after addition:

 

 

  Disassembly screenshot:

 

 

 

 

 

Experiment task 4:  

 

assume cs:code

data1 segment
    dw 2, 0, 4, 9, 2, 0, 1, 9
data1 ends 

data2 segment
    dw 8 dup(0)
data2 ends
stack segment
    db 16 dup(0)
stack ends
code segment
start:
    mov ax,data1
    mov ds,ax
    mov ax,stack
    mov ss,ax
    mov sp,16
    mov bx,0
    mov cx,8
s1:
    push ds:[bx]
    inc bx
    inc bx
    loop s1

    mov bx,16
    mov cx,8
s2:
    pop ds:[bx]
    inc bx
    inc bx
    loop s2

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

 

 

 

 

 

Experiment task 5:

 

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

 

 

  Function of line 19: sum the original data with 0dfh, that is, with 00001101111, so that the 6th bit becomes 0, that is, it is reduced by 32. So it is to unify the letters into uppercase.

  The function of Line4 is to add different colors to letters.

Experiment task 6:

 \

 

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 si,0
s:    mov al,[si]
    or al,00100000B
    mov [si],al
    mov al,[si+16]
    or al,00100000B
    mov [si+16],al
    mov al,[si+32]
    or al,00100000B
    mov [si+32],al
    mov al,[si+48]
    or al,00100000B
    mov [si+48],al
    inc si
    loop s
    
    mov ah, 4ch
    int 21h
code ends
end start

Experiment task 7:

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 ax,table
    mov es,ax

    mov bx,0
    mov bp,0
    mov si,20
    mov cx,5

s:  mov ax,ds:[bx]
    mov es:[bp],ax
    mov ax,ds:[bx+2]
    mov es:[bp+2],ax

    mov ax,ds:[si]
    mov es:[bp+5],ax
    mov word ptr es:[bp+7],0

    mov ax,ds:[si+10]
    mov es:[bp+10],ax

    mov ax,ds:[si]
    mov dl,ds:[si+10]
    div dl
    mov es:[bp+13],al
    mov byte ptr es:[bp+14],0

    add bx,4
    add bp,16
    add si,2

    loop s

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

  

 

 

Added by Frozenlight777 on Tue, 09 Nov 2021 01:58:01 +0200