News:

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

Main Menu

Strange jWasm

Started by Gunther, December 07, 2014, 06:26:30 AM

Previous topic - Next topic

Gunther

The following code assembles flawless with TASM 4:

        .486p

; Publics for PB

        public     CopyString

; Externals

        extrn      Get$Loc: FAR          ; internal PB functions
        extrn      Get$Alloc: FAR


DATA    segment word use16 public 'DATA'

str     db "Text from the Assembly Language Data Segment."

slen    equ $ - str                      ; string length

DATA    ends


code16  segment para public use16
        assume  cs:code16, ds:DATA

; FUNCTION CopyString
; Purpose:         Copy a string into a PB string.
; Input:           None
; Output:          ax = string handle ===> success
;                  ax = 0             ===> failed
CopyString proc far
        push       bp
        mov        bp, sp
        sub        sp, 2                 ; temporary storage
        push       ds
        push       es
        push       di
        push       si
        mov        ax, slen              ; get string length
        push       ax                    ; length onto stack
        call       Get$Alloc             ; allocate string space
        or         ax, ax                ; space available?
        jz         CopyString3           ; no: jump
        mov        [bp-2], ax            ; save new handle
        push       ax                    ; handle at stack
        call       Get$Loc               ; determine string address
                                         ; dx:ax = string address
                                         ; cx    = string length
        mov        es, dx
        mov        di, ax                ; es:di -> destinaton
        mov        si, offset str        ; ds:si -> source
       
CopyString1:

        mov        al, ds:[si]           ; read 1 byte
        mov        byte ptr es:[di], al  ; write 1 byte
        inc        di                    ; update pointers and counter
        inc        si
        dec        cx
        jnz        CopyString1
        mov        ax, [bp-2]            ; load string handle

CopyString2:

        pop        si
        pop        di
        pop        es
        pop        ds
        mov        sp, bp       
        pop        bp
        ret

CopyString3:

        xor        ax, ax                ; indicate error
        jmp        short CopyString2
CopyString endp

code16  ends
        end

There's nothing special. But the DOS version of jWasm produces the following error protocol:

ASMTEST.ASM(15) : Error A2218: Syntax error: db
ASMTEST.ASM(38) : Error A2066: Operand is expected
ASMTEST.ASM(50) : Error A2066: Operand is expected

What happens here? I've included the complete source and the running EXE into the archive ASMTEST.ZIP.

Gunther
You have to know the facts before you can distort them.

FORTRANS

Hi,

   Just a WAG, but "str" seems to be acting like a reserved word.
Or that is what the errors are telling me.  Try renaming it.

Regards,

Steve N.

Gunther

Hi Steve,

Quote from: FORTRANS on December 07, 2014, 07:37:39 AM
   Just a WAG, but "str" seems to be acting like a reserved word.
Or that is what the errors are telling me.  Try renaming it.

yes, renaming str in str1 eliminates the first error (strange!). But the other 2 remain.

Gunther
You have to know the facts before you can distort them.

sinsi

str shows up in three places, did you rename them all?
🍺🍺🍺

Gunther

Hi sinsi,

Quote from: sinsi on December 07, 2014, 08:00:46 AM
str shows up in three places, did you rename them all?

that's it.  :t That was my fault. By renaming, jWasm assembles now without error messages, but with errors. I've included the new source under this post. It is 16-bit code inside a 16-bit segment.The procedure is declared FAR, which needs the complete address (segment:offset) and not only the offset. The resulting EXE with the jWasm OBJ file crashes. Here are the reasons:


  • jWasm generates false addresses for the EXTERNAL procedures.
         

     call       Get$Loc = 9A 00000000se
     

     That's the right way what TASM does. jWasm produces for the same sequenz:
     
     call       Get$Loc = 669A000000000000
   

    [/li]
  • jWasm doesn't generate the appropriate RET instruction although the entire procedure is declared as FAR.
I've included both listing files (tasm.txt and jwasm.txt) into the archive LISTING.ZIP. So what's wrong? The EXE generated with the TASM OBJ file works fine.

Gunther
You have to know the facts before you can distort them.

dedndave

it would seem that JwAsm doesn't know to use a RETF in a FAR proc
just use explicit form of RETF

sinsi

What if you remove the .486 from the start? Jwasm seems to be using a 66h override.
🍺🍺🍺

jj2007

JWasm seems to work, but where is the linker supposed to find the externals?

*** Assemble 16-bit app using JWasm /c /omf /Fo "ASMTEST" ***
JWasm v2.12pre, Feb 18 2014, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

Tmp_File.asm: 81 lines, 2 passes, 0 ms, 0 warnings, 0 errors
*** Link using link16   ***

Microsoft (R) Segmented Executable Linker  Version 5.60.339 Dec  5 1994
Copyright (C) Microsoft Corp 1984-1993.  All rights reserved.

LINK : warning L4021: no stack segment

ASMTEST.obj(Tmp_File.asm) : error L2029: 'Get$Loc' : unresolved external
ASMTEST.obj(Tmp_File.asm) : error L2029: 'Get$Alloc' : unresolved external

LINK : warning L4038: program has no starting address

There were 2 errors detected
*** Link error ***

Gunther

Dave,

Quote from: dedndave on December 07, 2014, 12:57:53 PM
it would seem that JwAsm doesn't know to use a RETF in a FAR proc
just use explicit form of RETF

Yes that works. But this is weak.

sinsi,

Quote from: sinsi on December 07, 2014, 01:58:04 PM
What if you remove the .486 from the start? Jwasm seems to be using a 66h override.

I'll try that.

Jochen,

Quote from: jj2007 on December 07, 2014, 06:52:27 PM
JWasm seems to work, but where is the linker supposed to find the externals?

No, not really. What I'm doing here is to call an internal PB procedure from assembly language. The OBJ file must be linked into the PB EXE; that's the compiler's job. No external linker is needed. Are you sure that jWasm generates the right address format for the external procedures (without prefix 66h and as normal segment:offset)? Could you provide the listing file, please?

Gunther
You have to know the facts before you can distort them.

jj2007

Quote from: Gunther on December 07, 2014, 08:55:44 PMWhat I'm doing here is to call an internal PB procedure from assembly language. The OBJ file must be linked into the PB EXE; that's the compiler's job. No external linker is needed.

No PB.exe on this machine, sorry...

nidud

#10
deleted

Gunther

Hi nidud,

yes, I've figured out it in the mean time. It works now fine, see attached file WORKAROUND.ZIP.

Gunther
You have to know the facts before you can distort them.