汇编网首页登录博客注册
mr_crbn的学习博客
博客首页博客互动【做检测题】论坛求助

我的博客

个人首页 |  我的文章 |  我的相册 |  我的好友 |  最新访客 |  文章收藏 |  论坛提问 |  友情链接 |  给我留言  
图片载入中
学习动态
好友圈
文章收藏

[2019-07-15 18:02] 汇编语言监测点10.5的作业

【1】
assume cs:code

stack segment
dw 8 dup(0)
stack ends

code  segment

start:mov ax,stack;0 1 2

mov ss,ax ;3 4   把栈段地址给ss

mov sp,16 ;5 6 7  栈偏移为16

mov ds,ax ;8 9   数据段的段地址和栈段地址相同

mov ax,0  ;a  b c 
           
call word ptr ds:[0eh] ;d e f 10  push ip 压栈 为11h  再 jmp word ptrds:[0eh]  
;就是把ip 11h 压栈到 stack 栈段中的 0eh  然后 读取 这栈段地址存储的11h这个数据 然后程序继续执行

inc ax ; 11h  
inc ax
inc ax
mov ax,4c00h
int 21h
code  ends
end start
答 (ax)= 3

【2】



assume cs:code

data segment
dw 8 dup(0) ;定义八个字    s标号ip cs 0 0 0 0 nop指令的ip cs      0 ~ f
;目的:程序运行完 之后 ax,bx的值为多少?
data ends
code  segment
start: mov ax,data 
mov ss,ax  
mov sp,16     ;初始化 栈 和 数据段 这里的数据和栈用的同一个段
           
mov word ptr ss:[0],offset s ;把s标号的ip写到数据段里的开始
           
mov ss:[2],cs    ;将程序当前cs的数据 写到内存 ss:[2]里面去
call dword ptr ss:[0]; ip指向nop标号  》 push cs (此时的数据段也就是栈末尾的数据为 cs)》push ip 此时数据段0ch处的数据为 nop指令的ip 》;jmp dword ptr ss:[0]  跳过nop 执行标号s的指令
nop
s:mov ax,offset s ;取得当前s标号的ip  
sub ax,ss:[0ch];当前s标号的ip 减掉  nop指令的ip  ax,为1
mov bx,cs ; (bx )  = (cs)  
sub bx,ss:[0eh] ;此时数据0eh的数据为 cs   cs 减掉cs为0
mov ax,4c00h
int 21h
;ax为1 bx为0
code  ends
end start

答: (ax) = 1 (bx) =0
评论次数(0)  |  浏览次数(515)  |  类型(汇编作业) |  收藏此文  | 
 
 请输入验证码  (提示:点击验证码输入框,以获取验证码