回 帖 发 新 帖 刷新版面

主题:帮忙查错,谢谢。

功能为输出三角形的‘*’
源程序如下:

stack   segment stack
        dw      50 dup(?)
stack   ends

data    segment
x    db    '*'

data    ends

assume  cs:code,ds:data,ss:stack
start    proc    far
    push    ds
    mov    ax,0
    push    ax
    mov    ax,data
    mov    ds,ax
        mov     ax,stack
        mov     ss,ax     
    mov    dx,offset x
    mov    ah,9
    int    21h
    
next1:    mov     ah,1
    int    21h
    cmp    al,31h
    jb    next1
    cmp    al,39h
    ja    next1
    sub    al,30h
    mov    cl,al
    mov     ah,2
    mov    dl,0dh
    int    21h
    mov    dl,0ah
    int    21h
next3:    push    cx
next2:    mov    ah,2
    mov    dl,offset x
    int    21h
    loop    next2
    mov    dl,0dh
    int    21h
    mov    dl,0ah
    int    21h
    pop    cx
    loop    next3
    ret
start    endp
    end    start


错误提示:data emitted with no segment
          segment parameters are changed.
帮帮忙!
谢谢!

回复列表 (共6个回复)

沙发

;重写一个,
stack   segment stack 'stack'
        dw      50 dup(?)
stack   ends

data    segment
x        db '      *', 0DH, 0AH
        db '     * *', 0DH, 0AH
        db '    *   *', 0DH, 0AH
        db '   *     *', 0DH, 0AH
        db '  *       *', 0DH, 0AH
        db ' *         *', 0DH, 0AH
        db '*************', 0DH, 0AH
        db '$'
data    ends

code     segment
        assume  cs :code, ds :data, ss :stack
start    proc    far
        push    ds
        xor        ax, ax
        push    ax
        
        mov        ax, data
        mov        ds, ax
        
        mov        dx, offset x
        mov        ah, 9
        int        21H
        ret
start    endp
code    ends
        end  start

板凳

能告诉我哪出错了吗?

3 楼

注意代码段没有声明
code     segment
 ....
code     ends

4 楼


改完之后,当连接时,错误变成
 attempt to acess data outside segment bounds.

5 楼

晕,你还是自己仔细对照一下

6 楼

我重新试了一下,让程序只有  push cx,和pop cx 两条语句, 编译能通过,但是连接不能通过,错误是:attempt to acess data outside segment bounds

我来回复

您尚未登录,请登录后再回复。点此登录或注册