Howdy, Stranger!

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

Categories

[advise please] unable to run 16bit macro in 32bit masm. [thank you]

ciellecielle Member Posts: 11
[color=Blue]hi al,

I would like to asking for advises regarding on the application of macros in 32bit masm.

i have 3 macro as shown below. These macros function smoothly when i apply them in masm 16 bit. Yet, when i tried to apply the same macros in masm 32-bit, program is forced to be terminated (window error occur).

What should i modify on the macros so that they are application in masm 32 bit? and what is the reason of these problem? Isn't macro should be applicable for either 16 or 32 bits?[/color]

*************************macros************************

;-------------------- macro to clear part --------------------
CLEAR MACRO start_xy, end_xy
mov ax,0600H
mov cx,start_xy
mov dx,end_xy
mov bh,7
int 10h
mov ah,2
mov bh,0
mov dx,0
int 10h
ENDM

;----------------- macro to set colour window ----------------
SET_WINDOW MACRO COLOUR, START_XY, END_XY
mov ax,0600h ; scroll window
mov bh,COLOUR ; background, font
mov cx,START_XY ; coordinate start point
mov dx,END_XY ; coordinate end point
int 10h
ENDM

;---------------- macro to produce end of line ----------------
ENDL MACRO
mov ah,2
mov dl,CR
int 21h
mov ah,2
mov dl,LF
int 21h
ENDM




[color=Blue]Thanks for your reply.:)

cielle[/color]
«1

