- Assembly code
assume cs:codedata segmentdb 'Welcome to masm!',0data endsstack segmentdb 16 dup (0)stack endscode segmentstart:mov dh,8mov dl,3mov cl,2sub ch,chmov ax,datamov ds,axmov ax,stackmov ss,axmov sp,16sub si,sisub di,dimov ax,0b800hmov es,axcall show_strmov ax,4c00hint 21hshow_str:push cxmov cl,[si]jcxz okpop cxmov al,[si]mov ah,clmov es:[di+160*8+3],axadd di,2inc sijmp short show_strok:pop cxretcode endsend start
目的是在屏幕的8行3列,用绿色显示DATA段中的字符串。
------解决方案--------------------------------------------------------
子程序堆栈失衡。push/pop应成对才可保持堆栈平衡。