实验二

实验一:

(1)

assume ds:data, cs:code, ss:stack

data segment
    db 16 dup(0)
data ends

stack segment
    db 16 dup(0)
stack ends
code segment
start:
    mov ax, data
    mov ds, ax

    mov ax, stack
    mov ss, ax
    mov sp, 16

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

 

实验二

 

 cs:076c   ds: 076a   ss:076b

data段的段地址是X-2, stack的段地址是X-1

(2)

assume ds:data, cs:code, ss:stack

data segment
    db 4 dup(0)
data ends

stack segment
    db 8 dup(0)
stack ends
code segment
start:
    mov ax, data
    mov ds, ax

    mov ax, stack
    mov ss, ax
    mov sp, 8

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

  

实验二

 

  cs:076c   ds: 076a   ss:076b

data段的段地址是X-2, stack的段地址是X-1

(3)

assume ds:data, cs:code, ss:stack

data segment
    db 20 dup(0)
data ends

stack segment
    db 20 dup(0)
stack ends
code segment
start:
    mov ax, data
    mov ds, ax

    mov ax, stack
    mov ss, ax
    mov sp, 20

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

 

实验二

 

  cs:076e   ds: 076a   ss:076c

data段的段地址是X-4, stack的段地址是X-2

(4)

assume ds:data, cs:code, ss:stack
code segment
start:
    mov ax, data
    mov ds, ax

    mov ax, stack
    mov ss, ax
    mov sp, 20

    mov ah, 4ch
    int 21h
code ends

data segment
    db 20 dup(0)
data ends

stack segment
    db 20 dup(0)
stack ends
end start

 

实验二

 

   cs:076a   ds: 076c   ss:076e

data段的段地址是X+2, stack的段地址是X+4

(5)

 1)实际分配的内存为((N/16+1)*16 

2)task1_4.asm仍然可以执行;因为“end start”改为“end”,则程序不能识别 start,会从程序开头,数据段和栈段开始执行,不是从程序代码开始,数据段和栈段所代表的代码则是乱码

实验二:

assume cs:code
code segment
    mov ax, 0b800h
    mov ds, ax
    
    mov bx, 0f00h
    mov ax, 0403h
    mov cx, 160
s:  mov [bx], ax
    add bx, 2
    loop s
    
    mov ah, 4ch
    int 21h
code ends
end

 

结果:实验二

 

 

实验三:

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 bx,0    ;
    mov dx,0    ;
    mov cx,10    ;
    s:

        mov dx,0    
            
        mov ax,data1
        mov ds,ax
        add dl,[bx]
            
        mov ax,data2
        mov ds,ax
        add dl,[bx]
            
        mov ax,data3
        mov ds,ax
        mov [bx],dl
            
        inc bx
    loop s

code ends
end start

相加前

data1:实验二

 

 data2:实验二

 

 

data3:实验二

 

 

反汇编:实验二

 

 

结果:实验二

 

 

实验四:

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 ax,data2
    mov ss,ax
    mov sp,16 
 
    mov bx,0
    mov cx,8
s:
    push ds:[bx]
    add bx,2
    loop s

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

 

实验二

 

 在076A:0010处显示的是data2中的内容

实验五:

运行结果:

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

(2)

实验二

 

(3)line25执行之后、line27执行之前,观察 结果:

实验二

 

 

 实验二

 

 (4)源代码中line19的作用是:把单片机的AL与DF(1101 1111)进行与,就是把左边数过去的第三位清0

(5)line4中的字节数据,用于控制5个字符每个字符的颜色

实验六:

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 bx, 0
   mov cx, 5
s:
   mov al, [bx]
   or al, 00100000B
   mov [bx], al
   add bx, 16
   loop s    

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

调试:实验二

 

 反汇编:实验二

 

 

结果:

实验二

 

 实验七:

 

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 si,0
    mov di,0
    mov cx,5
s:
    mov ax,ds:[si]
    mov es:[di], ax
    mov ax,ds:[si+2]
    mov es:[di+2], ax
    mov ax,ds:[si+84]
    mov es:[di+5],ax
    mov dx,ds:[si+84+2]
    mov es:[di+7],dx
    push cx
    mov cx,ds:[84+84+bx]
    mov es:[di+0ah],cx
    div cx
    pop cx
    mov es:[di+0dh],ax
    add si,4
    add bx,2
    add di,16
loop s

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

table原始数据:

实验二

 运行完后:

实验二

 

上一篇:keras文件读取


下一篇:实验2