汇编语言
assume cs:code ss:datadata segment
dw 00,00,00,00,00,00,00
data ends
code segment
start:mov ax,data
mov ss,ax
mov ax,4
mov cx,2
push cx
d:mov cx,1
s:add ax,ax
loop s
pop cx
sub cx,1
push cx
loop d
mov ax,4c00h
int 21h
code ends
end start //计算4的3次方哪里错了
vanentu 发表于 2015-5-14 17:21
零基础
哪里不对
ss是存放栈的段地址,应该和stack相关联,而data是和ds相关联,用来存放代码
代码如下:
assume cs:code,ss:stack
stack segment stack
dw 0,0,0,0,0,0,0,0,0,0,0,0,0,0
stack ends
code segment
start: movax,stack
movss,ax
movsp,20h
movax,4
movcx,4
push cx
s: addax,ax
loop s
popcx
subcx,1
push cx
mov ax,4c00h
int 21h
code ends
end start
用t命令执行后其结果ax=0040h,及对应十进制中的64
http://bbs.fishc.com/template/dreambred_c_apple/images/common//emp.gif
页:
[1]