PDA

View Full Version : C++ w/ Assembly



KnightMareMan
11-04-2001, 11:15 AM
hello, im having problems with Turbo C++ 3.0, this is whats going down, I compile the C++ source code to get its .obj file, then I compile my assembly source w/ TASM, to get its .obj then I use TC++'s linker to link them together but it says undefined symbol gotoxy(int,int) anyway, these are my sources, thank you for your help.

----------------------------------------------------------------------------------
;*************************
; module: modwc.asm
;
;*************************
CODESG SEGMENT PARA

_gotoxy PROC FAR
PUBLIC _gotoxy
ASSUME CS:CODESG
PUSH BP
PUSH AX
PUSH DX

MOV BP,SP
MOV DX,[BP + 6]
MOV CX,04
SHL DX,CL ; move the y value to DH
MOV AX,[BP + 8]
XCHG DL,AL ; move the x value to DL
MOV AH,02 ; SET CURSOR POSITION FUNCTION
MOV BH,00 ; PAGE #
INT 10h

POP DX
POP AX
POP BP
RET 4 ; pop 4 bytes off stack, (2 bytes for x, 2 bytes for y)
_gotoxy ENDP

CODESG ENDS

end _gotoxy

------------------------------------------------------------------------------
// module: modwasm.cpp

extern void gotoxy(int,int);

void main()
{
gotoxy(20,5);
}

--------------------------------------------------------------------------------

thank you for your help.

KnightMareMan
11-04-2001, 12:03 PM
tried that, still is being poopy. thanks for help.

Hillbillie
11-04-2001, 01:19 PM
What exactly does gotoxy() do? If it simply moves the hardware cursor, then just use port I/O in C/C++.

KnightMareMan
11-04-2001, 01:37 PM
well the reason why I wouldn't use that is, I want it exactly as I have it, I dont' want to call any functions other than gotoxy, and I need to figure out how to make this work.

Hillbillie
11-04-2001, 01:48 PM
Well, this function uses no external functions to move the hardware cursor. It's made for DJGPP, yet I haven't tested it in DOS.



signed short int Put_Cursor(unsigned short int col, unsigned short int row)
{
unsigned short int offset;

// If coordinates are legit, move that sucker.
if((col < 81) && (col > 0) && (row < 26) && (row > 0))
{
// Calculate offset.
offset = (row - 1) * 80 + (col - 1);

// Move it.
asm volatile ("outb %%al,%%dx": :"d" 0x3D4, "a" 0x0F);
asm volatile ("outb %%al,%%dx": :"d" 0x3D5, "a" ((unsigned char)(offset & 0xFF)));
asm volatile ("outb %%al,%%dx": :"d" 0x3D4, "a" 0x0E);
asm volatile ("outb %%al,%%dx": :"d" 0x3D5, "a" ((unsigned char)((offset >> 8) & 0xFF)));

return 0;
}

return -1;
}

KnightMareMan
11-04-2001, 02:38 PM
well thank you for your help, but thats not what im looking for, i don't want to use an inline assembler, I just want to be able to link the two .obj's together so I can call the assembly procedure from the C++ source code. thanks for your help thou.

Hillbillie
11-04-2001, 03:40 PM
Sorry I couldn't help. Check your compiler and linker documentation. I'm sure the answer is there.

forge
11-07-2001, 06:06 AM
Hi,

KnightMareMan

What about this statement?



CODESG SEGMENT PARA

PUBLIC gotoxy

gotoxy PROC FAR

KnightMareMan
11-09-2001, 04:31 PM
Well It just doesn't want to work, I will keep trying though, thank you all for the help.

~The Knight Mare Man

Unregistered
11-23-2001, 11:19 AM
Greetings,

Try this:

// module: modwasm.cpp

extern "C" void gotoxy(int,int);

void main()
{
gotoxy(20,5);
}

KnightMareMan
11-25-2001, 01:16 PM
Tried, and its still not working. Thanks anyway.

gnu-ehacks
11-25-2001, 05:34 PM
Would that code actually work? I never knew you could use ASM and C++ and link them together...Interesting...