Oria Gruber
Oria Gruber

Reputation: 1533

assembly 8086 - Getting an overflow

I have a very basic question. I'm writing in assembler, and I need to declare a word in the data segment, so I wrote:

.model small
.stack 32h
.data
    X DW A0B0h

However, it won't compile. the compiler says "overflow! cannot be evaluated," and I don't understand why. A word is 2 bytes, A0b0h is 2 bytes (4 nibblets each hexa char, there are 4 chars, so 16 nibblets, that's 2 bytes).

And also, why is it that some people write values like this:

A DB 0120h

rather than:

A DB 120h

Could it be related to my error?

Upvotes: 2

Views: 1025

Answers (1)

Hans Passant
Hans Passant

Reputation: 941465

The first step an assembler makes when it processes your source code is to tokenize it. Splitting the file content into identifiable categories of tokens, a parser then interprets them. Like keyword, number, symbol, string, punctuation. A number is recognized by it starting with the digits 0..9. A symbol is recognized by it starting with a letter.

So "A0B0h" is not recognized as a number, it is a symbol. Like "X". You must write it as 0A0B0h, now it is a number.

You don't exactly get a very good error message for it, "overflow" is pretty bewildering of course. The assembler might jump the gun, it can't complain about an unknown identifier until the second pass. Perhaps already deciding in the 1st pass that it can't stick a 32-bit address into a 16-bit variable, something like that.

Upvotes: 3

Related Questions