Comments

  • jeffleydajeffleyda Member Posts: 390
    you cannot call INT functions from win32. win32 is protected mode, INT functions are real mode.


  • ciellecielle Member Posts: 11
    : you cannot call INT functions from win32. win32 is protected mode,
    : INT functions are real mode.
    :
    :
    :


    [size=5]Thanks for your prompt reply.[/size][size=3][color=Green][b][/b][/color][/size]

    So is that means that there is no way for me to apply those macros in 32bit?

    If so is how should i modify the existing (found in masm32 include file)

    (i) clearscreen proc so that i can clear part of the screen but not the entire screen? s
    (ii)settextcolour proc so that i can set the background colour depends on my desired area but not only the area with string?


    Thank u again..
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : : you cannot call INT functions from win32. win32 is protected mode,
    : : INT functions are real mode.
    : :
    : :
    : :
    :
    :
    : [size=5]Thanks for your prompt
    : reply.[/size][size=3][color=Green][b][/b][/color][/size]
    :
    : So is that means that there is no way for me to apply those macros
    : in 32bit?
    :
    : If so is how should i modify the existing (found in masm32 include
    : file)
    :
    : (i) clearscreen proc so that i can clear part of the screen but not
    : the entire screen? s
    : (ii)settextcolour proc so that i can set the background colour
    : depends on my desired area but not only the area with string?
    :
    :
    : Thank u again..
    :
    [color=Blue]
    In Windows to work on console window you need console API calls from that list:

    [link=http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx]http://msdn.microsoft.com/en-us/library/ms682073(VS.85).aspx[/link]
    [/color]
  • ciellecielle Member Posts: 11
    thanks for your prompt reply.

    But wat should i do to achieve the purpose to set the colour for desired area only but not on the GUI application?

    actually, i would like to write a program which is all about piano keyboard tutorial. i nid the respective key to be coloured when its respective note is played.

    But now the problem is i can;t implement the macro which i usually use in 16 masm to set certain area of background colour.

    i have to use 32 masm due to vista can;t play the frequency smoothly in 16 bits. I have to apply finale software to give me the music output.



    realy many thanks on your advise.
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : thanks for your prompt reply.
    :
    : But wat should i do to achieve the purpose to set the colour for
    : desired area only but not on the GUI application?
    :
    : actually, i would like to write a program which is all about piano
    : keyboard tutorial. i nid the respective key to be coloured when its
    : respective note is played.
    :
    : But now the problem is i can;t implement the macro which i usually
    : use in 16 masm to set certain area of background colour.
    :
    : i have to use 32 masm due to vista can;t play the frequency smoothly
    : in 16 bits. I have to apply finale software to give me the music
    : output.
    :
    :
    :
    : realy many thanks on your advise.
    :
    [color=Blue]Strange... the link from my post does not work. Did you try to go by the link by copying it into browser?

    Anyhow,

    The function you need is here:

    [link=http://msdn.microsoft.com/en-us/library/ms682662(VS.85).aspx]http://msdn.microsoft.com/en-us/library/ms682662(VS.85).aspx[/link]

    Say, you have the area of text on a console window and you need to set the background for the area to some specific color - to highlight it. You need to use this function on each row of text from that area.
    [/color]
  • ciellecielle Member Posts: 11
    [color=Blue]Thank you ASMGURU.[/color]

    i have study a bit of the function from the link given by you.
    Yet i need to put more effort to understand it as i m not that familiar with masm32 bit.
    Previously only deal with masm16.

    Lets say i wish to set the color for area start with [color=Red]coordinate 0010h until 0439h[/color]. Is it possible for me to do that by using FillConsoleOutputAttribute Function? as i notice its decription says that colour only cover area which contain string with it. But my purpose is colour the background on my own desired area.

    I can set the background colour start with coordinate 0010h until 0439h by using the macros below.

    [color=Green]SET_WINDOW MACRO [color=Red]COLOUR, START_XY, END_XY [/color]
    mov ax,0600h ; scroll window
    mov bh,COLOUR ; background, font
    mov cx,START_XY ; coordinate start point
    mov dx,END_XY ; coordinate end point
    int 10h
    ENDM[/color]


    Yet i can't use this bcoz it is in real mode.
    Masm32 run in protected mode.

    But can i modify the macro so that it can run in masm32?
    If that is impossible, i will try hard to understand the FillConsoleOutputAttribute.

    Sorry that if i kips on repeating the question as i m still have to digest the link that given by ASMGURU.

    MASM32 is confusing... -.-!!

    Thanks again!!!

    Regards,
    CIelle
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : [color=Blue]Thank you ASMGURU.[/color]
    :
    : i have study a bit of the function from the link given by you.
    : Yet i need to put more effort to understand it as i m not that
    : familiar with masm32 bit.
    : Previously only deal with masm16.
    :
    : Lets say i wish to set the color for area start with
    : [color=Red]coordinate 0010h until 0439h[/color]. Is it possible for
    : me to do that by using FillConsoleOutputAttribute Function? as i
    : notice its decription says that colour only cover area which contain
    : string with it. But my purpose is colour the background on my own
    : desired area.
    :
    : I can set the background colour start with coordinate 0010h until
    : 0439h by using the macros below.
    :
    : [color=Green]SET_WINDOW MACRO [color=Red]COLOUR, START_XY, END_XY
    : [/color]
    : mov ax,0600h ; scroll window
    : mov bh,COLOUR ; background, font
    : mov cx,START_XY ; coordinate start point
    : mov dx,END_XY ; coordinate end point
    : int 10h
    : ENDM[/color]
    :
    :
    : Yet i can't use this bcoz it is in real mode.
    : Masm32 run in protected mode.
    :
    : But can i modify the macro so that it can run in masm32?
    : If that is impossible, i will try hard to understand the
    : FillConsoleOutputAttribute.
    :
    : Sorry that if i kips on repeating the question as i m still have to
    : digest the link that given by ASMGURU.
    :
    : MASM32 is confusing... -.-!!
    :
    : Thanks again!!!
    :
    : Regards,
    : CIelle
    :
    [color=Blue]
    I see, when you say coordinate - you mean the row,col pair of values stored in a register.

    In short, you need a new macro, even better - a new function, because macro will be quite long, because it will be a loop.

    So, lets look at FillConsoleOutputAttribute():
    [/color]
    [code]
    invoke FillConsoleOutputAttribute, hConsole, color,
    nChars, coord, addr dwFilled
    [/code]
    [color]
    hConsole = a handle to Console returned by call to GetStdHandle().
    color = an attribute you want to apply on console characters.
    nChars = how many characters you want to highlight.
    coord = row,col of a location you want to begin highlighting.
    dwFilled = a DWORD variable which will be set to real character count of filled characters. Usually not used - just pass some address.

    Example: you need to highlight a rectangle with:

    left column = 10
    top row = 4
    right column = 50
    bottom row = 12

    You need to call the function for each row in that rectangle. Number of rows = 1+(12-4) = 9. nChars parameter is a rectangle width = 1+(50-10) = 41. So, you need a loop of 9 times and you need to pass the proper coord parameter for each row.
    [/color]
  • ciellecielle Member Posts: 11
    [color=Blue]Hi ASMGURU. Thanks for your explaination.

    I tried to implement the function. Code can be assemble. Yet it shows nthg.

    I tried to get a rectangle manualy (without using loop) for 1st trial.
    Yet i failed. Below is my code. Kindly advise me pls where is my mistake[/color].

    .486
    .model flat, stdcall
    option casemap :none

    include masm32includewindows.inc
    include masm32includeuser32.inc
    include masm32includekernel32.inc
    include masm32includeadvapi32.inc ; needed for Registry functions
    include C:Masm32INCLUDEmasm32.inc
    include C:Masm16INCLUDEwinmm.inc ; multimedia for music playback

    include C:Masm615INCLUDEmacros.asm ; MASM support macros

    includelib masm32libuser32.lib
    includelib masm32libkernel32.lib
    includelib masm32libadvapi32.lib ; needed for Registry functions

    includelib C:Masm16libmasm32.lib
    includelib C:Masm16libwinmm.lib ; multimedia for music playback



    .code
    main:

    ;invoke FillConsoleOutputAttribute, hConsole, color,
    Chars, coord, addr dwFilled

    invoke FillConsoleOutputAttribute, 1, 2, 7, 0306h, 4
    invoke FillConsoleOutputAttribute, 1, 2, 7, 0406h, 4
    invoke FillConsoleOutputAttribute, 1, 2, 7, 0506h, 4

    invoke ExitProcess,0

    end main


    [color=Blue]I had tried to surf net for further explanation. But i failed to get a proper example which show the proper way of application of FillConsoleOutputAttribute proc.


    Thanks for giving and correct my mistake!

    Regards,
    Cielle
    [/color]

  • anthrax11anthrax11 Member Posts: 511
    [color=Green]Don't try to link 16-bit stuff to 32-bit, it won't work.

    You almost had the FillConsoleOutputAttribute call right, but not quite :)
    Also, you need a handle to the console, try this:[/color]
    [code].486
    .model flat, stdcall
    option casemap :none

    include masm32includewindows.inc
    include masm32includekernel32.inc
    includelib masm32libkernel32.lib

    .data
    hConsole HANDLE ?
    dwFilled dd ?

    .code
    main:

    invoke GetStdHandle, STD_OUTPUT_HANDLE
    mov hConsole, eax

    invoke FillConsoleOutputAttribute, hConsole, FOREGROUND_GREEN, 7, 00030006h, addr dwFilled
    invoke FillConsoleOutputAttribute, hConsole, FOREGROUND_GREEN, 7, 00040006h, addr dwFilled
    invoke FillConsoleOutputAttribute, hConsole, FOREGROUND_GREEN, 7, 00050006h, addr dwFilled

    invoke ExitProcess, 0

    end main[/code]
  • ciellecielle Member Posts: 11
    hi!

    i tried with your code d..

    But it still give no output on the exe file.

    Wrong is the problem pls?

    Thanks for your advise again..
«1
Sign In or Register to comment.