Results 1 to 34 of 34

Thread: VC++ Help plz...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312

    VC++ Help plz...

    right, i need to write in some ASSEMBLY, in VC++, anyone know how to do this???

    thanx

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    yeah thanx, EAX is set to 13

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    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

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    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

  6. #6
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post 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

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    assmebly compiles straight into system code and so its faster...

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    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

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  11. #11
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    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!

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  14. #14

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    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

  15. #15

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    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
    Last edited by JafferAB; Sep 13th, 2001 at 05:09 PM.

  16. #16
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  17. #17

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    ahh nuts, ive been working on this allll day

    suppose i shoud try and get DJGPP to work

  18. #18
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  19. #19

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    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

  20. #20
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Don't bother trying to do graphics if you're only just learning.

    PS:
    Code:
    #include "stdafx.h"
    #include "stdio.h"
    Change this to:
    Code:
    #include <stdio.h>
    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

  21. #21

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    right, im not learning asm, im learning C, the tutorial told me to do it this way

    and it dont work without stdafx.h

    and it DOES work with CPP extention

  22. #22
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  23. #23
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  24. #24

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    thanx fo rthe procompiler info bee, and it does exactly the saem when the filename is C and not CPP

  25. #25
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  26. #26

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    England
    Posts
    312
    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

  27. #27
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73
    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);
    }

  28. #28
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  29. #29
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73
    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);
    }

  30. #30
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  31. #31
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73
    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);
    }

  32. #32
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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

  33. #33
    Lively Member
    Join Date
    Dec 2000
    Location
    Indiana
    Posts
    73
    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);
    }

  34. #34
    Fanatic Member MoMad's Avatar
    Join Date
    Oct 2000
    Location
    Seattle, WA
    Posts
    625
    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.
    :MoMad:
    Nice Sig!

    http://go.to/momad/ Status: Not Ready

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width