【问题标题】:Assembly Error A2071: initializer magnitude too large for specific size装配错误 A2071:初始化程序幅度对于特定大小来说太大
【发布时间】:2017-07-24 01:59:56
【问题描述】:

所以我对组装非常非常陌生,我们有一个学校任务来计算功能: z = x^2 * y - 16 (4 - y)

我已使用 MASM 尝试编译它以确定它是否可以工作,但我一直收到错误消息,错误 2071:初始化器幅度对于指定大小而言太大。

我的代码是:

title Assignment3_JoelCatterall.asm
.model small
.stack 100h

.data
include const.inc

x   dw  ?
y   dw  ?
z   dw  ?

ntrfir   db      'Enter first number $'
ntrsec   db       cr, lf, 'Enter second number $'
pntequ   db       cr, lf, 'The point (', x, ', ', y, ') is $'

.code

extrn getint: proc, putint: proc

main proc

; -- initalize DS
    mov     ax, @data
    mov     ds, ax

;write "Enter first number" 
    mov     ah, dispstr
    mov     dx, offset ntrfir
    int     dosfunc

; read x
    call    getint
    mov     x, ax

;write cr, lf, 'Enter second number'
    mov     ah, dispstr
    mov     dx, offset ntrfir
    int     dosfunc

; read y
    call    getint
    mov     y, ax;

; z (x,y) = x^2 * y - 16 * (4 - y)
    mov     ax, x
    imul    x
    imul    y
    mov     cx, ax
    mov     ax, 16
    mov     bx, 4
    sub     bx, y
    imul    ax
    sub     cx, bx
    mov     z, cx

; write cr, lf, 'The point(x, y) is :'
    mov     ah, dispstr
    mov     dx, offset pntequ
    int     dosfunc
    mov     ax, z
    call    putint

 ; return -- to DOS
    mov     ah, ret2dos
    int     dosfunc

 main    endp
    end     main 

错误提示在:

     pntequ     db      cr, lf, 'The point (', x, ', ', y, ') is $'

我尝试将db 更改为dwdd,但随后收到错误消息:

错误 A2084:常数值太大

就像我说的,我对此很陌生,所以您提供的任何帮助或信息都会有很大帮助! 谢谢!

【问题讨论】:

    标签: assembly compiler-errors masm


    【解决方案1】:

    对于 db ... 使用“...”而不是 '...'。

    【讨论】:

      猜你喜欢
      • 2015-07-28
      • 2018-11-24
      • 2016-09-10
      • 2020-03-03
      • 1970-01-01
      • 2022-12-20
      • 2013-06-07
      • 2013-06-15
      • 2021-12-15
      相关资源
      最近更新 更多