how to solve constant too large error in TASM?
You'll have to give us a good deal more detail about the problem, I'm afraid. What kind of constant are you trying to use? I assume it is an integer, in which case you probably don't have many options - Turbo Assembler (which is the TASM I assume you mean - there were at least two others which went by that acronym) was a 16-bit real mode assembler for MS-DOS, and did not work directly with values greater than FFFF hex (65536 decimal). There are ways to work around this, but they aren't particularly easy.
Which leads to the next question: why TASM? is this for coursework (in which case you probably don't have any choice), and is there a reason why it is in an archaic 16-bit assembly dialect for MS-DOS? Current versions of Windows (Vista and later) won't even run 16-bit real mode programs except through an emulator such as DosBox; if you have any choice at all in the matter, I recommend that you ditch TASM for a modern assembler that actually still runs, such as NASM or FASM.
Yes, you are right, i am sorry about that, i don't mean integer i mean string constant. for example
.model tiny .code ORG 100h HOST: mov ah,9 mov dx, OFFSET MSG int 21h mov ah, 4C00h int 21h MSG db 'Hello I'm not a virus$.' END HOST
When i compile it, it say constan too long Error is at line 10
I am using TASM 1.4 and Intel Core i3 CPU
Thanks, No i certainly don't mean ax. thanks for the link.
You may want to check your code. Examples of the call show
MOV AX,4C00H INT 21H
Well, aside from the fact that 4C00 hex is far too large to fit in to fit into a byte (the maximum value for a single byte - that is to say, 8 bits - is FF hex, or 256 decimal), a quick check of Ralf Brown's Interrupt List's entry for interrupt vector 21h shows no parametric function for 4C00h. Are you sure you didn't want (INT 21h, AH=4Ch)[http://www.ctyme.com/intr/rb-2974.htm] (exit with a shell return value)? That would be the usual function to call at the end of a MS-DOS program, IIRC.
SOLVED. IT WAS REALLY AX NOT AH.
I think you'll find that it was
AH, and that you wanted to set that to 4Ch; however, since
AH is the high byte of
MOV AX, 4C00h is the same as assigning
MOV AH, 4Ch followed by
MOV AL, 00h. The effect is (almost) the same, since you were returning a zero to the shell anyway (zero is used by the shell to indicate a successful completion of the program), but this is misleading; for other interrupt calls, you will sometimes need to pass an argument through
AL, and if you had set
AX instead of
AH, you'd have a serious problem. In this case, it works out (and even saves an instruction, technically speaking), but you should be aware of why it works, and what is really happening, in order to see the potential problems in that approach.
yes,it works as well with ah 4ch. thanks guys.