News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

HJWASM 2.17 bugs

Started by powershadow, December 29, 2016, 03:53:22 AM

Previous topic - Next topic

habran

I have checked also what C does and it comes out the same as masm and your fix, so I have implemented your idea and now hjwasm does the same. Here is the c source:

static ret_code GetAndExpression(struct hll_item *hll, int *i, struct asm_tok tokenarray[], int ilabel, bool is_true, char *buffer, struct hll_opnd *hllop)
/***********************************************************************************************************************************************************/
{
  char *ptr = buffer;
  uint_32 truelabel = 0;
  char buff[16];
  int nlabel;
  int olabel;

  DebugMsg1(("%u GetAndExpression(>%.32s< buf=>%s<) enter\n", evallvl, tokenarray[*i].tokpos, buffer));

  if (ERROR == GetSimpleExpression(hll, i, tokenarray, ilabel, is_true, ptr, hllop))
    return(ERROR);
  while (COP_AND == GetCOp(&tokenarray[*i])) {

    (*i)++;
    DebugMsg1(("%u GetAndExpression: &&-operator found, is_true=%u, lastjmp=%s\n", evallvl, is_true, hllop->lastjmp ? hllop->lastjmp : "NULL"));

    if (is_true) {
      /* todo: please describe what's done here and why! */
      if (hllop->lastjmp) {
        char *p = hllop->lastjmp;
        InvertJump(p);          /* step 1 */
        if (truelabel == 0)     /* step 2 */
          truelabel = GetHllLabel();

        if (*p ) {/* v2.11: there might be a 0 at lastjmp */
          p += 4;               /* skip 'jcc ' or 'jmp ' */
          GetLabelStr(truelabel, p);
          strcat(p, EOLSTR);
        }
        /* HJWasm 2.18  fixed WHILE with &&  */
        if (hllop->lasttruelabel)
          ReplaceLabel(buffer,hllop->lasttruelabel, truelabel);
        if (hll->cmd == HLL_WHILE){     // this is nidud's idea
          nlabel = GetHllLabel();
          olabel = GetLabel(hll, ilabel);
          GetLabelStr(olabel, buff);
          strcat(ptr, buff);
          strcat(ptr, LABELQUAL EOLSTR);
          DebugMsg1(("%u GetAndExpression: label added >%s<\n", evallvl, ptr));
          ReplaceLabel(buffer, olabel, nlabel);
          }
        else{
          DebugMsg1(("%u GetAndExpression: jmp inverted >%s<\n", evallvl, hllop->lastjmp));
          ReplaceLabel(buffer, GetLabel(hll, ilabel), truelabel);
          }
        hllop->lastjmp = NULL;
      }
    }
    ptr += strlen(ptr);
    hllop->lasttruelabel = 0; /* v2.08 */
    if (ERROR == GetSimpleExpression(hll, i, tokenarray, ilabel, is_true, ptr, hllop))
      return(ERROR);
  };

  if (truelabel > 0) {
    ptr += strlen(ptr);
    GetLabelStr(truelabel, ptr);
    strcat(ptr, LABELQUAL EOLSTR);
    DebugMsg1(("%u GetAndExpression: label added >%s<\n", evallvl, ptr));
    hllop->lastjmp = NULL;
  }
  return(NOT_ERROR);
}
Cod-Father

nidud

#31
deleted

LiaoMi

Quote from: habran on December 29, 2016, 03:19:25 PM
Bug #3, I have to check yet and Bug #4 is half true, if you use original HJWasm from Teraspace, it will show source code and line nmbers because it is built with msvc2005ddk. Visual Studio is producing different debug info which HJWasm doesn't support.
So, to have fast and small exe with a proper debug info you need to build it with the msvc2005ddk

Hello everybody!

Where can I download msvc 2005 ddk? On the Internet is very hard to find ..

Happy New Year! Thanks!

hutch--

See if this will give you the correct version.

https://www.microsoft.com/en-au/download/details.aspx?id=11800

habran

LiaoMi, I think that msvc2003R2.zip is what you need
and here is the .cmd file:

