汇编语言实验5(王爽)

(1)

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

data segment
         dw 0123h,0456h,0789h,0abch,0defh,0fedh,0cbah,0789h
data ends

stack segment
          dw 0,0,0,0,0,0,0,0
stack ends

code segment

    start:mov  ax,stack
          mov  ss,ax
          mov  sp,16

          mov  ax,data
          mov  ds,ax

          push ds:[0]
          push ds:[2]
          pop  ds:[2]
          pop  ds:[0]

          mov  ax,4c00h
          int  21h
code ends

end start

汇编语言实验5(王爽)
1.不变
2.cs=076C ss=076B ds=076A(每人电脑得到的答案应该不同)
3. code段地址X data段地址X-1 stack段地址X-2

(2)

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

data segment
         dw 0123h,0456h
data ends

stack segment
          dw 0,0
stack ends

code segment

    start:mov  ax,stack
          mov  ss,ax
          mov  sp,16

          mov  ax,data
          mov  ds,ax

          push ds:[0]
          push ds:[2]
          pop  ds:[2]
          pop  ds:[0]

          mov  ax,4c00h
          int  21h
code ends

end start

不变
cs=076C ss= 076B ds=076A
code段地址x data段地址x-2 stack段地址 x-1
段中N个字节,程序加载后,该段实际空间为(N+15)/16*16
(小于等于16字节按16字节算)

(3)

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

code segment

    start:mov  ax,stack
          mov  ss,ax
          mov  sp,16

          mov  ax,data
          mov  ds,ax

          push ds:[0]
          push ds:[2]
          pop  ds:[2]
          pop  ds:[0]

          mov  ax,4c00h
          int  21h
code ends

data segment
         dw 0123h,0456h
data ends

stack segment
          dw 0,0
stack ends

end start

汇编语言实验5(王爽)
1.不变
2.cs=076A ss=076E ds=076D
3.code段地址X data段地址X+3 stack段地址X+4

(4)

第三题。不指明程序入口,程序就从程序第一段开始执行,(1)(2)中开头的数据段中的数据会被翻译成汇编指令执行

(5)

assume cs:code
a segment
    db 1,2,3,4,5,6,7,8
a ends

b segment
    db 1,2,3,4,5,6,7,8
b ends

c segment
    db 0,0,0,0,0,0,0,0
c ends

code segment
start:	mov ax,a
		mov ds,ax
		
		mov ax,b
		mov es,ax
		
        mov ax,c
        mov ss,ax

        mov bx,0
        mov cx,8
s:      mov ax,[bx]     
        add ax,es:[bx]
        mov ss:[bx],ax
        inc bx
        loop s
		
		mov ax,4c00h
    	int 21h
    	
code ends
end start

汇编语言实验5(王爽)
运行不了,尚未解决

(6)

assume cs:code
a segment
    dw 1,2,3,4,5,6,7,8,9,0ah,0bh,0ch,0dh,0eh,0fh,0ffh
a ends

b segment
    dw 0,0,0,0,0,0,0,0
b ends

code segment
start:	mov ax,b
		mov ss,ax	
		mov sp,16
		
		mov ax,a
		mov ds,ax
		
		mov bx,0
		
		mov cx,8
s:		push [bx]
		add bx,2
		loop s

    	mov ax,4c00h
    	int 21h

code ends
end start

汇编语言实验5(王爽)
上面的是放在b段中的数据,下面的是a段中的数据,正好相反

上一篇:数据库 DATEDIFF() 函数


下一篇:mysql 查询json字符串条件