Queries in 80x86 Assembly Language Programming
Results 1 to 7 of 7

Thread: Queries in 80x86 Assembly Language Programming

  1. #1
    Junior Member
    Join Date
    Jan 2003
    Posts
    18

    Queries in 80x86 Assembly Language Programming

    8086 Assembly language programming posted Today 06:59 PM
    (post #10)

    Hey guys, i'm writing a code in assembly language using Turbo Assembler 2.0. If anybody out there is using it too then maybe you can help me with my question. ( I just hope cheeseball can read this.)

    I'm creating in assembly language a game. To provide a good user interface i have a module
    which invokes function 06h of BIOS int 10h to
    create a window (with shadow). the width and height of the window depends on the coordinates passed into the stack. the color is also passed to the stack.

    (i'll just strip the lines which gets parameters from the stack)

    In assembly, I'll only invoke function 06 of int 10 like this:

    module proc near
    ;(assume that these comment lines are the codes which get parameters
    ;(from the stack

    mov ah, 06 ; create window
    mov al, 00
    mov bh, 17h ; assume that these are the actual parameters
    mov cx, 0a14h
    mov dx, 143dh
    int 10h

    ret
    module endp

    now, my problem is when i try to remove the window, the underlying screen data is removed too.

    how do i display this window so that when i remove it, the underlying data is also preserved?
    And, how do I allocate memory dynamically in assembly?


    __________________
    Turn on. Tune in. Drop out.
    Turn on. Tune in. Drop out.

  2. #2
    Banned
    Join Date
    Dec 2002
    Posts
    394
    Hello frz,
    I might can point U in the right direction, but I use NASM for assembling code. Even thou that really doesn't matter which assembler you use the code will be the same just different in invoking the assembler. Looking at your code:

    mov ah,06
    mov al, 00
    mov bh, 17h
    mov cx, 0a14h
    mov dx, 143dh
    First why write a 16-bit game? Nevermind! Still let's optimise this code.

    mov ah, 06h ;2bytes
    mov al, 00h ;2bytes
    ;total 4 bytes
    replace with:
    mov ax 0600h ;3 bytes, save one
    (U don't have to use my suggest it's only purpose is for faster execution )

    OK back to your ? Memory try : 48ah -allocates mem
    bx - # of paragraphs of mem requested
    int 21h

    There is different ways of doing this with different interrupts. Get a copy of Ralf Brown's Interrupt list it contains documented and undocumented int's and functions.

    [shadow]asm will give U a rope to hang yourself if not careful[/shadow]

  3. #3
    Junior Member
    Join Date
    Jan 2003
    Posts
    18
    HI phaza27. Thanks for the kind words. Well, I'm writing a 16-bit game for the simple reason that I wanted to challenge myself how to create a really functional program in assembly language. I want to feel the thrill.

    Yes, I tried to use function 48 of interrupt 21. I tried to allocate a memory dynamically of 4k bytes (4*1024) but you know what? it returns an error and returns the highest memory that can be allocated in BX which is BX=0004!

    gosh! I can't work on with 4 bytes of memory ( that is if 0004 is really 0004 not 0400 (you know, back-words storage)! I tried anyway to allocate memory greater than 0004 and i still have an error. I run the program in DOS 6.22 (gee!) and also used mem to see the memory blocks and i found i have lots of them. So, what do you think is wrong? And by the way,
    I still have my old problem: that is, let's say I have a screenful of data , well, on the screen. Now, I want to display the window on top of it by calling my module which invokes function 06 of interrupt 10. Now, after displaying the window in the given coordinates with the given width and height and deciding to remove it and go back to the original screenful of data, it leaves a gaping hollow square right on the screen. So, how do I display the window in such a way that when I remove it, the underlying data is still there?


    (i'll try also to check out ralph brown's interrupt list. ciao! thanks by the way for taking the time to reply.)
    Turn on. Tune in. Drop out.

  4. #4
    Banned
    Join Date
    Dec 2002
    Posts
    394
    Try using int2f it is also use to allocate mem for as your screen poblem I will look around and C If i can help.

  5. #5
    Junior Member
    Join Date
    Jan 2003
    Posts
    18
    Thanks a lot. I'll try to explore int2f. And I still haven't had the chance to see ralph brown's interrupt list.
    Turn on. Tune in. Drop out.

  6. #6
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    OK, I don't quite remember how this works, but you have
    four display pages of video memory available.

    Code:
    mov ax,0003           ;set video mode #3 (also clears screen)
    int 10                ;BIOS video services
    mov ax,09db           ;write character # DB hex
    mov bx,0001           ;display page #0,char attribute #01 (blue)
    mov cx,07d0           ;# of repetitions of char to fill screen
    int 10                ;BIOS video services
    The above code will fill the screen with blue characters, effectively
    turning the screen blue.
    The line that says MOV BX, 0001 uses display page 00, because
    BH is set to 00

    If I said MOV BX, 0101, Iwould be using display page 01.
    Now, I don't know the details in your case, but if you set up
    your window in another display page than the default 00,
    you may preserve the other page beneath it, so it will still
    be there when the window is gone.
    I came in to the world with nothing. I still have most of it.

  7. #7
    Junior Member
    Join Date
    Jan 2003
    Posts
    18

    Thumbs up thanks rcgreen. it works!

    hi rcgreen. thanks for the nice tip. I see what you mean. Yes, there are four 'display pages' in video memory. and by using different video page other than the default page of my program, I I can 'pop-up' my window on the new video page and then switch to my default page to go back to my previous screen data. In this case, the data is preserved.

    Yes it works!!!

    But one thing I noticed is this: when i display the characters in a different video page, the old screen is 'lost' (it's as if I executed a command to clear the screen and then display the window afterwards. it would be very nice however if my window just 'float' above my screen data just like how other programs work) and i'm left with the single window on the new screen. ( but of course, when i switch back to my old screen page the data is back).

    What I want to happen is this: to display the new window on top of my previous screen data without 'clearing the screen' and then remove the window without leaving a hollow area and return to my previous screen data.

    I'll keep working on it and I'll tell you the update about my program in assembly. And then if I have some difficulty, I'll just tell you about it. Ok?

    Thanks a lot.
    In our country ( philippines ) we say 'salamat', which means thank you.
    Again, salamat.
    Turn on. Tune in. Drop out.

Posting Permissions

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