inline asm

Im just learning assembler programming and im trying to use it inline in a c++ program using

__asm, i tried some of the dos functions and they fail miserably ex.. print a char 'a'

main()

{

__asm {

mov dl, 'a'

mov ah, 2

int 21H

} //compiles but causes the program to crash



return 0;

}

what am i doing wrong



also if it is possible how to i use a c variable in assembler




Comments

  • your code work jes' fine here. prob'ly a bug in some other part of the proggy


  • Hope your not using VC++ to compile that.



    : your code work jes' fine here. prob'ly a bug in some other part of the proggy

    :






  • : Hope your not using VC++ to compile that.

    :

    : : your code work jes' fine here. prob'ly a bug in some other part of the proggy

    : :

    :

    :

    :

    I am using vc++, why wont that work ??

    I tried to look it up i think it may be because

    i need to use AT&T syntax, or something, theres

    nothing on the internet about it.



    But please tell me why not vc++!!!

    Thanks.








  • Because VC++ cant do DOS, that black box that opens up and looks like good old 16-bit DOS is not DOS, its called 32-bit console mode. There's no difference really here than trying to run those lines in Linux, each is a different OS.



    I heard Borland has its DOS Turbo C compiler to download for free on their site, or you can always download the free djgpp compiler if you want..



    : : Hope your not using VC++ to compile that.

    : :

    : : : your code work jes' fine here. prob'ly a bug in some other part of the proggy

    : : :

    : :

    : :

    : :

    : I am using vc++, why wont that work ??

    : I tried to look it up i think it may be because

    : i need to use AT&T syntax, or something, theres

    : nothing on the internet about it.

    :

    : But please tell me why not vc++!!!

    : Thanks.

    :

    :

    :

    :






  • Are you calling software interrupts from a Win32 machine? Try running it in a pure DOS environment. If you're using Win95(other), I think you should use the corresponding APIs (or GetProcAddress, etc. and push your values).



    : Im just learning assembler programming and im trying to use it inline in a c++ program using

    : __asm, i tried some of the dos functions and they fail miserably ex.. print a char 'a'

    : main()

    : {

    : __asm {

    : mov dl, 'a'

    : mov ah, 2

    : int 21H

    : } //compiles but causes the program to crash

    :

    : return 0;

    : }

    : what am i doing wrong

    :

    : also if it is possible how to i use a c variable in assembler

    :

    :






Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories