当前位置: 代码迷 >> 汇编语言 >> 帮忙看下什么有关问题好么
  详细解决方案

帮忙看下什么有关问题好么

热度:4801   发布时间:2013-02-26 00:00:00.0
帮忙看下什么问题好么?
小弟正在写一段汇编程序
编写计算Y=X^2+6*X+9的程序。

代码如下:
Assembly code
DATA SEGMENTX DB 04HY DB ?DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:PUSH DATAXOR AX,AXXOR CX,CXPUSH AXMOV AX,DATAMOV DS,AXMOV AL,XMOV CL,XMUL CL    MOV BX,AX    ;实现X*X,结果存入BXMOV AX,XMOV CL,1SHL AX,CLMOV DX,AXSHL AX,CLADD DX,AX    ;实现6*X,结果存入DXMOV AX,BXADD AX,DXADD AX,9MOV Y,AXMOV AX,YMOV DL,ALAND DL,0F0HMOV CL,04HSHR DL,CLADD DL,30HMOV AH,02HINT 21HMOV DL,YADD DL,0FHADD DL,30HADD AH,02HINT 21HCODE ENDSEND START


结果,在MASM 5.0编译出错误:
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987. All rights reserved.

Object filename [cc33.OBJ]:
Source listing [NUL.LST]:
Cross-reference [NUL.CRF]:
cc33.asm(9): error A2056: Immediate mode illegal
cc33.asm(20): warning A4031: Operand types must match
cc33.asm(29): warning A4031: Operand types must match
cc33.asm(31): warning A4031: Operand types must match

50734 + 450386 Bytes symbol space free

3 Warning Errors
1 Severe Errors

求解释啊,求解释


------解决方案--------------------------------------------------------
cc33.asm(9): error A2056: Immediate mode illegal 不该用立即数的你用了
cc33.asm(20): warning A4031: Operand types must match 类型不匹配
cc33.asm(29): warning A4031: Operand types must match
cc33.asm(31): warning A4031: Operand types must match

Assembly code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;    编写计算Y=X^2+6*X+9的程序。;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DATA SEGMENTX DB 04HY DB ?DATA ENDSCODE SEGMENTASSUME CS:CODE,DS:DATASTART:;把你那两个PUSH删掉了MOV AX,DATAMOV DS,AXMOV AL,XMOV CL,XMUL CL    MOV BL,AL    ;实现X*X,结果存入BXMOV AL,XMOV CL,1SHL AL,CLMOV DL,ALSHL AL,CLADD DL,AL    ;实现6*X,结果存入DXMOV AL,BLADD AL,DLADD AL,9MOV Y,ALMOV DL,YAND DL,0F0HMOV CL,04HSHR DL,CLADD DL,30HMOV AH,02HINT 21HMOV DL,YAND DL,0FHADD DL,30HMOV AH,02HINT 21H;没转化成10进制输出了MOV DL,'H'      ;我加的MOV AH,2INT 21HMOV AH,7        ;我加的  INT 21HMOV AX,4C00HINT 21HCODE ENDSEND START
  相关解决方案