|
-
Sep 12th, 2001, 04:51 PM
#1
Thread Starter
Hyperactive Member
VC++ Help plz...
right, i need to write in some ASSEMBLY, in VC++, anyone know how to do this???
thanx
-
Sep 12th, 2001, 05:09 PM
#2
Monday Morning Lunatic
Certainly. Use the __asm keyword:
Code:
int function() {
__asm {
mov eax, 5
}
}
You can ignore the "no return value" warnings as long as you set EAX to something.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 12th, 2001, 05:18 PM
#3
Thread Starter
Hyperactive Member
yeah thanx, EAX is set to 13
-
Sep 13th, 2001, 01:51 AM
#4
Thread Starter
Hyperactive Member
righty ho, thats all well and good and im getting less errors now, but i am still getting some i cant work out looksee
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!
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...
The things in red are commends by me in the code to tell you the lines of the errors 
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
-
Sep 13th, 2001, 01:52 AM
#5
Thread Starter
Hyperactive Member
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
-
Sep 13th, 2001, 07:13 AM
#6
Fanatic Member
Hi
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?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Sep 13th, 2001, 09:49 AM
#7
Thread Starter
Hyperactive Member
assmebly compiles straight into system code and so its faster...
-
Sep 13th, 2001, 10:09 AM
#8
Thread Starter
Hyperactive Member
righty ho, i have this now, which works with 1 warning...
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);
}
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!
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
-
Sep 13th, 2001, 10:48 AM
#9
Either use void Assembly() or return a value.
"%s" gets a string, use
char testing[100];
and use
scanf("%s", testing);
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 13th, 2001, 10:49 AM
#10
And I'm not sure if windows allows you to use that interrupt.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 13th, 2001, 11:26 AM
#11
Monday Morning Lunatic
Also, you didn't actually call the function
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 13th, 2001, 04:44 PM
#12
Thread Starter
Hyperactive Member
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);
}
right, this works, but it doesnt do anything atall apart from the MAIN function, the assembly bit is totally missed out!
-
Sep 13th, 2001, 04:47 PM
#13
Monday Morning Lunatic
Just because you defined a function doesn't mean it gets called. You have to add an assembly(); line (pun intended ) into main().
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 13th, 2001, 04:49 PM
#14
Thread Starter
Hyperactive Member
-
Sep 13th, 2001, 05:04 PM
#15
Thread Starter
Hyperactive Member
-
Sep 13th, 2001, 05:12 PM
#16
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 13th, 2001, 05:22 PM
#17
Thread Starter
Hyperactive Member
-
Sep 13th, 2001, 05:35 PM
#18
Monday Morning Lunatic
I suppose. It's not *that* difficult 
Anyway, there are better graphics alternatives now, especially since direct hardware access is forbidden under NT.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 14th, 2001, 02:17 AM
#19
Thread Starter
Hyperactive Member
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
-
Sep 14th, 2001, 03:40 AM
#20
Monday Morning Lunatic
Don't bother trying to do graphics if you're only just learning.
PS:
Code:
#include "stdafx.h"
#include "stdio.h"
Change this to:You don't need stdafx.h (it's inserted by VC++6), and system includes should have angle-brackets round them.
Also, rename your source file to have a .c extension, which will make it compile as C rather than C++.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 14th, 2001, 06:44 AM
#21
Thread Starter
Hyperactive Member
-
Sep 14th, 2001, 07:57 AM
#22
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
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 14th, 2001, 08:15 AM
#23
Monday Morning Lunatic
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:
Code:
void function(void) {
int val;
val = 5;
int other = val * 2;
}
(One of the things about C is that all variables must be declared at the start of the block).
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 14th, 2001, 09:55 AM
#24
Thread Starter
Hyperactive Member
thanx fo rthe procompiler info bee, and it does exactly the saem when the filename is C and not CPP
-
Sep 14th, 2001, 11:12 AM
#25
Monday Morning Lunatic
Then that means that you wrote good C code, well done :thumbsup: (damn we still need that smiley! )
It's best to force C compilation if you want to write in C.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 14th, 2001, 04:50 PM
#26
Thread Starter
Hyperactive Member
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 )
thanx n e way peeps
-
Sep 15th, 2001, 08:47 PM
#27
Lively Member
I actually prefer using C++.... its more flexible, has more features, and all C code is valid C++ code.
if(GetWindowLong(hwnd,GWL_ID)==IDC_MICROSOFT_APPLICATION)
{
SetWindowText(hwnd,"I suck.");
SendMessage(hwnd,WM_START_SUCKING,0,0);
SendMessage(hwnd,WM_CRASH,0,0);
}
-
Sep 16th, 2001, 05:22 AM
#28
Monday Morning Lunatic
Originally posted by TadaTensai
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 16th, 2001, 08:31 AM
#29
Lively Member
ooo..... never really noticed that, but now that you mention it.......
Is there a way to compile as C code in VisualC++?
if(GetWindowLong(hwnd,GWL_ID)==IDC_MICROSOFT_APPLICATION)
{
SetWindowText(hwnd,"I suck.");
SendMessage(hwnd,WM_START_SUCKING,0,0);
SendMessage(hwnd,WM_CRASH,0,0);
}
-
Sep 16th, 2001, 08:34 AM
#30
Monday Morning Lunatic
Use a .c extension on your source file
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 16th, 2001, 11:32 AM
#31
Lively Member
oh, alrighty then, thanks... Argh, damn popup window
if(GetWindowLong(hwnd,GWL_ID)==IDC_MICROSOFT_APPLICATION)
{
SetWindowText(hwnd,"I suck.");
SendMessage(hwnd,WM_START_SUCKING,0,0);
SendMessage(hwnd,WM_CRASH,0,0);
}
-
Sep 16th, 2001, 01:29 PM
#32
Monday Morning Lunatic
The Sprinks one? Use custard-flavoured VBSquare style
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Sep 16th, 2001, 06:30 PM
#33
Lively Member
I actually [U}prefer[/U] that one....
How can I use it for these boards?
if(GetWindowLong(hwnd,GWL_ID)==IDC_MICROSOFT_APPLICATION)
{
SetWindowText(hwnd,"I suck.");
SendMessage(hwnd,WM_START_SUCKING,0,0);
SendMessage(hwnd,WM_CRASH,0,0);
}
-
Sep 16th, 2001, 06:34 PM
#34
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|