using assembly in turbo c++, help
-
this is code of gotoxy, i have made in c++ using assembly, but it is not working and giving an error of invalid operand. plz help!!!! void _gotoxy(int row,int cols) { asm MOV AH,0x2 asm MOV DH,row// problem is here,if we use asm MOV DL,cols//constant here, it works asm MOV BH,0x0 asm INT 0x10 } void main() { clrscr(); _gotoxy(15,15); printf("x"); getch(); }
-
this is code of gotoxy, i have made in c++ using assembly, but it is not working and giving an error of invalid operand. plz help!!!! void _gotoxy(int row,int cols) { asm MOV AH,0x2 asm MOV DH,row// problem is here,if we use asm MOV DL,cols//constant here, it works asm MOV BH,0x0 asm INT 0x10 } void main() { clrscr(); _gotoxy(15,15); printf("x"); getch(); }
Just a guess (it's been a long time :~ ), but aren't DH and DL only 8 bits? Try this:
void _gotoxy(int row, int col)
{
asm
{
mov ah, 2
mov bh, 0
mov dh, row & 0xff
mov dl, col & 0xff
int 0x10
}
}
CPUA 0x5041 Sonork 100.11743 Chicken Little "So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies Within you lies the power for good - Use it!
-
Just a guess (it's been a long time :~ ), but aren't DH and DL only 8 bits? Try this:
void _gotoxy(int row, int col)
{
asm
{
mov ah, 2
mov bh, 0
mov dh, row & 0xff
mov dl, col & 0xff
int 0x10
}
}
CPUA 0x5041 Sonork 100.11743 Chicken Little "So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies Within you lies the power for good - Use it!
i have checked that but it is not working, suggest any thing else, plz help!!!!
-
i have checked that but it is not working, suggest any thing else, plz help!!!!
The only other thing I can think of would be to use
char
instead ofint
. void _gotoxy (char x, char y) otherwise I have no idea why it would work with a constant and not a variable. I do not have Turbo C++ to test it myself. What does your manual say about using variables in inline assembly?
CPUA 0x5041 Sonork 100.11743 Chicken Little "So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies Within you lies the power for good - Use it!
-
The only other thing I can think of would be to use
char
instead ofint
. void _gotoxy (char x, char y) otherwise I have no idea why it would work with a constant and not a variable. I do not have Turbo C++ to test it myself. What does your manual say about using variables in inline assembly?
CPUA 0x5041 Sonork 100.11743 Chicken Little "So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies Within you lies the power for good - Use it!
Hey Im not a real advanced programer or anything, but when I use Turbo C++ in class, I can include and freely use gotoxy(int,int); thoughout the program to move the cursor to a certain spot on the screen and print something there. What the hell is up with visual c++. It's telling me that gotoxy(int,int); is an "undeclared identifier". Well Im lost...:omg: