Results 1 to 15 of 15
  1. #1
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love

    [Help]Using BIOS interrupt 10h using inline asm crashes

    I tried making an alt. cls other than using

    system("cls");

    so i made this, but it crashes when it is supposed to clear the screen.

    [php]
    //lets make the asm section live dabid !!
    #include <iostream>
    using namespace std;

    void clearScr()
    {
    __asm
    {
    MOV AH,6h
    MOV AL,0
    MOV BH,7
    MOV CH,0
    MOV CL,0
    MOV DH,24
    MOV DL,79
    INT 10h
    }
    }

    int main()
    {
    cout << "Press enter to clear the screen using a BIOS interrupt\n";
    cin.get();

    /*------------------------------------------------*/

    clearScr(); //crashes D:

    /*------------------------------------------------*/

    return 0;
    }[/php]

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  2. #2
    -Raz0r-'s Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Australia
    Posts
    117
    Reputation
    15
    Thanks
    38
    My Mood
    Lurking
    Could be totally wrong, but try making that a __declspec(naked) function
    Languages: C, C++, x86 ASM, PHP, Lua

  3. #3
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by -Raz0r- View Post
    Could be totally wrong, but try making that a __declspec(naked) function
    Changing the function attribute to have no epilogue/prologue doesn't really change anything does it? Idk, I'm not too good at this.

    Maybe you could try compiling in 16-bit?

    I'm not really sure what it could be. |:

  4. The Following User Says Thank You to Void For This Useful Post:

    therofl (11-01-2010)

  5. #4
    -Raz0r-'s Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Australia
    Posts
    117
    Reputation
    15
    Thanks
    38
    My Mood
    Lurking
    Neither, I just tried playing around but I can't get any int 0x10's to work o_O
    I've only ever needed int 3 =D
    Languages: C, C++, x86 ASM, PHP, Lua

  6. #5
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by -Raz0r- View Post
    Neither, I just tried playing around but I can't get any int 0x10's to work o_O
    I've only ever needed int 3 =D
    I was able to use int 10 here: https://www.mpgh.net/forum/34-assembl...-assembly.html

    But that was all done in assembly and assembling in 16bit wasn't a problem for me. |:

    Idk what could be wrong with this. D:

  7. The Following User Says Thank You to Void For This Useful Post:

    therofl (11-01-2010)

  8. #6
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    daum /
    Could i link a seperate .com and call it with C++?

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  9. #7
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by Kallisti View Post
    daum /
    Could i link a seperate .com and call it with C++?
    Why would you do that? If you want to create a COM file from C++ and assembly, compile them both in 16 bit and use a 16 bit linker to link them using the tiny model.

  10. The Following User Says Thank You to Void For This Useful Post:

    therofl (11-01-2010)

  11. #8
    Kallisti's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,019
    Reputation
    52
    Thanks
    376
    My Mood
    In Love
    Quote Originally Posted by Void View Post
    Why would you do that? If you want to create a COM file from C++ and assembly, compile them both in 16 bit and use a 16 bit linker to link them using the tiny model.
    I mean make a COM from an ASM file

    [php].i386
    .model small
    .stack
    .data

    .code
    main proc
    MOV AH,6h
    MOV AL,0
    MOV BH,7
    MOV CH,0
    MOV CL,0
    MOV DH,24
    MOV DL,79
    INT 10h
    main endp
    end main[/php]

    and call it from C++?

    未来が見えなくて怖いから
    未来が見えてしまって悲しいから
    目を閉じて優しい思い出に浸ってしまう




  12. #9
    hobosrock696's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    45
    Reputation
    9
    Thanks
    1
    My Mood
    Mellow
    Wait isn't this being run in protected mode flat model? Doesn't protected mode have certain issues with certain interrupts. What I am saying could be irrelevant but I'm reading a book that mentioned something of that nature.

    What assembler is that syntax for? Also what linker. MAYBE that could be messing with it?
    Last edited by hobosrock696; 10-21-2010 at 10:04 PM.

  13. #10
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by hobosrock696 View Post
    Wait isn't this being run in protected mode flat model? Doesn't protected mode have certain issues with certain interrupts. What I am saying could be irrelevant but I'm reading a book that mentioned something of that nature.

    What assembler is that syntax for? Also what linker. MAYBE that could be messing with it?
    Actually, I've used interrupt 10 in protected mode before. See here: https://www.mpgh.net/forum/34-assembl...-assembly.html

    I eventually got it to work, but I didn't use inline assembly ( meaning I didn't use a C/C++ compiler ).

  14. The Following User Says Thank You to Void For This Useful Post:

    therofl (11-01-2010)

  15. #11
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Ah... I miss BA. I don't program assembly so, and if I do it's 32 bit, so I have no idea what's going on.

    I only think its curious that some of your numbers are in hex and the rest in decimal. That might be the problem but only a guess...

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  16. #12
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by why06 View Post
    Ah... I miss BA. I don't program assembly so, and if I do it's 32 bit, so I have no idea what's going on.

    I only think its curious that some of your numbers are in hex and the rest in decimal. That might be the problem but only a guess...
    I didn't notice that.

    Patrick, if you want the assembler to assume those numbers as hex you have to use the suffix 'h' at the end. Otherwise it assumes them to be of base 10. If you want the assembler to see it as binary for any reason, use the 'b' suffix.

  17. The Following User Says Thank You to Void For This Useful Post:

    therofl (11-01-2010)

  18. #13
    hobosrock696's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    45
    Reputation
    9
    Thanks
    1
    My Mood
    Mellow
    Hey void wait did you solve that last problem in the thread you linked by using the segmented model? I did a char by char program for dos with a certain char meaning next line and i thought i had to use segmented to gain control of the segment registers....

    Also change your first two lines of asm to

    mov ax, 600H

    That will move 6 into ah and 0 into all in one swift move
    also yea add the h at the end

    MOV CH,0
    MOV CL,0

    change to

    mov cx, 0h

    and this
    MOV DH,24
    MOV DL,79

    to

    mov dx, 2479h

    Thatl make for less and slightly faster code XD (as if it was slow before...)

  19. #14
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by hobosrock696 View Post
    Hey void wait did you solve that last problem in the thread you linked by using the segmented model? I did a char by char program for dos with a certain char meaning next line and i thought i had to use segmented to gain control of the segment registers....

    Also change your first two lines of asm to

    mov ax, 600H

    That will move 6 into ah and 0 into all in one swift move
    also yea add the h at the end

    MOV CH,0
    MOV CL,0

    change to

    mov cx, 0h

    and this
    MOV DH,24
    MOV DL,79

    to

    mov dx, 2479h

    Thatl make for less and slightly faster code XD (as if it was slow before...)
    Yeah, but my way is much easier to follow. I'm not a super pro at asm \:

  20. #15
    hobosrock696's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Posts
    45
    Reputation
    9
    Thanks
    1
    My Mood
    Mellow
    Thats true but in that case comment your lines

    The rule for assembly is MINIMUM 1 comment per line but good practice is a comment per line plus a comment per block of code.

    Yeah and from what I have read that code should work perfectly... Please post back if you fix it. I would like to know whats wrong here. Personally I would write a function that doesn't use a call. If you want such a function I have written some code that does exactly that but you might have to modify it slightly to clear the screen I'd be happy to share as soon as I can get my assembly off of my dos machine which will be when I get my pc with a floppy drive running so I will have a way of transferring my code.
    Last edited by hobosrock696; 10-22-2010 at 08:57 PM.

Similar Threads

  1. [Source Code] (16 Bit..DOS ONLY) C++ using Assembly BIOS interrupts, draw rectangle
    By Auxilium in forum C++/C Programming
    Replies: 9
    Last Post: 05-28-2011, 05:53 AM
  2. Help using Seans chams and i lag?
    By almia101 in forum Combat Arms Help
    Replies: 0
    Last Post: 02-01-2010, 03:42 PM
  3. [Help] Using dim's from Public Functions
    By apezwijn in forum Visual Basic Programming
    Replies: 4
    Last Post: 10-10-2009, 10:05 AM
  4. Help using haks pls
    By mpghisawesome in forum General Hacking
    Replies: 0
    Last Post: 03-06-2009, 06:48 PM
  5. Help using hacks
    By rigedw00t in forum Operation 7 General
    Replies: 0
    Last Post: 02-07-2009, 07:18 PM