I have a little program that I was testing strings with, for some reason when I add to much to a string variable, and run the program, the console cursor just flits around the screen (and the console doesn't clear, which is before any output was even supposed to happen), and never seems to really stop. The reason I crammed all of this into one string variable is because for some reason, when I had three or more string variables, Windows would tell me I have used an illegal instruction. So I have two problems really. I have no idea what to do, as I have just come from C++.

Line1 db "+CALCULATE+", 0Dh, 0Ah, "   1.Add   ", 0Dh, 0Ah, "   2.Sub   ", 0Dh, 0Ah, "$"


menuinput:
mov ax,03 ;Clear screen code
int 10h ;Run the clearing

mov ah, 09
mov dx, offset Line1
int 21h

exit:
mov ah, 4Ch
mov AL, 00
int 21h
[org 0x0100] ;required for .COM files
[section .text] ;Think of this as a code section
menuinput:
mov ax,03 ;Clear screen code
int 10h ;Run the clearing

mov ah, 09
mov dx,Line1 ;dont need offset
int 21h

exit:
mov ah, 4Ch
xor al,al ;same as mov al,00 --but faster
int 21h

[section .data] ;define all variables etc here
	Line1 db "+CALCULATE+", 0Dh, 0Ah, "   1.Add   ", 0Dh, 0Ah, "   2.Sub   ", 0Dh, 0Ah, "$"

I assume you're using a COM file since there is no header, so you need [org 0x0100] at the top. The reason it was not working is because it was executing the bytes for your string when it encountered them-- You need to define bytes etc away from executed code.

The code I just pasted works when compiled in NASM, however you did not specify which assembler you were using so I can not guarantee that it'll work.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.