The MASM Forum Archive 2004 to 2012

Project Support Forums => HLA Forum => Topic started by: bolzano_1989 on November 11, 2011, 08:44:20 AM

Title: How to generate the MASM source code from HLA source code?
Post by: bolzano_1989 on November 11, 2011, 08:44:20 AM
From the following topic:
http://www.masm32.com/board/index.php?topic=15040.msg132014#msg132014
I tried hla -masm myprog.hla but it didn't work.
Coud someone give me a hand  :bg ?
Title: Re: How to generate the MASM source code from HLA source code?
Post by: TmX on November 11, 2011, 09:31:28 AM
Could you tell what error message you got?

Maybe like this?
Quote'ml' is not recognized as an internal or external command,
operable program or batch file.
Error returned by Assembler = 1

If yes then it means that you need to put \masm32\bin in the %PATH%.
However, the HLA compiler already generated the asm file for you.
Let's say you just called hla -masm test1.hla. test1.asm should appear.
Title: Re: How to generate the MASM source code from HLA source code?
Post by: bolzano_1989 on November 11, 2011, 04:48:51 PM
Quote from: TmX on November 11, 2011, 09:31:28 AM
Could you tell what error message you got?

Maybe like this?
Quote'ml' is not recognized as an internal or external command,
operable program or batch file.
Error returned by Assembler = 1

If yes then it means that you need to put \masm32\bin in the %PATH%.
However, the HLA compiler already generated the asm file for you.
Let's say you just called hla -masm test1.hla. test1.asm should appear.

Thank you, for
hla -masm 1_01HelloWorld.hla
I received:
QuoteIllegal command line option '-masm'
Usage: hla options filename(s)

My HLA version:
QuoteHLA (High Level Assembler - FASM back end, POLINK linker)
Version 1.99 build 12920 (prototype)
Title: Re: How to generate the MASM source code from HLA source code?
Post by: bolzano_1989 on November 11, 2011, 05:22:18 PM
After I updated HLA to version 2.16 build 4413, I tried
hla -masm 1_01HelloWorld.hla
And it works but when I opened the 1_01HelloWorld.asm with Quick Editor of MASM32 package and tried "Console Assemble & Link" but received the errors:
Quote1_01HelloWorld.obj : error LNK2001: unresolved external symbol STDOUT_NEWLN
1_01HelloWorld.obj : error LNK2001: unresolved external symbol DefaultExceptionH
andler__hla_
1_01HelloWorld.obj : error LNK2001: unresolved external symbol HardwareException
__hla_
1_01HelloWorld.obj : error LNK2001: unresolved external symbol BuildExcepts__hla
_
1_01HelloWorld.obj : error LNK2001: unresolved external symbol STDOUT_PUTS
1_01HelloWorld.obj : error LNK2001: unresolved external symbol __imp__ExitProces
s@4
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1_01HelloWorld.exe : fatal error LNK1120: 7 unresolved externals
_
Link error

How could I fix this so that it will work with qeditor of MASM32 package?
Here are the contents of 1_01HelloWorld.hla and 1_01HelloWorld.asm generated:

1_01HelloWorld.hla
program helloWorld;
#include( "stdlib.hhf" );

begin helloWorld;

    stdout.put( "Hello, World of Assembly Language", nl );

end helloWorld;


1_01HelloWorld.asm
; Assembly code emitted by HLA compiler
; Version 2.16 build 4413 (prototype)
; HLA compiler written by Randall Hyde
; MASM compatible output

  if @Version lt 612
  .586p
  else
  .686p
  .mmx
  .xmm
  endif
  .model flat, syscall
  option noscoped
  option casemap:none


offset32 equ <offset flat:>

  assume fs:nothing
