right, i need to write in some ASSEMBLY, in VC++, anyone know how to do this???
thanx
Printable View
right, i need to write in some ASSEMBLY, in VC++, anyone know how to do this???
thanx
Certainly. Use the __asm keyword:You can ignore the "no return value" warnings as long as you set EAX to something.Code:int function() {
__asm {
mov eax, 5
}
}
yeah thanx, EAX is set to 13 :D
righty ho, thats all well and good and im getting less errors now, but i am still getting some i cant work out :( looksee
this is meant to go into fullscreen 320x300 (i tihnk) in 256 colors, then print TESIN on the screen and waity for a little user input, but i get these errors...Code:#include "stdafx.h"
#include "stdio.h"
int function() {
__asm {
mov eax, 0x13
int ox10
Line 13 }
int main(void)
Line 17 {
char testing;
printf("testing");
scanf("%s", testing);
return(0);
}
Line 14, and there is nothing here!
The things in red are commends by me in the code to tell you the lines of the errors :D
C:\My Coding Stuff\C\my first pixel\my first pixel.cpp(13) : error C2415: improper operand type
C:\My Coding Stuff\C\my first pixel\my first pixel.cpp(17) : error C2601: 'main' : local function definitions are illegal
C:\My Coding Stuff\C\my first pixel\my first pixel.cpp(24) : fatal error C1004: unexpected end of file found
ok then, lol, i just saw the ox10 instead of 0x10, so thats fixed now and the error that is on line 13 and is
C:\My Coding Stuff\C\my first pixel\my first pixel.cpp(13) : error C2415: improper operand type
is gone now :D
Hi I am new to VC++ I don't know how to write programs in VC++ nor Assembly. Can you?
Well, what's the advantage of assembly?
assmebly compiles straight into system code and so its faster...
righty ho, i have this now, which works with 1 warning...
right. it works, but, the assembly i did, what exactly will it do, i learned it in a tutorial, and its meant to make it fullscreen, and it did nothing!Code:// my first pixel.cpp :
//
//how to make a PIXEL (YES A WHOLE ONE!!!! :D)
//a stepping stone in the way of C/Assembly for me
//Alex Bunting
#include "stdafx.h"
#include "stdio.h"
int assembly()
{
__asm {
mov eax, 0x13
int 0x16
}
}
int main(void)
{
char testing;
printf("testing...type something : ");
scanf("%s", &testing);
return(0);
}
any help plz, the warning i get is
C:\My Coding Stuff\C\my first pixel\my first pixel.cpp(22) : warning C4035: 'assembly' : no return value
Either use void Assembly() or return a value.
"%s" gets a string, use
char testing[100];
and use
scanf("%s", testing);
And I'm not sure if windows allows you to use that interrupt.
Also, you didn't actually call the function :)
right, this works, but it doesnt do anything atall apart from the MAIN function, the assembly bit is totally missed out!Code:// my first pixel.cpp :
//
//how to make a PIXEL (YES A WHOLE ONE!!!! :D)
//a stepping stone in the way of C/Assembly for me
//Alex Bunting
#include "stdafx.h"
#include "stdio.h"
void assembly()
{
__asm {
mov eax, 0x13
int 0x1
mov eax, 0x13
int 0x19
}
}
int main(void)
{
char testing[100];
printf("testing...type something : ");
scanf("%s", &testing);
return(0);
}
Just because you defined a function doesn't mean it gets called. You have to add an assembly(); line (pun intended :p) into main().
ahhh, thanx alot for that, ididnt know how to call a function, hehehe, thanx alot, it goes wrong now, but at least i know its trying to work :D:D:D
ohhh bugger :( how do i gettit to directly access the vido memory??? i can for DJGPP but i dont have that :(
and :(:(:( what are the VC++ equivalents of these DJGPP header files...
go32.h
dpmi.h
sys/nearptr.h
thanx alot :P
You can't, sorry. It doesn't work like that under windows.
go32.h - DPMI
dpmi.h - DPMI
sys/nearptr.h - segmented pointers
They're all pointless in a 32-bit protected mode environment.
To access the video memory or the closest thing to it requires DirectX in some form, I'm afraid.
ahh nuts, ive been working on this allll day :(
suppose i shoud try and get DJGPP to work :(:(
I suppose. It's not *that* difficult ;)
Anyway, there are better graphics alternatives now, especially since direct hardware access is forbidden under NT.
hehehe, im using NT 5, lol, anyways, im only a biginner at C, and was trying to learn in C how to do GFX :(
Thanx all anyways
Don't bother trying to do graphics if you're only just learning.
PS:Change this to:Code:#include "stdafx.h"
#include "stdio.h"
You don't need stdafx.h (it's inserted by VC++6), and system includes should have angle-brackets round them.Code:#include <stdio.h>
Also, rename your source file to have a .c extension, which will make it compile as C rather than C++.
right, im not learning asm, im learning C, the tutorial told me to do it this way :D:D:D
and it dont work without stdafx.h
and it DOES work with CPP extention :D:D:D
to make it work without stdafx.h you ether have to create an empty project at the beginning or later select "don't use precompiled header" in project->settings->linker->precompiled header
It may well compile as C++, but you're not learning C then, you're learning C++.
Trust me, you'll be much better off using a .c extension or weird things happen. For example, this is valid C++, but not valid C:(One of the things about C is that all variables must be declared at the start of the block).Code:void function(void) {
int val;
val = 5;
int other = val * 2;
}
thanx fo rthe procompiler info bee, and it does exactly the saem when the filename is C and not CPP
Then that means that you wrote good C code, well done :thumbsup: (damn we still need that smiley! :D)
It's best to force C compilation if you want to write in C.
lol, ok, but tid alot of bother for me, VC++ likes to mess me around when i try and change the filename (int he program :D)
thanx n e way peeps
I actually prefer using C++.... its more flexible, has more features, and all C code is valid C++ code.
Wrong, I'm afraid. C lets you get away with a lot that C++ won't. For example, C will do automatic pointer conversion - with C++ you have to explicitly cast them.Quote:
Originally posted by TadaTensai
all C code is valid C++ code.
ooo..... never really noticed that, but now that you mention it.......
Is there a way to compile as C code in VisualC++?
Use a .c extension on your source file :)
oh, alrighty then, thanks... Argh, damn popup window
The Sprinks one? Use custard-flavoured VBSquare style :)
I actually [U}prefer[/U] that one....
How can I use it for these boards?
Hey Jafer, C and C++ are great languages to learn and they take time... also, it takes time and practice to learn them.
You can learn C and then after that, learn C++. You see, the basics are the same in both. C++ is just a v2.0 (so to say) of C (if you get my drift). Anyways, the only difference in C and C++ besides the fact that classes and templates and improved macros and inline and const and single line comments and improved casting are all added to the language, is absolutely nothing more than a mere change of the file extention :)
You can learn alot of stuff about C/C++ in many places, books for example. If you are like me and prefer lots of examples and code instead of just reading all day... you might want to try the following:
Planet Source Code
http://www.planetsourcecode.com/
CProgramming
http://www.cprogramming.com/
C++ Made Easy (made by myself and a friend:))
http://library.thinkquest.org/C0111571/
Sam's Teach Yourself C++ in 21 days
http://newdata.box.sk/bx/c/
C++ dot com
http://www.cplusplus.com/
and of course loads more.,...
http://www.free-ed.net/catalog/crsem...nC=3&nD=2&nO=3
Good luck.