汇编学习笔记-实验5 编写,调试具有多个段的程序[1]

将下面的程序进行编译,跟踪,回答问题

data segment
	dw 0123h,0456h,0789h,0abch,0defh,0fedh,0abch,0987h
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 ;10h
	  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


cpu执行程序,程序运行返回前,data中的数据为多少? 23 10 56 04 89 07....87 09

cpu执行程序程序运行返回前,cs=076c  ss=076b ds=076a

设程序加载后,code段的段地址为x,则data段的段地址为 x-2,stack段的段地址为x-1   

 

将下面的程序进行编译,跟踪,回答问题

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	   

cpu执行程序,程序运行返回前,data中的数据为多少? 23 10 56 04 00 00..

cpu执行程序程序运行返回前,cs=076c  ss=076b ds=076a

设程序加载后,code段的段地址为x,则data段的段地址为 x-2,stack段的段地址为x-1   

4.对于如下定义的段

name segment

...

name ends

如果段中的数据占用了N个字节,则程序加载后,该段实际占有空间为  16*(n/16+1)

 

编译 跟踪

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	


 


 

cpu执行程序,程序运行返回前,data中的数据为多少? 23 01 56 04

cpu执行程序程序运行返回前,cs=076a  ss=076e ds=076d

设程序加载后,code段的段地址为x,则data段的段地址为 x+3     stack段的段地址为x+4

如果将 1. 2. 3中的end start改成end,哪个程序可以正确运行?请说明原因,

第三个,因为当源程序未设置入口点时,cpu将按照顺序向下执行.

 

你可能感兴趣的:(ASM)