. : : Assembly Language : : .  |  首页  |  我提出的问题  |  我参与的问题  |  我的收藏  |  消息中心   |  游客  登录  | 
刷新 | 提问 | 未解决 | 已解决 | 精华区 | 搜索 |
  《汇编语言》论坛 ->包含多个段的程序
  管理员: assembly   [回复本贴] [收藏本贴] [管理本贴] [关闭窗口]
主题 : :  实验5.5.我的程序出了哪些问题?请达人看看  [已解决] 回复[ 4次 ]   点击[ 373次 ]  
ryan1779
[帖 主]   [ 发表时间:2009-07-14 18:51 ]   [引用]   [回复]   [ top ] 
荣誉值:6
信誉值:5
注册日期:2009-05-25 11:39
编译不成功,请达人看看
assume cs:code

a segment
   db 1,2,3,4,5,6,7,8
a ends

b segment
   db 1,2,3,4,5,6,7,8
b ends

c segment
   db 0,0,0,0,0,0,0,0
c ends

code segment

start:mov ax,c
      mov ds,ax

      mov es,a
      mov bx,0
      mov cx,8
    s:mov [bx],es:[bx]
      add bx,2
      loop s

      mov es,b
      mov bx,0
      mov cx,8
   s0:add [bx],es:[bx]
      add bx,2
      loop s0

      mov ax,4c00h
      int 21h

code ends

end start


C:\masm>masm c:\s5.txt;
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.

c:\s5.txt(20): error A2056: Immediate mode illegal
c:\s5.txt(23): error A2052: Improper operand type
c:\s5.txt(27): error A2056: Immediate mode illegal
c:\s5.txt(30): error A2006: Phase error between passes

  50550 + 450170 Bytes symbol space free

      0 Warning Errors
      4 Severe  Errors

C:\masm>
居然有4个错误。我一个都没看出来。-。-!!编完的时候自我感觉还很良好,闷!
ryan1779
[第1楼]   [ 回复时间:2009-07-15 11:01 ]   [引用]   [回复]   [ top ] 
荣誉值:6
信誉值:5
注册日期:2009-05-25 11:39
经过思考。改进2个错误
start:mov ax,c
      mov ds,ax

      mov es,a
      mov bx,0
      mov cx,8
    s:mov dx,es:[bx]          ;原错误1
      mov [bx],dx
      add bx,2
      loop s

      mov es,b
      mov bx,0
      mov cx,8
   s0:mov dx,es:[bx]           ;原错误2
      add [bx],dx
      add bx,2
      loop s0

      mov ax,4c00h
      int 21h



C:\masm>masm
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987.  All rights reserved.

Source filename [.ASM]: c:\s5.txt;
c:\s5.txt(20): error A2056: Immediate mode illegal
c:\s5.txt(28): error A2056: Immediate mode illegal

  50550 + 450170 Bytes symbol space free

      0 Warning Errors
      2 Severe  Errors

C:\masm>
tsembrace
[第2楼]   [ 回复时间:2009-07-15 17:02 ]   [引用]   [回复]   [ top ] 
荣誉值:31
信誉值:3
注册日期:2009-06-15 19:20
仔细看报错提示呗~
c:\s5.txt(20): error A2056: Immediate mode illegal
错误指令行:第20行,错误原因:立即数模式非法(自己带着猜的翻译)
依据提示看第20行:mov es,a
a在编译过程中以立即数形式存在,而es和ds一样都是段寄存器,不能直接传递立即数。
一样的采用通用寄存器过渡。
ryan1779
[第3楼]   [ 回复时间:2009-07-16 11:30 ]   [引用]   [回复]   [ top ] 
荣誉值:6
信誉值:5
注册日期:2009-05-25 11:39
哎,学了后面忘了前面,看样子要多往前看看~!谢LZ提醒
ryan1779
[第4楼]   [ 回复时间:2009-07-16 11:30 ]   [引用]   [回复]   [ top ] 
荣誉值:6
信誉值:5
注册日期:2009-05-25 11:39
此贴由 贴主 于 [ 2009-07-16 11:30 ] 结贴。 结贴原因:问题已解决
得分情况: 2楼(tsembrace):4分  
此问题已结贴!
    Copyright © 2006-2024   ASMEDU.NET  All Rights Reserved