@SET Path=C:\code1\msvc2003R2\bin\amd64
@SET INCLUDE=C:\code1\msvc2003R2\include\crt;
@SET LIB=C:\code1\msvc2003R2\lib\amd64
cl -c -Zl -GS- -O2 -Ox -I..\HJWasm-master\H ..\HJWasm-master\*.c -D_CRT_SECURE_NO_DEPRECATE -DDEBUG_OUT -DWIN64 -DAVXSUPP
cl main.obj apiemu.obj assemble.obj assume.obj atofloat.obj backptch.obj bin.obj branch.obj cmdline.obj codegen.obj coff.obj condasm.obj context.obj cpumodel.obj data.obj dbgcv.obj directiv.obj elf.obj end.obj equate.obj errmsg.obj expans.obj expreval.obj extern.obj fastpass.obj fixup.obj fpfixup.obj hll.obj input.obj invoke.obj label.obj linnum.obj listing.obj loop.obj lqueue.obj macro.obj mangle.obj memalloc.obj msgtext.obj omf.obj omffixup.obj omfint.obj option.obj parser.obj posndir.obj preproc.obj proc.obj queue.obj reswords.obj safeseh.obj segment.obj simsegm.obj string.obj symbols.obj tbyte.obj tokenize.obj types.obj libc.lib bufferoverflowu.lib -o hjwa64v200R2clib.exe
@DEL *.obj
pause
Cod-Father

habran

I think that TWell can give you all info you need about building with DDK, you can PM him 8)
Cod-Father

TWell

#36
For x86 old MS Visual C++ Toolkit 2003 should work, but it is hard to find :(
Also x86 compiler and libc.lib are in 1830_usa_ddk.iso

EDIT: Server 2003 SP1 Platform SDK ISO

habran

Thanks TWell, excellent stuff :t
Cod-Father

Vortex

Quote from: TWell on January 02, 2017, 08:03:27 AM
For x86 old MS Visual C++ Toolkit 2003 should work, but it is hard to find :(

You can check this link :

http://www.unfiles.info/vctoolkitsetup.exe/m-download-23770.html

ragdog

#39
Hello

I testing hJwasm as new Assembler why give hJwasm to cryptic output

Total compile time 734 ms
×ܹ²±àÒëʱ¼ä 734 ºÁÃë  <<<<<<<<

And give any macro or function to auto translate registers?

example

if _WIN64 EQU 1 ; registers are auto translated eax to rax etc...

Code example my way is really dirty to use a one project  code to build a x86 app or X64
Or has any a better solution or macro?


IFDEF _WIN64 
    _eax TEXTEQU <rax>
    _ebx TEXTEQU <rbx>
    _ecx TEXTEQU <rcx>
    _edx TEXTEQU <rdx>
    _esi TEXTEQU <rsi>
    _edi TEXTEQU <rdi>
    _ebp TEXTEQU <rbp>
    _esp TEXTEQU <rsp>
ELSE
    _eax TEXTEQU <eax>
    _ebx TEXTEQU <ebx>
    _ecx TEXTEQU <ecx>
    _edx TEXTEQU <edx>
    _esi TEXTEQU <esi>
    _edi TEXTEQU <edi>
    _ebp TEXTEQU <ebp>
    _esp TEXTEQU <esp>
ENDIF


mov _eax,1

Greets,

habran

Hi ragdog,
It sims to me that you are using some other language then English for your text editor :biggrin:
It is pretty complex job to write source that can be used for both 32 and 64 bit.
You can ask rrr314159 about the best way how to do that because he has done some conversion few years ago.
Cod-Father

habran

#41
Hi Vortex,
I have downloaded and installed Toolkit 2003 from your link, however, it is only 32 bit.

Here is Russian link for platformSDK2003SP1
Cod-Father

ragdog

QuoteIt sims to me that you are using some other language then English for your text editor

I use Radasm2 as Texteditor and use default language ( English)

Greets,

habran

I don't know how to setup Radasm2 for HJWasm, I am using Visual Studio Community 2013 to build my programs.
You can PM Johnsa, to give you some tips how to setup Radasm2 for HJWasm.
Cod-Father

ragdog