help with inline asm

Hi i'm using dev-c++ compiler and i'm trying to use and inline asm clear screen function. i found this code on PH's boards:

[code]
void cls()
{
asm mov AH,2;
asm mov BH,0;
asm mov DX,0;
asm int 16 ;
asm mov AH,9;
asm mov CX,2000;
asm mov AL,' ';
asm mov BL,7;
asm int 16 ;
asm mov AH,2;
asm mov BH,0;
asm mov DX,0;
asm int 16 ;
}

[/code]

now when i tried to compile i got parse error before the first ah. i did some looking in the help files of dev-c++ and found this:

The assembler uses AT&T (not Intel). Here's an example of such a syntax :

[code]
__asm("mov %dx,%ax") ; // AX --> DX
[/code]

so i changed the code to that form. then i get a problem with the line:

[code]
__asm("int 16");
[/code]

it says "suffix or operands invalid for 'int'. Is there some other way i need to code this in the "AT&T assembler"? thanks for the help!

JJ


Comments

  • : Hi i'm using dev-c++ compiler and i'm trying to use and inline asm clear screen function. i found this code on PH's boards:
    :
    : [code]
    : void cls()
    : {
    : asm mov AH,2;
    : asm mov BH,0;
    : asm mov DX,0;
    : asm int 16 ;
    : asm mov AH,9;
    : asm mov CX,2000;
    : asm mov AL,' ';
    : asm mov BL,7;
    : asm int 16 ;
    : asm mov AH,2;
    : asm mov BH,0;
    : asm mov DX,0;
    : asm int 16 ;
    : }
    :
    : [/code]
    :
    : now when i tried to compile i got parse error before the first ah. i did some looking in the help files of dev-c++ and found this:
    :
    : The assembler uses AT&T (not Intel). Here's an example of such a syntax :
    :
    : [code]
    : __asm("mov %dx,%ax") ; // AX --> DX
    : [/code]
    :
    : so i changed the code to that form. then i get a problem with the line:
    :
    : [code]
    : __asm("int 16");
    : [/code]
    :
    : it says "suffix or operands invalid for 'int'. Is there some other way i need to code this in the "AT&T assembler"? thanks for the help!
    :
    : JJ
    :
    :
    :

    int 16h is the keyboard interrupt and it seems that you would need to use int 10h to clear the screen. Down load Ralph Brown's Interrupt list.
  • : : Hi i'm using dev-c++ compiler and i'm trying to use and inline asm clear screen function. i found this code on PH's boards:
    : :
    : : [code]
    : : void cls()
    : : {
    : : asm mov AH,2;
    : : asm mov BH,0;
    : : asm mov DX,0;
    : : asm int 16 ;
    : : asm mov AH,9;
    : : asm mov CX,2000;
    : : asm mov AL,' ';
    : : asm mov BL,7;
    : : asm int 16 ;
    : : asm mov AH,2;
    : : asm mov BH,0;
    : : asm mov DX,0;
    : : asm int 16 ;
    : : }
    : :
    : : [/code]
    : :
    : : now when i tried to compile i got parse error before the first ah. i did some looking in the help files of dev-c++ and found this:
    : :
    : : The assembler uses AT&T (not Intel). Here's an example of such a syntax :
    : :
    : : [code]
    : : __asm("mov %dx,%ax") ; // AX --> DX
    : : [/code]
    : :
    : : so i changed the code to that form. then i get a problem with the line:
    : :
    : : [code]
    : : __asm("int 16");
    : : [/code]
    : :
    : : it says "suffix or operands invalid for 'int'. Is there some other way i need to code this in the "AT&T assembler"? thanks for the help!
    : :
    : : JJ
    : :
    : :
    : :
    :
    : int 16h is the keyboard interrupt and it seems that you would need to use int 10h to clear the screen. Down load Ralph Brown's Interrupt list.
    :
    [blue]int 16 (decimal here, there is no 'h') - it is int 10h actually.[/blue]
  • I'm not familiar with AT&T syntax, but

    INT 10
    AH = 02h
    VIDEO - SET CURSOR POSITION

    DH,DL = row, column (0,0 = upper left)
    BH = page number
    0 in graphics modes
    0-3 in modes 2&3
    0-7 in modes 0&1

    INT 10
    AH = 09h
    VIDEO - WRITE ATTRIBUTES/CHARACTERS AT CURSOR POS

    AL = character
    BH = display page
    BL = attributes of char (alpha modes) or color (graphics modes)
    if bit 7 == 1 in graphics mode, character is xor'ed onto screen
    CX = number of times to write character
    Note: all characters are displayed, including CR, LF, and BS

    [code]
    mov ah, 09h
    mov dx, message ;print hello message
    int 21h

    mov ah, 08h ;wait for key press
    int 21h

    mov ah, 02h
    mov dx, 0000h ;set position of cursor to upper left of screen
    mov bh, 00h
    int 10h

    mov ah, 09h
    mov al, ' '
    mov bh, 00h
    mov cx, 07d0h ;blank the screen 80x25 times
    int 10h

    mov ah, 02h
    mov dx, 0000h ;set position of cursor to upper left of screen
    mov bh, 00h
    int 10h

    mov ah, 08h ;wait for key press
    int 21h

    mov ax, 4c00h ; terminate program
    int 21h


    message db "Hello", 13, 10, "$"

    [/code]

    I tried this .com program and it seemed to work right. Forgive me for my sloppy code, I wrote it in a hurry. But anyways it gives you an idea.

  • : [blue]int 16 (decimal here, there is no 'h') - it is int 10h actually.[/blue]
    :

    Thank you for pointing out my oversite. My fault for not catching it initially.
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