Jay Catt
Jay Catt

Reputation: 71

Assembly Error A2071: initializer magnitude too large for specific size

So I am very, very new to assembly, and we have an assignment for school to computer the function: z = x^2 * y - 16 (4 - y)

I have been used MASM to try and compile it to determine if it'll work, but I keep receiving an error, Error 2071: initializer magnitude too large for specified size.

My code is :

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 

The error is being prompt at:

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

I attempted to change db to dw or dd but then receiving the error:

Error A2084: constant value too large

Like I said, I'm very new to this, so whatever help or information you provide would be of great help! Thanks!

Upvotes: 0

Views: 982

Answers (1)

rcgldr
rcgldr

Reputation: 28818

For db ... use " ... " instead of ' ... ' .

Upvotes: 1

Related Questions