ExceptionPtr__hla_ equ <(dword ptr fs:[0])>



        public     QuitMain__hla_
        public     DfltExHndlr__hla_
        public     _HLAMain
        public     HWexcept__hla_
        public     start


  .code


        externdef  STDOUT_NEWLN:near32
        externdef  DefaultExceptionHandler__hla_:near32
        externdef  abstract__hla_:near32
        externdef  HardwareException__hla_:near32
        externdef  BuildExcepts__hla_:near32
        externdef  STDOUT_PUTS:near32
        externdef  Raise__hla_:near32
        externdef  shortDfltExcept__hla_:near32






  .code




;/* HWexcept__hla_ gets called when Windows raises the exception. */

HWexcept__hla_ proc near32
        jmp        HardwareException__hla_
HWexcept__hla_ endp

DfltExHndlr__hla_ proc near32
        jmp        DefaultExceptionHandler__hla_
DfltExHndlr__hla_ endp



_HLAMain proc near32

start   proc near32
start   endp

        call       BuildExcepts__hla_
        db         06ah
        db         00h
        db         055h
        db         055h
        db         08dh
        db         06ch
        db         024h
        db         04h


        db         068h
        dd         offset32 str__hla_1888
        call       STDOUT_PUTS
        call       STDOUT_NEWLN
QuitMain__hla_::
        db         06ah
        db         00h
        db         0ffh
        db         015h
        dd         offset32 __imp__ExitProcess@4
_HLAMain endp









  .code


        align      (4)
len__hla_1888 dd         021h
        dd         021h
str__hla_1888 label byte
db "Hello, World of Assembly Language"
db 0

db 0
db 0




  .data

        externdef  MainPgmCoroutine__hla_:byte
        externdef  __imp__MessageBoxA@16:dword
        externdef  __imp__ExitProcess@4:dword
        align      (4)




end

Title: Re: How to generate the MASM source code from HLA source code?
Post by: TmX on November 11, 2011, 07:21:31 PM
This error:
Quote1_01HelloWorld.obj : error LNK2001: unresolved external symbol STDOUT_NEWLN
1_01HelloWorld.obj : error LNK2001: unresolved external symbol DefaultExceptionH
andler__hla_
1_01HelloWorld.obj : error LNK2001: unresolved external symbol HardwareException
__hla_
1_01HelloWorld.obj : error LNK2001: unresolved external symbol BuildExcepts__hla
_
1_01HelloWorld.obj : error LNK2001: unresolved external symbol STDOUT_PUTS
1_01HelloWorld.obj : error LNK2001: unresolved external symbol __imp__ExitProces
s@4
LINK : error LNK2001: unresolved external symbol _mainCRTStartup
1_01HelloWorld.exe : fatal error LNK1120: 7 unresolved externals
_
Link error

happened because the linker couldn't found the required lib. It's hlalib.lib (in my system, it's could be found in C:\hla\hlalib.lib).

After some trial and errors, I could build the code correctly using this command.
Quotelink /subsystem:console /entry:HLAMain /libpath:C:\hla\hlalib hlalib.lib /libpath:C:\masm32\lib kernel32.lib user32.lib 1_01HelloWorld.obj

I don't know how to do that from Qeditor, though.
Title: Re: How to generate the MASM source code from HLA source code?
Post by: bolzano_1989 on November 12, 2011, 03:41:24 PM
Is there anyway to generate MASM source code (from HLA source code) independent from those lib files from HLA :bg ?
Title: Re: How to generate the MASM source code from HLA source code?
Post by: TmX on November 12, 2011, 05:03:25 PM
Well honestly I don't know.
Maybe you'd better ask Mr Hyde (http://www.masm32.com/board/index.php?action=profile;u=78) :wink
Title: Re: How to generate the MASM source code from HLA source code?
Post by: Sevag.K on November 15, 2011, 04:12:57 AM
Quote from: bolzano_1989 on November 12, 2011, 03:41:24 PM
Is there anyway to generate MASM source code (from HLA source code) independent from those lib files from HLA :bg ?

yeah, don't use the lib files.