All BASIC

Message Boards => Translators => Topic started by: jcfuller on October 19, 2011, 11:37:25 AM

Title: BxbAsm
Post by: jcfuller on October 19, 2011, 11:37:25 AM
I was interested in Steve's BxbAsm so I ported it to Ubx on both Windows and Linux.
It is not a complete port of course because Steve is still working on converting BxbAsm to use JWAsm.

James
Title: Re: BxbAsm
Post by: SteveA on October 19, 2011, 12:33:50 PM
This is way too cool James.

Steve
Title: Re: BxbAsm
Post by: jcfuller on October 19, 2011, 12:45:48 PM
Here are the sources.

James
Title: Re: BxbAsm
Post by: SteveA on October 19, 2011, 01:34:55 PM
This is awesome James.
The question now is, will it do an assembly ?
Title: Re: BxbAsm
Post by: SteveA on October 21, 2011, 10:35:39 AM
I've been setting up JWasm and making a few modifications to Bxbasm, to bring it up to date, so the two will work together.
I can get JWasm working just fine, (so far), using Masm32 Include and Lib files, but, that isn't the point.
The key is to get Bxbasm source files to compile and assemble using Include and Lib files other than Masm32.
I hope to have something working by today.
Title: Re: BxbAsm
Post by: jcfuller on October 21, 2011, 12:33:06 PM
JWasm has a wininc and you can create the *.lib you need.
The biggest stumbling block is the same one I ran into and that is the vast macros and proc's in masm32.lib

James
Title: Re: BxbAsm
Post by: SteveA on October 21, 2011, 02:09:08 PM
Quote
The biggest stumbling block is the same one I ran into and that is the vast macros and proc's in masm32.lib

Yes, that's what I'm looking at now.
Title: Re: BxbAsm
Post by: SteveA on October 21, 2011, 04:00:03 PM
Quote
JWasm has a wininc and you can create the *.lib you need.

Hmm...
I created the predefined *.lib files from ..\wininc\Def\ .
I'm not at all clear on how to create my own *.lib files or the missing ..\Include\ files.
Any pointers ?
Title: Re: BxbAsm
Post by: jcfuller on October 21, 2011, 04:23:35 PM
I don't know why you need to create libs at this juncture.
To start you will need to write or find substitutes for the missing procs/macros you were using from masm32.lib.
The sources are available which might give you insight into writing your own or as I suggested in my email use the MinGW libs.

James

Title: Re: BxbAsm
Post by: SteveA on October 21, 2011, 06:53:35 PM
Quote
I don't know why you need to create libs at this juncture.

There are Includes and Libs that Bxbasm uses (in Masm32) that are not part of JWasm.
Code: [Select]
; Include files
    include \masm32\include\windows.inc
    include \masm32\include\masm32.inc
    include \masm32\include\user32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\kernel32.inc
    include \masm32\include\Comctl32.inc
    include \masm32\include\comdlg32.inc
    include \masm32\include\shell32.inc
    include \masm32\include\oleaut32.inc
    include \masm32\include\crtdll.inc
    include \masm32\include\fpu.inc

    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\kernel32.lib
    includelib \masm32\lib\Comctl32.lib
    includelib \masm32\lib\comdlg32.lib
    includelib \masm32\lib\shell32.lib
    includelib \masm32\lib\oleaut32.lib
    includelib \masm32\lib\crtdll.lib
    includelib \masm32\lib\fpu.lib

Masm32.inc is one part of it.
The current functionality of Bxbasm is dependant on a number of things being present.
Title: Re: BxbAsm
Post by: jcfuller on October 22, 2011, 04:12:42 AM
Steve,
  I did get test.bas to translate and compile using this bxb.inc but not linked as the items in masm32.lib are missing.

James

Code: [Select]
;/* BXB.INC */

; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
; Include files
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
include \jwasm\wininc\include\WINDOWS.INC

    include \jwasm\wininc\include\windows.inc
;    include \masm32\include\masm32.inc
;    include \jwasm\wininc\include\user32.inc
;    include \jwasm\wininc\include\gdi32.inc
;    include \jwasm\wininc\include\kernel32.inc
    include \jwasm\wininc\include\Commctrl.inc
    include \jwasm\wininc\include\commdlg.inc
    include \jwasm\wininc\include\shellapi.inc
    include \jwasm\wininc\include\oleauto.inc
;    include \jwasm\wininc\include\crtdll.inc
;    include \masm32\include\fpu.inc

;    includelib \masm32\lib\masm32.lib
;    includelib \jwasm\wininc\lib\user32.lib
;    includelib \jwasm\wininc\lib\gdi32.lib
;    includelib \jwasm\wininc\lib\kernel32.lib
    includelib \jwasm\wininc\lib\Commctrl.lib
    includelib \jwasm\wininc\lib\commdlg.lib
    includelib \jwasm\wininc\lib\shellapi.lib
    includelib \jwasm\wininc\lib\oleauto.lib
    includelib \jwasm\wininc\lib\crtdll.lib
;    includelib \masm32\lib\fpu.lib

;----------------------------------
; лллллллл PROTO лллллллл PROTO лллллллл PROTO лллллллл PROTO ллллллллллллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
    Main      proto
    copystrng_bffr proto
    copystrng proto
    catstrng  proto
    chrstr    proto
    leftstr   proto
    rightstr  proto
    mid_str   proto
    spacestr  proto
    strsIval  proto
    strsFval  proto
    stringstr proto
    inkeystr  proto
    inputstr  proto
    wherexy   proto
    reset_cursor proto
    get_sys_date proto
    get_sys_time proto
    datestr   proto
    timestr   proto
    closeallfiles proto
    closeafile    proto
    getfilehandle proto
    clearstrng_bffr proto
    setupiobuffer   proto
    mkistr         proto
    mkdstr         proto
    mkqstr         proto
    lsetstr        proto
    rsetstr        proto
    Do_initialize   proto
    clear_allvars   proto
    clearstrvar  proto
    clearintvar  proto
    clearfltvar  proto
    clearLngstrng_bffr proto
    movstrng_bffr  proto
    readintstr   proto
    readfltstr   proto
    readQintstr  proto
    getfilelength  proto
    setcolortext   proto
    dimstrarray    proto
    getArryOffst proto

;jcfuller added
    StdOut proto :DWORD
    StdIn        PROTO :DWORD,:DWORD
    FloatToStr2 proto stdcall fpin:QWORD, szDbl:PTR CHAR
    StrToFloat proto stdcall szIn:PTR BYTE, fpout:PTR DWORD
    malloc PROTO C :VARARG
    free PROTO C :VARARG

; лллллллл MACROS лллллллл MACROS лллллллл MACROS лллллллл MACROS ллллллллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл

ifndef HIWORD
    _hiword macro a
        mov  eax, a
        shr  eax, 16
        and  eax, 0FFFFH
    endm
    HIWORD equ  _hiword
endif
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
ifndef LOWORD
    _loword macro a
        mov  eax, a
        and  eax, 0FFFFH
    endm
    LOWORD equ  _loword
endif
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
ifndef max
    max macro a,b
    LOCAL endmax
         mov  eax, a
         mov  ebx, b
         cmp  eax, ebx
         jge  endmax
         mov  eax, ebx
    endmax:
    endm
endif
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
ifndef min
    min macro a,b
    LOCAL endmin
         mov  eax, a
         mov  ebx, b
         cmp  eax, ebx
         jle  endmin
         mov  eax, ebx
    endmin:
    endm
endif
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
get MACRO a, b
    push edi
    push ebx
    mov edi, offset a
    mov eax, b
    mov ebx, 4
    mul bl
    add edi, eax
    mov eax, [edi]    ;  mov eax, szLabel+4
    pop ebx
    pop edi
ENDM
;------------------
;USE:
;       mov ndx, 3
;       get szLabel,ndx
;------------------
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
_conditionl MACRO pa, pb, rc, rd
LOCAL isTrue
LOCAL isDone
  mov  eax, pa   ;tm.tmPitchAndFamily
  and  eax, pb   ;1     ; (tm.tmPitchAndFamily & 1 ? 3 : 2)
  jnz  isTrue
  ;
  mov  eax, rd   ;2
  jmp  isDone
isTrue:
  mov  eax, rc   ;3
isDone:
endm
CondtnlExp   equ _conditionl
;USE:
;  Conditionl var1, var2, result1, result2
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
_sconditionl MACRO pa, pb, rc, rd
LOCAL isTrue
LOCAL isDone
  mov  eax, pa   ;0x08000000H & lParam ? "Down" : "Up")
  and  eax, pb   ;lParam
  jnz  isTrue
  ;
  mov  eax, rd   ;"Up"
  jmp  isDone
isTrue:
  mov  eax, rc   ;"Down"
isDone:
endm
sCondtnlExp   equ _sconditionl
;USE:
;  sConditionl var1, var2, str1, str2
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
print MACRO Quoted_Text:VARARG
   LOCAL Txt
      .data
          Txt db Quoted_Text,0
      .code
        invoke StdOut,ADDR Txt
ENDM
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
printstr    MACRO   stringVar
    invoke StdOut,ADDR stringVar    ; printstr astring
ENDM
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
printvar    MACRO   reg
    invoke StdOut, reg              ; printstr astring
ENDM
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
cls     MACRO
    invoke ClearScreen            ; CLS
ENDM
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------


; лллллллллллл STRUCTURES лллллллллл STRUCTURES лллллллллл STRUCTURES ллллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл


; ллллллллл EQUATES лллллллл EQUATES ллллллллл EQUATES ллллллл EQUATES лллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
ifndef BUFFR_SIZ
    BUFFR_SIZ       equ     128
endif
ifndef BUFSIZE
    BUFSIZE         equ     256
endif
ifndef MBUFSIZE
    MBUFSIZE        equ     65535
endif

NUM_ATTRIB    equ     15

;##########################################################################
; лллллллллллл DATA ллллллллл DATA ллллллллл DATA лллллллллл DATA ллллллллл
.data
; ллллллллллллCONSTANT ASSIGNMENTSллллллллллллллллллллллллллллллллллллллллл
ff          db  12,0
lf          db  13,10,0     ; line feed
tab         db  9,0         ; tab
n_          dd  10          ; newline
x_          dd  0           ; any character
_Altern_$ DB  'wb+',0      ; alternate I/O Mode
Lprint$     db  'lpt1',0    ; for LPRINT
Lprnmode$   db  'w',0       ; for LPRINT

; лллллллллллллллDO NOT DELETEллллллллллллллллллллллллллллллллллллллллллллл

Title: Re: BxbAsm
Post by: SteveA on October 22, 2011, 12:05:09 PM
Okay, I got it to compile and assemble this sample:
Code: [Select]
CLS
BEEP
PRINT "hello world"
END

using this modified Bxb.inc:
Code: [Select]
;/* BXB.INC */

; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
; Include files
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
    include \JWasm\JWasm206\Include\windows.inc
    include \JWasm\JWasm206\Include\CommCtrl.inc
    include \JWasm\JWasm206\Include\commdlg.inc
    include \JWasm\JWasm206\Include\oleauto.inc

;----------------------------------
    ;include \masm32\include\masm32.inc
    ;include \masm32\include\user32.inc
    ;include \masm32\include\gdi32.inc
    ;include \masm32\include\kernel32.inc
    ;include \masm32\include\shell32.inc
    ;include \masm32\include\crtdll.inc
    ;include \masm32\include\fpu.inc

;----------------------------------
    includelib \JWasm\JWasm206\Lib\user32.lib
    includelib \JWasm\JWasm206\Lib\gdi32.lib
    includelib \JWasm\JWasm206\Lib\kernel32.lib
    includelib \JWasm\JWasm206\Lib\Comctl32.lib
    includelib \JWasm\JWasm206\Lib\comdlg32.lib
    includelib \JWasm\JWasm206\Lib\shell32.lib
    includelib \JWasm\JWasm206\Lib\oleaut32.lib
    includelib \JWasm\JWasm206\Lib\crtdll.lib

;----------------------------------
    ;includelib \masm32\lib\masm32.lib
    ;includelib \masm32\lib\fpu.lib

;----------------------------------

It did generate a linker warning, but, it produced an .exe.
Title: Re: BxbAsm
Post by: jcfuller on October 22, 2011, 02:30:46 PM
Steve,
  I'm approaching it a little bit differently.
I am using elf file format to compile the bxbasm generated asm file.
I am not using any of the jwasm library files but instead using the MinGW libraries.
I cheated a bit and compiled a few of the needed items from m32lib and created a gcc compatable
bxbasmlib.

James


My two batch files
console
Code: [Select]
@setlocal
@ECHO OFF
@SET MINGW=C:\MinGW
@SET LIB=%MINGW%\lib -Lc:\jwasm\bxbasm\lib
@SET INCLUDE=%MINGW%\include;%MINGW%\include\sys
@SET PATH=C:\jwasm;C:\jwasm\jwlink;%MINGW%\bin;%PATH%
@SET GCCCFL= --format elf32-i386 --subsystem console
jwasm -elf %1.asm
ld  %GCCCFL% -s -o %1.exe %1.obj -L%LIB% -lbxbasmlib -lmingw32 -lmsvcrt -lkernel32 -luser32 -lgdi32 -lcomctl32 -ladvapi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lwinmm -lcomdlg32 -limagehlp -lversion
REM ECHO All Done
endlocal
gui
Code: [Select]
@setlocal
@SET MINGW=C:\MinGW
@SET LIB=%MINGW%\lib -Lc:\jwasm\bxbasm\lib
@SET INCLUDE=%MINGW%\include;%MINGW%\include\sys
@SET PATH=C:\jwasm;C:\jwasm\jwlink;%MINGW%\bin;%PATH%
@SET GCCCFL= --format elf32-i386 --subsystem windows
@jwasm -elf %1.asm
@ld  %GCCCFL% -s -o %1.exe %1.obj -L%LIB% -lmingw32 -lmsvcrt -lkernel32 -luser32 -lgdi32 -lcomctl32 -ladvapi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lwinmm -lcomdlg32 -limagehlp -lversion
ECHO All Done

Tests.bas
Code: [Select]
'  test.bas  masm32 version 1
'
    DIM array$(3,3,3)
    array$(1,1,1) = "hello"
    array$(2,2,2) = "world!"
    array$(3,3,3) = "yahoo!"
    qaz$ = array$(1,1,1)
    wsx$ = array$(2,2,2)
    edc$ = array$(3,3,3)
    array$(1,1,2) = array$(1,1,1) + CHR$(32) + array$(2,2,2) + " " + array$(3,3,3)
    rfv$ = array$(1,1,2)
'
    PRINT "qaz$=array111", qaz$
    PRINT "wsx$=array222", wsx$
    PRINT "edc$=array333", edc$
    PRINT "rfv$=all above", rfv$
    PRINT array$(1,1,1) + array$(2,2,2) + array$(3,3,3) + array$(1,1,2)
'
    val = ASC(array$(1,1,1))
    len = LEN(array$(1,1,1))
    PRINT "val= "; val, "len= "; len
    val = ASC(array$(2,2,2))
    len = LEN(array$(2,2,2))
    PRINT "val= "; val, "len= "; len
    val = ASC(array$(3,3,3))
    len = LEN(array$(3,3,3))
    PRINT "val= "; val, "len= "; len
    val = ASC(array$(1,1,2))
    len = LEN(array$(1,1,2))
    PRINT "val= "; val, "len= "; len
'
    array$(1,1,3) = "100.123456"
    val# = VAL(array$(1,1,3))
    PRINT "val= "; val#
    '
TheEnd:
' ------------------------------------------
  END
' ------------------------------------------





BXB.INC

Code: [Select]
;/* BXB.INC */

; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
; Include files
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл

    include \jwasm\wininc\include\windows.inc
    include \jwasm\wininc\include\Commctrl.inc
    include \jwasm\wininc\include\commdlg.inc
    include \jwasm\wininc\include\shellapi.inc
    include \jwasm\wininc\include\oleauto.inc
;    include \jwasm\wininc\include\crtdll.inc
;    include \masm32\include\fpu.inc

;----------------------------------
; лллллллл PROTO лллллллл PROTO лллллллл PROTO лллллллл PROTO ллллллллллллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
    Main      proto
    copystrng_bffr proto
    copystrng proto
    catstrng  proto
    chrstr    proto
    leftstr   proto
    rightstr  proto
    mid_str   proto
    spacestr  proto
    strsIval  proto
    strsFval  proto
    stringstr proto
    inkeystr  proto
    inputstr  proto
    wherexy   proto
    reset_cursor proto
    get_sys_date proto
    get_sys_time proto
    datestr   proto
    timestr   proto
    closeallfiles proto
    closeafile    proto
    getfilehandle proto
    clearstrng_bffr proto
    setupiobuffer   proto
    mkistr         proto
    mkdstr         proto
    mkqstr         proto
    lsetstr        proto
    rsetstr        proto
    Do_initialize   proto
    clear_allvars   proto
    clearstrvar  proto
    clearintvar  proto
    clearfltvar  proto
    clearLngstrng_bffr proto
    movstrng_bffr  proto
    readintstr   proto
    readfltstr   proto
    readQintstr  proto
    getfilelength  proto
    setcolortext   proto
    dimstrarray    proto
    getArryOffst proto

;jcfuller added
    StdOut proto :DWORD
    StdIn        PROTO :DWORD,:DWORD
    FloatToStr2 proto stdcall fpin:QWORD, szDbl:PTR CHAR
    StrToFloat proto stdcall szIn:PTR BYTE, fpout:PTR DWORD
    malloc PROTO C :VARARG
    free PROTO C :VARARG

; лллллллл MACROS лллллллл MACROS лллллллл MACROS лллллллл MACROS ллллллллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл

ifndef HIWORD
    _hiword macro a
        mov  eax, a
        shr  eax, 16
        and  eax, 0FFFFH
    endm
    HIWORD equ  _hiword
endif
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
ifndef LOWORD
    _loword macro a
        mov  eax, a
        and  eax, 0FFFFH
    endm
    LOWORD equ  _loword
endif
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
ifndef max
    max macro a,b
    LOCAL endmax
         mov  eax, a
         mov  ebx, b
         cmp  eax, ebx
         jge  endmax
         mov  eax, ebx
    endmax:
    endm
endif
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
ifndef min
    min macro a,b
    LOCAL endmin
         mov  eax, a
         mov  ebx, b
         cmp  eax, ebx
         jle  endmin
         mov  eax, ebx
    endmin:
    endm
endif
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
get MACRO a, b
    push edi
    push ebx
    mov edi, offset a
    mov eax, b
    mov ebx, 4
    mul bl
    add edi, eax
    mov eax, [edi]    ;  mov eax, szLabel+4
    pop ebx
    pop edi
ENDM
;------------------
;USE:
;       mov ndx, 3
;       get szLabel,ndx
;------------------
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
_conditionl MACRO pa, pb, rc, rd
LOCAL isTrue
LOCAL isDone
  mov  eax, pa   ;tm.tmPitchAndFamily
  and  eax, pb   ;1     ; (tm.tmPitchAndFamily & 1 ? 3 : 2)
  jnz  isTrue
  ;
  mov  eax, rd   ;2
  jmp  isDone
isTrue:
  mov  eax, rc   ;3
isDone:
endm
CondtnlExp   equ _conditionl
;USE:
;  Conditionl var1, var2, result1, result2
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
_sconditionl MACRO pa, pb, rc, rd
LOCAL isTrue
LOCAL isDone
  mov  eax, pa   ;0x08000000H & lParam ? "Down" : "Up")
  and  eax, pb   ;lParam
  jnz  isTrue
  ;
  mov  eax, rd   ;"Up"
  jmp  isDone
isTrue:
  mov  eax, rc   ;"Down"
isDone:
endm
sCondtnlExp   equ _sconditionl
;USE:
;  sConditionl var1, var2, str1, str2
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
print MACRO Quoted_Text:VARARG
   LOCAL Txt
      .data
          Txt db Quoted_Text,0
      .code
        invoke StdOut,ADDR Txt
ENDM
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
printstr    MACRO   stringVar
    invoke StdOut,ADDR stringVar    ; printstr astring
ENDM
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
printvar    MACRO   reg
    invoke StdOut, reg              ; printstr astring
ENDM
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
cls     MACRO
    invoke ClearScreen            ; CLS
ENDM
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------
; лллллллллллллллллллллллллллллллллллллллл
;-----------------------------------------


; лллллллллллл STRUCTURES лллллллллл STRUCTURES лллллллллл STRUCTURES ллллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл


; ллллллллл EQUATES лллллллл EQUATES ллллллллл EQUATES ллллллл EQUATES лллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
ifndef BUFFR_SIZ
    BUFFR_SIZ       equ     128
endif
ifndef BUFSIZE
    BUFSIZE         equ     256
endif
ifndef MBUFSIZE
    MBUFSIZE        equ     65535
endif

NUM_ATTRIB    equ     15

;##########################################################################
; лллллллллллл DATA ллллллллл DATA ллллллллл DATA лллллллллл DATA ллллллллл
.data
; ллллллллллллCONSTANT ASSIGNMENTSллллллллллллллллллллллллллллллллллллллллл
ff          db  12,0
lf          db  13,10,0     ; line feed
tab         db  9,0         ; tab
n_          dd  10          ; newline
x_          dd  0           ; any character
_Altern_$ DB  'wb+',0      ; alternate I/O Mode
Lprint$     db  'lpt1',0    ; for LPRINT
Lprnmode$   db  'w',0       ; for LPRINT

; лллллллллллллллDO NOT DELETEллллллллллллллллллллллллллллллллллллллллллллл

Title: Re: BxbAsm
Post by: SteveA on October 22, 2011, 06:41:17 PM
Wow !
This looks great, James.
My hat's off to you. You know this conversion process way better than I do.

Question: what MinGW files are you using ?
My MinGW is a bit dated and I only have ".h" (include) and ".a" (lib) files.

What's the advantage of "elf" files ?
I understand the reasoning for Linux, but, I thought your example was Win.
Title: Re: BxbAsm
Post by: jcfuller on October 23, 2011, 03:47:35 AM
Steve,
  I was using 4.4.1 but just this am downloaded 4.6.1 and it seems to work fine.
I use the web installer to handle all my many versions on my computer.
It recommends not installing to MinGW directory so I add the version -> MinGW461.
This is the web installer.
http://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%20Installer/tdm-gcc-webdl.exe/download
Run it as administrator and install the 32bit (top selection) version. I deselect the last two options.
Because I use a couple different ones I never have the path in my global environment path. Always set via bat files.

Re: -elf
I believe (?) this is the default for MinGW. If you look at the jwasm gtk01.asm example you'll see japeth uses that
so I assumed MinGw also uses it as default. Another hint is you cannot use visual c obj files with MinGW.

There is a huge amount of work to make the output of BxbAsm cross platform. I spent weeks trying to get cross platform console/terminal working in Ubx.

James
Title: Re: BxbAsm
Post by: SteveA on October 23, 2011, 04:48:11 PM
Thanks for the SF link.
I downloaded v-461.
I'll see what I can make of it.

Title: Re: BxbAsm
Post by: SteveA on October 28, 2011, 09:57:57 AM
Code: [Select]
<snip>
jwasm -elf %1.asm
ld  %GCCCFL% -s -o %1.exe %1.obj -L%LIB% -lbxbasmlib -lmingw32 -lmsvcrt -lkernel32 -luser32 -lgdi32 -lcomctl32 -ladvapi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lwinmm -lcomdlg32 -limagehlp -lversion

Hey James,
Once Bxbasm is compiled, I don't want it to be dependant on Mingw, beyond that point.

With the Masm32 setup, all that was required was that the end-user install Masm32 and possibly any updates.
If I switch to JWasm, I don't want to force the end-user to also install Mingw (for the linking).
That is why I'm trying to figure a way to make the Mingw headers and libraries work with JWasm, (if you get my drift).

((On a side note (re: drizz) why do some people have to turn a simple question into a pissing contest, Jeez !?))

JWasm seems very limited in what it has available in terms of includes and libraries.
I don't want to wait for japheth to expand those items.
I'd rather do it myself, if someone else hasn't already.

I'm also working on getting the missing macros and functions incorporated, too.
That's not too hard to do, since I know what I need.

Oh, I forgot to mention,
I asked japheth about the mingw headers and libs.
He indicated that they might be made to work, but there are subtle differences between MS and Mingw.
He too suggested linking with LD if I chose to go that route.
I suppose LD.exe could always replace JWlink.exe in the final distro.
Hmm, your thoughts ?
Title: Re: BxbAsm
Post by: jcfuller on October 28, 2011, 12:33:01 PM
Steve,
  From the Masm forum you have all the links to the tools to create your own.
It really depends on where you want to go with BxbAsm.
It you are even contemplating a Linux version I'd say stick with MinGW and only use the "c" runtime calls. No Windows API calls at all or wrap them with your own that can be swapped out for a Linux version.


James

 
Title: Re: BxbAsm
Post by: SteveA on October 28, 2011, 01:49:13 PM
From the Masm forum you have all the links to the tools to create your own.

I tried using some of the conversion tools (h-to-inc, def-to-lib)
They don't always produce the desired results.
The product seems to generate errors.
Title: Re: BxbAsm
Post by: jcfuller on October 28, 2011, 03:12:13 PM
Well just how many proto's and libraries do you really need  to support the Bxbasm language?
Just use the MinGW setup for developing BxbAsm in c (should be c++ in my opinion but I'm class happy :)).
You can always borrow some of the individual macros and routines from m32lib and recompile with jwasm ( that shouldn't bother Steve that much - he's more worried on wholesale appropriation of the whole library)

James
Title: Re: BxbAsm
Post by: SteveA on October 28, 2011, 06:37:39 PM
Well just how many proto's and libraries do you really need  to support the Bxbasm language?

I don't want the language to be limited to where it is at this point.
The reason for resuming the project is to expand the language capabilities.
Today, Bxbasic (the interpreter) far exceeds the abilities of Bxbasm.

The resulting windows.inc, after running windows.h thru h2incx generates errors with jwasm. Too bad.
Japheth does state that it doesn't work perfectly.
H2INC (original microsoft version) fails completely. I don't even know why MS ever released it.
Title: Re: BxbAsm
Post by: John on October 28, 2011, 10:35:45 PM
Quote
Just use the MinGW setup for developing BxbAsm in C

I agree with James on this. I think what the user of BxAsm is looking for is a way to turn HIS BxBasic code into ASM source. I would prefer if BxASM used .h files for external libraries and system API calls for flexibility and portability.

Title: Re: BxbAsm
Post by: jcfuller on October 29, 2011, 02:34:54 AM
I don't want the language to be limited to where it is at this point.
The reason for resuming the project is to expand the language capabilities.
Today, Bxbasic (the interpreter) far exceeds the abilities of Bxbasm.

How is the language going to limited? You know as you create new functionality what you need for library support. Just add the protos then for a new release. Unless of course you are going to allow in line assembler within basic source? If so I think it's the users responsibility.

James


Title: Re: BxbAsm
Post by: jcfuller on October 29, 2011, 05:07:44 AM
Steve,
  Maybe tcc has something you can use?
http://bellard.org/tcc/

James
Title: Re: BxbAsm
Post by: jcfuller on October 29, 2011, 07:50:39 AM
Why not start with just the "c" runtime functions.
This may not be a complete list but as a "c" programmer you probably know already.
James
Code: [Select]
<process.h>
 <conio.h>
 <direct.h>
 <io.h>
 <ctype.h>
 <fcntl.h>
 <math.h>
 <stdio.h>
 <string.h>
 <stddef.h>
 <stdlib.h>
 <setjmp.h>
 <time.h>
 <stdarg.h>
 <sys/types.h>
 <sys/stat.h>
 <unistd.h>
Title: Re: BxbAsm
Post by: SteveA on October 29, 2011, 11:49:21 AM
... Unless of course you are going to allow in line assembler within basic source?

Actually, that is already an intrinsic function of Bxbasm.
Quote
   ASM                     passes assembly language code to the assembler

=======================================================================
ASM Command
ASM mov  eax, [esi]

ASM is not a standard Basic command, but, Bxbasic passes along to the assembler any statement that follows the ASM command.
Bxbasic does not syntax check the ASM text string.

=======================================================================

Bxbasm has had the ability to dynamically use any assembly language command or API function from day one.

John will recall..., it took me forever to find out how, (with the help of others here on this forum), an interpreter could dynamically call API functions. Which Bxbasic (the interpreter) can now do.
Title: Re: BxbAsm
Post by: jcfuller on October 30, 2011, 03:13:45 AM
Steve,
  One addition I would like to see is in BsbAsm is directives ala Bcx.
With Bcx there is the $ONEXIT directive: $ONEXIT "GCTD.BAT $FILE$"
This directive shells to the batch file GCTD.BAT passing the currnet filename (no extension) after translation is complete.
There are several others that would also prove very useful.

James
Title: Re: BxbAsm
Post by: SteveA on November 02, 2011, 05:10:56 PM
I'm having some difficulty getting JWlink to link a .lib file, that I have created, that would contain some routines.
I have exchanged messages with japheth about this, but, I have no solution yet.

The .lib file is created with C. It takes a function name ( testlib() ) and decorates it like so ( _testlib@0 ).
japheth had me do a "dumpbin" on the .lib file and every thing looks ok.
The problem is, that jwlink can't seem to see (or find) the function name.

Still working on it.

Title: Re: BxbAsm
Post by: jcfuller on November 04, 2011, 05:16:09 AM
Steve,
  I thought I'd try jwlink with a couple c routines in a library.
Everything works fine using gcc to create the object files and ar to create the library.
James

c sources:
jcf17.c
Code: [Select]

int jcftest17 (void);

int jcftest17 (void)
{
  int      i;
  i= 17;
  return i;
}

jcf18.c
Code: [Select]

int jcftest18 (void);

int jcftest18 (void)
{
  int      i;
  i= 18;
  return i;
}

I was using MinGWTDM64 hence the -m32
compiled with:
gcc -c jcf17.c -m32
gcc -c jcf18.c -m32

created the library with:

ar rcs libjcflib.a jcf17.o jcf18.o

This is the jwasm asm source:
Code: [Select]
                       ;
;+---------------------------+
;|  use CRT (MSVCRT) in ASM  |
;+---------------------------+

.386
.MODEL FLAT, stdcall
option casemap:none
     public _start

WIN32_LEAN_AND_MEAN equ 1
include \jwasm\wininc\include\windows.inc
include \jwasm\wininc\include\stdio.inc


 ;my c functions
 jcftest17 proto c
 jcftest18 proto c


;--- CStr(): macro function to simplify defining a string

CStr macro pszText:VARARG
local szText
.const
szText db pszText,0
.code
exitm <offset szText>
endm
 .data
  buffer db 20 dup (0)
 .data?
 Argc dd ?
 Argv db ?
 CmdL LPSTR ?

.CODE

_start:



Mymain  proc
    invoke jcftest17
    invoke printf,CStr("%d",10),eax
    invoke jcftest18
    invoke printf,CStr("%d",10),eax
ret

Mymain endp
  invoke Mymain
  invoke ExitProcess, NULL

    end _start


And this is my batch file for compiling

Code: [Select]
@setlocal
@ECHO OFF
@SET LIB=\jwasm\wininc\lib;\jwasm\samples\jcfuller
@SET PATH=C:\jwasm;C:\jwasm\jwlink;c:\jwasm\wininc\lib;c:\jwasm\wininc;%PATH%
@REM add more libraries below
@SET LIBS=LIBRARY kernel32.lib, msvcrt.lib, libjcflib.a

jwasm  %1.asm
jwlink  name %1.exe file %1.obj %LIBS%

endlocal
Title: Re: BxbAsm
Post by: SteveA on November 04, 2011, 06:43:34 AM
Okay..., with some advice from japheth,
I was able to narrow down what the problem might be.
He could see that the "calling convention" was the source of the problem.

In your sample, it looks like you have specified that as C [ansi],
Quote
;my c functions
 jcftest17 proto c
 jcftest18 proto c

(which any C programmer might consider as standard).
However, I needed to change that to "_stdcall".

In VC, it was relatively easy, I just needed to set a switch, (once I found it).
I have not found such a switch in Lcc.
As a result, when using Lcc, I need to specify "_stdcall" in the code.

In either case, it compiles and links now without errors.
Title: Re: BxbAsm
Post by: jcfuller on November 04, 2011, 07:26:08 AM
Same here with gcc.
James

Code: [Select]
int __stdcall jcftest17 (void);

int __stdcall jcftest17 (void)
{
  int      i;
  i= 17;
  return i;
}

and then no "c" in the protos.

Code: [Select]
;my c functions
 jcftest17 proto
 jcftest18 proto
Title: Re: BxbAsm
Post by: SteveA on November 04, 2011, 01:56:46 PM
Okay, looks like you're on top of it.
I've never had this issue before.
Libs I've created in the past were used with C programs, so they just seemed to work.
This is the first time I've tried to use a C lib with asm.

Anyway, problem solved.
Now, back to building the Bxb routines to put in the lib.
Thanks
Title: Re: BxbAsm
Post by: jcfuller on November 04, 2011, 03:01:15 PM
I really don't "do" c/c++. ;D This is the actual Bcx code that produced the c.
James
Code: [Select]
$PRJ
$NOWIN
$NOMAIN
$ONEXIT "gcc -c $FILE$.c -m32"
Function jcftest17() As Integer stdcall
    Raw As Integer i
    i = 17
    Function = i
End Sub

Title: Re: BxbAsm
Post by: SteveA on November 05, 2011, 03:40:57 PM
Quote
I really don't "do" c/c++.  This is the actual Bcx code that produced the c.
...ahh. Yes, that can be helpful.
Title: Re: BxbAsm
Post by: SteveA on November 09, 2011, 08:39:42 AM
I'm getting some mixed results with JWasm when testing some code.
I'm using the same code I used with Masm and Masm32, but, I occasionally get "missing prototype" errors from standard C runtime functions.
I think it's partly because so many of the header (INC) files are missing from jwasm and I don't know what to replace them with.

I'm going to post on masm32, see what that turns up.
Title: Re: BxbAsm
Post by: SteveA on November 11, 2011, 08:26:59 AM
I'm going over bxbasm source code with a fine tooth comb right now.
When I last revised the code, I made a considerable number of changes as to how variables were handled, which I now regret.
As one might expect, major changes to existing code have a tendancy of introducing new bugs.

The way I left it, it was trending towards a VB style of variable interface, which is really not very Bxbasic.
Also, since what I was working on was never quite completed, there are large holes in the program that need to be plugged.
I need to take it back to the roots and decide what I want the out-come to look like.

Known (actual) bugs:
1: multiple data types can be (erroneously) assigned to the same variable name,
   like:  abc = 123
          abc# = 99.9
          PRINT abc

   This should produce a parser error, (invalid data type), or, create two distinct variables.

2: no trap to guard against using reserved words as variable names,
   like:  test$ = "foobar"

   generates an assembler error.
   Originally, there was a mechanism in place (Hungarian notation) to guard against that happenning.
   For some reason, I removed that safeguard. Can't remember why tho'.
Title: Re: BxbAsm
Post by: John on December 07, 2011, 12:21:35 PM
Hi Steve,

It's been almost a month since we heard from you last. How is the project going?


John
Title: Re: BxbAsm
Post by: SteveA on December 12, 2011, 12:34:16 PM
Hi Steve,
It's been almost a month since we heard from you last. How is the project going?
John
Sorry for the delay in updates.
1) I've been quite busy, (seasonal thing),
2) I'm performing a complete rewrite of the variables parser-handler for bxbasm.

When I started looking at my original code for bxbasm, I could see that the way I parsed variables differed too greatly from the way bxbasic does at present. Not that there was anything wrong in the way I did it, it's just that I would like source script from one dialect to be compilable via the other. And that wasn't going to happen.
Over the years, bxbasic had grown and gone through many rewrites and bxbasm hadn't.
So, I'm bringing bxbasm up to the same level.
I'm not talking about cosmetic things, I'm talking about the core engine of the thing.

I'll try and be a little more conversant about the details of what's happening.
Title: Re: BxbAsm
Post by: SteveA on December 29, 2011, 07:56:08 AM
Current update:
Well, I've been working away on Bxbasm.
I've done almost a complete rewrite of the way variables are processed.
The way I had left it, (years ago), just wasn't to my likeing at the present time.
As I've stated previously, when I last worked on it, it was looking more like VB.
I wanted to take it back to a simpler form. More QB like and most importantly, more Bxbasic like.

Right now, I'm testing all the functions and making sure it compiles, assembles and works as expected.
There have been a few glitches along the way that I have had to correct.
I have to say, it's much easier to write new, fresh code than it is to rework old code.
When reworking older code, you always seem to break other things along the way. That's to be expected.

Anyway, I'm running through all the test examples I've written and making tweaks along the way.
At the rate I'm progressing, I should have a test release ready in a week or two.
Title: Re: BxbAsm
Post by: John on December 29, 2011, 10:02:51 AM
Steve,

Thanks for the update and good to hear you're making progress.

Should this topic be moved to the compiler section with a new thread title? I assume you're not using Ubx to get there.

John
Title: Re: BxbAsm
Post by: SteveA on December 29, 2011, 11:38:28 AM
Should this topic be moved to the compiler section with a new thread title? I assume you're not using Ubx to get there.

Funny thing...,
I thought I had created a thread over there (compilers), but, I didn't see it.


edit:
my mistake...
I had a thread in interpreters.
Yes, I should have stated a thread in compilers.
Title: Re: BxbAsm
Post by: jcfuller on December 29, 2011, 12:07:32 PM
Steve,
  Great to hear of your progress but isn't BxbAsm still a translator?
Basic source to assembler source then compiled to and exe by JWasm ??

James



Title: Re: BxbAsm
Post by: SteveA on December 30, 2011, 09:15:21 AM
... but isn't BxbAsm still a translator?
Basic source to assembler source then compiled to and exe by JWasm ??

Very good point, James.
Yes, it is a translator.
However, I have found that there is a grey area there where translator fades to compiler (as it were).

In my opinion (and that is all it is) a true compiler would be one single program (both frontend and backend) that did everything from start to finish.
By that I mean, take the original source code (script) and generate the object code and ultimately link and create the finished executable.
All in one program.
However, no one actually does that.
As we are all quite aware, the compile process is a multi-step process.
I have found that in many cases, compiler creators borrow steps from other compilers.

I wish I had the time, financial resources and know-how, to just jump right in a do it, start to finish.
I've certainly read up enough on the subject.
At this point in time, I would simply like to produce the front-end and borrow someone elses mid-section and back-end.
Time will tell...
Title: Re: BxbAsm
Post by: John on December 30, 2011, 10:02:41 AM
Quote
However, no one actually does that.

I disagree. I think OxygenBasic is a true compiler. (JIT is optional)

Title: Re: BxbAsm
Post by: aurel on December 30, 2011, 12:11:36 PM
I think that Oxygen Basic is not 'true compiler' then JIT.Still exe depend on oxygen.dll
Oh yes ...
there is option with rtl and in this case there is no need for oxygen.dll.
oups i forget..
Title: Re: BxbAsm
Post by: SteveA on December 30, 2011, 12:31:26 PM
I disagree. I think OxygenBasic is a true compiler.

That may very well be the case.
I have not had the time to examine OxygenBasic, but, it does sound very interesting.
I am intrigued by it.
Title: Re: BxbAsm
Post by: aurel on December 30, 2011, 02:03:05 PM
Hi Steve ...
Intrigue...
I found him very simple with clean code.
Hmmm i think that i forget little bit update OxyEdit ::)
Title: Re: BxbAsm
Post by: Charles Pegge on December 30, 2011, 08:52:28 PM
Just to clarify: Oxygen goes all the way down to machine code, without a token layer. Oxygen.dll contains both a compiler and a run-time library. By including an RTl32 or RTL64 with the source code, the binary can be made independent of Oxygen.dll

For the new year, I will be investigating possible emitters and translators by tapping off the compiler pipeline at various stages. (The devil is always in the detail :) )

Charles
Title: Re: BxbAsm
Post by: SteveA on January 09, 2012, 01:48:34 PM
Update:
It's been over a week so I thought I'd better give an update.
First, I've been a bit under the weather for the past week, (cold/flu) whatever is going around.
I did manage to do some work on Bxbasm in spite of it.

I've been putting the current version of bxbasm thru some tests. I dug out my old samples and I'm testing each one and doing some fine tuning.
Funny, I was stuck for about three days trying to find a bug in the file I/O section.
It seemed to me that random file I/O was not working the way it was supposed to and producing so odd results.
I disected the code from beginning to end and could find nothing wrong.
As it turned out, the code was correct and the file I/O was working just as it was supposed to.
That's what happens when you try coding when you are sick.

Anyway, still plugging away here. I should be making some progress this week.
Title: Re: BxbAsm
Post by: SteveA on January 10, 2012, 06:55:52 AM
As you may be aware, I'm making modifications to Bxbasm so that it assembles with both Jwasm and Masm, seamlessly.
I am a bit concerned about continuing with Jwasm, tho'.

Nearly a month ago, Japheth posted this message on SourceForge:
Quote
2011-12-15 00:36:41 PST

Hello,

I'm busy with real life issues and cannot work for JWasm currently.

I hope that this state will change in 01/2012.

japheth
http://sourceforge.net/projects/jwasm/forums/forum/927109/topic/4883161

Hmmm,
The last time I said something like that was back in 2004, when I suspended development on Bxbasm..., until now.
Again, mine was due to real life issues as well.

Title: Re: BxbAsm
Post by: jcfuller on January 10, 2012, 08:12:44 AM
Steve,
  JWasm is quite stable so what are your concerns?

Maybe take another approach with LLVM?

http://llvm.org/

James
Title: Re: BxbAsm
Post by: SteveA on January 10, 2012, 09:21:37 AM
  JWasm is quite stable so what are your concerns?

I agree, it does seem quite stable.
My only concern is that I don't know what JWasm lacks.
If there are unknown, undocumented features or bugs that japheth hasn't the time or desire to fix.
I didn't start using Jwasm when it first came out for those same reasons.

That is one reason why I have used Masm for so many years.
Despite the fact that MS has discontinued support for Masm, they still supply new versions with their software packages.

We've all seen so many projects abandoned in mid-stream, just when they were getting good.
I'm happy to be using JWasm. It seems to be doing everything I need it to do, at the moment.
But, then, I've only started.

I'm not going to stress over it too much.
I've got a lot of work to do on Bxbasm that will keep me occupied for a fair amount of time.
Hopefully japheth will be able to find some spare time to keep jwasm updated.
Title: Re: BxbAsm
Post by: SteveA on February 03, 2012, 08:29:00 AM
I'm still here, plugging away, every day or every chance I get on Bxbasm.
I'd like to put out a new release, but, I keep finding issues I need to deal with.
I hate putting out something that I know will be seen as being buggy.

I'm still working on writing a replacement for the Masm32 utilities, macros and routines.
Right now I'm trying to create a solution to comparing real numbers with the FPU and being able to branch in the right direction.
In case you didn't know it before, the x86 has a great set of compare and branch instructions.
Unfortunately, these are only x86 instructions and only work with integer values.
There are no FPU compare and branch instructions for testing real numbers and branching based on the test result.
This seems really odd to me, that the designers didn't feel the need.
The solution, (if it truely is a solution, as it's more of a work-around), is to use a combination of both instruction sets.
This is not an ideal solution.
Title: Re: BxbAsm
Post by: John on February 03, 2012, 08:53:40 AM
Quote
I hate putting out something that I know will be seen as being buggy.

We can't help or learn if we can't see code.

This is what AllBasic is about, developers helping developers.

I'm looking for help building a cross platform IDE using IUP for ScriptBasic. I would like to use the GUI layout tool that comes with IUP for the GUI designer and incorporate the ScriptBasic sdbg debugging pre-processor into the mix for single step execution and variable display.

I'm currently working on finishing up the CD (canvas draw) extension to the IUP API. Building an IDE would also shake out any issues that might still be hiding.
Title: Re: BxbAsm
Post by: SteveA on February 03, 2012, 10:43:58 AM
We can't help or learn if we can't see code.

This is what AllBasic is about, developers helping developers.
You're right.
I'll see if I can put something together today and upload what I have, (bugs and all).
Uploading raw code is not a problem, by something I mean documentation, because the current docs don't account for all the changes made.
I kind of need to explain what works and what's different.

Title: Re: BxbAsm
Post by: Charles Pegge on February 04, 2012, 03:40:48 AM
Steve,

For FPU comparisons use FCOMI / FCOMIP. This directly sets flags in the CPU. (but not the sign flag). So you can branch with JA JB JAE JBE JZ JNZ.

FCOMI / FCOMIP only works between st(0) and st(1..7). And the comparison is in reverse to what you would normally expect. So try with a few simple cases to get the right polarity.

Charles
Title: Re: BxbAsm
Post by: jcfuller on February 04, 2012, 06:32:32 AM
I see by the source this is to be Windows Only?
I thought one of the reasons for using JWasm was the possibility of a Linux version??
And LccWin32?

James
 
Title: Re: BxbAsm
Post by: jcfuller on February 04, 2012, 08:08:19 AM
I did manage to compile with gcc by commenting out :
//#define LccWin32
and
//#include <winuser.h>.
so linux port may be possible after all?
Have not tried running it yet.

James


Title: Re: BxbAsm
Post by: SteveA on February 04, 2012, 02:49:10 PM
For FPU comparisons use FCOMI / FCOMIP. This directly sets flags in the CPU. (but not the sign flag). So you can branch with JA JB JAE JBE JZ JNZ.
Thanks for the information Charles.
I did manage to locate some of that on another forum, but, your reply was the most direct and to the point.


Quote
Thanks for the information Charles.
And the comparison is in reverse to what you would normally expect. So try with a few simple cases to get the right polarity.

Yes, I did discover the polarity issue.
At first I wondered what was going on.
So I played with it until I understood what was happening.
Thanks
Title: Re: BxbAsm
Post by: SteveA on February 04, 2012, 03:12:29 PM
I see by the source this is to be Windows Only?
I thought one of the reasons for using JWasm was the possibility of a Linux version??

You are correct about Linux.
I figured that a Linux version can simply omit the windows specific stuff.

Note, this is not, in any way, an official release.
This is just an opportunity for you to see the work-in-progress as it is, at this point.
This is not something I would ever release for general consumption.
I figure, since this is a developer site, it's fair to share what's under the hood (so to speak).

Right now, I'm just trying to get what I had previously written, re-written and headed in the right direction and stable.
Bare in mind, that's the major reason why I have not up loaded anything until now.
There was just too much revising taking place.

Only now, is most everything working again.
At one point, most everything was broken and not in a working state.

Quote
And LccWin32?

I prefer LccWin32.
Over the years that I have been using it, I have found Lcc to be extremely stable and reliable.
Plus, if I have a problem or a question about something concerning Lcc, I can email Jacob Navia and we discuss it.
It's nice to have a one-on-one with the developer.
Title: Re: BxbAsm
Post by: SteveA on February 04, 2012, 03:22:44 PM
I did manage to compile with gcc by commenting out :
//#define LccWin32

That might work.
Originally, when I was compiling under 2 different compilers, that was there for that reason.
With Lcc I was using the TCCONIO library for lowlevel console graphics I/O.

Quote
//#include <winuser.h>.

so linux port may be possible after all?
Have not tried running it yet.

I don't remember what the reason is that I was using winuser.h.
But, at some point I needed it for something.
It's entirely possible that I don't and I just didn't remove it.
Any way, try running it.

edit:
Remember..., this is still a ruff cut.
Title: Re: BxbAsm
Post by: jcfuller on February 05, 2012, 08:25:36 AM
Steve,
  Don't forget Raymond's FPU library is available for use.
http://www.ray.masmcode.com/fpu.html#fpulib

James
Title: Re: BxbAsm
Post by: SteveA on February 06, 2012, 09:15:21 AM
  Don't forget Raymond's FPU library is available for use.

Right.
I have conversed a bit with Ray recently and I consider him to be a genuine authority on the FPU routines.
I have studied a number of his routines in the past.
He certainly knows the FPU like not many people do.
I rank his work quite highly.
Title: Re: BxbAsm
Post by: jcfuller on February 07, 2012, 04:26:37 AM
Steve,
  Observations.
I managed to compile and link this example with the bxbasm created with MinGw.
Code: [Select]
'-----cut-n-paste------'
REM  test.bas version 1
PRINT "hello world!"
BEEP
END
'-----cut-n-paste------'

I do not have conio.inc in jwasm or masm32 include directories.

I created a console mode app using the batch file below.
I noticed all your batch files are creating a windows gui?
I may be wrong as it's been awhile since I studied jwlink.

These are the batch files I am using.

for console:
jwcon.bat:
Code: [Select]
@setlocal
@ECHO OFF
@SET LIB=\jwasm\wininc\lib
@SET PATH=C:\jwasm;C:\jwasm\jwlink;c:\jwasm\wininc\lib;c:\jwasm\wininc;c:\jwasm\wininc\Include;%PATH%
@REM add more libraries below
@REM SET LIBS=LIBRARY kernel32.lib, msvcrt.lib, user32.lib
@REM @SET LIBS=LIBRARY libc.lib

jwasm  %1.asm
jwlink  system pe_con name %1.exe file %1.obj %LIBS% %2 %3 %4
REM ECHO All Done
endlocal

for gui:
jwgui.bat:

Code: [Select]
@setlocal
@ECHO OFF
@SET LIB=\jwasm\wininc\lib;\jwasm\samples\jcfuller
@SET PATH=C:\jwasm;C:\jwasm\jwlink;c:\jwasm\wininc\lib;c:\jwasm\wininc;c:\jwasm\wininc\Include;%PATH%
@REM add more libraries below
@SET LIBS=LIBRARY kernel32.lib, msvcrt.lib,  user32.lib

jwasm  %1.asm
jwlink  system pe_gui name %1.exe file %1.obj %LIBS% %2 %3 %4 %5 %6
REM ECHO All Done
endlocal


James
Title: Re: BxbAsm
Post by: jcfuller on February 07, 2012, 06:13:26 AM
Steve,
  While I had luck compiling with gcc, g++ (as well as borland bc5++) balked at all your malloc's.
I added casts and all is fine.
attached is modified source.

James
Title: Re: BxbAsm
Post by: SteveA on February 07, 2012, 07:39:19 AM

I noticed all your batch files are creating a windows gui?
I may be wrong as it's been awhile since I studied jwlink.

Yes..., maybe..., you could be right.

That was the only way I could seem to get everything working.
I found the documentation very hard to understand.
Way too much information and no real examples.
See attachment:

I wasn't trying to build a gui app, it was supposed to be console:

JWlink format windows pe file "%1.obj" library bxblib.lib > jwlink.err

Quote
jwlink  system pe_con name %1.exe file %1.obj %LIBS% %2 %3 %4
jwlink  system pe_gui name %1.exe file %1.obj %LIBS% %2 %3 %4 %5 %6
Title: Re: BxbAsm
Post by: SteveA on February 07, 2012, 07:46:28 AM
....g++ (as well as borland bc5++) balked at all your malloc's.
I added casts and all is fine.

Yeh...,
I have read that (in C) mallocs should not be type-cast.
Sometimes I do, only when a compiler requires it.
It could be because you were using g++ (and Borland C++), which may be assuming that it is a C++ file, with C code inserted.
C and C++ compilers are not the same.

Things like that happen when I use VC++.
I have to tell VC++ to compile C, otherwise I get warnings and errors.

edit:
C code should not be compiled as C++ code.
Even though all C++ compilers will compile C code (not really, tho) they expect the code to conform to C++ requirements.

You have to specifically tell the compiler to compile C source code as a C file.
Otherwise, you are compiling and producing a C++ file and executable.
LccWin32 only compiles plain-jane C.

Most compilers out there (link MingW) are C/C++.
Meaning that they contain both a C and C++ compiler.
Title: Re: BxbAsm
Post by: jcfuller on February 07, 2012, 08:05:46 AM
Steve,
Yeah I know and I was purposely converting to c++. I am hooked on objects and the STL.  :)
vectors and strings make a whole world of difference.

Edit:
  Now that I added the casts you have the opportunity to switch to a c++ compiler while you are still
in the early stages of redevelopment :)

James
 
Title: Re: BxbAsm
Post by: SteveA on February 07, 2012, 08:11:05 AM
Yeah I know and I was purposely converting to c++.

James,
step back a couple of posts.
I modified one of my posts to add a .txt file, regarding the linker.


edit:
oops, I forgot my original train of thought........back to your quote:

Okay, I wasn't sure, but that makes perfect sense, now.
I have on several occasions compiled using C++ just to make sure my code would compile and work.
I have MingW, gcc/c++, Pelles-C, VC++....etc.
Title: Re: BxbAsm
Post by: jcfuller on February 07, 2012, 10:03:49 AM
It took me awhile to track down where I got the info for my batch files:
Code: [Select]
In the JWlink.chm file:
Linking Executable Files for Various Systems
    Linking 32-and 64-bit Executable Files
        Linking Win32/Win64 Console Executable Files
        Linking Win32/Win64 GUI Executable Files

James
Title: Re: BxbAsm
Post by: SteveA on February 07, 2012, 10:59:13 AM
It took me awhile to track down where I got the info for my batch files:

Thanks James

Title: Re: BxbAsm
Post by: SteveA on February 07, 2012, 11:39:49 AM
Quote
jwlink  system pe_con name %1.exe file %1.obj

Odd...,
I remember, when I was first setting up jwlink to use the first time, I was getting a bunch of linker errors.
Code: [Select]
...\bin\JWlink system pe_con file "%1.obj" library bxblib.lib > jwlink.err
The above code produces those same linker errors:
Quote
JWlink Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
Warning! W1107: undefined system name: pe_con
loading object files
searching libraries
Warning! W1008: cannot open bxblib.lib : No such file or directory
Warning! W1014: stack segment not found
creating an OS/2 linear extended executable

When I use my version:
Code: [Select]
...\bin\JWlink format windows pe file "%1.obj" library bxblib.lib > jwlink.err

I get no errors.
I don't get what I'm missing here.
Title: Re: BxbAsm
Post by: jcfuller on February 07, 2012, 02:13:04 PM
Maybe system pe_con does not work with file, only name %1.exe?

James

Title: Re: BxbAsm
Post by: jcfuller on February 07, 2012, 02:22:38 PM
Here is the output from translation,compile,link using the jwcon.bat file
I added:
@SET LIBS=LIBRARY bxblib.lib to the bat file

James

Code: [Select]
C:\BcxRadAsm\RadAsm3\Bcx\Projects\BcxBxbAsm>bcxbxbasm hello.bas
Copyright: Blunt_Axe_Basic, BxbAsm, Bxbasic (c) sarbayo, 2004-2012
Alpha Release: 1.06.3, Bxbasm Compiler

Destination file: hello.asm
Lines compiled: 6
Done.

C:\BcxRadAsm\RadAsm3\Bcx\Projects\BcxBxbAsm>\jwasm\jwcon hello
JWasm v2.07pre, Nov  2 2011, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

hello.asm: 137 lines, 2 passes, 172 ms, 0 warnings, 0 errors
JWlink Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
loading object files
searching libraries
creating a PE executable
Title: Re: BxbAsm
Post by: jcfuller on February 08, 2012, 03:53:26 AM
Steve,
  This is an FYI when compiling bxbasm with Pelles C.

James

Code: [Select]
Setting 32-bit environment for Pelles C...
Compiling "BCXBXBASM.c"..........
bxbasm163\AInput.c(97): warning #2114: Local 'pi' is not referenced.
bxbasm163\AInput.c(96): warning #2114: Local 'varname' is not referenced.
bxbasm163\AInput.c(96): warning #2114: Local 'ch' is not referenced.
bxbasm163\AUtils.c(496): warning #2114: Local 'count' is not referenced.
bxbasm163\AUtils.c(721): warning #2114: Local 'ch' is not referenced.
bxbasm163\AUtils.c(754): warning #2114: Local 'ch' is not referenced.
bxbasm163\AFunct.c(1632): warning #2114: Local 'pi' is not referenced.
bxbasm163\AFunct.c(1631): warning #2114: Local 'varname' is not referenced.
bxbasm163\AFunct.c(1631): warning #2114: Local 'ch' is not referenced.
bxbasm163\AFunct.c(1751): warning #2114: Local 'temp' is not referenced.
bxbasm163\AFunct.c(1762): warning #2114: Local 'ch' is not referenced.
bxbasm163\AVars.c(318): warning #2114: Local 'ch' is not referenced.
bxbasm163\AVars.c(347): warning #2114: Local 'ch' is not referenced.
bxbasm163\AVars.c(415): warning #2114: Local 'ch' is not referenced.
bxbasm163\AVars.c(771): warning #2114: Local 'value' is not referenced.
bxbasm163\AVars.c(771): warning #2114: Local 'ndx' is not referenced.
bxbasm163\AVars.c(770): warning #2114: Local 'temp' is not referenced.
bxbasm163\AVars.c(770): warning #2114: Local 'ch' is not referenced.
bxbasm163\AVars.c(813): warning #2114: Local 'ndx' is not referenced.
bxbasm163\AVars.c(895): warning #2114: Local 'temp' is not referenced.
bxbasm163\AVars.c(895): warning #2114: Local 'ch' is not referenced.
bxbasm163\AVars.c(942): warning #2114: Local 'temp' is not referenced.
bxbasm163\AVars.c(942): warning #2114: Local 'ch' is not referenced.
bxbasm163\ARdp.c(102): warning #2114: Local 'Value' is not referenced.
bxbasm163\ARdp.c(239): warning #2114: Local 'ch' is not referenced.
bxbasm163\ARdp.c(724): warning #2114: Local 'ch' is not referenced.
bxbasm163\ARdp.c(955): warning #2114: Local 'varname' is not referenced.
bxbasm163\ARdp.c(988): warning #2114: Local 'varname' is not referenced.
bxbasm163\ARdp.c(1019): warning #2114: Local 'varname' is not referenced.
bxbasm163\ANinput.c(17): warning #2114: Local 'ch' is not referenced.
bxbasm163\ANinput.c(34): warning #2114: Local 'ch' is not referenced.
bxbasm163\ALoops.c(12): warning #2114: Local 'mark_or' is not referenced.
bxbasm163\ALoops.c(12): warning #2114: Local 'pi' is not referenced.
bxbasm163\ALoops.c(37): warning #2114: Local 'pi' is not referenced.
bxbasm163\ALoops.c(257): warning #2114: Local 'len' is not referenced.
bxbasm163\ALoops.c(382): warning #2114: Local 'type' is not referenced.
bxbasm163\ALoops.c(571): warning #2114: Local 'ab_code' is not referenced.
bxbasm163\ALoops.c(569): warning #2114: Local 'ch' is not referenced.
bxbasm163\ALoops.c(640): warning #2114: Local 'ch' is not referenced.
bxbasm163\AIf.c(73): warning #2114: Local 'len' is not referenced.
bxbasm163\AIf.c(596): warning #2114: Local 'len' is not referenced.
bxbasm163\AIf.c(818): warning #2114: Local 'varname' is not referenced.
bxbasm163\AString.c(75): warning #2114: Local 'size' is not referenced.
bxbasm163\AString.c(74): warning #2114: Local 'ndx' is not referenced.
bxbasm163\AString.c(73): warning #2114: Local 'ch' is not referenced.
bxbasm163\AString.c(233): warning #2114: Local 'ch' is not referenced.
bxbasm163\AString.c(264): warning #2114: Local 'ch' is not referenced.
bxbasm163\AString.c(381): warning #2114: Local 'ch' is not referenced.
bxbasm163\AString.c(597): warning #2114: Local 'ch' is not referenced.
bxbasm163\AString.c(635): warning #2114: Local 'ch' is not referenced.
bxbasm163\AString.c(673): warning #2114: Local 'ch' is not referenced.
bxbasm163\AString.c(692): warning #2114: Local 'ch' is not referenced.
bxbasm163\AFile.c(276): warning #2114: Local 'ch' is not referenced.
bxbasm163\AFile.c(420): warning #2114: Local 'size' is not referenced.
bxbasm163\AFile.c(641): warning #2114: Local 'size' is not referenced.
bxbasm163\AFile.c(718): warning #2114: Local 'fld_len' is not referenced.
bxbasm163\AFile.c(716): warning #2114: Local 'ch' is not referenced.
bxbasm163\AFile.c(815): warning #2114: Local 'format' is not referenced.
bxbasm163\Scandim.c(454): warning #2114: Local 'ch' is not referenced.
bxbasm163\Scandim.c(491): warning #2114: Local 'ch' is not referenced.
bxbasm163\Scanmisc.c(140): warning #2114: Local 'size' is not referenced.
bxbasm163\Scanmisc.c(139): warning #2114: Local 'ii' is not referenced.
bxbasm163\Scanmisc.c(138): warning #2114: Local 'NVar' is not referenced.
bxbasm163\Scanfor.c(11): warning #2114: Local 'ch' is not referenced.
bxbasm163\Scanfor.c(206): warning #2114: Local 'ch' is not referenced.
bxbasm163\Scanfile.c(14): warning #2114: Local 'value' is not referenced.
bxbasm163\Scanfile.c(12): warning #2114: Local 'file' is not referenced.
bxbasm163\Scanfile.c(263): warning #2114: Local 'ch' is not referenced.
bxbasm163\Scanfile.c(345): warning #2114: Local 'ch' is not referenced.
bxbasm163\Scanfile.c(373): warning #2114: Local 'ival' is not referenced.
Linking ................
Finished!

Title: Re: BxbAsm
Post by: SteveA on February 08, 2012, 07:45:33 AM
  This is an FYI when compiling bxbasm with Pelles C.
Code: [Select]
Setting 32-bit environment for Pelles C...
Compiling "BCXBXBASM.c"..........

Yeh, those just reflect changes I've made along the way and have yet to clean up.
They're all local variables that I discontinued using as time went on.
They don't affect the outcome of the program.

Thanks for providing that list James. I'll clean those up asap.
Title: Re: BxbAsm
Post by: SteveA on February 10, 2012, 06:56:03 PM
 ;)
Here's this weeks updated code (attached).
This zip file contains the executable and all the source files (zipped).
Not everything is included, as not everything has changed.
The .txt file lists the new things added to this version.
Additionally, there is an examples.zip containing some .bas examples.

James,
many of the things needing fixes, that you illustrated, have been corrected.
However, I did not make the C++ related changes.

Title: Re: BxbAsm
Post by: jcfuller on February 11, 2012, 02:51:34 AM
Steve,
  I can still compile with g++ if I use -fpermissive except for line 1133 of Input.c. You have no data type for ndx.

changing:
Code: [Select]
void var_types(ndx)                    /* tokenize variable types */
To
Code: [Select]
void var_types(int ndx)                    /* tokenize variable types */

fixes the problem.

I am surprised both LCWin32 and Pelles accepts this? Is this a "c" defult standard?

James
Title: Re: BxbAsm
Post by: jcfuller on February 11, 2012, 04:06:26 AM
Steve,
  I know this is still alpha but I report all I find that is not quite what I expect.

In Epilog() AInput.c remove.

Code: [Select]
  writeln("  invoke StdIn, addr BffrInput, BUFFR_SIZ   ; pause");

The pause should be in the basic source if you want/need it for display.

It also appears your PAUSE only responds to Enter Key. Needs to be changed to any key in my opinion

James

Edit:

Steve,
  I use _getch() for both Windows and Linux with ubx.
In Output.c I changed
Code: [Select]
writeln("invoke gets, addr BffrInput");
To:
Code: [Select]
writeln("invoke _getch");
and it appears to work fine.
Contrary to some info I found _getch() is avaiable everywhere I tried it?



Title: Re: BxbAsm
Post by: jcfuller on February 11, 2012, 06:09:32 AM
Steve,
  Sources for bxblib.lib ???

James
Title: Re: BxbAsm
Post by: SteveA on February 11, 2012, 03:42:43 PM
I can still compile with g++ if I use -fpermissive except for line 1133 of Input.c. You have no data type for ndx.

Actually, it's prototyped as:     void var_types(int);
I think that's why its accepted.

My bad tho'.  ???
Your fix is correct.  ;)

As I looked at the code, I noticed that I'm not using that function, ( var_types() ),  anyway.
But, I'm not ready to delete it, just yet.
Thanks for the heads up.
Title: Re: BxbAsm
Post by: SteveA on February 11, 2012, 03:55:23 PM
Code: [Select]
  writeln("  invoke StdIn, addr BffrInput, BUFFR_SIZ   ; pause");
The pause should be in the basic source if you want/need it for display.
It also appears your PAUSE only responds to Enter Key. Needs to be changed to any key in my opinion

Yes, I did it that way only because I was using QEditor as my IDE.
QEditor pops open a console window, on top of the GUI screen, during execution.
I needed to suspend the console in place after execution, since I didn't yet have a PAUSE command in place.

Quote
  I use _getch() for both Windows and Linux with ubx.

"Roger"..., I'll make that change.
Thanks.
Title: Re: BxbAsm
Post by: SteveA on February 11, 2012, 04:11:00 PM
 Sources for bxblib.lib ???

 ???
My bad.
Title: Re: BxbAsm
Post by: SteveA on February 14, 2012, 04:58:43 PM
 ???
I was working on adding some more math functionality and hit a snag with fabs().
At first, jwasm gave me a missing prototype error like:
Quote
INVOKE requires prototype for procedure

so, I went into math.inc and saw that the proto line for fabs was commented out.
I un-commented it and now get this error:
Quote
math.inc(81) : Error A2082: Must be in segment block
 math.inc(81): Included by
   Test2.asm(15): Main line code
Test2.asm(117) : Error A2159: INVOKE requires prototype for procedure

I've no idea what that should mean.
Any ideas ?   :-\
Title: Re: BxbAsm
Post by: jcfuller on February 15, 2012, 03:03:16 AM
Steve,
  I ran h2incx against MinGW and TCC math.h and both spit out fabs_ ?
While waiting on a reply at sourceforge try creating your own proto.

James
Title: Re: BxbAsm
Post by: SteveA on February 15, 2012, 06:59:47 AM
I ran h2incx against MinGW and TCC math.h and both spit out fabs_ ?

Hmm.
I noticed that Japheth uses inc and lib files from Visual Studio 6.
I was planning on trying VS 2008 and Mingw, to see if they work.
Also, I searched math.inc for anything with *fabs*.
There are several, but, none are "fabs_".

Quote
While waiting on a reply at sourceforge try creating your own proto.

Yeh, that was one of the first things I did. It didn't have any affect.
I think it's a bug of some sort in the lib file, having nothing to do with the proto.
I think that's why Japheth commented-out the original proto in math.inc.
He must have encountered the bug, previously.
Title: Re: BxbAsm
Post by: SteveA on February 20, 2012, 05:07:33 PM
Here's the past weeks updated code (attached).
This zip file contains the executable and all the source files (zipped).

Again, not everything is included, as not everything has changed.
The .txt file lists the new functionality added to this version.
The examples.zip contains a few .bas examples.

There are numerous math routines added, but, the most significant addition is SUBs.
SUBs are available only in a limited way.
The example Sub1.bas shows the limited extent of the testing.

Steve
Title: Re: BxbAsm
Post by: SteveA on February 21, 2012, 01:48:26 PM
I'll be working on further development of SUBs.
So don't be discouraged that they are still in a primitive state.

So far, (as can be seen by the examples), SUBs can be declared and be passed simple variables.
Next I need to be able to declare and assign local variables.

Steve
Title: Re: BxbAsm
Post by: SteveA on February 24, 2012, 07:47:18 AM
Okay, attached is this weeks update.
I've done more work on SUBs and am now able to DIM local variables.
Only the files affected are included in the zip.

Additionally, a couple of bugs were fixed that involve While/Wend.

For anyone new to this forum, and reading this for the first time, go back and first download the prior zip files from earlier posts.
Since this is not an official release of bxbasm, no setup or installation info is included.
I can only assume that you already have Jwasm installed, (off the root directory of the C drive).

James,
let me know if you get this running on Linux and any problems or issues.

If anyone else has been able to get bxbasm installed and working, on either platform, please let me know.

Thanks,
Steve
Title: Re: BxbAsm
Post by: SteveA on April 09, 2012, 07:51:16 AM
James,
haven't heard from you in a while.
Are you still working with Bxbasm ?

If so, I wanted to touch base on a few things.
If not, no biggy.
Title: Re: BxbAsm
Post by: jcfuller on April 10, 2012, 03:06:29 AM
Steve,
  I have  not done anything recently. My Linux 32bit box died and I have not fully set up the new one to do any Bxbasm testing.

James
Title: Re: BxbAsm
Post by: SteveA on April 10, 2012, 06:31:52 AM
Aww,   :'(
sorry to hear that.
Hope you are able to fully recover soon.
Title: Re: BxbAsm
Post by: SteveA on April 11, 2012, 11:10:02 AM
Well, I guess I should post something..., lest people think I've quite working on this.

I've been busy working on a number of things, but, where it concerns Bxb, I've done a little bug fixing on Bxbasic just to make sure Bxbasic and Bxbasm function in a similar way. I don't want to be producing two seperate dialects.  As a reminder, Bxbasic is the core dialect that I'm working from.

Here's what I've been up to:
1) cleaning up Bxbasic (interpreter) and resolving some known issues,
2) continually working on Bxbasm and adding functionality, to bring it up to the level of Bxbasic,
3) working on some new documentation for Bxbasm,
4) tossing around some ideas for a new tutorial series and possibly a new revised and extended "Let's build a Scripting Engine/Compiler".

I've pretty much resolved my earlier issues with Jwasm. I think I've got it figured out. The Includes and Libs are kind of a mish-mash, but, maybe I can rework that for my purposes. I have found that, because of the way it was done, (or thrown together), some of the prototypes for functions and macros don't work correctly. So, when I encounter an issue, I just try to short-circuit the problem.

I originally thought I was going to have to reconstruct the Masm32 macros and utilities to make Bxbasm work, but, I've discovered that I really don't need them at all. I can just build the utilities I need and disregard the rest.

I have not produced an installation package, because I find I keep needing to make modifications to the Inc and Lib files. I suppose I can always add changes to the *updates*.

Over all, Jwasm (win32 ver.) seems to work quite well. That does bring up a couple of points:
1) I really would like to see a Linux version of Bxbasm,
2) I'm starting to add Win32 GUI stuff to Bxbasm.

Since I don't have a Linux machine setup, I guess I'm going to have to get one and figure out what the differences are.
Right now, Bxbasm can produce console mode apps without too much dependancy on Win32. However, if ported to Linux, there are a few things that may require ncurses. At least that's what I've heard.

If anyone is interested, I can upload the latest versions of what I've got at present. I should do it in two files, tho'. One for console mode only and a second with the new GUI/GDI stuff I'm adding.

Again, none of this is an official release, as none of it has been tested to any degree.
It works on paper!

Steve
Title: Re: BxbAsm
Post by: John on April 11, 2012, 05:33:04 PM
Quote from: Steve
If anyone is interested, I can upload the latest versions of what I've got at present.

I have a Ubuntu 11.04 32 bit box I can do some testing with and provide feedback. I have zero ASM background so unlike James, my feedback will be limited. Please zip/post a complete development package and let me/us know what dependencies might be needed to install from external resources.

Title: Re: BxbAsm
Post by: SteveA on April 11, 2012, 06:03:07 PM
Hey John,
the asm part should either work or not work, assuming an x86, since much of it (console mode) uses the C library.

It's the Win GUI stuff that will present problems.
I'm not familiar with the Linux API's.
The only C on Linux programming I've done was console mode stuff with GCC.

Title: Re: BxbAsm
Post by: jcfuller on April 12, 2012, 03:04:14 AM
Steve,
  I'm surprised John didn't mention it but I think using IUP for the gui might be the way to go.

James
Title: Re: BxbAsm
Post by: SteveA on April 12, 2012, 07:34:12 AM
  I'm surprised John didn't mention it but I think using IUP for the gui might be the way to go.

Hey James,
I'm sure that using a tool kit could possibly solve a lot of immediate problems. Certainly it could speed up development.
I personally have refrained from using tool kits in the past and instead opted for native API code.
I think I would leave that choice up to the end-user. I don't want to create just another wx??? style program.
I would like Bxb to have as much of the API as possible to be intrinsic, or at least the ability to directly call any API function directly.

I've had some experience with this in the past, when I aided T. Chandler create a fork of Bxbasic that used Allegro, giving it GUI capability.
Allegro is okay, I just don't much care for the idea of depending on third-party Libs and DLLs.
I would like the language itself to be as robust as possible and let the end-user decide if they want to use a tool kit.
Title: Re: BxbAsm
Post by: John on April 12, 2012, 11:24:36 AM
Steve,

What is your plans for external library support?

It would be nice to be able to use .h include files.

I think what James was saying about IUP is that it uses the native API for GUI. (win32api for Windows and Gtk for Linux)

John
Title: Re: BxbAsm
Post by: SteveA on April 12, 2012, 02:52:05 PM
What is your plans for external library support?
It would be nice to be able to use .h include files.

I'm not clear what that means.
".h" = C header files.
How would that affect Bxbasm ?
Bxbasm is constructed using C, but, Bxbasm generates Assembler.
Do you want Bxbasm to be able to include C source code ?

Quote
I think what James was saying about IUP is that it uses the native API for GUI. (win32api for Windows and Gtk for Linux)

http://en.wikipedia.org/wiki/IUP_(software)

To me, (and I could be wrong) the Win32 API is native to Windows, at it's root.
GTK is a widgets tool kit, (much like wxWidgets and similar tool kits), and uses the native API, but is not the API.
No ?

Linux has it's own API, does it not ?
I would prefer to use it over a tool kit.
That's what I meant when I stated: "I don't want to create just another wx??? style program".

It makes no difference to me whether you call it wxCompiler/Interpreter or gtkCompiler/Interpreter or whatever.
I have no objection to Bxbasm being able to make use of widget tool kits, but, I don't want to build something that is dependant on them.
Like everything else that begins with wx or whatever prefix.
I guess programming with tool kits just doesn't impress me.
I'm not sold on tool kits.
Title: Re: BxbAsm
Post by: John on April 12, 2012, 03:34:08 PM
If I wanted to add SQLite3 to my project, how would I declare the functions?

Gtk is your native GUI for Linux. (GNOME) There are others (KDE, X, ...) but Gtk 3 is the current standard.



Title: Re: BxbAsm
Post by: AIR on April 12, 2012, 05:28:59 PM
I have no objection to Bxbasm being able to make use of widget tool kits, but, I don't want to build something that is dependant on them.

Same approach I took with MBC, so I agree 100%. 
Title: Re: BxbAsm
Post by: SteveA on April 12, 2012, 06:11:24 PM
If I wanted to add SQLite3 to my project, how would I declare the functions?

Okay..., anything in a LIB can be compiled into Bxbasm.
So, if you have a LIB, that contains compiled functions, an .INC file can contain the prototypes.
Example:
    include C:\...\...\Include\bxblib.inc    ; list: prototypes

    includelib C:\...\...\Lib\bxblib.lib        ; library: compiled functions

Then, it's just a simple matter of calling the function directly with whatever parameters it requires.
In the case of DLLs, a function may need to be constructed to parse the parameter list and call the DLL in the proper manner.


Quote
Gtk is your native GUI for Linux. (GNOME) There are others (KDE, X, ...) but Gtk 3 is the current standard.

No problem.
I am confident that Bxbasm can be made flexible enough to work with any API and/or tool kit.
I'm just not familiar with the list of Linux API functions and what resembles or replaces the Win-API.

EDIT: re: SQLite3:
Ok..., I had to take a look at the sqlite3 header file.
A component of jwasm is a utility called h2inc. It scans ".h" (C header) files and converts them into ".inc" (assembly proto) files.
Then, it's a simple matter of linking Bxbasm with sqlite3.lib.
Example:
    include C:\...\...\Include\sqlite3.inc    ; list: prototypes

    includelib C:\...\...\Lib\sqlite3.lib        ; library: compiled functions

Call SQL functions normally, as you would in C.
Title: Re: BxbAsm
Post by: jcfuller on April 13, 2012, 02:41:20 AM
Quote
Linux has it's own API, does it not ?

Yes and No. read up on xwindows - many in the know say it is one of the worst creations ever to be bestowed on *nix.

James
Title: Re: BxbAsm
Post by: jcfuller on April 13, 2012, 06:00:54 AM
Steve,
  I'm trying to get back up to speed with bxbasm and was able to compile the last source (Feb 24?) on linux. Unfortunately it hung when trying to parse a source sample.
Will try again when you provide your latest updated source.

James
Title: Re: BxbAsm
Post by: SteveA on April 13, 2012, 10:22:08 AM
Will try again when you provide your latest updated source.

Okay, that will be the next thing I do this morning.
Stay tuned, thanks.

Title: Re: BxbAsm
Post by: SteveA on April 13, 2012, 01:20:55 PM
Okay,
here is the latest version of Bxbasm, without any Windows GUI specific stuff added.
It dates back to 03-13-12.
...okay..., so that was a month ago.
It has a number of small functions added from the CRT and some minor refinements.

The single zip file contains a cluster of zips within. Each zip is labeled as to the location where it should be unzipped.
Example:
      bin-folder.zip:  ../jwasm/bin/*.*        ::contains a win32 EXE and batch files I use to compile,
bxbasm-folder.zip:  ../jwasm/bxbasm/*.*  ::(or working directory) contains bxbasm needed include files,
  inc-lib-folder.zip:  ../jwasm/Include/*.*  :: bxbasm include file
                           ../jwasm/Lib/*.*        :: bxbasm lib file

I have not made any changes to bxblib.lib, so, the sources for that file remain the same as the prior version.

James,
if you run into the same *snag* as before, please let me know what it pertains to.
I'd like to resolve that problem.

And, the same to anyone else..., since there has been minimal testing, I'd like to be made aware of the breaking points.

Thanks,
Steve


P.S.
the document Bxbasic.txt contains a listing of the most recent function additions in chronological order.
Title: Re: BxbAsm
Post by: jcfuller on April 13, 2012, 04:06:59 PM
Steve,
  In my opinion you need to eliminate all Windows api code in your bas -> asm translation.
I don't even have a number of of the jwasm inc files you stuff in the asm code.

I can compile bxbasm.c with gcc and tcc on windows using:

Code: [Select]
/* Bxbasm.c : Masm, JWasm  alpha version 1.06.3 */
/* Bxbasic, Bxbasm (C) Copyright sarbayo, 2004-2012 */


//#define LccWin32


/*--------------------- DECLARE HEADERS ---------------------*/
/*----------------------               ----------------------*/
#include <stdio.h>
#include <conio.h>
#include <io.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <time.h>
//#include <winuser.h>
//#include <windows.h>
#include <direct.h>
#include <stdbool.h>

and by eliminating:
//SetConsoleTitle(t_holder);

in main()


I know this is an alpha but I see no way to port it with the windows specific asm source output.


It compiled on linux by eliminating:
#include <conio.h>
#include <io.h>
#include <winuser.h>
#include <windows.h>
#include <direct.h>

but still hangs after printing the copyright and destination file name when attempting to translate a bas file to asm.

James


Title: Re: BxbAsm
Post by: SteveA on April 13, 2012, 04:57:46 PM
Here is a Win32 (exclusive) version that incorporates some GDI functions.
Title: Re: BxbAsm
Post by: SteveA on April 13, 2012, 05:20:02 PM
In my opinion you need to eliminate all Windows api code in your bas -> asm translation.
I don't even have a number of of the jwasm inc files you stuff in the asm code.

In a Linux version I would do just that.
Bare in mind, I am working with a Win32 system.
There is no way to write one single piece of code that is going to compile on both a Win32 and Linux system.
I didn't expect the Win32 version to compile correctly, under Linux, without modifications.

Yes, I've had to add new INC files to jwasm, as jwasm is missing many headers and/or some don't work correctly.


Quote
...and by eliminating:
//SetConsoleTitle(t_holder);

in main()

I know this is an alpha but I see no way to port it with the windows specific asm source output.

No..., you are right.
That part of the code needs to be changed to whatever Linux requires.
As I've indicated, I do not have a Linux system setup at this time and I am unfamiliar with the Linux API.

It can be ported by substituting the win32 specific function calls with the correct Linux calls.
Are you saying, for instance, Linux has no substitution for "SetConsoleTitle" ?

Quote
It compiled on linux by eliminating:
#include <conio.h>
#include <io.h>
#include <winuser.h>
#include <windows.h>
#include <direct.h>

but still hangs after printing the copyright and destination file name when attempting to translate a bas file to asm.

There are a number of required functions within those headers. That may be the problem.
Title: Re: BxbAsm
Post by: John on April 13, 2012, 05:51:24 PM
Maybe it would be easier to port if there was a working version on whatever platform.

My vote is to get a stable Windows version going. (largest user base)

This will give you time to get up to speed with Linux.

Charles (O2) is getting his arms around Linux as well. He is a member/developer here and I hope he finds time to  chime in.

I find this project interesting because of the intermediate ASM source code that is generated. Once it works, the fun begins when the hard core ASM guys feel the need to tweak it just a bit more.  :D
Title: Re: BxbAsm
Post by: jcfuller on April 14, 2012, 04:24:24 AM

Quote
There is no way to write one single piece of code that is going to compile on both a Win32 and Linux system.

I did it with ubx with just one CONSTANT (#define).

I am also working on bcx9 which is a windows only app but will spit out *nix compatable source on demand.

This is what I use for linux:
Code: [Select]
// *********************************************************************
// Created with BCX32 - BASIC To C/C++ Translator (V) 9.0.0.7 (2012/03/23)
//                 BCX (c) 1999 - 2012 by Kevin Diggins
// *********************************************************************
//          Translated for compiling with an ANSI/ISO C Compiler
// *********************************************************************
#include <ctype.h>      // dos/linux
#include <fcntl.h>      // dos/linux
#include <math.h>       // dos/linux
#include <stdio.h>      // dos/linux
#include <string.h>     // dos/linux
#include <stddef.h>     // dos/linux
#include <stdlib.h>     // dos/linux
#include <setjmp.h>     // dos/linux
#include <time.h>       // dos/linux
#include <stdarg.h>     // dos/linux
#include <sys/types.h>
#include <sys/stat.h>   
#include <wchar.h>      // linux only
#include <stdbool.h>    // linux only
#include <dirent.h>     // linux only
#include <sys/wait.h>   // linux only
#include <unistd.h>     // linux only
#include <dlfcn.h>      // linux only
#include <termios.h>    // linux only

and this is for Windows:

Code: [Select]
// *********************************************************************
// Created with BCX32 - BASIC To C/C++ Translator (V) 9.0.0.7 (2012/03/23)
//                 BCX (c) 1999 - 2012 by Kevin Diggins
// *********************************************************************
//          Translated for compiling with an ANSI/ISO C Compiler
// *********************************************************************
#include <process.h>    // dos
#include <conio.h>      // dos
#include <direct.h>     // dos
#include <io.h>         // dos
#include <ctype.h>      // dos/linux
#include <fcntl.h>      // dos/linux
#include <math.h>       // dos/linux
#include <stdio.h>      // dos/linux
#include <string.h>     // dos/linux
#include <stddef.h>     // dos/linux
#include <stdlib.h>     // dos/linux
#include <setjmp.h>     // dos/linux
#include <time.h>       // dos/linux
#include <stdarg.h>     // dos/linux
#include <sys/types.h> 
#include <sys/stat.h>   


There are big differences in console/terminal manipulation code( pos,locate,color...) as Linux uses escape sequences (ala old dos)
 where with windows you do need the winapi.

I have the code if you want it when you reach that stage but first I think you need to create code that only uses the standard "c" libraries.

James
Title: Re: BxbAsm
Post by: jcfuller on April 15, 2012, 05:38:49 AM
Steve,
  I tried to track down the problems on Linux to no avail. It appears to hang at different places depending on the source to be translated.
I ran it against valgrind but it did not help.
I am really a novice when it comes to linux (and "c") so unless an experienced linux lurker helps out I'm afarid it's windows only.

James
Title: Re: BxbAsm
Post by: SteveA on April 15, 2012, 03:08:21 PM
Maybe it would be easier to port if there was a working version on whatever platform.

Maybe...,.
This version does work, as long as you don't expect more than linear, console mode apps.

There was a small learning (more like remembering) curve, at the start, but, once I revisited my old source code and understood it (again) I was able to get a handle on Jwasm. I pretty much think I have a better understanding of Jwasm (or rather, the collection of utilities which I refer to as the "Jwasm package", since they are designed to work together). So far, Jwasm does not appear to be especially buggie, altho' it does have a few (minor) problems that I think I can live with. Even Masm has a number of known bugs that require work-arounds.

Quote
Once it works, the fun begins when the hard core ASM guys feel the need to tweak it just a bit more.

There are a few things I would change (tweak),  pretty much right off the bat. They just aren't too important to me at the moment.
Title: Re: BxbAsm
Post by: SteveA on April 15, 2012, 03:47:20 PM
Quote from: steve
There is no way to write one single piece of code that is going to compile on both a Win32 and Linux system.

I did it with ubx with just one CONSTANT (#define).

Okay, I should have been more clear.
I never was writing a strictly console mode app.
Much of Bxbasic (interpreter) is built upon a blend of C Library (console) and win32 console mode utilities and functions.
I took the same approach in designing Bxbasm: "I used from all available parts".

I pretty much figured that if the Win32 API has a function called "foo.api" and I use it for its intended purpose, (for simplicity, let's say to clear the screen, for instance), then Linux must have a corresponding function, maybe its called: koo.??, or poo.??, or boo.??, or ???.??, that clears the screen.
Simple..., you do a one for one switch.
I must be in error.
I must have assumed too much.

Quote
There are big differences in console/terminal manipulation code( pos,locate,color...) as Linux uses escape sequences (ala old dos)
 where with windows you do need the winapi.

From what I'm gathering, I may have to approach Linux programming more like programming MS-DOS.
Does Linux use an API, or do you call interrupts and ANSI.SYS functions, like DOS ?

Quote
I have the code if you want it when you reach that stage but first I think you need to create code that only uses the standard "c" libraries.
Well, (in my opinion), to change Bxbasm to the point that: "you need to create code that only uses the standard "c" libraries", would seriously be a step backwards.
Now, that said, what I can do is to make a modified version, specifically for a Linux port, that "only uses the standard "c" libraries".
It will be devoid of some existing functionality.
I already know what some of that will be, as I used win32 API functions to create that functionality.

I'll see what I can do and what we end up with.
Let you know, soon.
Title: Re: BxbAsm
Post by: SteveA on April 15, 2012, 08:13:14 PM
Okay,
here it is.
Totally untested, but, it compiles without errors.
This is, as far as I can tell, using no win32 functions.
C runtime library only.

Let me know if it compiles under GCC and if it produces working assembly code.
Thanks.

edit:
I deleted this attachment, as it was full of glitches.
Title: Re: BxbAsm
Post by: jcfuller on April 16, 2012, 03:21:58 AM
Steve,
  Same results on linux. Compiles fine but hangs when translating basic source to asm.
 Need ctrl-c to return to terminal prompt.

I doctored up the previous version with numerous printf's to see if I could find out why but it failed in different places depending
on the source being translated. I am not proficient enough in "c" debugging to help much more than that.

James

 
Title: Re: BxbAsm
Post by: jcfuller on April 16, 2012, 04:28:03 AM
Steve,
  This is a sample of the output with printf's added by me on two samples;Sub1 and ucase
James

Sub1:
Code: [Select]
james@magic-micro ~/bxbasmx/examples $ ../Bxbasm Sub1
Copyright: Blunt_Axe_Basic, BxbAsm, Bxbasic (c) sarbayo, 2004-2012
Alpha Release: 1.06.3, Bxbasm Compiler

** stripped down version for Linux

before init_fldbffrs()
back from init_fldbffrs()
back from load_src
back from loader_1
In loader_2 nrows = 28
temp_byte[ndx] = 56
temp_byte[ndx] = 56
temp_byte[ndx] = 56
temp_byte[ndx] = 56
temp_byte[ndx] = 46
temp_byte[ndx] = 46
temp_byte[ndx] = 46
temp_byte[ndx] = 59
temp_byte[ndx] = 59
temp_byte[ndx] = 59
temp_byte[ndx] = 59
temp_byte[ndx] = -1
temp_byte[ndx] = 8
temp_byte[ndx] = 57
temp_byte[ndx] = 4
temp_byte[ndx] = 58
temp_byte[ndx] = 57
temp_byte[ndx] = 4
^C

ucase:

Code: [Select]
james@magic-micro ~/bxbasmx/examples $ ../Bxbasm ucase
Copyright: Blunt_Axe_Basic, BxbAsm, Bxbasic (c) sarbayo, 2004-2012
Alpha Release: 1.06.3, Bxbasm Compiler

** stripped down version for Linux

before init_fldbffrs()
back from init_fldbffrs()
back from load_src
back from loader_1
In loader_2 nrows = 10
temp_byte[ndx] = 46
temp_byte[ndx] = 1
temp_byte[ndx] = 4
temp_byte[ndx] = 4
temp_byte[ndx] = 1
temp_byte[ndx] = 4
temp_byte[ndx] = 1
temp_byte[ndx] = 4
temp_byte[ndx] = -1
temp_byte[ndx] = 8
after loop nrows = 10
back from loader_2
back from line_cnt
Destination file: ucase.asm
^C
james@magic-micro ~/bxbasmx/examples $

Title: Re: BxbAsm
Post by: jcfuller on April 16, 2012, 04:53:11 AM
Steve,
  Also note there is no CR (13) in linux text files. All lines end with just a LF (10).
gcc on linux will handle both I believe but if you are checking for CR anywhere it will probably fail.

James
Title: Re: BxbAsm
Post by: SteveA on April 16, 2012, 05:50:56 AM
Also note there is no CR (13) in linux text files. All lines end with just a LF (10).
gcc on linux will handle both I believe but if you are checking for CR anywhere it will probably fail.

Yes, I am testing for CR, in a number of places.
That is a major development !

Ok, let me look at it and see if I can find them.
Title: Re: BxbAsm
Post by: jcfuller on April 16, 2012, 06:29:56 AM
Steve,
  I traced the Sub1 hang to an endless loop in str_func2.

James
Title: Re: BxbAsm
Post by: SteveA on April 16, 2012, 08:57:33 AM
I've found some other things that I hadn't noticed prior.
I've got to take a deeper look at them and either fix them or disable them.
Bxb uses a lot of reusable code in many places, so, one problem can easily cascade.
Title: Re: BxbAsm
Post by: SteveA on April 16, 2012, 11:05:10 AM
  I traced the Sub1 hang to an endless loop in str_func2.

I'd go back to the earliest examples in BXBASIC.TXT and try running those really simple tests before running the later examples.
Stripped down, I'm having trouble getting it to assemble and compile even the simplest: PRINT "Hello" test.
Not being able to use any of the win32 headers is a big problem.

I'm still working on it.
I've had to redo bxblib.lib, too.
So far, I can't get much of anything to compile and execute without error.
Title: Re: BxbAsm
Post by: SteveA on April 16, 2012, 07:29:50 PM
Okay,
attachement is the latest "working" (maybe it's ready for Linux) version.
I had to rewrite some functions and eliminate others.

NOTE: Bxblib.lib needs to be recompiled.

Here are the console functions that no longer work:
CLS
LOCATE
BEEP
COLOR
SLEEP
MESSAGEBOX
DATE$
TIME$
TIMER

as they relied on win32 api function calls.

Everything else I tried was working as intended.
Now the question is, will any of it work on Linux ?
Title: Re: BxbAsm
Post by: jcfuller on April 17, 2012, 03:58:51 AM
Now the question is, will any of it work on Linux ?

No.
Same results with ucase and Sub1 examples although without my added printf's I have no idea where they are hanging.

James
Title: Re: BxbAsm
Post by: jcfuller on April 17, 2012, 04:08:56 AM
Steve,
  Ran it against test and test version 2 from BXBASIC.TXT and it converted by removing after I removed BEEP.

James
Title: Re: BxbAsm
Post by: SteveA on April 17, 2012, 06:36:11 AM
No.
Same results with ucase and Sub1 examples although without my added printf's I have no idea where they are hanging.

Boy, that's funny, because I tested those, specifically.
Let me take another look.

Quote
Ran it against test and test version 2 from BXBASIC.TXT and it converted by removing after I removed BEEP.

Yeh, I got everything in Bxbasic.txt to run, after I removed BEEP, LOCATE, etc.



Title: Re: BxbAsm
Post by: SteveA on April 17, 2012, 07:24:36 AM
No.
Same results with ucase ....I have no idea where they are hanging.

Okay,
here is the definition for _strupr and _strlwr, in string.inc:
Quote
@DefProto _CRTIMP, strchr, c, , <:ptr SBYTE, :DWORD>
@DefProto _CRTIMP, _strcmpi, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, _stricmp, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, strcoll, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, _stricoll, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, _strncoll, c, , <:ptr SBYTE, :ptr SBYTE, :size_t>
@DefProto _CRTIMP, _strnicoll, c, , <:ptr SBYTE, :ptr SBYTE, :size_t>
@DefProto _CRTIMP, strcspn, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, _strdup, c, , <:ptr SBYTE>
@DefProto _CRTIMP, _strerror, c, , <:ptr SBYTE>
@DefProto _CRTIMP, strerror, c, , <:DWORD>
@DefProto _CRTIMP, _strlwr, c, , <:ptr SBYTE>
@DefProto _CRTIMP, strncat, c, , <:ptr SBYTE, :ptr SBYTE, :size_t>
@DefProto _CRTIMP, strncmp, c, , <:ptr SBYTE, :ptr SBYTE, :size_t>
@DefProto _CRTIMP, _strnicmp, c, , <:ptr SBYTE, :ptr SBYTE, :size_t>
@DefProto _CRTIMP, strncpy, c, , <:ptr SBYTE, :ptr SBYTE, :size_t>
@DefProto _CRTIMP, _strnset, c, , <:ptr SBYTE, :DWORD, :size_t>
@DefProto _CRTIMP, strpbrk, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, strrchr, c, , <:ptr SBYTE, :DWORD>
@DefProto _CRTIMP, _strrev, c, , <:ptr SBYTE>
@DefProto _CRTIMP, strspn, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, strstr, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, strtok, c, , <:ptr SBYTE, :ptr SBYTE>
@DefProto _CRTIMP, _strupr, c, , <:ptr SBYTE>
@DefProto _CRTIMP, strxfrm, c, , <:ptr SBYTE, :ptr SBYTE, :size_t>

Take a look at your Linux version of string.inc (or .h, or whatever) and make sure it's the same.

Here is the asm code that calls it:
Code: [Select]
 lea  eax, StringBffr
  mov  [eax], byte ptr 0 ; clear string-copy buffer
  push eax
  invoke  _strupr, string ; CRT function str-to-uppercase
  mov esi, eax
  pop eax
  call copystrng

This is the only place it can possibly fail.
Title: Re: BxbAsm
Post by: SteveA on April 17, 2012, 07:35:38 AM
No.
Same results with ucase and Sub1 examples although without my added printf's I have no idea where they are hanging.

Wait a minute...
I had to go back and re-read prior posts...,

I need to be clear on what's happening...,

a)  those programs will not compile, or,
b)  they do compile, but, fail to execute ?

Title: Re: BxbAsm
Post by: jcfuller on April 17, 2012, 07:45:58 AM
Steve,
  Sub1,bas and ucase.bas cause Bxbasm to hang when trying to translate *.bas -> *.asm.

Also note linux file names are case sensitive:
#include "Ainput.c" -> #include "AInput.c"

If I compile gcc -Wall there are numerous warnings. I have had issues in the past where warnings meant failure of the executable?


James
Code: [Select]
gcc -Wall -o "Bxbasm" "Bxbasm.c" (in directory: /home/james/bxbasmx/source)
In file included from Bxbasm.c:18:0:
globals.h:141:32: warning: "/*" within comment [-Wcomment]
globals.h:150:32: warning: "/*" within comment [-Wcomment]
In file included from Bxbasm.c:21:0:
Input.c: In function Сline_cntТ:
Input.c:61:39: warning: "/*" within comment [-Wcomment]
Input.c: In function Сloader_1Т:
Input.c:153:13: warning: variable СlenТ set but not used [-Wunused-but-set-variable]
In file included from Bxbasm.c:23:0:
AInput.c: In function Сload_tmpdataТ:
AInput.c:308:9: warning: variable СxТ set but not used [-Wunused-but-set-variable]
In file included from Bxbasm.c:25:0:
AFunct.c: At top level:
AFunct.c:266:1: warning: "/*" within comment [-Wcomment]
AFunct.c:488:40: warning: "/*" within comment [-Wcomment]
AFunct.c:500:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1114:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1149:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1171:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1195:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1212:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1257:1: warning: "/*" within comment [-Wcomment]
AFunct.c: In function СDo_printТ:
AFunct.c:1582:37: warning: "/*" within comment [-Wcomment]
AFunct.c:1606:52: warning: "/*" within comment [-Wcomment]
AFunct.c:1683:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1702:40: warning: "/*" within comment [-Wcomment]
AFunct.c: At top level:
AFunct.c:1775:5: warning: "/*" within comment [-Wcomment]
AFunct.c:1779:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1783:27: warning: "/*" within comment [-Wcomment]
AFunct.c:1787:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1854:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1856:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1859:35: warning: "/*" within comment [-Wcomment]
AFunct.c:1864:35: warning: "/*" within comment [-Wcomment]
AFunct.c:1867:35: warning: "/*" within comment [-Wcomment]
AFunct.c:1869:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1876:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1882:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1906:1: warning: "/*" within comment [-Wcomment]
In file included from Bxbasm.c:27:0:
AVars.c:17:1: warning: "/*" within comment [-Wcomment]
AVars.c: In function СDo_redimArrayТ:
AVars.c:35:45: warning: "/*" within comment [-Wcomment]
AVars.c: In function СDo_eraseТ:
AVars.c:115:18: warning: variable СtypeТ set but not used [-Wunused-but-set-variable]
AVars.c: In function СDo_dimVarТ:
AVars.c:191:41: warning: "/*" within comment [-Wcomment]
AVars.c:209:55: warning: "/*" within comment [-Wcomment]
AVars.c:234:50: warning: "/*" within comment [-Wcomment]
AVars.c:187:18: warning: unused variable СndxТ [-Wunused-variable]
AVars.c: In function СDo_dimArrayТ:
AVars.c:247:43: warning: "/*" within comment [-Wcomment]
AVars.c:259:65: warning: "/*" within comment [-Wcomment]
AVars.c:263:57: warning: "/*" within comment [-Wcomment]
AVars.c: At top level:
AVars.c:358:1: warning: "/*" within comment [-Wcomment]
AVars.c: In function СDo_letТ:
AVars.c:438:36: warning: "/*" within comment [-Wcomment]
AVars.c:453:52: warning: "/*" within comment [-Wcomment]
AVars.c:434:18: warning: unused variable СndxТ [-Wunused-variable]
In file included from Bxbasm.c:28:0:
ARdp.c: In function Сasn_numarryТ:
ARdp.c:327:40: warning: "/*" within comment [-Wcomment]
ARdp.c: At top level:
ARdp.c:1354:1: warning: "/*" within comment [-Wcomment]
In file included from Bxbasm.c:30:0:
ALoops.c: In function СDo_whileТ:
ALoops.c:154:9: warning: variable СpiТ set but not used [-Wunused-but-set-variable]
ALoops.c: In function СwboolexpressТ:
ALoops.c:244:32: warning: "/*" within comment [-Wcomment]
ALoops.c:230:42: warning: unused variable СxТ [-Wunused-variable]
ALoops.c:230:30: warning: unused variable Сab_codeТ [-Wunused-variable]
ALoops.c:230:9: warning: variable СpiТ set but not used [-Wunused-but-set-variable]
In file included from Bxbasm.c:31:0:
AIf.c: In function СDo_ifТ:
AIf.c:12:9: warning: variable СpiТ set but not used [-Wunused-but-set-variable]
AIf.c: In function Сget_ExptypeТ:
AIf.c:477:63: warning: "/*" within comment [-Wcomment]
AIf.c: In function СDo_SwitchТ:
AIf.c:852:9: warning: variable СpiТ set but not used [-Wunused-but-set-variable]
In file included from Bxbasm.c:32:0:
AString.c: At top level:
AString.c:420:32: warning: "/*" within comment [-Wcomment]
AString.c:427:1: warning: "/*" within comment [-Wcomment]
AString.c:431:32: warning: "/*" within comment [-Wcomment]
AString.c:438:1: warning: "/*" within comment [-Wcomment]
AString.c: In function СstrsvalТ:
AString.c:521:29: warning: unused variable СtmpТ [-Wunused-variable]
In file included from Bxbasm.c:33:0:
AFile.c: In function Сlineinput_ioТ:
AFile.c:415:10: warning: variable СchТ set but not used [-Wunused-but-set-variable]
AFile.c: In function Сinput_ioТ:
AFile.c:897:30: warning: unused variable СwflagТ [-Wunused-variable]
In file included from Bxbasm.c:35:0:
Scandim.c: In function Сdim_arrayТ:
Scandim.c:394:42: warning: "/*" within comment [-Wcomment]
Scandim.c:406:54: warning: "/*" within comment [-Wcomment]
Scandim.c:431:41: warning: "/*" within comment [-Wcomment]
Scandim.c: In function Сparse_local_dimТ:
Scandim.c:593:18: warning: unused variable СndxТ [-Wunused-variable]
In file included from Bxbasm.c:36:0:
Scanlet.c: In function СScanLetТ:
Scanlet.c:15:20: warning: unused variable СxТ [-Wunused-variable]
Scanlet.c:15:9: warning: unused variable Сab_codeТ [-Wunused-variable]
Scanlet.c: In function СScanStringТ:
Scanlet.c:119:29: warning: "/*" within comment [-Wcomment]
Scanlet.c: In function СScanMathFuncТ:
Scanlet.c:369:43: warning: "/*" within comment [-Wcomment]
Scanlet.c:425:38: warning: "/*" within comment [-Wcomment]
Scanlet.c: In function СScanNumericТ:
Scanlet.c:438:41: warning: "/*" within comment [-Wcomment]
Scanlet.c:446:35: warning: "/*" within comment [-Wcomment]
Scanlet.c:453:60: warning: "/*" within comment [-Wcomment]
Scanlet.c:486:53: warning: "/*" within comment [-Wcomment]
Scanlet.c:503:42: warning: "/*" within comment [-Wcomment]
Scanlet.c:523:41: warning: "/*" within comment [-Wcomment]
Scanlet.c:435:20: warning: unused variable СxТ [-Wunused-variable]
Scanlet.c:435:9: warning: unused variable Сab_codeТ [-Wunused-variable]
Scanlet.c: In function СSav_Destin_AТ:
Scanlet.c:537:37: warning: "/*" within comment [-Wcomment]
In file included from Bxbasm.c:37:0:
Scanprint.c: In function СScanPrintТ:
Scanprint.c:17:40: warning: "/*" within comment [-Wcomment]
Scanprint.c:24:56: warning: "/*" within comment [-Wcomment]
Scanprint.c:44:52: warning: "/*" within comment [-Wcomment]
Scanprint.c:80:64: warning: "/*" within comment [-Wcomment]
Scanprint.c:104:58: warning: "/*" within comment [-Wcomment]
Scanprint.c:130:55: warning: "/*" within comment [-Wcomment]
Scanprint.c:148:56: warning: "/*" within comment [-Wcomment]
Scanprint.c:152:40: warning: "/*" within comment [-Wcomment]
Scanprint.c: In function СScanFPrintТ:
Scanprint.c:227:36: warning: "/*" within comment [-Wcomment]
Scanprint.c:250:37: warning: "/*" within comment [-Wcomment]
Scanprint.c:161:24: warning: unused variable СwflagТ [-Wunused-variable]
Scanprint.c: In function СScanLPrintТ:
Scanprint.c:321:35: warning: "/*" within comment [-Wcomment]
Scanprint.c:258:24: warning: unused variable СwflagТ [-Wunused-variable]
In file included from Bxbasm.c:38:0:
Scanmisc.c: In function СScanIfТ:
Scanmisc.c:79:36: warning: "/*" within comment [-Wcomment]
Scanmisc.c: In function СScanMsgBoxТ:
Scanmisc.c:184:18: warning: unused variable СtypeТ [-Wunused-variable]
Scanmisc.c:184:13: warning: unused variable СlenТ [-Wunused-variable]
In file included from Bxbasm.c:40:0:
Scanfile.c: In function СScanFieldТ:
Scanfile.c:214:39: warning: "/*" within comment [-Wcomment]
Scanfile.c:258:36: warning: "/*" within comment [-Wcomment]
In file included from Bxbasm.c:41:0:
Output.c: At top level:
Output.c:23:30: warning: "/*" within comment [-Wcomment]
Output.c:24:37: warning: "/*" within comment [-Wcomment]
Output.c:29:35: warning: "/*" within comment [-Wcomment]
Output.c:40:5: warning: "/*" within comment [-Wcomment]
Output.c:43:1: warning: "/*" within comment [-Wcomment]
Output.c:59:25: warning: "/*" within comment [-Wcomment]
Output.c:65:40: warning: "/*" within comment [-Wcomment]
Output.c:81:25: warning: "/*" within comment [-Wcomment]
Output.c:83:42: warning: "/*" within comment [-Wcomment]
Output.c:97:25: warning: "/*" within comment [-Wcomment]
Output.c:99:42: warning: "/*" within comment [-Wcomment]
Output.c:103:25: warning: "/*" within comment [-Wcomment]
Output.c:105:1: warning: "/*" within comment [-Wcomment]
In file included from Bxbasm.c:42:0:
ASubs.c: In function СDo_sub_functionsТ:
ASubs.c:233:9: warning: variable СxТ set but not used [-Wunused-but-set-variable]
Compilation finished successfully.

Title: Re: BxbAsm
Post by: SteveA on April 17, 2012, 07:50:35 AM
Okay,
I'm looking at this last post.


Okay,
most of those are just comments, like: 
  /* some code here;  /* my comment */

Quote
AFunct.c:1783:27: warning: "/*" within comment [-Wcomment]
AFunct.c:1787:1: warning: "/*" within comment [-Wcomment]
AFunct.c:1854:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1856:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1859:35: warning: "/*" within comment [-Wcomment]
AFunct.c:1864:35: warning: "/*" within comment [-Wcomment]
AFunct.c:1867:35: warning: "/*" within comment [-Wcomment]
AFunct.c:1869:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1876:40: warning: "/*" within comment [-Wcomment]
AFunct.c:1882:1: warning: "/*" within comment [-Wcomment]

those mean nothing.
Title: Re: BxbAsm
Post by: jcfuller on April 17, 2012, 07:57:27 AM
Steve,
  Here are jwasm includes for the standard "c" libray.

James
Title: Re: BxbAsm
Post by: SteveA on April 17, 2012, 08:08:21 AM
Quote
Input.c:153:13: warning: variable СlenТ set but not used
AInput.c:308:9: warning: variable СxТ set but not used
AVars.c:115:18: warning: variable СtypeТ set but not used
AVars.c:187:18: warning: unused variable СndxТ [-Wunused-variable]
AVars.c:434:18: warning: unused variable СndxТ [-Wunused-variable]
ALoops.c:154:9: warning: variable СpiТ set but not used
ALoops.c:230:30: warning: unused variable Сab_codeТ [-Wunused-variable]
ALoops.c:230:9: warning: variable СpiТ set but not used
AIf.c:12:9: warning: variable СpiТ set but not used
AIf.c:852:9: warning: variable СpiТ set but not used
AString.c:521:29: warning: unused variable СtmpТ [-Wunused-variable]
AFile.c:415:10: warning: variable СchТ set but not used
AFile.c:897:30: warning: unused variable СwflagТ [-Wunused-variable]
Scandim.c:593:18: warning: unused variable СndxТ [-Wunused-variable]
Scanlet.c:15:20: warning: unused variable СxТ [-Wunused-variable]
Scanlet.c:15:9: warning: unused variable Сab_codeТ [-Wunused-variable]
Scanlet.c:435:20: warning: unused variable СxТ [-Wunused-variable]
Scanlet.c:435:9: warning: unused variable Сab_codeТ [-Wunused-variable]
Scanprint.c:161:24: warning: unused variable СwflagТ [-Wunused-variable]
Scanmisc.c:184:18: warning: unused variable СtypeТ [-Wunused-variable]
Scanmisc.c:184:13: warning: unused variable СlenТ [-Wunused-variable]
ASubs.c:233:9: warning: variable СxТ set but not used


All of these are very non-critical variable declarations, that I ended up not using, within functions.
Nothing that would cause a crash.

Everything else is just a comment.
Title: Re: BxbAsm
Post by: SteveA on April 17, 2012, 08:22:10 AM
 Here are jwasm includes for the standard "c" libray.

Okay,
it looks like Linux has no _strupr or _strlwr.
So, UCASE$ and LCASE$ are out.

That doesn't explain why it hangs on compiling tho'.

And I'm at a loss about SUB1, too.

The only thing they have in common, is that they are both late additions to Bxbasm.
But, they use the same exact code as everything else.

edit:
funny thing..., MingW does include those functions:
Quote
_CRTIMP int __cdecl __MINGW_NOTHROW   _strcmpi (const char*, const char*);
_CRTIMP int __cdecl __MINGW_NOTHROW   _stricmp (const char*, const char*);
_CRTIMP int __cdecl __MINGW_NOTHROW   _stricoll (const char*, const char*);
_CRTIMP char* __cdecl __MINGW_NOTHROW   _strlwr (char*);
_CRTIMP int __cdecl __MINGW_NOTHROW   _strnicmp (const char*, const char*, size_t);
_CRTIMP char* __cdecl __MINGW_NOTHROW   _strnset (char*, int, size_t);
_CRTIMP char* __cdecl __MINGW_NOTHROW   _strrev (char*);
_CRTIMP char* __cdecl __MINGW_NOTHROW   _strset (char*, int);
_CRTIMP char* __cdecl __MINGW_NOTHROW   _strupr (char*);
_CRTIMP void __cdecl __MINGW_NOTHROW   _swab (const char*, char*, size_t);
Title: Re: BxbAsm
Post by: jcfuller on April 17, 2012, 09:26:18 AM
Steve,
  I believe they are not ansi standard.
This is what ubx uses:
James

Code: [Select]

char *_strupr_(char *string)
{
  char *s;
  if (string)
     {
      for(s = string; *s; ++s)
         *s = toupper(*s);
     }
   return string;
}

char *_strlwr_(char *string)
{
    char *s;

    if (string)
    {
       for (s = string; *s; ++s)
           *s = tolower(*s);
    }
    return string;
}


Title: Re: BxbAsm
Post by: SteveA on April 17, 2012, 10:18:27 AM
 I believe they are not ansi standard.

Yeh,
I figured I'd have to use toupper/tolower, in a loop, to make the conversion.
Title: Re: BxbAsm
Post by: jcfuller on April 18, 2012, 03:18:15 AM
Steve,
  I found the problem.
 It was line endings. When I cut and pasted test, test2 from README.TXT they were saved with linux line endings LF, but the Sub1 and ucase were used as is and they had CRLF. When save with just LF they converted just fine.

James
Title: Re: BxbAsm
Post by: jcfuller on April 18, 2012, 05:37:46 AM
Steve,
  In your asm output I believe you need to replace the ret in your Main proc to:
Code: [Select]
invoke exit,0

I added a proto in bxb.inc
Code: [Select]
exit proto c :DWORD

The ret caused a gpf on Linux. The invoke exit,0 appears to work fine on windows?

Conrary to what I though there is no _getch() on Linux. I looked in the ubx code and found how it was done,
and wrote a library that I linked to the demos and it worked fine.

I see you have a couple console routines in bxblib. I do believe that is the way to go.
Put all your routines in the library and I can help out by converting them to linux compatable code.

Go ahead and add your console routines back in and I'll see what I can do with them on Linux.


James
Title: Re: BxbAsm
Post by: SteveA on April 18, 2012, 07:19:52 AM
Quote
It was line endings.
...but the Sub1 and ucase were used as is and they had CRLF.
When save with just LF they converted just fine.

This is good to know.
I wonder how I could fix that ?

Quote
In your asm output I believe you need to replace the ret in your Main proc to:

You are right, it should be "exit, 0"
It was originally "ExitProcess", which is a win32 function.
I was playing around with it and never finished it.
In old dos programs you could use "ret".

Title: Re: BxbAsm
Post by: SteveA on April 18, 2012, 07:24:54 AM
What do you want to replace "_getch" with ?
Title: Re: BxbAsm
Post by: jcfuller on April 18, 2012, 07:52:44 AM
What do you want to replace "_getch" with ?


Nothing. It's working fine now that I added a Linux substitute and link it in during jwasm compiling / linking of the asm source.

James
Title: Re: BxbAsm
Post by: SteveA on April 18, 2012, 08:02:07 AM
Nothing. It's working fine now that I added a Linux substitute and link it in during jwasm compiling / linking of the asm source.

Okay.

About the console mode functions:
if I understand correctly, you want me to reactivate them...?

For the most part, I didn't delete them, I just commented them out.
That's what all the comment warnings were about, yesterday.
So, you want me to uncomment them...?
Title: Re: BxbAsm
Post by: jcfuller on April 18, 2012, 08:08:42 AM
 I tried to uncomment just CLS because I wanted to test code I had added but I got a gpf on translation from bas -> asm

Code: [Select]
REM  test.bas version 1
CLS
PRINT "hello world!"

END


I figured I must have missed something??

On another front:

  In order to compile test 5 from BXBASIC.txt I needed to compile BxbLib.c.
Was there a reason for _stdcall? I removed it and used proto c when adding the Float2Str2 proto to bxb.inc.
Compiled and worked fine. On linux the conversion routine is gcvt.

James


Title: Re: BxbAsm
Post by: SteveA on April 18, 2012, 08:12:49 AM
Quote
In order to compile test 5 from BXBASIC.txt I needed to compile BxbLib.c.
Was there a reason for _stdcall?

No, that's a windows thing.
They should be normal C calls.

Quote
I removed it and used proto c when adding the Float2Str2 proto to bxb.inc.
Compiled and worked fine. On linux the conversion routine is gcvt.

Right.



Title: Re: BxbAsm
Post by: jcfuller on April 18, 2012, 08:17:03 AM
Steve,
  I found my error. I missed uncommenting  in Input.c

James
Title: Re: BxbAsm
Post by: SteveA on April 18, 2012, 08:17:56 AM
Bxblib.inc, in /../Include, needs to be changed:

Here is how it reads:

Code: [Select]
testlib      proto stdcall
value2strng  proto stdcall :REAL8, :SBYTE
FloatToStr2  proto stdcall :REAL8, :PTR DWORD
ClearScreen  proto stdcall
locate       proto stdcall :DWORD, :DWORD
StrToFloat   proto stdcall :PTR DWORD, : PTR QWORD

remove all "stdcall".
Title: Re: BxbAsm
Post by: SteveA on April 18, 2012, 08:33:28 AM
When uncommenting, check these, in this order:

1)  Input.c, --> get_byte()

2)  Bxbasm.c --> parser()

3)  prototype.h  --> any/all

4)  the functions themselves, in whatever filename.c
     prototype.h lists file name.
Title: Re: BxbAsm
Post by: jcfuller on April 18, 2012, 10:48:03 AM
Steve,
  I would like to suggest a different approach for os dependent items.
Instead of outputing asm to be compiled use a precompiled library and link to it.
Case in point cls.
I created an object file with this code
Code: [Select]
#include <stdio.h>
#include <curses.h>
// clear console screen linux
char    ESC [2]={27,0};  // Escape
void cls(void);
void cls(void)
{
printf("%s%s%s%s",ESC,"[2J",ESC,"[H");
}
compiled with gcc -c cls.c

I then added it to a library with ar:

ar cr libbxbasm.a cls.o

I then linked this library when compiling test1.asm with this script:
Code: [Select]
~/jwasm/jwasm -elf -zcw -Fo=$1.o $1.asm
gcc -s -nostartfiles -o $1 $1.o /home/james/bxbasmx/bxblib/BxbLib.o -L/home/james/bxbasmx/bxblib -lbxbasm


Your console routines seem to be in spread out in more than one file. Your Do_color is in AVars.c while Do_locate is in AFunc.
Can these be moved to individual files, compiled, then added to a static library?
James

Title: Re: BxbAsm
Post by: SteveA on April 18, 2012, 11:15:38 AM
  I would like to suggest a different approach for os dependent items.
Instead of outputing asm to be compiled use a precompiled library and link to it.

I think that is a great idea.


Quote
Your console routines seem to be in spread out in more than one file.
Your Do_color is in AVars.c while Do_locate is in AFunc.
Can these be moved to individual files, compiled, then added to a static library?

Yes,
I previously wasn't too concerned with where they ended up.
Okay, I'll gather up all the win32/console functions and put them in a seperate file.
Would you suggest a seperate file or would you prefer a seperate LIB ?
Like: console.c or console.lib ?



Title: Re: BxbAsm
Post by: jcfuller on April 18, 2012, 01:23:38 PM
Steve,
  To keep it as granular as possible put each func in a file by itself and compile them separately. Combine the obj files to create a library. That will also will help me on the Linux side to see just what needs to be supplied.

James
Title: Re: BxbAsm
Post by: SteveA on April 19, 2012, 01:00:39 PM
Hey james,
were you able to get any of the deleted functions working ?

Do the normal C library functions seem to be working okay ?
Title: Re: BxbAsm
Post by: jcfuller on April 19, 2012, 02:55:37 PM
Steve,
  Got side tracked and had a bit of a problem following setcolor. cls works fine and I think I got locate almost working.
 Time for dinner and then the Yankee game. I'll let you know more tomorrow.

James
 
Title: Re: BxbAsm
Post by: SteveA on April 19, 2012, 03:53:56 PM
Hey James,
no problem. Just wanted to know if there were any issues I need to fix.
Have a nice evening, enjoy the game.
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 03:47:00 AM
Steve,
  I'm a bit confised with locate.
In the example from BXBASIC.TXT:
Code: [Select]
1  REM  test.bas version 6
   DIM Row = 0, Column = 0
2  CLS
3  PRINT "hello world!"
4  LET Row = 2
5  LET Column = 10
6  LOCATE Row, Column
7  PRINT "hello world!"
8  LET Row = 4
9  LET Column = 20
10 LOCATE Row, Column
11 PRINT "hello world!"
12 END

you are calling with Row, Column but in your commented function in BxbLib.c you have

Code: [Select]
//void  locate(int cx, int cy)
//{
//    COORD coordScreen;
//    HANDLE hConsole;
//
//
//    coordScreen.X = cx;
//    coordScreen.Y = cy;
//                             /* Get this console handle */
//    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
//
//                             /* Put the cursor at its coordinates */
//    SetConsoleCursorPosition(hConsole, coordScreen);
//
//}

I may be mistaken but I believe coordScreen.X is Column and coordScreen.Y is Row??

Also you require Row and Column names specifically in the basic source???

James
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 04:07:16 AM
Ok I think I see now. BxbAsm is translating to:
Code: [Select]
invoke locate, Column, Row

but it is confusing.

James
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 05:50:59 AM
Steve,
  I have cls,locate,color working. I think it would be best for now to change settextcolor to a "c" proc instead of asm code.
Using invoke color,fg,bg
I put them all in one object file as I didn't figure it needed to be anymore granular than that.
I added the protos to bxb.inc for now
I'm going to try to do the same on the windows side.

Using this basic source:
Code: [Select]
CLS
DIM Row = 0, Column = 0
LET Row = 10
LET Column = 5
COLOR 4,7
LOCATE Column,Row
PRINT "Hello World"
END

I modified the asm listing by hand before compiling with jwasm

Code: [Select]
  ;mov  eax, 4
  ;mov  ebx, 7
  ;call setcolortext
  invoke color,4,7

This is the console.c compiled to an object and added to libbxbasm.a with ar and linked to the demo executable

Code: [Select]
#include <stdio.h>
#include <curses.h>
#include <termios.h>
//void cls(void);
void cls(void)
{
printf("%c%s%c%s",27,"[2J",27,"[H");
}
//==============================================================================
//void locate(int,int);
void  locate(int col, int row)
{
printf("%c%s%u%s%u%s",27,"[",row,";",col,"H");
}
//==============================================================================
//void color (int, int)
void color (int fg,int bg)
{
  printf("%c%s%u%s%u%s",27,"[",30+(fg&7),";",40+(bg&7),"m");
}
//==============================================================================
//int _getch_(int);
int _getch_(int waitkey)
{

    struct termios initial_settings, new_settings;
    unsigned char ch;

    tcgetattr(0,&initial_settings);
    new_settings = initial_settings;
    new_settings.c_lflag &= ~ICANON;
    new_settings.c_lflag &= ~ECHO;
    new_settings.c_lflag &= ~ISIG;
    new_settings.c_cc[VMIN] = waitkey;
    new_settings.c_cc[VTIME] = 0;
    tcsetattr(0, TCSANOW, &new_settings);
    ch = getchar();
    tcsetattr(0, TCSANOW, &initial_settings);
    return ch;

}

//void bxbPause(void)
void _getch(void)
{
    int ch;
    printf("Press any key to continue . . .\n");
ch = _getch_(1);
}
//==============================================================================


James
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 05:57:11 AM
  LOCATE Row, Column

Yes, this is not a mistake.
It's that way because QuickBasic does it that way.
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 05:59:15 AM
LOCATE Column,Row

This statement would be in error.

Yes, I double checked the QuickBasic 4.5 Docs and it's: LOCATE Row, Column
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 06:18:29 AM
Quote
This is the console.c compiled to an object and added to libbxbasm.a with ar and linked to the demo executable

I'm not familiar with "ar". I don't know what it does. Must be a Linux thing.

edit:
Oh, I see, MingW has it too, archiver of some sort.

Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 06:51:37 AM
Steve,
  Works on windows.

I use this for the libbxbasm.a library on windows.

Code: [Select]
#include <windows.h>
void cls(void)
{
system("cls");
}
//==============================================================================
void  locate(int cx, int cy)
{
    COORD coordScreen;
    HANDLE hConsole;


    coordScreen.X = cx;
    coordScreen.Y = cy;
                             /* Get this console handle */
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

                             /* Put the cursor at its coordinates */
    SetConsoleCursorPosition(hConsole, coordScreen);

}
//==============================================================================

void color (int fg,int bg)
{

 HANDLE hConsole;
 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
 SetConsoleTextAttribute (hConsole,fg+bg*16);

}
//==============================================================================


James
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 06:53:31 AM
Steve,
  Doesn't LccWin32 have a library maker? It should work the same. I'm just more familiar with ar.

James
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 07:44:31 AM
 Doesn't LccWin32 have a library maker? It should work the same. I'm just more familiar with ar.

You can create ".Lib" files, (like bxblib.lib), but, I don't know of a "library maker".

LccWin32 is not a console mode application.
It is based on an IDE called "Wedit".
I've not seen a Wedit function for adding functions to .Lib files.
You just add new C source and recompile your .Lib.

When you mentioned "granularity", I kind of went  ???
I just don't know how I would do that.
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 08:16:54 AM
Steve,
  Check out the LccWin32 lcclib Utility.

James

Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 08:24:41 AM
Steve,
  What I mean by granualrity:
Several years ago I was active with FreeBASIC and wrote a library of routines and created a library with them which I linked to apps that I wrote. I was under the false knowledge that the linker was smart enough to only link the functions used. This is not the case.
I went back and put each function in it's own source file, compiled each one to an object file and then used ar to put all the object files in a library. Now when I linked the library only the functions I used were added to the exe.

LIB.exe is the MS equivalent to ar.

James
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 09:45:05 AM
  Check out the LccWin32 lcclib Utility.

Right.
That's what you use (thru Wedit) to create .Libs.
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 09:52:16 AM
What I mean by granualrity:
I was under the false knowledge that the linker was smart enough to only link the functions used.
This is not the case.

Right,
that's why I designed Bxbasm--Afunc.c the way I did:

Code: [Select]
void Do_functions()
{
    if(stringcopy == 1)
    {
        copystrng_bffr();
    }

    if(asnchrstr == 1)
    {
        func_chrstr();
    }

    if(asnleftstr == 1)
    {
        func_leftstr();
    }
(snip)


Code: [Select]
void func_rightstr()
{
    writeln("; --------------------------------------------------");
    writeln("rightstr proc ");
    writeln("; --------------------------------------------------");
    writeln("  mov  edi, offset BffrInput");
    writeln("  invoke szRight, esi, edi, eax");
    writeln("  mov  [edi+eax], byte ptr 0");
    writeln("  mov  esi, offset BffrInput");
    writeln("  ret");
    writeln("; --------------------------------------------------");
    writeln("rightstr endp");
    writeln("; =========================================================================");
}
/*---------- end func_rightstr ----------*/


void func_leftstr()
{
    writeln("; --------------------------------------------------");
    writeln("leftstr proc ");
    writeln("; --------------------------------------------------");
    writeln("  mov  edi, offset BffrInput");
    writeln("  invoke szLeft, esi, edi, eax");
    writeln("  mov  [edi+eax], byte ptr 0");
    writeln("  mov  esi, offset BffrInput");
    writeln("  ret");
    writeln("; --------------------------------------------------");
    writeln("leftstr endp");
    writeln("; =========================================================================");
}
/*---------- end func_leftstr ----------*/


void func_chrstr()
{
    writeln("; --------------------------------------------------");
    writeln("chrstr proc ");
    writeln("; --------------------------------------------------");
    writeln("  mov  esi, offset BffrInput");
    writeln("  mov  [esi], byte ptr al");
    writeln("  mov  [esi+1], byte ptr 0");
    writeln("  ret");
    writeln("; --------------------------------------------------");
    writeln("chrstr endp");
    writeln("; =========================================================================");
}
/*---------- end func_chrstr ----------*/


Sort of "conditional assembly", without all the clutter.
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 10:21:03 AM
Steve,
  Yes but you can eliminate all the testing and adding of the function source by compiling each function to an object file and add them individually to a library. Then all you need to do is translate the function call from basic to asm syntax and link to the library. In this case only the functions used will be added to the exe.

James
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 10:21:58 AM
This is the list of commands for lcclib:

Quote
lcclib processes options in the order specified on the command line and in command files. If an option is repeated with different arguments, the last one to be processed takes precedence.

/VERBOSE
Displays details about the progress of the session. The information is sent to standard output and can be redirected to a file.
/LIST
Displays information about the output library to standard output. The output can be redirected to a file. You can use /LIST to determine the contents of an existing library without modifying it.
/OUT:filename
Overrides the default output filename. By default, the output library is created in the current directory, with the base name of the first library or object file on the command line and the extension .LIB.
/REMOVE:object
Omits the specified object from the output library. LCCLIB creates an output library by first combining all objects (whether in object files or libraries), and then deleting any objects specified with /REMOVE.


I just don't think it works quite the same as ar.
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 10:59:19 AM
Steve,
From lcc.chm:

The lcclib Utility

The purpose of this utility is to build library files (.lib) from a list of object files. The general format of the command line is:

lcclib <options>  <library file>  <object files >


James
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 12:19:54 PM
The lcclib Utility
The purpose of this utility is to build library files (.lib) from a list of object files. The general format of the command line is:
lcclib <options>  <library file>  <object files >

Right, it builds library files, that's how I built bxblib.lib.
But, isn't that somehow different from what you are proposing and what you are doing with ar ?

I put all my source code in bxblib.c and bxblib.h and compile it as a .lib file.
It seems to me you are suggesting something else.

edit:
Q:
what is the advantage of compiling each function into an .obj and then (using ar or lcclib) adding each individual .obj to the lib ?
how does the result differ from simply compiling the source code for each function (at one time) and building a .lib ?

clearly I'm not grasping something here.
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 01:08:50 PM
Steve,
  As I mentioned earlier I did some testing with FreeBASIC in the past. It uses the MinGW linker ld.
I found that if I compiled a source with a number of functions to a library ALL the functions were added
to an exe that linked to the library even though I maybe only called one from my app.
But if I compiled each function to an object file then added each object file separately only the functions I actually called
were added to the exe.

Now maybe some linkers are smarter than others???

Try it with lcc and see what happens.

James
Title: Re: BxbAsm
Post by: jcfuller on April 20, 2012, 01:16:30 PM
Steve,
  Also note how Hutch creates the Masmlib. He uses all individual asm files with just one function in each.

James
Title: Re: BxbAsm
Post by: SteveA on April 20, 2012, 01:33:17 PM
Try it with lcc and see what happens.

I've been playing around with lcclib, making a .lib from .obj's.
I'm not used to using Lcclib from the commandline.
There is no IDE option for constructing .Libs this way.

I'm going test it in a moment to see if it's working the way we need.
Title: Re: BxbAsm
Post by: jcfuller on April 21, 2012, 05:38:43 AM
Steve,
  For more info on static libraries take a look at the libraries topic in asmintro.chm from the Masm32 package.

James
Title: Re: BxbAsm
Post by: SteveA on April 21, 2012, 05:33:35 PM
James,
It looks like making .Libs, from unrelated .Obj's, is going to be from the commandline.
I see no provision within Wedit for building .Libs from multiple .Objs.
That's why I originally thought it couldn't be done. And, I could not find any Wedit documentation regarding it.

I tried it, (lcclib) from the commandline and it does appear to work.
Hmm...,
now I need to figure out how I'm going to make all those functions into Obj's.

I do like the idea of doing it this way.
As you've noted, the way I designed the functions in Afunct.c, my original intention was to build the smallest possible Exe's.
And, as you've pointed out, a single .Lib file, created from a single .Obj file, does not always do that.

Steve
Title: Re: BxbAsm
Post by: jcfuller on April 22, 2012, 08:17:13 AM
Steve,
  Probably the best way would be with a make file. I noticed Lcc has a make utility  but no info on how it's used.
I am most familiar with the gnu make and because I haven't used it lately I've forgotten most of what I learned.
I also don't have a "c" ide that I am comfortable with. I thought of using code::blocks but I can't seem to just compile to an object file.
All my c/c++ work has been mostly c++ using bcx to do the actual code generation.

The MinGW set up for RadAsm3 (my preferred ide) is borked so I think I'll spend the time trying to get it to work with just
MinGW gcc "c" files.

I thought about Geany but I had problems with it not deleteing temporary files. I use it on Linux and like it a lot.

James
Title: Re: BxbAsm
Post by: jcfuller on April 23, 2012, 07:58:16 AM
Steve,
  Here is a gcc example of how to create a library using a make file.
James

c Files placed in their own directory:
cls.c
Code: [Select]
#include <windows.h>
void cls(void)
{
system("cls");
}
Locate.c
Code: [Select]
#include <windows.h>
void  locate(int cx, int cy)
{
    COORD coordScreen;
    HANDLE hConsole;


    coordScreen.X = cx;
    coordScreen.Y = cy;
                             /* Get this console handle */
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

                             /* Put the cursor at its coordinates */
    SetConsoleCursorPosition(hConsole, coordScreen);

}
color.c
Code: [Select]
#include <windows.h>
void color (int fg,int bg)
{

 HANDLE hConsole;
 hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
 SetConsoleTextAttribute (hConsole,fg+bg*16);

}
StrToFloat
Code: [Select]
#include <stdlib.h>
void  StrToFloat(char *NumStr, double *result)
{

    *result = atof(NumStr);

}
FloateToStr2
Code: [Select]
#include <string.h>
#include <windows.h>
void  FloatToStr2(double orgvalue, char *buffer)
{   char asciiValue[30];
    int len;


    gcvt(orgvalue, 80, buffer);       /* convert double to ascii */

    len = strlen(buffer);
    len--;

    if(buffer[len] == '.')
    {                             /* if this is an integer, get rid */
        buffer[len] = '\0';       /* of trailing decimal point. */
    }

    if(orgvalue >= 0)
    {
        strcpy(asciiValue, " ");       /* add leading blank space */
        strcat(asciiValue, buffer);
        strcpy(buffer, asciiValue);
    }
}
Value2Str.c
Code: [Select]
#include <stdio.h>
#include <string.h>
char *  value2strng(double value, char vartype)
{   static char buffer[81];
    int len, idx=0, dot=0;
    char ch, chx = vartype;
//    char ch, chx='#';
//    double value = 10;


    /* --- convert to ascii, here --- */
    sprintf(buffer, "% f", value);
    len = strlen(buffer);
    ch = buffer[idx];

    /* --- trim trailing zeros --- */
    if(chx == '#')                          /* Double: '#' */
    {
        idx = (len-1);
        ch = buffer[idx];

        while(ch == '0')
        {
            idx--;
            ch = buffer[idx];
        }
        buffer[(idx+1)] = '\0';
    }

    /* --- round up to .nn --- */
    else if(chx == '!')                     /* Single: '!' */
    {
        dot = (len-5);
        idx = (len-1);

        while(idx > dot)
        {
            if((buffer[idx] >= '5') && (buffer[(idx-1)] == '9'))
            {
                buffer[idx] = '\0';
            }
            else if(buffer[idx] >= '5')
            {
                buffer[(idx-1)]++;
                buffer[idx] = '\0';
            }
            else
            {
                buffer[idx] = '\0';
            }
            idx--;
        }
    }
    /* --- trim to dot --- */
    else                           /* Integers: '%' */
    {
        idx = (len-7);
        buffer[idx] = '\0';
    }

    return buffer;
}

The make file to compile and add all to a library.

Code: [Select]
AR = ar rcs
CC = gcc
OBJECTS = cls.o locate.o color.o StrToFloat.o FloatToStr2.o Value2Str.o

all : library clean_object_files
@echo Successful Build

#----------------------------------------
# compile all the *.c files in the directory
#----------------------------------------
%.o : %.c
$(CC) -Wall -c $<

#----------------------------------------
# create the library from the list of object files
#----------------------------------------
library : $(OBJECTS)
$(AR) libbxbasm.a $(OBJECTS)

#----------------------------------------
#remove all the object files
#----------------------------------------
clean_object_files :
@echo Cleaning Up
@del *.o

#----------------------------------------
#remove the object files and the library
#----------------------------------------
clean : clean_object_files
@echo Removing All Object and Library Files
@del *.a


Title: Re: BxbAsm
Post by: SteveA on April 23, 2012, 11:51:25 AM
Hey James,
okay, let me study this for a bit.


Title: Re: BxbAsm
Post by: jcfuller on April 24, 2012, 05:14:21 AM
Steve,
  While fixing my Radasm3 setup I noticed  jwasm is configured to use PellesC linker and librarian. This may be a better choice for your distribution of Bxbasm. Very liberal license and much better documentation than jwlink. I think all you need is permission from Pelle to include polink in your distribution .

James
 
Title: Re: BxbAsm
Post by: SteveA on April 24, 2012, 07:44:28 AM
Hey James,

Very liberal license and much better documentation than jwlink.

I'll have a look.

On a side note:
[rant]
Boy I sure hate licenses. They always seem to have caveats.
Like, you can use it for this, but only if you are not using it for that.
"for educational purpose only", "for private usage only", "for non-commercial use",....etc.
There are licenses and versions of versions of licenses.

What ever happened to good 'ol Public Domain.
I like a clean Copywrite (c) and a simple disclaimer.
Give credit where credit is due and use it at your own risk.

When I first released Bxbasic I included a GPL.
I then pulled the license and released a statement indicating as much.

Why the need to make free software "free with strings attached" ?

People who write software aren't lawyers and shouldn't pretend they are.
What people don't understand is that the spoken word and the meaning of the law are two different things.
[/ rant]
Title: Re: BxbAsm
Post by: SteveA on April 24, 2012, 07:52:25 AM
On another note,
I was playing around with creating Obj's from the small routines and making Lib's from the resulting code.
I think I can come up with a method of making it all work without too much complexity.
I just need to build a template of sorts to put it all together.
It would be nice if I could add it as a function of the IDE, (Wedit), but, I don't see a way to do that.
However, I do like using Hutch's Qeditor and it does make it easy to do that type of thing, just by modifying the menu.
Too bad there isn't a version of Qeditor for Linux.

Steve
Title: Re: BxbAsm
Post by: SteveA on April 24, 2012, 01:03:16 PM
James,
I've been testing wlib.exe, that come with jwasm and I seems to work quite well.
I think I like it.
It has a whole list of commands and options, unlike lcclib.
It's quite easy to use.
Does the Linux version of jwasm come with wlib ?
Steve
Title: Re: BxbAsm
Post by: jcfuller on April 24, 2012, 01:37:40 PM
Steve,
  No. ar is the library maker on linux as is using gcc/ld as the linker.

James
Title: Re: BxbAsm
Post by: jcfuller on April 24, 2012, 01:46:23 PM
Steve,
  Where did you find wlib.exe. It's not in the download from jwasm site.

James
Title: Re: BxbAsm
Post by: SteveA on April 24, 2012, 02:02:34 PM
James,
its in jwasm-206\JWlinkbw.zip

Title: Re: BxbAsm
Post by: SteveA on April 24, 2012, 02:14:37 PM
It looks like, with wlib, I only have to use lcclib on those C functions that I create in Wedit, (C functions).
Then, combine the C-Objs and the ASM-Objs using wlib into the final .Lib.
Since, I think, most of the Objs will be from assembled code rather than compiled C code, I will be using wlib more.
Title: Re: BxbAsm
Post by: jcfuller on April 25, 2012, 07:21:15 AM
Steve,
  I found RadAsm3 is the best for creating libraries with jwasm.
Just toggle each source as a module, select Assemble Modules then build. All done.
I used polib from pellesc.
James
Title: Re: BxbAsm
Post by: jcfuller on April 26, 2012, 08:24:25 AM
Steve,
  FWIW I ported the IUP headers to jwasm.
James

Code: [Select]
   .486
    .model flat, c
    option casemap :none
    
    include \jwasm\include\crt\crt.inc
    include \jwasm\iup\include\iup.inc
    includelib \jwasm\wininc\Lib\msvcrt.lib
    includelib \iup_dll6\iup.lib
;==============================================================================
CStr macro pszText:VARARG
local szText
    .const
szText    db pszText,0
    .code
    exitm <offset szText>
endm
;==============================================================================    
    .code
start:
    call main
    invoke exit,0
;==============================================================================
quit_cb proc
    mov eax,IUP_CLOSE
    ret
quit_cb endp
;==============================================================================
AddChild proc parent:PTR Ihandle,child:PTR Ihandle
    invoke IupAppend,parent,child
    invoke IupRefresh,parent
    ret
AddChild endp
;==============================================================================
Create proc Value:PTR BYTE,Attr:PTR BYTE,parent:PTR Ihandle
    LOCAL ihWnd:PTR Ihandle
    mov ihWnd,0
    invoke IupCreate,Value
    .IF eax
        mov ihWnd,eax
        invoke strlen,Attr
        .IF eax
            invoke IupSetAttributes,ihWnd,Attr
        .endif
        .IF parent
            invoke AddChild,parent,ihWnd
        .endif
        mov eax,ihWnd
    .endif
    ret
Create endp
;==============================================================================
main proc
    LOCAL \
    win:PTR Ihandle,\
    vbox:PTR Ihandle,\
    topBox:PTR Ihandle,\
    serverFrame:PTR Ihandle,\
    serverBox:PTR Ihandle,\
    serverCombo:PTR Ihandle,\
    btnFetch:PTR Ihandle,\
    controlFrame:PTR Ihandle,\
    controlBox:PTR Ihandle,\
    btnAbout:PTR Ihandle,\
    btnClear:PTR Ihandle,\
    btnExit:PTR Ihandle,\
    dictFrame:PTR Ihandle,\
    serverList:PTR Ihandle,\
    transFrame:PTR Ihandle,\
    text:PTR Ihandle,\
    bottomBox:PTR Ihandle,\
    lbl:PTR Ihandle,\
    entry:PTR Ihandle,\
    btnSearch:PTR Ihandle,\
    chkAll:PTR Ihandle,\
    chkUTF:PTR Ihandle
          
    invoke IupOpen,0,0
    invoke Create,CStr("dialog"),CStr("TITLE=Thesaurus, SIZE=500x300"),NULL
    mov win,eax
    invoke Create,CStr("vbox"),CStr("MARGIN=10x10"), NULL
    mov vbox,eax
    invoke Create,CStr("hbox"),CStr(" GAP=10"), vbox
    mov topBox,eax
    invoke Create,CStr("frame"),CStr("TITLE=Servers, EXPAND=YES"), topBox
    mov serverFrame,eax
    invoke Create,CStr("hbox"),CStr("GAP=5"), serverFrame
    mov serverBox,eax
    invoke Create,CStr("list"),CStr("DROPDOWN=YES, SIZE=120x, EXPAND=HORIZONTAL, VALUE=1"), serverBox
    mov serverCombo,eax
    invoke Create,CStr("button"),CStr("TITLE=Fetch, SIZE = 50x"), serverBox
    mov btnFetch,eax
    invoke Create,CStr("frame"),CStr("TITLE=Controls"), topBox
    mov controlFrame,eax
    invoke Create,CStr("hbox"),CStr("Margin=6x6, GAP=5"), controlFrame
    mov controlBox,eax
    invoke Create,CStr("button"),CStr("TITLE=About, SIZE = 50x"), controlBox
    mov btnAbout,eax
    invoke Create,CStr("button"),CStr("TITLE=Clear, SIZE = 50x"), controlBox
    mov btnClear,eax
    invoke Create,CStr("button"),CStr("TITLE=Exit, SIZE = 50x"), controlBox
    mov btnExit,eax
    invoke IupSetCallback,btnExit,CStr("ACTION"),OFFSET quit_cb
    invoke Create,CStr("frame"),CStr("TITLE=Dictionaries"), vbox
    mov dictFrame,eax
    invoke Create,CStr("list"),CStr("EXPAND=YES, VISIBLELINES=1"), dictFrame
    mov serverList,eax
    invoke Create,CStr("frame"),CStr("TITLE=Translation"), vbox
    mov transFrame,eax
    invoke Create,CStr("text"),CStr("MULTILINE=YES, EXPAND=YES"), transFrame
    mov text,eax
    invoke Create,CStr("hbox"),CStr("GAP=10"), vbox
    mov bottomBox,eax
    invoke Create,CStr("label"),CStr("TITLE=Enter Word to Search For:,SIZE=x12"), bottomBox
    mov lbl,eax
    invoke Create,CStr("text"),CStr(" EXPAND=HORIZONTAL"), bottomBox
    mov entry,eax
    invoke  Create,CStr("button"),CStr("TITLE=Search, SIZE=50x"), bottomBox
    mov btnSearch,eax
    invoke Create,CStr("toggle"),CStr("TITLE=ALL, VALUE=ON,SIZE=x12"), bottomBox
    mov chkAll,eax
    invoke Create,CStr("toggle"),CStr("TITLE=UTF-8, SIZE=x12"), bottomBox
    invoke AddChild,win,vbox
    invoke IupShow,win
    invoke IupSetFocus,btnFetch
    invoke IupMainLoop
    invoke IupClose
    mov eax,0
    ret
main endp
end start

Title: Re: BxbAsm
Post by: John on April 26, 2012, 08:56:13 AM
Nice job James!

I'm glad to see you becoming comfortable with IUP.

Title: Re: BxbAsm
Post by: SteveA on April 26, 2012, 10:29:31 AM
Nice job James!
I'm glad to see you becoming comfortable with IUP.

Yes, nice.

James,
I've been incrementally converting the funct.c functions over to individual .obj files and adding them to bxblib.lib.
I'm doing it one at a time, because I want to test each one, to make sure it's working correctly.
In some cases I have to make a few modifications so that everything works correctly, like: proto's, externdef's and includes.
The functions themselves work, I just need to let the assembler and linker know what's going on.
Over-all, it's going well.

I did discover another function that may not work correctly under Linux, due to the fact that it uses win32 API calls.
That's the INPUT statement.

Such as:   INPUT ;"First: "; first$; " Initial: "; init$; " Last: "; last$:

The INPUT statement controls the cursor positioning on the screen.

Steve
Title: Re: BxbAsm
Post by: jcfuller on April 26, 2012, 05:07:15 PM
Steve,
  The INPUT statements I'm familiar with (Bcx,ubx/mbc,Bacon) use fgets I believe.

James
Title: Re: BxbAsm
Post by: jcfuller on April 27, 2012, 05:58:31 AM
Steve,
  Food for thought re INPUT.
Here is the "c" output of ubx from this basic code.
James

ubx basic code:
Code: [Select]
Dim A, B$

Input "Enter A Number ", A


Select Case A

  Case   >1 And <10
  Print ">1 And <10 "

  Case   >10 And <20
  Print ">10 And <20"

  Case   31,32,33
  Print "31,32,33"

  Case Else
  Print "No special case found"

End Select


PRINT

input "Type one, two, qwerty, or other ", B$

select case B$

  case  "one","two"
  Print "one, two"

  case  "qwerty"
  Print "qwerty"

  case else
    Print "else"
end select

produces this "c" code. I don't see any WinApi?
Code: [Select]
// *********************************************************************
//   Created with Ubx 311.46 (2012/01/14)by James C. Fuller
//   Based on OSX port by Armando Rivera
//   Ported from BCX32 BASIC To C/C++ Translator (V) 5.12
//   BCX (c) 1999 - 2009 by Kevin Diggins
// *********************************************************************
//   Translated for compiling with the g++ Compiler
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <commdlg.h>
#include <mmsystem.h>
#include <shellapi.h>
#include <shlobj.h>
#include <richedit.h>
#include <wchar.h>
#include <objbase.h>
#include <ocidl.h>
#include <winuser.h>
#include <olectl.h>
#include <oaidl.h>
#include <ole2.h>
#include <oleauto.h>
#include <conio.h>
#include <direct.h>
#include <ctype.h>
#include <io.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <setjmp.h>
#include <time.h>
#include <stdarg.h>
#include <process.h>
#include <stdbool.h>


// ***************************************************
// Compiler Defines
// ***************************************************
  #define C_EXPORT extern "C"
  #define C_IMPORT extern "C"

#ifndef stat
  #define lstat stat
#endif
#ifndef _fcloseall
  #define _fcloseall _fcloseall
#endif
#ifndef MAX_PATH
  #define MAX_PATH 2048
#endif
#ifndef CALLBACK
  #define CALLBACK
#endif

// *************************************************
//                System Variables
// *************************************************

char    *AR_fgets_retval;
int     ScanError;
char    InputBuffer[1048576];

// *************************************************
//            User Global Variables
// *************************************************

static PCHAR   *G_argv;
static int     G_argc;
static int     A;
static char    B[2048];



// *************************************************
//               Standard Macros
// *************************************************



// *************************************************
//               Standard Prototypes
// *************************************************

int     str_cmp(char*, char*);
char*   BCX_TmpStr(size_t);
char*   mid (char*, int, int=-1);
char*   left (char*,int);

char*   RemoveStr (char*,char*);
int     instr_b(char*,char*,int=0,int=0);
char    *MakeLCaseTbl(void);
char    *_stristr_(char*,char*);
char    *_strstr_(char*,char*);
int     scan (char *input, char *format, ... );
int     Split (char [][2048], char*, char*, int=0);


// *************************************************
//            User Global Initialized Arrays
// *************************************************


// *************************************************
//                  Main Program
// *************************************************

int main(int argc, char *argv[])
{
  G_argc = argc;
  G_argv = argv;
  printf("Enter A Number ");
  A=0;
  AR_fgets_retval=fgets(InputBuffer,sizeof(InputBuffer),stdin);
  InputBuffer[strlen(InputBuffer)-1]=0;
  ScanError = scan(InputBuffer,"%d",&A);
 
  *InputBuffer=0;
  for(;;)
  {
    if(A>1&&A<10)
      {
        printf("%s\n",">1 And <10 ");
        break;
      }
    if(A>10&&A<20)
      {
        printf("%s\n",">10 And <20");
        break;
      }
    if(A==31||A==32||A==33)
      {
        printf("%s\n","31,32,33");
        break;
      }
      // case else
      {
        printf("%s\n","No special case found");
      }
    break;
  }
  printf("\n");
  printf("Type one, two, qwerty, or other ");
  *B=0;
  AR_fgets_retval=fgets(InputBuffer,sizeof(InputBuffer),stdin);
  InputBuffer[strlen(InputBuffer)-1]=0;
  ScanError = scan(InputBuffer,"%s",B);
 
  *InputBuffer=0;
  for(;;)
  {
    if(str_cmp(B,"one")==0 ||  str_cmp(B,"two")==0)
      {
        printf("%s\n","one, two");
        break;
      }
    if(str_cmp(B,"qwerty")==0)
      {
        printf("%s\n","qwerty");
        break;
      }
      // case else
      {
        printf("%s\n","else");
      }
    break;
  }
  return 0;   //  End of main program
  }

// *************************************************
//                 Runtime Functions
// *************************************************

char *BCX_TmpStr (size_t Bites)
{
  static int   StrCnt;
  static char *StrFunc[2048];
  StrCnt=(StrCnt + 1) & 2047;
  if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
    #if defined BCX_MAX_VAR_SIZE
  if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)
  {
  printf("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\n",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);
  abort();
  }
  #endif
  return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
}


int str_cmp (char *a, char *b)
{
  int counter=0;
  for(;;)
   {
    if((a[counter]^b[counter]))
     {
      if((UINT) a[counter]>= (UINT) b[counter])
      return  1;
      return -1;
     }
    if(!a[counter]) return 0;
    counter++;
   }
}


char *left (char *S, int length)
{
  int tmplen = strlen(S);
  if(length<1) return BCX_TmpStr(1);
  if(length<tmplen) tmplen=length;
  char *strtmp = BCX_TmpStr(tmplen);
  return (char*)memcpy(strtmp,S,tmplen);
}


char *mid (char *S, int start, int length)
{
  char *strtmp;
  int tmplen = strlen(S);
  if(start>tmplen||start<1) return BCX_TmpStr(1);
  if (length<0 || length>(tmplen-start)+1)
    length = (tmplen-start)+1;
  strtmp = BCX_TmpStr(length);
  return (char*)memcpy(strtmp,&S[start-1],length);
}


char *RemoveStr (char *a, char *b)
{
  char *strtmp, *p, *d;
  int  tmplen;
  strtmp = d = BCX_TmpStr(strlen(a));
  if(!b || !*b) return strcpy(strtmp,a);
  p=_strstr_(a,b); tmplen = strlen(b);
  while(p)
   {
     memcpy(d,a,p-a);
     d+= (p-a);
     a=p+tmplen;
     p=_strstr_(a,b);
   }
  strcpy(d,a);
  return strtmp;
}



int instr_b(char* mane,char* match,int offset,int sensflag)
{
  char *s;
  if (!mane || !match || ! *match || offset>(int)strlen(mane)) return 0;
  if (sensflag)
    s = _stristr_(offset>0 ? mane+offset-1 : mane,match);
  else
    s = _strstr_(offset>0 ? mane+offset-1 : mane,match);
  return s ? (int)(s-mane)+1 : 0;
}


char  *MakeLCaseTbl (void)
{
  static char tbl[256];
  if(!tbl['a'])
    {
      int i; for (i=0; i < 256; i++)
        tbl[i] = (char)(int)tolower(i);
    }
  return tbl;
}


char *_stristr_(char *String, char *Pattern)
{
  int   mi=-1;
  char *LowCase = MakeLCaseTbl();
  while(Pattern[++mi])
   {
     if(String[mi]==0) return 0;
     if(LowCase[(unsigned char)String[mi]]!=LowCase[(unsigned char)Pattern[mi]])
       { String++; mi=-1; }
   }
  return String;
}


char *_strstr_(char *String, char *Pattern)
{
  int   mi=-1;
  while(Pattern[++mi])
   {
     if(String[mi]==0) return 0;
     if(String[mi]!=Pattern[mi])
       { String++; mi=-1; }
   }
  return String;
}


int scan(char *input, char *format, ... )
{
  int c,d ;
  char     *s_;
  int      *intptr;
  float    *floatptr;
  double   *doubleptr;
  char     A[50][2048];
  va_list  marker;
  c = 0;
  d = Split(A,input,",");
  va_start(marker, format); //Initialize arguments
  while(d && *format)
   {
     if(*format == '%') format++;
     if(*format == 's')
       {
         s_ = va_arg(marker, char *);
         strcpy(s_, A[c]);
         c++;
         d--;
       }
  if(*format == 'd')
    {
      intptr = va_arg(marker, int *);
      *intptr = atoi(A[c]);
      c++;
      d--;
    }
  if(*format == 'g')
    {
      floatptr = va_arg(marker, float *);
      *floatptr = atof(A[c]);
      c++;
      d--;
    }
 if(*format == 'l')
    {
      format++;
      doubleptr = va_arg(marker, double *);
      *doubleptr = atof(A[c]);
      c++;
      d--;
     }
  format++;
   }
  va_end(marker);              // Reset variable arguments
  if(d) return(1);             // More data than variables
  if(*format == 0) return(0);  // OK
  return(-1);                  // More variables than data
}


int Split (char Buf[][2048], char *T, char *Delim, int Flg)
{
  int  Begin = 0;
  int  Count = 0;
  int  Quote = 0;
  int  Index,i;
  int  lenT  = strlen(T);
  char Chr34[2]={34,0};
  for(Index=1;Index<=lenT;Index++)
    {
      if(instr_b(Delim,mid(T,Index,1))&&!Quote)
        {
          strcpy(Buf[Count],(char*)mid(T,Begin,Index-Begin));
          if ((Flg & 2) == 0)  // 0 if old version
           Count++;
          else
           if (Buf[Count][0] != 0) Count++;
           Begin=0;
           if((Flg & 1) == 1)   // 1 if true
              strcpy(Buf[Count++],(char*)mid(T,Index,1));
        }
   else
     {
       if(strcmp(mid(T,Index,1),Chr34)==0) Quote=!Quote;
       if(Begin==0) Begin=Index;
     }
   }
  if(Begin)
     strcpy(Buf[Count++],(char*)mid(T,Begin,Index-Begin));
  if((Flg & 1) == 0)   // 0 if false
      for(i=0;i<Count;i++) strcpy(Buf[i],(char*)RemoveStr(Buf[i],Chr34));
  return Count;
}


Title: Re: BxbAsm
Post by: SteveA on April 27, 2012, 07:40:05 AM
It's not really about using fgets or _getche, or ...

This statement:
Quote
  Input "Enter A Number ", A

isn't exactly the same as:
Quote
  INPUT ;"First: "; first$; " Initial: "; init$; " Last: "; last$

What I'm saying is that the bxbasm routines use win32 cursor controls to reposition the cursor when entering multiple variables.

For instance:
if, when entering a variable value or character string, the [enter] key is pressed, the cursor will end up on the next line.
The Bxb routines prevent that from happening, (via the win32 API functions).

I don't have BCX installed, but try my example, using BCX.
What is the code that is generated ?
Does it control cursor re-positioning or does the cursor drop to the next line, when the [enter] key is pressed ?
Title: Re: BxbAsm
Post by: John on April 27, 2012, 08:46:55 AM
FWIW:  ScriptBasic only supports a minimal set of screen control functions and relies on an extension module for extended support. At this point, INPUT with a single input and support for new line and tab should be adequate for a console Basic.

Are you going to be supporting redirection? (STDIN/STDOUT/STDERR)
 
Title: Re: BxbAsm
Post by: jcfuller on April 27, 2012, 10:21:48 AM
Steve,
  Bcx has only one prompt but multi vars. Must be entered separated by commas.

INPUT "Enter values ->",a!,b#,c$,d%,e$[5],f$

James

Title: Re: BxbAsm
Post by: SteveA on April 27, 2012, 10:45:42 AM
Bcx has only one prompt but multi vars. Must be entered separated by commas.

INPUT "Enter values ->",a!,b#,c$,d%,e$[5],f$


Okay,...
Bxb was designed this way (multiple prompts) to mirror QuickBasic.

But, looking at it again, you already figured out how to convert the "LOCATE" statement, so it actually might work.
Because, the INPUT routines call "locate" to reposition the cursor.
Title: Re: BxbAsm
Post by: jcfuller on April 27, 2012, 11:35:22 AM
Steve,
  Duh it finally dawned on me as long as your routines are in a library you can use all the windows routines you want ( as long as there
is some way to do it in linux). It would be easier for me if you use msvcrt functions but no biggie.

James
Title: Re: BxbAsm
Post by: jcfuller on April 29, 2012, 02:54:44 AM
Steve,
  check your yahoo mail.

James
Title: Re: BxbAsm
Post by: SteveA on April 30, 2012, 08:18:01 AM
Right,
was out for the weekend.
Thanks James.
Title: Re: BxbAsm
Post by: SteveA on April 30, 2012, 12:10:33 PM
James,
I converted all the "funct.c" functions into .Obj's and created a .Lib.
Do you want me to up load them ?
They are in a win32 format (STDCALL) and would probably need to be modified for for Linux.

Like so:
Code: [Select]
; *************BxbAsm Compiler*************
; Copyright: sarbayo (c) 2004-2012
; =========================================================================
  .486                       ; use 486 instructions
  .model flat, stdcall       ; Win32 memory model
  option casemap:none        ; case sensitive

 
  EXTERNDEF BffrInput:BYTE

  .code

chrstr proc
; --------------------------------------------------
  mov  esi, offset BffrInput
  mov  [esi], byte ptr al
  mov  [esi+1], byte ptr 0
  ret
; --------------------------------------------------
chrstr endp

end

Steve
Title: Re: BxbAsm
Post by: jcfuller on April 30, 2012, 12:40:22 PM
Steve,
  Yes.
If the focus is for portability wouldn't "c" be better that stdcall?

James
Title: Re: BxbAsm
Post by: SteveA on April 30, 2012, 02:25:00 PM
If the focus is for portability wouldn't "c" be better that stdcall?

As far as I know, in Windows, STDCALL is the default (required).

Once again, I don't see how a single piece of source code can compile as both Windows and Linux.
I must be wrong on this point, because I'm under the impression that Windows and Linux have very different requirements.

From my perspective, regarding portability, portability only exists in console mode.
As soon as GUI and the win32 API enters into the picture, there is no more portability.
So, I'm not overly concerned with portability.

The way I see it, there has to be two distinct versions: Win32 and Linux.
I must be missing something, as I see no way around it.

I can't base everything I want Bxbasic to do just on the 'C' RunTime Library.
Once I get a Linux machine up and running, I will be happy to learn what I have to, regarding the Linux API (if such a thing exists) and what it takes to get GUI working under Linux.

I have an entire section of code, that is exclusively win32 API based, that I am in the process of making into .Obj files at this time.
Title: Re: BxbAsm
Post by: jcfuller on May 01, 2012, 04:52:54 AM
Steve,
Quote
As far as I know, in Windows, STDCALL is the default (required).
  You are correct in that STDCALL is the default in windows api but not with crt.
Quote
Once again, I don't see how a single piece of source code can compile as both Windows and Linux.
  I believe there can be both a Windows and Linux version using basically the same source (there may need to be a few IF WIN/NIX equates). Place all OS dependant code in a library with wrapper calls. One BxB.inc for each OS.

Quote
From my perspective, regarding portability, portability only exists in console mode.
As soon as GUI and the win32 API enters into the picture, there is no more portability.
So, I'm not overly concerned with portability.

There is no nix gui per se. All gui  is done through libraries (primarily gtk. nix is a text only system. You can program with
assembler and system interrupts just like in the old dos days but I see no reason to go there. (see the jwasm samples)

The more I look at IUP the more convinced I am that this would be the perfect compliment to BxbAsm for GUI.


Quote
I can't base everything I want Bxbasic to do just on the 'C' RunTime Library.

Examples?


I have not looked at the new code yet.

James

Title: Re: BxbAsm
Post by: jcfuller on May 01, 2012, 05:54:02 AM
Steve,
  Do you have a working bxbasm using the library?
I tried replacing AFunct.c but Bxbasm.c would not compile?

James
Title: Re: BxbAsm
Post by: SteveA on May 01, 2012, 06:55:07 AM
Do you have a working bxbasm using the library?
I tried replacing AFunct.c but Bxbasm.c would not compile?

Yes I do.
I'll wrap it up and upload it. I will need a little time.
I'll email you as such.
Now, this will only have been tested on Win, but it does compile.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 02, 2012, 05:37:10 AM
Steve,

The BxbAsm code compiled fine with gcc.
The BxbAsm.exe translated the test1.bas to test1.asm.
Jwasm was able to compile test1.asm to test1.obj
polink was able to link test1.obj to test1.exe
test1.exe ran as expected.

Looking at the Bxbasm.lib asm modules and the bxbasm generated asm code it appears there is even more dependancy on the WinApi than in the last code I tested.

At this juncture, with the direction you are going I really don't see a Linux port.
I did try.
Bxbasm compiled fine on linux.
The resulting executable converted test1.bas to test1.asm after I saved all the files with unix lf endings.
I commented all the windows specific EXTERNDEF's in BXB.inc
jwasm compile the test1.asm to test1.o.

Many errors in the linking stage though.


Also the coding of the Bxbasm.lib asm modules has me scratching my head? Why all the globals instead of proc parameters?
I understand on input and string buffers but ....

James

Title: Re: BxbAsm
Post by: jcfuller on May 02, 2012, 07:32:13 AM
Steve,
  I did get gcc to link test1.o -> test on linux.
My poor memory and lack of writing things down (or if I do forget where I put it) lead to the initial failure.

James
 
Title: Re: BxbAsm
Post by: SteveA on May 02, 2012, 03:08:02 PM
Looking at the Bxbasm.lib asm modules and the bxbasm generated asm code it appears there is even more dependancy on the WinApi than in the last code I tested.

At this juncture, with the direction you are going I really don't see a Linux port.

Is this the current status ?

My upload labeled and dated: bxblinux-041612.zip
is as linux ready as I can make it.

My most recent upload: bxblinux-050112.zip
contains the same source files as the prior, with the exception that this list of files has changed:
bxblib.lib
bxb.inc
bxbasm.inc
...plus...
the addition of the .asm and .obj files.

Some of those (snuck back in and) were not intended for the Linux port and should be deleted and removed from bxblib.lib.
Some of those would be: clearscreen, locate, color, StdOut, StrLen, gdi_oldbrush, wherexy, etc.
In other words, any win32 related .obj's, just delete from bxblib.lib.
Sorry about that.

In their stead, the original or Linux specific code can be used.

Steve
Title: Re: BxbAsm
Post by: SteveA on May 02, 2012, 03:17:15 PM
Also the coding of the Bxbasm.lib asm modules has me scratching my head? Why all the globals instead of proc parameters?

The EXTENDEFs and the associated global variables are system variables.
In some cases, they could be passed as proc parameters, but, then there would be no point, as they are global.
In a few cases I use a system variable as an expedient to standardize (make generic) procedures.
It's not hurting anything.
Title: Re: BxbAsm
Post by: John on May 02, 2012, 05:32:38 PM
Quote
In other words, any win32 related .obj's, just delete from bxblib.lib.

ScriptBasic only has one source tree. The #IF meta statements for platform specific code works well for that project.

Title: Re: BxbAsm
Post by: SteveA on May 02, 2012, 06:18:32 PM
Quote
In other words, any win32 related .obj's, just delete from bxblib.lib.
ScriptBasic only has one source tree. The #IF meta statements for platform specific code works well for that project.

Hey John,
Yeh,...
ifdef
  bla bla bla...
endif

works well, but, it turns into really ugly code (to me that is).

Here's what a snippet from stdio.inc looks like:
Code: [Select]
if _MSC_VER gt 1000
;#pragma once
endif
ifndef _INC_STDIO
_INC_STDIO EQU <>
if  0 eq defined(_WIN32) AND  0 eq defined(_MAC)
.err <ERROR : Only Mac or Win32 targets supported ! >
endif
ifdef _MSC_VER
;#pragma pack ( push , 8 )
endif
ifdef __cplusplus
;extern "C"
;{
endif
ifndef _CRTIMP
ifdef _DLL
_CRTIMP EQU <__declspec ( dllimport )>
else
_CRTIMP EQU <>
endif
endif
if ( 0 eq defined(_MSC_VER) AND  0 eq defined(__cdecl))
__cdecl EQU <>
endif
ifndef _CRTAPI1
if _MSC_VER ge 800 AND _M_IX86 ge 300
_CRTAPI1 EQU <__cdecl>
else
_CRTAPI1 EQU <>
endif
endif
ifndef _SIZE_T_DEFINED
size_t typedef DWORD
_SIZE_T_DEFINED EQU <>
endif
ifndef _MAC
ifndef _WCHAR_T_DEFINED
wchar_t typedef WORD
_WCHAR_T_DEFINED EQU <>
endif
ifndef _WCTYPE_T_DEFINED
wint_t typedef WORD
wctype_t typedef WORD
_WCTYPE_T_DEFINED EQU <>
endif
endif


I'd rather have two distinct (clean) versions of source code.


Title: Re: BxbAsm
Post by: John on May 02, 2012, 11:58:26 PM
Here is the ScriptBasic filesys.c (http://files.allbasic.info/ScriptBasic/filesys.c.txt) that supports Windows, Linux and Mac OS.

I would think this is as extensive as it gets with conditional compiling directives in SB.

Title: Re: BxbAsm
Post by: jcfuller on May 03, 2012, 02:56:31 AM

Some of those (snuck back in and) were not intended for the Linux port and should be deleted and removed from bxblib.lib.
Some of those would be: clearscreen, locate, color, StdOut, StrLen, gdi_oldbrush, wherexy, etc.
In other words, any win32 related .obj's, just delete from bxblib.lib.
Sorry about that.
In their stead, the original or Linux specific code can be used.


Steve,
  That is exactly the opposite of what I suggested I think.
I believe my suggestion was to put all Win32 related code in a library wrapped with generic procs called from the main asm source... I would try to duplicate functionality in a library for linux. Where it was impossible (or not known how to implement) there could be dummy procs during the development cycle. So you would have for example Win32 cls,locate,color in the library and I would have the linux versions I demonstrated.

Also your bxb.inc would be OS specific.
James
 

Title: Re: BxbAsm
Post by: jcfuller on May 03, 2012, 03:46:29 AM
Steve,
  On reflection I did advocate a library instead of source ( bad memory -> mine) so I guess you would need two.
One for the generic functions (the one you just created) and one for os specific functions.

James
Title: Re: BxbAsm
Post by: jcfuller on May 03, 2012, 05:39:20 AM
Steve,
 I was able to compile most of the BxbLib modules and add them to a library. A number were win only.
ltoa is win only but I found "c" code for it,compiled to object file and added it to the library so that is covered.
I also did timestr and datestr even though all the time date code is windows only I believe I have code somewhere that can be placed in an OS specific library.
 Not sure any of these work yet :) but it is one step closer.

James
 
modules compiled on linux
Code: [Select]
atodw.o
catstrng.o
chrstr.o
clear_allvars.o
clearfltvar.o
clearintvar.o
clearLngstrng_bffr.o
clearstrng_bffr.o
clearstrvar.o
closeafile.o
closeallfiles.o
copystrng_bffr.o
copystrng.o
datestr.o
dblArryElement.o
dimstrarray.o
Do_initialize.o
dwtoa.o
freeArray.o
getArryOffst.o
getfilehandle.o
getfilelength.o
leftstr.o
lsetstr.o
ltoa.o
mid_str.o
mkdstr.o
mkistr.o
mkqstr.o
movstrng_bffr.o
quadArryElement.o
readfltstr.o
readintstr.o
readQintstr.o
redimarray.o
rightstr.o
rsetstr.o
setupiobuffer.o
spacestr.o
stringstr.o
strsFval.o
strsIval.o
szLeft.o
szMid.o
szRight.o
timestr.o

Title: Re: BxbAsm
Post by: jcfuller on May 03, 2012, 06:12:16 AM
Steve,
  How about using crt time date functions instead of Windows?
Here is a bcx -> c demo.
James

Code: [Select]
// *********************************************************************
// Created with BCX32 - BASIC To C/C++ Translator (V) 9.0.0.7 (2012/03/23)
//                 BCX (c) 1999 - 2012 by Kevin Diggins
// *********************************************************************
//          Translated for compiling with an ANSI/ISO C Compiler
// *********************************************************************

// ***************************************************
// types from winapi that may be needed
// ***************************************************
typedef char *PCHAR,*LPCH,*PCH,*NPSTR,*LPSTR,*PSTR;
typedef unsigned int UINT;
typedef char byte;
typedef unsigned long DWORD,ULONG;
typedef unsigned char UCHAR;
//----------------------------------------------------

#include <stdlib.h>
#include <stdio.h>
#include <time.h>

// *************************************************
//        User's GLOBAL ENUM blocks
// *************************************************

// *************************************************
//            System Defined Constants
// *************************************************

#define cSizeOfDefaultString 2048

// *************************************************
//            User Defined Constants
// *************************************************


// *************************************************
//               Standard Prototypes
// *************************************************

// char*   BCX_TmpStr(size_t,size_t= 128,int= 1);
char*    BCX_TmpStr(size_t,size_t,int);
// char*   timef(int=0, int=0);
char*    timef(int,int);
// *************************************************
//          User Defined Types And Unions
// *************************************************


// *************************************************
//                System Variables
// *************************************************


// *************************************************
//            User Global Variables
// *************************************************

static PCHAR   *g_argv;
static int     g_argc;


// *************************************************
//            User Global Initialized Arrays
// *************************************************



// *************************************************
//                 Runtime Functions
// *************************************************

#ifndef BCXTmpStrSize
#define BCXTmpStrSize  2048
#endif
char *BCX_TmpStr (size_t Bites,size_t  iPad,int iAlloc)
{
  static int   StrCnt;
  static char *StrFunc[BCXTmpStrSize];
  StrCnt=(StrCnt + 1) & (BCXTmpStrSize-1);
  if(StrFunc[StrCnt]) {free (StrFunc[StrCnt]); StrFunc[StrCnt] = NULL;}
#if defined BCX_MAX_VAR_SIZE
  if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)
  {
  printf("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\n",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);
  abort();
  }
#endif
  if(iAlloc) StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
  return StrFunc[StrCnt];
}


char *timef (int t, int u)
{
  time_t elapse_time;
  struct tm *tp;
  char *strtmp = BCX_TmpStr(256,128,1);
  time (&elapse_time);
  if(u==0)
    tp = localtime(&elapse_time);
  else
    tp = gmtime(&elapse_time);
  switch (t)
  {
   case 0:
   strftime(strtmp,256,"%H:%M:%S",tp); break;
   case 1:
   strftime(strtmp,256,"%H",tp); break;
   case 2:
   strftime(strtmp,256,"%M",tp); break;
   case 3:
   strftime(strtmp,256,"%S",tp); break;
   case 4:
   strftime(strtmp,256,"%p",tp); break;
   case 5:
   strftime(strtmp,256,"%Y",tp); break;
   case 6:
   strftime(strtmp,256,"%m",tp); break;
   case 7:
   strftime(strtmp,256,"%d",tp); break;
   case 8:
   strftime(strtmp,256,"%A",tp); break;
   case 9:
   strftime(strtmp,256,"%w",tp); break;
   case 10:
   strftime(strtmp,256,"%j",tp); break;
   case 11:
   strftime(strtmp,256,"%U",tp); break;
  }
  return strtmp;
}



// ************************************
//       User Subs and Functions
// ************************************

// *************************************************
//                  Main Program
// *************************************************

int main(int argc, char *argv[])
{
  g_argc = argc;
  g_argv = argv;
printf("%s%s\n","Printing TIME$   ",timef( 0 , 0));
printf("%s\n","-----------------");
printf("%s%s\n","Printing HOUR    ",timef( 1 , 0));
printf("%s%s\n","Printing MINUTE  ",timef( 2 , 0));
printf("%s%s\n","Printing SECOND  ",timef( 3 , 0));
printf("%s%s\n","Printing AMPM    ",timef( 4 , 0));
printf("%s\n","-----------------");
printf("%s%s\n","Printing YEAR    ",timef( 5 , 0));
printf("%s%s\n","Printing MONTH   ",timef( 6 , 0));
printf("%s%s\n","Printing DAY     ",timef( 7 , 0));
printf("%s\n","-----------------");
printf("%s%s\n","Printing DAYNAME ",timef( 8 , 0));
printf("%s%s\n","Printing WEEKDAY ",timef( 9 , 0));
printf("%s%s\n","Printing YEARDAY ",timef( 10 , 0));
printf("%s%s\n","Printing WEEK    ",timef( 11 , 0));
  return 0;   /* End of main program */
}

Title: Re: BxbAsm
Post by: jcfuller on May 03, 2012, 06:34:14 AM
Steve,
  I am probably jumping the gun here but is file i/o operational?
I get a fault on both Windows and linux with:
Code: [Select]
'  test.bas version 37
'  CLS
'
  PRINT "Opening Test File"
  OPEN "I", #1, "test.txt"
  CLOSE 1
' ------------------------------------------
TheEnd:
  END


James
Title: Re: BxbAsm
Post by: SteveA on May 03, 2012, 09:29:33 AM
 I am probably jumping the gun here but is file i/o operational?
I get a fault on both Windows and linux with:

Yes,
did you create test.txt ahead of time ?
As it needs to exist to open it for INPUT.

Quote
Before we can run this next program, you will need to create a file named
Test.txt. Using Notepad, create an empty file,  just hit the return key
about three or four times, then save the file to your working directory,
naming it "Test.txt", and close it.

edit:
I just tested that exact code and it works just fine.
Create test.txt.
Title: Re: BxbAsm
Post by: SteveA on May 03, 2012, 09:53:43 AM
 How about using crt time date functions instead of Windows?

Sure.
Give me a bit to switch that over.
I'll upload the .asm files when done.


edit:
crt modified data/time .asm files attached.

I hope this works right.
Looking at the difference between the CRT -vs- Win32 struct's.

I wasn't sure it would work without making several other changes.
But, it appears to be working...or not.


edit:
oops...false positive.
Title: Re: BxbAsm
Post by: jcfuller on May 03, 2012, 11:24:33 AM
Steve,
  Not working as you are still using the Windows call.
There is no SYSTEMTIME structure in time.h.
comment out the windows include. Should not be needed

James
 
Title: Re: BxbAsm
Post by: SteveA on May 03, 2012, 12:20:29 PM
Not working as you are still using the Windows call.
There is no SYSTEMTIME structure in time.h.

As I feared, I will need to make several other changes.
This may take a while, it's not going to be as easy as commenting something out.
I need to change the structure setup.
Title: Re: BxbAsm
Post by: jcfuller on May 03, 2012, 12:26:53 PM
Steve,
  I don't know if this works but it compiled ok. I just followed what bcx did.

James


get_sys_date
Code: [Select]
; *************BxbAsm Compiler*************
; Copyright: sarbayo (c) 2004-2012
; =========================================================================
  .486                       ; use 486 instructions
  .model flat, stdcall       ; Win32 memory model
  option casemap:none        ; case sensitive

    ;include C:\JWasm\JWasm206\Include\windows.inc
    ;include C:\JWasm\JWasm206\Include\time.inc
    include BxbLib.inc
  
    EXTERNDEF system_time:tm
    EXTERNDEF iYear:DWORD
    EXTERNDEF iMonth:DWORD
    EXTERNDEF iDay:DWORD

  .code

get_sys_date  proc
  ; --------------------------------------------------
;  invoke  GetLocalTime, addr system_time    ;Win32: Get Local Time
;  invoke  localtime, addr system_time    ; Get Local Time
local elapsed_time:DWORD
invoke time,addr elapsed_time
invoke localtime,addr elapsed_time
mov system_time,eax
xor  eax, eax
mov  eax, system_time.tm_year
mov  iYear, eax
mov  eax, system_time.tm_mon
mov  iMonth, eax
mov  eax, system_time.tm_wday
mov  iDay, eax
ret
; --------------------------------------------------
get_sys_date  endp

end


get_sys_time
Code: [Select]
; *************BxbAsm Compiler*************
; Copyright: sarbayo (c) 2004-2012
; =========================================================================
  .486                       ; use 486 instructions
  .model flat, stdcall       ; Win32 memory model
  option casemap:none        ; case sensitive

    ;include C:\JWasm\JWasm206\Include\windows.inc
    ;include C:\JWasm\JWasm206\Include\time.inc
  include BxbLib.inc
    ;EXTERNDEF system_time:SYSTEMTIME
    EXTERNDEF system_time:tm
    EXTERNDEF iHour:DWORD
    EXTERNDEF iMinute:DWORD
    EXTERNDEF iSecond:DWORD
    EXTERNDEF iMilli:DWORD

  .code

get_sys_time  proc
; --------------------------------------------------
;  invoke  GetLocalTime, addr system_time       ; Win32: Get Local Time
  ;invoke  localtime, addr system_time       ; Get Local Time
local elapsed_time:DWORD
invoke time,addr elapsed_time
invoke localtime,addr elapsed_time
mov system_time,eax
  
xor  eax, eax
mov  eax, system_time.tm_hour
mov  iHour, eax
mov  eax, system_time.tm_min
mov  iMinute, eax
mov  eax, system_time.tm_sec
mov  iSecond, eax
;  mov  eax, system_time.wMilliseconds
;  mov  iMilli, eax
ret
; --------------------------------------------------
get_sys_time  endp

end

Title: Re: BxbAsm
Post by: SteveA on May 03, 2012, 06:50:13 PM
Okay,...
I have to say, using the crt time functions is a real pain.
Not at all easy, like the API.

Now, program files that need to be un-commented:
  prototyp.h
  input.c
  ainput.c
  astring.c
  globals.h

so that the date and time functions work properly and compile without error.
Title: Re: BxbAsm
Post by: jcfuller on May 04, 2012, 07:23:51 AM
Steve,
  Will you be putting together a new package soon?
 I thought I might be able to make the changes but really have no idea what's needed especially in AInput.c

James

Title: Re: BxbAsm
Post by: SteveA on May 04, 2012, 08:46:08 AM
Well, I thought about it just yesterday, but, decided not to, because I don't know what you have and what changes/corrections you have made.
That's why I simply uploaded the specific files in question.

I don't want to be counter-productive to the work you are doing.
When I upload a complete package, I cringe at the thought that what I have may conflict with what you have.
I don't want changes I've made to wipe-out changes you've made.

On my system, I have two (2) distinct versions of Bxbasm in production.
One for Win32 and one that I share with you for Linux development.

The one I share with you, I consider to be the "stripped down version", is free of win32 references.
To create that version, in most cases, I simply commented-out certain functions and variables that specifically used win32 API.
As in the case of the TIME$ and DATE$ functions, that list of files that I mentioned was where there were references to the date and time functions and variables.

The only way to prevent collisions would be if I know what modifications you have made.
I can send you what I have, but, then you would need to compare code and figure out what changes exist, so as to prevent those collisions.
Title: Re: BxbAsm
Post by: jcfuller on May 04, 2012, 09:18:30 AM
Steve,
  As bad as my memory is I prefer the complete stripped down version that is working on windows (without any Win32 api calls).
There really isn't all that much to change; mainly include directories. I plan to automate the library creation.
I use diff-merge on windows and linux.

James
Title: Re: BxbAsm
Post by: SteveA on May 04, 2012, 02:39:09 PM
James,
here is a list of commands and functions that I know I commented-out:

Commands:
   LOCATE
   BEEP
   CLS
   COLOR
   SLEEP

Functions:
   TIME$
   DATE$
   TIMER

plus, associated references in various places.
Can you provide me with any code that you are using that allows them to work on linux ?
If so, I'd like to update the files on my end.
That way, I don't keep sending you obsolite code.

From yesterdays discussion, did you get file I/O working.
As far as I know, file I/O is only using CRT.
Title: Re: BxbAsm
Post by: jcfuller on May 04, 2012, 03:24:40 PM
Steve,
  First thing tomorrow.
 What I would like first is the new Prolog code from AInput.c for the new crt Time/Date.

James
Title: Re: BxbAsm
Post by: SteveA on May 04, 2012, 04:09:40 PM
ainput.c attached.
Title: Re: BxbAsm
Post by: jcfuller on May 05, 2012, 04:14:01 AM
Steve,
  This may take a bit as I want to set up a working environment on both windows and linux.
FWIW jwasm uses the INCLUDE environment variable so you don't have to use complete paths in your source.

James
 
Title: Re: BxbAsm
Post by: jcfuller on May 05, 2012, 11:25:43 AM
Steve,
  I'm trying to get a windows build working before I migrate it to linux.
I may have missed something in the time/date update because I am getting many warnings on the same line of code:
Code: [Select]
C:\BxbAsm\examples>jwasm /coff test1.asm
JWasm v2.07pre, Nov  2 2011, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm(29) : Warning A4184: Instructions and initialized data not supported i
n BSS segments
test1.asm: 86 lines, 2 passes, 187 ms, 10 warnings, 0 errors

C:\BxbAsm\examples>polink /SUBSYSTEM:CONSOLE test1.obj /OUT:test1.exe
C:\BxbAsm\examples>


line 29 is the last line showing here.
If I comment it out compiles and runs fine. Well it runs fine with it but I dislike warnings :)

Code: [Select]
; =========================================================================
;  UNINITIALIZED DATA
; =========================================================================
 .data?
system_time tm  <> ;current date & time

James
Title: Re: BxbAsm
Post by: SteveA on May 05, 2012, 05:25:22 PM
Code: [Select]
; =========================================================================
;  UNINITIALIZED DATA
; =========================================================================
 .data?
system_time tm  <> ;current date & time

Funny, because that is where the CRT time/date data structure "tm" is declared.
It assembles and links completely without error on my system, not even a warning.

Previously, it said:
   system_time    SYSTEMTIME  <>         ;current date & time

which is the win32 date/time struct declaration.
Both versions assemble without warning.

edit:
I only notice one difference between your commandline and mine:

      C:\BxbAsm\examples>jwasm /coff test1.asm
C:\JWasm\JWasm206\bin\JWasm /c /coff "%1.asm"

I use mine via a batch file, that's why the:  "%1.asm".
Title: Re: BxbAsm
Post by: jcfuller on May 06, 2012, 03:13:55 AM
Steve,
  Try it with JWasm v2.07pre if you can? I don't have 2.06 installed

James

Edit: I tried it with 2.06 with the same results.
 
Title: Re: BxbAsm
Post by: SteveA on May 06, 2012, 08:24:35 PM
Okay,
what I'm going to do is, (in the morning), upoad the linux version, that is fully working.
I will include everything and it will be fully functioning, (minus anything that is win32 specific).

What I would like you to do, when you have the time, is to give it a try, without any modifications on Windows.
Then, after you have verified that it assembles and links correctly, you can make whatever changes you wish.

I don't know why it's working on my system and not yours.
I do use full paths, as opposed to environment variables. I do that for a reason and not convenience.
Title: Re: BxbAsm
Post by: jcfuller on May 07, 2012, 02:38:35 AM
Steve,
  Can you do a version with cls,locate,and color working using a separate library for those three items?
I have linux code for them.

James

Edit: actually you should be able to have all the Win32 functions you want in this configuration as long as they are noted in bxb.inc.
I can added dummy functions in a linux libaray if there is no way to implement.

Title: Re: BxbAsm
Post by: SteveA on May 07, 2012, 11:41:00 AM
Can you do a version with cls,locate,and color working using a separate library for those three items?
I have linux code for them.

Okay,
Here's what I've got:
  bxb-linux.zip: contains the EXE plus the LIB and INC files.

  disabled-procs.zip: contains dummy functions.
  asm-procs.zip: contains all the working asm procs
  bxblib-c-sources: contains some lib functions that are in C.
  bxbasm-linux-sources.zip: contains all C source for bxbasm.

Quote
Edit: actually you should be able to have all the Win32 functions you want in this configuration as long as they are noted in bxb.inc.
I can added dummy functions in a linux libaray if there is no way to implement.

So that you can test everything, the executable is fully functioning.
Rather than cripple the EXE, I've placed dummy procs in bxblib.lib.
That way, everything should assemble and link correctly.
Just those functions in question will not be fully functional. But, they will assemble.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 07, 2012, 12:33:14 PM
Steve,
  I'm still getting the BSS segments warning and I think it may be the the result of different include files. Mine is a bit of a mix.
Might be a good idea to upload yours.

James
Title: Re: BxbAsm
Post by: jcfuller on May 07, 2012, 01:41:22 PM
Steve,
  I really did not want disabled procs just a list of those that were specifically Win32.
As it is anything I wanted to test on Windows is now just a dummy.

I'm also confused with the bxblib-c-source.zip and the disabled-procs.zip. They appear to be the same procs one in c and  the other in asm?

James
Title: Re: BxbAsm
Post by: SteveA on May 07, 2012, 04:33:01 PM
I really did not want disabled procs just a list of those that were specifically Win32.
As it is anything I wanted to test on Windows is now just a dummy.

Actually, that's not the case.
    get_sys_data: is just fine,
    get_sys_time: is just fine,
      ClearScreen: is an empty function,
              locate: is an empty function,
       Do_initialize: has only one line commented-out,
      setcolortext: has only one line commented-out,
 get_HiRez_Timer: only has two lines commented-out,
            wherexy: the entire function is commented out.

Here is the code for ClearScreen:
Code: [Select]
/* BXBLIB.C */
/*
/*  *************BxbAsm Compiler*************
/*  Copyright: sarbayo (c) 2004-2012
/* ========================================================================= */


#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>


#include "bxblib.h"





void _stdcall ClearScreen()
{
    COORD coordScreen = { 0, 0 };    // home for the cursor
    DWORD cCharsWritten;
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    DWORD dwConSize;

    HANDLE hConsole;


    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

    // Get the number of character cells in the current buffer.

    if(!GetConsoleScreenBufferInfo(hConsole, &csbi))
    {
        printf("abort at: 1\n");
        return;
    }

    dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

    // Fill the entire screen with blanks.

    if(!FillConsoleOutputCharacter(hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten))
    {
        printf("abort at: 2\n");
        return;
    }

    // Get the current text attribute.

    if(!GetConsoleScreenBufferInfo(hConsole, &csbi))
    {
        printf("abort at: 3\n");
        return;
    }

    // Set the buffer's attributes accordingly.

    if(!FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten))
    {
        printf("abort at: 4\n");
        return;
    }

    // Put the cursor at its home coordinates.

    SetConsoleCursorPosition(hConsole, coordScreen);

}
/*------ end ClearScreen ------*/


this code is provided in file: bxblib-c-sources.zip

Here is the code for locate:
Code: [Select]

/* BXBLIB.C */
/*
/*  *************BxbAsm Compiler*************
/*  Copyright: sarbayo (c) 2004-2012
/* ========================================================================= */


#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <math.h>


#include "bxblib.h"





void _stdcall locate(int cx, int cy)
{
    COORD coordScreen;
    HANDLE hConsole;


    coordScreen.X = cx;
    coordScreen.Y = cy;
                             /* Get this console handle */
    hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

                             /* Put the cursor at its coordinates */
    SetConsoleCursorPosition(hConsole, coordScreen);

}
/* ------ end locate ------ */


this code is provided in file: bxblib-c-sources.zip

Quote
I'm also confused with the bxblib-c-source.zip and the disabled-procs.zip. They appear to be the same procs one in c and  the other in asm?

Some files were never converted to ".asm", that's why the C source code was provided.
It was not meant to confuse, just to be thorough.

Title: Re: BxbAsm
Post by: jcfuller on May 08, 2012, 03:46:55 AM
Steve,
  Using the new library and includes test6 compiles and runs fine but I get a linker warning when using polink my prefered linker.
James

Code: [Select]
C:\bxb-linux>polink /SUBSYSTEM:CONSOLE "test6.obj" kernel32.lib msvcrt.lib user3 2.lib fpu.lib bxblib.lib /OUT:"test6.exe"
POLINK: warning: Unrecognized option 'library:<tcconio.lib>'; ignored.
POLINK: warning: Unrecognized option 'library:<tcconio.lib>'; ignored.
Title: Re: BxbAsm
Post by: SteveA on May 08, 2012, 07:34:28 AM
 Using the new library and includes test6 compiles and runs fine but I get a linker warning when using polink my prefered linker.
Code: [Select]
C:\bxb-linux>polink /SUBSYSTEM:CONSOLE "test6.obj" kernel32.lib msvcrt.lib user3 2.lib fpu.lib bxblib.lib /OUT:"test6.exe"
POLINK: warning: Unrecognized option 'library:<tcconio.lib>'; ignored.
POLINK: warning: Unrecognized option 'library:<tcconio.lib>'; ignored.

Hmm,
I don't know where the reference to tcconio.lib is coming from.
I don't see that in the source code.


edit:
oh oh...
I see the problem.
let me fix something.

Okay, it appears that in my haste, yesterday, I copied the wrong sources, (from the wrong folder).
Here are the correct sources.
Sorry about that.

Steve


Title: Re: BxbAsm
Post by: jcfuller on May 08, 2012, 07:38:33 AM
Steve,
  I had a feeling it was from compiling ClearScreen and locate with lcc.
  I extracted all the object files from bxblib.lib and replaced ClearScreen and locate with:
ClearScreen:
Code: [Select]
; *************BxbAsm Compiler*************
; Copyright: sarbayo (c) 2004-2012
; =========================================================================
    .486                       ; use 486 instructions
    .model flat, stdcall       ; Win32 memory model
    option casemap:none        ; case sensitive

    include windows.inc
    include stdlib.inc
  

  .code
CStr macro pszText:VARARG
local szText
.const
szText db pszText,0
.code
exitm <offset szText>
endm
;------------------------------------------------------------------------------
ClearScreen proc
; --------------------------------------------------
invoke system,CStr("cls")
  ret
; --------------------------------------------------
ClearScreen endp

end

locate:
Code: [Select]
   .486                      
    .model flat, stdcall      
    option casemap:none        
    include windows.inc

.code
locate proc col:DWORD,row:DWORD
    local coordScreen:COORD,hConsole:HANDLE
mov eax,col
    mov coordScreen.X,ax
    mov eax,row
    mov coordScreen.Y,ax
    invoke GetStdHandle,STD_OUTPUT_HANDLE
    mov hConsole,eax
    invoke SetConsoleCursorPosition,hConsole,coordScreen
    ret
locate endp

end


I then created a new library with ar and used jwlink to link.
output:
Code: [Select]
C:\bxb-linux>jwasm /c /coff /Cp "test6.asm"
JWasm v2.07pre, Nov  2 2011, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

test6.asm: 137 lines, 2 passes, 187 ms, 0 warnings, 0 errors

C:\bxb-linux>jwlink  system pe_con name test6.exe file test6.obj  LIBRARY kernel
32.lib,msvcrt.lib, user32.lib,fpu.lib, bxblib.lib
JWlink Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
loading object files
searching libraries
creating a PE executable
C:\bxb-linux>

All is well:)
Now time for more testing and then a try at porting

James

Edit: test6.bas
Code: [Select]
1  REM  test.bas version 6
   DIM Row = 0, Column = 0
2  CLS
3  PRINT "hello world!"
4  LET Row = 2
5  LET Column = 10
6  LOCATE Row, Column
7  PRINT "hello world!"
8  LET Row = 4
9  LET Column = 20
10 LOCATE Row, Column
11 PRINT "hello world!"
12 END

Title: Re: BxbAsm
Post by: SteveA on May 08, 2012, 07:53:41 AM
James,
read my latest post, on prior page.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 08, 2012, 09:22:10 AM
Steve,
  I don't follow. I have not recompiled bxbasm.c -> exe yet. I'm using the one in the zip.
Does this exe not create correct asm code?
Please forgive my slowness but I don't see how that is related to my last post?

James
Title: Re: BxbAsm
Post by: SteveA on May 08, 2012, 09:28:19 AM
  I don't follow. I have not recompiled bxbasm.c -> exe yet. I'm using the one in the zip.
Does this exe not create correct asm code?
Please forgive my slowness but I don't see how that is related to my last post?

It's okay.
The EXE in the zip is good.
I thought you recompiled.
If that was the case, then the C source would have been the wrong one.
When you are ready to recompile, toss the first one and use the second one I posted.

Steve
Title: Re: BxbAsm
Post by: SteveA on May 08, 2012, 09:32:21 AM
That still makes me wonder why it was calling for tcconio. (?)
I looked at the sources and could find no reference.

That's when I looked inside the zip I posted, to see what that source had.
That's how I discovered I zipped the wrong folder, because that code did call for tcconio.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 08, 2012, 10:09:25 AM
Steve,
  What library app did you use to create bxblib.lib? Maybe that is the culprit or maybe lcc embedded something in the locate and ClearScreen object files, as tcconio is lcc specific.

  It also appears you attached the wrong bxblib asm-procs source too.
The time date functions use SYSTEMTIME instead of tm while the time date functions in bxblib.lib work correctly with tm.

James
Title: Re: BxbAsm
Post by: SteveA on May 08, 2012, 11:34:08 AM
Okay, I feel like a total idiot.
I must have been more rushed, yesterday, than I thought I was.

What library app did you use to create bxblib.lib?

I used jwasm's "wlib.exe".


Quote
Maybe that is the culprit or maybe lcc embedded something in the locate and ClearScreen object files, as tcconio is lcc specific.

No, I don't think that was it, but, I'm puzzled.

Quote
It also appears you attached the wrong bxblib asm-procs source too.
The time date functions use SYSTEMTIME instead of tm while the time date functions in bxblib.lib work correctly with tm.

Yeh...,
I was supposed to delete those "TIME" related files from that zip, (asm.procs.zip).
The "TIME" files in "disabled" are the correct ones.
Those are the ones used to create the .LIB.

I just forgot to delete the others.

Steve


EDIT:
You may be right on this count:
Quote
Maybe that is the culprit or maybe lcc embedded something in the locate and ClearScreen object files, as tcconio is lcc specific.

looking back, I noticed that the ".OBJ" files for locate and ClearScreen were created with LCC.
Since they were still using C source code, they had to be created with LCC.

All the rest were created (asm source) with jwasm.
Those two C ".OBJ"s were added to bxblib.lib using wlib.exe.

That should explain it.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 09, 2012, 05:10:45 AM
Steve,
 
Quote
looking back, I noticed that the ".OBJ" files for locate and ClearScreen were created with LCC.
Since they were still using C source code, they had to be created with LCC.

All the rest were created (asm source) with jwasm.
Those two C ".OBJ"s were added to bxblib.lib using wlib.exe.

That should explain it.

I think I mentioned that above :)

You probably have your lcc directories in your path so you would not notice.
As I said lcc uses it's own library for coino while gcc and vcc use the msvcrt library.

You are going to run into this with many "c" library routines compiled with lcc.

James
Title: Re: BxbAsm
Post by: jcfuller on May 09, 2012, 08:13:10 AM
Steve,
  I went through all the asm/c sources for bxblib.lib and created obj files for all.
I used gcc for the "c" ones.
I seem to have a problem with StdOut.asm

Code: [Select]
C:\bxb-linux>jwasm /c /coff /Cp "test6.asm"
JWasm v2.07pre, Nov  2 2011, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

test6.asm: 137 lines, 2 passes, 172 ms, 0 warnings, 0 errors

C:\bxb-linux>jwlink  system pe_con name test6.exe file test6.obj  LIBRARY kernel
32.lib,msvcrt.lib, user32.lib,fpu.lib, bxblib.lib
JWlink Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
loading object files
searching libraries
Error! E2028: _stdout is an undefined reference
Error! E2028: _strng is an undefined reference
creating a PE executable
file bxblib.lib(StdOut.asm): undefined symbol _strng
file bxblib.lib(StdOut.asm): undefined symbol _stdout
C:\bxb-linux>jwcon test6

but if I use the StdOut.obj file extracted from  your last bxblib.lib post and add it to mine all is well???

This is the code using your include files:

Code: [Select]
; *************BxbAsm Compiler*************
; Copyright: sarbayo (c) 2004-2012
; =========================================================================
  .486                       ; use 486 instructions
  .model flat, stdcall       ; Win32 memory model
  option casemap:none        ; case sensitive


    include \jwasm\jw-inc\windows.inc
    include \jwasm\jw-inc\stdio.inc

    EXTERNDEF strng:BYTE

  .code

StdOut proc lpszText:DWORD
; --------------------------------------------------
    invoke fprintf, stdout, addr strng, lpszText
    ret
; --------------------------------------------------
StdOut endp
end



James
Title: Re: BxbAsm
Post by: SteveA on May 09, 2012, 09:01:46 AM
Code: [Select]
; *************BxbAsm Compiler*************
; Copyright: sarbayo (c) 2004-2012
; =========================================================================
  .486                       ; use 486 instructions
  .model flat, stdcall       ; Win32 memory model
  option casemap:none        ; case sensitive


    include \jwasm\jw-inc\windows.inc
    include \jwasm\jw-inc\stdio.inc

    EXTERNDEF strng:BYTE

  .code

StdOut proc lpszText:DWORD
; --------------------------------------------------
    invoke fprintf, stdout, addr strng, lpszText
    ret
; --------------------------------------------------
StdOut endp
end


Add this line to BXB.INC:

    EXTERNDEF strng:BYTE

at the bottom of the other EXTERNDEF's.

Title: Re: BxbAsm
Post by: jcfuller on May 09, 2012, 03:10:48 PM
Steve,
  I'm working through the examples from BxbBasic.txt and found a couple of problems.
Test 21,22,24 have issues with variable name conflict and test32  is not working correctly.
If I enter James for First it leaves the es on screen when prompting for Initial.

James
Title: Re: BxbAsm
Post by: SteveA on May 09, 2012, 06:05:42 PM
Test 21,22,24 have issues with variable name conflict and test32  is not working correctly.
If I enter James for First it leaves the es on screen when prompting for Initial.

Regarding var-names:
Let me guess...."test" and "ten".
yes,
I have encountered situations where asm does not decorate names, var-names cannot conflict with reserved words.
Like: test, ten, cx, bx, and/or constants, etc.

I am working on some new docs to clarify that.


EDIT:
It sounds to me like "locate" and/or "wherexy" are not working.

Fixed wherexy.asm: (attached)

I included a test.bas for it, too.
Works good on my end.

Steve

P.S.
I've added a revised bxbasic.txt, that has some corrections in the samples.
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 02:50:57 AM
Steve,
  The attached wherexy.asm is the same one I have.

James

Edit: the attached bxblib.lib has the same problem.


Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 03:23:53 AM
Steve,
  Your attached library has the problems mentioned before.
It appears you can't use Lcc to create object modules.

James

Code: [Select]
C:\bxb-linux\examples>build test1x

C:\bxb-linux\examples>..\bxbasm test1x.bas
Copyright: Blunt_Axe_Basic, BxbAsm, Bxbasic (c) sarbayo, 2004-2012
Alpha Release: 1.06.3, Bxbasm Compiler

** stripped down version for Linux

Destination file: test1x.asm
Lines compiled: 20
Done.



C:\bxb-linux\examples>jwasm /c /coff /Cp "test1x.asm"
JWasm v2.07pre, Nov  2 2011, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

test1x.asm: 304 lines, 2 passes, 172 ms, 0 warnings, 0 errors

C:\bxb-linux\examples>jwlink  system pe_con name test1x.exe file test1x.obj  LIB
RARY kernel32.lib,msvcrt.lib, user32.lib,fpu.lib, bxblib.lib
JWlink Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
loading object files
searching libraries
Warning! W1173: file bxblib.lib(c:\programming\lcc\projects\bxblib\lib\floattost
r2.c): unknown directive '-library' ignored
Warning! W1173: file bxblib.lib(c:\programming\lcc\projects\bxblib\lib\clearscre
en.c): unknown directive '-library' ignored
Warning! W1173: file bxblib.lib(c:\programming\lcc\projects\bxblib\lib\strtofloa
t.c): unknown directive '-library' ignored
creating a PE executable
C:\bxb-linux\examples>
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 05:03:28 AM
Steve,
  Test 52 has problems.

James
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 06:51:59 AM
The attached wherexy.asm is the same one I have.

Edit: the attached bxblib.lib has the same problem.

Then, I can't imagine what the problem might be.
The function "wherexy" controls cursor placement for INPUT statements.

The problem must be elsewhere. I'll go thru the main code and see if I can find it.

EDIT:
Okay...........
I think I've got it,
when I originally stripped this version down, I commented-out some of the ".asm" code that called "wherexy".
The source code and EXE I had sent you was still containing that "blocked-out" code, where as mine was fine.

SEE attached:
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 07:32:42 AM
Your attached library has the problems mentioned before.
It appears you can't use Lcc to create object modules.


Yeh, it's doing something strange.
I don't know why that is, but it certainly is adding something to the ".obj".
I'm going to have to ask Jacob Navia about that.

Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 07:43:42 AM
EDIT:
Okay...........
I think I've got it,
when I originally stripped this version down, I commented-out some of the ".asm" code that called "wherexy".
The source code and EXE I had sent you was still containing that "blocked-out" code, where as mine was fine.

That fixed it.

James
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 07:52:11 AM
Steve,
  I don't think Random I/O is working.
The file created by test46 shows binary data when viewed.

James
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 07:55:17 AM
Your attached library has the problems mentioned before.
It appears you can't use Lcc to create object modules.


Yeh, it's doing something strange.
I don't know why that is, but it certainly is adding something to the ".obj".
I'm going to have to ask Jacob Navia about that.



you will have to include lcc library files anyway in order to build  asm -> exe using bxblib.lib because lcc does not use msvcrt for conio.

James
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 08:00:11 AM
I don't think Random I/O is working.
The file created by test46 shows binary data when viewed.

No,
actually, it's working.
If you view the .txt file in an editor other than notepad, (like wordpad), it will display.


Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 08:18:58 AM
Steve,
  Test 48 crashes.

James
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 08:33:10 AM
 Test 48 crashes.

Not on my machine.
I'm using the same Bxbasm.exe as I uploaded to you this AM.

This is the code for #48:
Code: [Select]
'-----cut-n-paste------'
'  test.bas version 48
    DIM az#=1.012345, bz!=123.456
    DIM cz%=123456, dz = 12345, rec = 1, ix = 0
    DIM A$ = "", B$ = "", C1$ = "", D$ = "", E$ = ""
    DIM w$ = "end"
    CLS
'
    OPEN "R", #1, "test.txt", 34
    FIELD #1, 4 AS A$, 4 AS B$, 8 AS C1$, 8 AS D$, 10 AS E$
    FOR ix = 1 TO 5 STEP 1
        LSET A$ = MKI$(dz)
        LSET B$ = MKI$(cz%)
        LSET C1$ = MKS$(bz!)
        LSET D$ = MKD$(az#)
        RSET E$ = w$
        PUT 1, rec
        rec = rec + 1
    NEXT ix
    CLOSE 1
    CLEAR
'
    OPEN "R", #1, "test.txt", 34
    FIELD #1, 4 AS A$, 4 AS B$, 8 AS C1$, 8 AS D$, 10 AS E$
    GET 1, 1
'
    az# = CVD(D$)
    bz! = CVS(C1$)
    cz% = CVI(B$)
    dz =  CVI(A$)
    PRINT "az#="; az#
    PRINT "bz!="; bz!
    PRINT "cz%="; cz%
    PRINT "dz ="; dz
    CLOSE 1
' ------------------------------------------
TheEnd:
  END
' ------------------------------------------


It executes correctly.

EDIT:
Attach your ".asm" file for test48.
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 09:11:02 AM
Steve,
  I tried with your bxbasm.exe from today, and mine that I created from your source of today. Same results.
I also tried both yours and my  bxblib.lib. same
I also included the test.txt file

James
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 09:33:27 AM
I assembled your test48.asm and it is working just fine.
I compared your test.txt with mine and it is correct.

Explain to me what you mean by "crash".


EDIT:
This is what the stored (binary) data looks like in wordpad:
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 10:25:37 AM
Steve,
  here's what I get:
James
Edit: Win7/64

Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 10:32:51 AM
Steve,
  Here's the exe.

James
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 10:38:59 AM
Test48.exe executes absolutely fine on XP.
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 12:55:15 PM
James,
Since I have no way of testing it, all I can figure is to eliminate a section of code and see where the breaking point is.
The test.txt file is correct. I can only assume that it's working correctly up to that point.
So, I'd comment-out this entire block:

Code: [Select]
'    CLEAR
'
'    OPEN "R", #1, "test.txt", 34
'    FIELD #1, 4 AS A$, 4 AS B$, 8 AS C1$, 8 AS D$, 10 AS E$
'    GET 1, 1
'
'    az# = CVD(D$)
'    bz! = CVS(C1$)
'    cz% = CVI(B$)
'    dz =  CVI(A$)
'    PRINT "az#="; az#
'    PRINT "bz!="; bz!
'    PRINT "cz%="; cz%
'    PRINT "dz ="; dz
'    CLOSE 1


and see if it compiles end executes correctly.
Then, little by little, uncomment lines until we find the one that breaks.

I can't tell if it's a win7 issue or a 64-bit issue.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 01:05:26 PM
Steve,
Runs fine when commented but crashes if only CLEAR is uncommented so that appears to be the culprit.

James
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 01:09:15 PM
Steve,
  I noticed the lea's and something is nagging in the back of my brain with problems using lea's.??????

James
Title: Re: BxbAsm
Post by: jcfuller on May 10, 2012, 01:34:52 PM
Steve,
  By commenting out just CLEAR compiles and executes fine. BUT CLEAR worked fine in test47??

James
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 01:58:37 PM
I noticed the lea's and something is nagging in the back of my brain with problems using lea's.??????
Quote
By commenting out just CLEAR compiles and executes fine. BUT CLEAR worked fine in test47??

I'm going to have to run it thru the debugger and see just what's happening.
This is very odd.
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 02:01:05 PM
Clear is introduced in test12 and hasn't failed up to now.
But, something about it is causing the problem.
Title: Re: BxbAsm
Post by: SteveA on May 10, 2012, 05:47:31 PM
I've single stepped it thru the debugger and CLEAR appears to be doing exactly what I expected it to do.
The only thing that I can think of that it could possibly be is, in the clear process, it call "free" to free malloc'ed memory for strings.
It doesn't fail on my end, but, possibly it does on win7/64.
Let me see if I can rig some kind of a test for that.

In the mean time, I guess we should avoid using CLEAR.

Thanks for all your patience and help with this James.
Steve
Title: Re: BxbAsm
Post by: jcfuller on May 11, 2012, 07:36:22 AM
I'm going to try debugging here although I have not done any single step debugging since 16bit days.
I downloaded ollydbg and pelles also has a debugger built it.
Now I need to reorganize the source so I can compile all the library modules with debugging info.

James
Title: Re: BxbAsm
Post by: SteveA on May 11, 2012, 09:59:32 AM
James,
I've snipped the 'clear-strings' portion form the CLEAR function and added it to the '.asm' listing:
Code: [Select]
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;  call clear_allvars
;
  mov  esi, _var_start
  mov  edi, _int_start        ; clear strings
  mov  ecx, 0
  add  esi, 4
@@:
  .if esi < edi
    mov  eax, [esi]
    .if eax != 0
      pushad
      invoke free, eax
      popad
      mov  [esi], ecx
    .endif
    add  esi, 4
    jmp  @B
  .endif
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


I've zipped the EXE and the .asm file.

So, rather than calling the 'clear' function, it's inserted into the code.
I'm of the feeling that the "free" might be the issue.
CLEAR first clears strings, then integers, then floats.
Only clearing strings calls "free".

I've tested it here, but, of course it works fine.
If you could run the EXE and see if it crashes, that might point in the right direction.
Thanks,
Steve
Title: Re: BxbAsm
Post by: jcfuller on May 11, 2012, 10:35:39 AM
Steve,
  It spits an exception here just as before.
I was able to create a debug version of  bxblib and in turn created a debug version of both your most recent test48a.asm and the parred down test48  with debug info. Pelles loads and debugs it fine it's just I have no idea what I'm doing with it or what I'm looking for :)

James
Title: Re: BxbAsm
Post by: SteveA on May 11, 2012, 11:44:33 AM
Hey James,
Okay, the fact that it crashes with only the clear-string portion tells me a lot.
That means that "free" could really be the culprit.
Try this, in Test48A.asm, comment-out "invoke free", like this:

Code: [Select]
 .if esi < edi
    mov  eax, [esi]
    .if eax != 0
      pushad
;;      invoke free, eax
      popad
      mov  [esi], ecx
    .endif
    add  esi, 4
    jmp  @B
  .endif


See if it still crashes.
Steve
Title: Re: BxbAsm
Post by: SteveA on May 11, 2012, 11:52:36 AM
Pelles loads and debugs it fine it's just I have no idea what I'm doing with it or what I'm looking for :)

Well, the idea would be to step it into the 'clear string' section, then continue single stepping it while noting which instruction causes the crash.


EDIT:

In Olly, here is a screen shot of where the 'clear string' section is:
F7 single steps.
In the event of a CALL, Ctrl-F9 will "advance thru" any CALLs and bring you to the next RET, where you will F7 again.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 11, 2012, 12:14:47 PM
No crash with free commented.

What I need is a simpler piece of code that crashes.

James

Title: Re: BxbAsm
Post by: SteveA on May 11, 2012, 12:28:23 PM
No crash with free commented.
What I need is a simpler piece of code that crashes.


Here is a quote from the Lcc-Win32 Standard Library docs:
Quote
The free function causes the space pointed to by ptr to be deallocated, that is, made available for further allocation. If ptr is a null pointer, no action occurs. Otherwise, if the argument does not match a pointer earlier returned by the calloc, malloc,or realloc function, or if the space has been deallocated by a call to free or realloc, the behavior is undefined.

Title: Re: BxbAsm
Post by: jcfuller on May 11, 2012, 12:52:28 PM
Well I think you are getting undefined as I think it is crashing in RtlInitUnicodeString called from RtlfreeHeap called from free.

James
Title: Re: BxbAsm
Post by: jcfuller on May 11, 2012, 12:57:57 PM
Here is olly screen at exception.
Title: Re: BxbAsm
Post by: SteveA on May 11, 2012, 01:00:16 PM
Well I think you are getting undefined as I think it is crashing in RtlInitUnicodeString called from RtlfreeHeap called from free.

Okay.
I wonder if it has something to do with it being associated with the open file...?
You know, the LSET...

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 11, 2012, 01:11:09 PM
Here is the pelles screen at exception
Note the bottom right call stack
James
Title: Re: BxbAsm
Post by: SteveA on May 11, 2012, 03:52:32 PM
James,
I was wondering if maybe you could try adding a CLEAR statement to test46.
Just after the CLOSE 1.
See what that does.
I'm trying to figure out what the circumstances are that sets up the problem.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 11, 2012, 05:53:24 PM
Steve,
  Test46 with a CLEAR is fine.

James
Title: Re: BxbAsm
Post by: SteveA on May 11, 2012, 05:56:32 PM
Hmm,
now that's interesting.
Title: Re: BxbAsm
Post by: jcfuller on May 12, 2012, 03:21:28 AM
Steve,
  This code causes bxbasm to crash in the translation process.

James

Code: [Select]
'  test.bas version 48X2
    DIM az#=1.012345, bz!=123.456
    DIM cz%=123456, dz = 12345, rec = 1, ix = 0
'    DIM A$ = "", B$ = "", C1$ = "", D$ = "", E$ = ""
    DIM A$ = "", B$ = "", C1$ = "", D$ = ""
    DIM w$ = "end"
    CLS
'
'    OPEN "R", #1, "test.txt", 34
    OPEN "R", #1, "test.txt", 24
'    FIELD #1, 4 AS A$, 4 AS B$, 8 AS C1$, 8 AS D$, 10 AS E$
    FIELD #1, 4 AS A$, 4 AS B$, 8 AS C1$, 8 AS D$
'    FOR ix = 1 TO 5 STEP 1
        LSET A$ = MKI$(dz)
        LSET B$ = MKI$(cz%)
        LSET C1$ = MKS$(bz!)
        LSET D$ = MKD$(az#)
'        RSET E$ = w$
        PUT 1, rec
        rec = rec + 1
'    NEXT ix
    CLOSE 1
    CLEAR
    PRINT "ALL DONE"
'
'    OPEN "R", #1, "test.txt", 34
'    FIELD #1, 4 AS A$, 4 AS B$, 8 AS C1$, 8 AS D$, 10 AS E$
'    GET 1, 1
'
'    az# = CVD(D$)
'    bz! = CVS(C1$)
'    cz% = CVI(B$)
'    dz =  CVI(A$)
'    PRINT "az#="; az#
'    PRINT "bz!="; bz!
'    PRINT "cz%="; cz%
'    PRINT "dz ="; dz
'    CLOSE 1
' ------- -----------------------------------
TheEnd:
  END
' ------------------------------------------

Title: Re: BxbAsm
Post by: jcfuller on May 12, 2012, 04:15:25 AM
Steve,
  Not sure it's relevant but your comments do not reflect the names of the vars in clear_allvars when compared to comments in AInput.c

James



Code: [Select]

clear_allvars proc
; --------------------------------------------------
  mov  esi, _var_start
  mov  edi, _int_start        ; clear strings
  mov  ecx, 0
  add  esi, 4
@@:
  .if esi < edi
    mov  eax, [esi]
    .if eax != 0
      pushad
      invoke free, eax
      popad
      mov  [esi], ecx
    .endif
    add  esi, 4
    jmp  @B
  .endif
  mov  edi, _flt_start        ; clear integers
  add  esi, 4
@@:
  .if esi < edi
    mov  [esi], ecx
    add  esi, 4
    jmp  @B
  .endif
  mov  edi, _var_endzz        ; clear floats
  add  esi, 4
@@:
  .if esi < edi
    mov  [esi], ecx
    add  esi, 4
    mov  [esi], ecx
    add  esi, 4
    jmp  @B
  .endif
  ret
; --------------------------------------------------
clear_allvars endp

From AInput.c

Code: [Select]

    s_writeln("\t_var_start\tdd\t?");           /* string data */
    i_writeln("\t_int_start\tdd\t?");           /* integer data */
    f_writeln("\t_flt_start\tdd\t?");           /* float data */
    x_writeln("\t_arry_start\tdd\t?");          /* arrays data */

Title: Re: BxbAsm
Post by: SteveA on May 12, 2012, 04:05:42 PM
Not sure it's relevant but your comments do not reflect the names of the vars in clear_allvars when compared to comments in AInput.c

Actually, it does, it's just not obvious.

_var_start :  is where the vars section (and strings) begin         /* string data */
_int_start  :  is where strings end and integers begin                 /* integer data */
_flt_start   :  is where integers end and floats begin                  /* float data */
_arry_start :  is where floats end and arrays begin                    /* arrays data */

So,...
when you see this:

; --------------------------------------------------
  mov  esi, _var_start
  mov  edi, _int_start        ; clear strings
  mov  ecx, 0
  add  esi, 4
@@:


esi is loaded with the address of the start of strings.
edi is loaded with the end of strings (start of integers).
When esi is equal to edi, strings are done.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 13, 2012, 01:44:45 PM
Steve,
  Even with the current CLEAR problem I started a linux port and at this time it does not look good.
There is no such animal as _msize on linux nor does a work around exists. All references I found indicate it is the programmers
responsibility to store the size data from a malloc; so unless you can eliminate it there will be no linux port.

James
Title: Re: BxbAsm
Post by: AIR on May 14, 2012, 08:11:48 AM
Maybe #define _msize(...) malloc_usable_size(...)??

A.
Title: Re: BxbAsm
Post by: jcfuller on May 14, 2012, 08:24:25 AM
Thanks Armando.
I do remember that now, but it did not show up in any of the discussions I found on a search _msize on linux.

James
Title: Re: BxbAsm
Post by: SteveA on May 14, 2012, 08:39:13 PM
This code causes bxbasm to crash in the translation process.

I think it goes back to the original CLEAR issue.
If I narrow it down to just the two floats,

    FIELD #1, 8 AS C1$, 8 AS D$
        LSET C1$ = MKS$(bz!)
        LSET D$ = MKD$(az#)

followed by a clear, then it does throw an exception.
I've got to single step this, thru Olly, to see what's happening.

Steve
Title: Re: BxbAsm
Post by: SteveA on May 15, 2012, 11:22:15 AM
Your attached library has the problems mentioned before.
It appears you can't use Lcc to create object modules.


James,
I posted a message for Jacob Navia regarding this matter:

Quote
Hello Jacob,
I'm using jwlink (originally open watcom) to build static libraries.
I consistantly get "unknown directive" warnings from the lcc
created .obj files that I add to my ".LIB".
This has been tested using polink as well, with the same warnings.
The EXE is created, but, I am annoyed by the warnings.

"JWlink Version 1.9
Portions Copyright (c) 1985-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
loading object files
searching libraries
Warning! W1173: file mylib.lib(c:\lcc\projects\lib\floattostr2.c): unknown directive '-library' ignored
Warning! W1173: file mylib.lib(c:lcc\projects\lib\clearscreen.c): unknown directive '-library' ignored
Warning! W1173: file mylib.lib(c:\lcc\projects\lib\strtofloat.c): unknown directive '-library' ignored
creating a PE executable"

I searched the group archives, but, I find nothing.
Any suggestions ?


but, have not heard back from him yet.
I guess I should have emailed him.

In the mean time, I got this response from someone else:

Quote
From: "Fred J. Scipione" <FredJScipi...@alum.RPI.edu>

Near the bottom of his webpage http://www.japheth.de/JWlink.html,
Japheth notes that JWLink does not support MS link's /DEF option, which
is where the LIBRARY directives are used.  I expect that your most
direct course of action is to take advantage of the fact that JWLink is
open source, and add your own /DEF handling code :-).

The fact that the '-library' directive is reported with a leading dash
suggests that it may be a command-line directive.  How are you invoking
JWLink?


I suppose that another route might be to add an option to suppress the
'unknown directive' warnings for '-library' directives.  The suppression
could be implemented for either or both the command-line and /DEF cases.

===================================================================

From: steve <blunt.axe.ba...@gmail.com>

Hello Fred,
Actually I mis-spoke, I'm using wlib.exe and not jwlink.
Wlib.exe is the library tool for creating libraries from ".obj" files.
The commandline would be: wlib -b my.lib some.obj

s.

===================================================================

From: steve <blunt.axe.ba...@gmail.com>

The linker warning comes up when I link to the function in the
library.
I call the linker from a batch file: JWlink format windows pe file
"%1.obj"

s.

===================================================================

From: "Fred J. Scipione" <FredJScipi...@alum.RPI.edu>

If you follow the 'list of changes' link on Japheth's page to
http://www.japheth.de/JWlink/Changes.html, it says -

if the linker finds a directive in section ".directive" that it doesn't
understand, it will emit warning "unknown directive '-%s' ignored".


So, JWLink is adding the dash in the warning for an unknown 'library'
directive it finds inside the object modules.  That means that the
compiler is creating the 'library' directives (in a ".drectve" section)
within the object modules you are producing from the floattostr2.c,
clearscreen.c, and strtofloat.c sources.  The 'library' directive is a
valid MSLink-compatible directive.  The problem is that JWLink does not
implement handling of the 'library' directive.


Assuming that it is OK for JWLink to ignore the 'library' directives,
you must either -
1. Live with the warnings.
2. See if there is something special about those 3 .c sources which
produce the 'library' directive (which you can remove?).
3. See if there is some way to get the compiler to not generate the
'library' directives (does it not do so for certain other .c sources
going into your library?  Why?).
4. Change and re-compile JWLink to implement or quietly ignore the
'library' directives.
5. Create a program that deletes 'library' directives from object
modules.  Extract the offending modules from your library, delete their
'library' directives, and replace the modules in your library with the
modified ones.


It might be helpful to find and use an object module 'dumper', which
will give you a better view of where and how the 'library' directive
appears within your object modules.

Title: Re: BxbAsm
Post by: SteveA on May 15, 2012, 01:03:04 PM
This code causes bxbasm to crash in the translation process.

James,
just on a hunch, I thought I'd run this code, (that causes an error), thru an earlier version of bxbasm that assembles using Masm:

Code: [Select]
'-----cut-n-paste------'
'  test.bas version 48X2
    DIM az#=1.012345, bz!=123.456
    DIM rec = 1
    DIM C1$ = "", D$ = ""
    CLS
'
    OPEN "R", #1, "test.txt", 16
    FIELD #1, 8 AS C1$, 8 AS D$
        LSET C1$ = MKS$(bz!)
        LSET D$ = MKD$(az#)
        PUT 1, rec
        rec = rec + 1
    CLOSE 1
    CLEAR
    PRINT "ALL DONE"
'
' ------------------------------------------
TheEnd:
  END
' ------------------------------------------
'-----cut-n-paste------'


It works perfectly and does not crash.
Odd !

That begs the questions:
what did I change between that version and this ?
is it Masm -vs- Jwasm ?

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 15, 2012, 01:07:16 PM
Steve,
  Isn't the library warning primarily the result of using the LCCWin32 console library?
I'll upload my version shortly using gcc.
James

Title: Re: BxbAsm
Post by: jcfuller on May 15, 2012, 01:19:31 PM
Here is my complete Library source directory. I used make and a makefile to create it.
Note I used gcc for the "c" modules and ar to create the library.
Because of gcc/ld conventions for linking I named the library libbxblib.a
You can rename it any thing you want; I'd assume bxblib.lib

James
Title: Re: BxbAsm
Post by: jcfuller on May 15, 2012, 01:26:56 PM
Steve,
  Here is my complete Bxbasm project directory. The exe is named BxbAsm5_10.exe with BxbAsm5_10.c the
main source file compiled with gcc. I fixed all the comment warnings but there are still warnings for unused variables.

James
Title: Re: BxbAsm
Post by: jcfuller on May 15, 2012, 01:39:50 PM
Quote
James,
just on a hunch, I thought I'd run this code, (that causes an error), thru an earlier version of bxbasm that assembles using Masm:

Steve,
  I'm confused here. Bxbasm is written in "c" and it crashed when trying to translate the snippet I posted. Nothing to do with masm/jwasm is there? Unless the translation code is different??

James
 
Title: Re: BxbAsm
Post by: SteveA on May 15, 2012, 02:29:14 PM
I'm confused here. Bxbasm is written in "c" and it crashed when trying to translate the snippet I posted.
Nothing to do with masm/jwasm is there? Unless the translation code is different??

It never crashed on translation, on my end.
It translated, assembled and linked without error of any kind.
It did, however, thro an exception on execution.

That is what confused me, even tho' I could find no error in the code.
That prompted me to try assembling with Masm.
Which succeeded, without error of any kind and executed without error.
Title: Re: BxbAsm
Post by: SteveA on May 15, 2012, 02:32:33 PM
Isn't the library warning primarily the result of using the LCCWin32 console library?

I don't think it is.
Lcc must be inserting an instruction of some sort into the .obj.
Title: Re: BxbAsm
Post by: SteveA on May 15, 2012, 03:55:16 PM
James,
this from Jacob:

Quote
From: jacob navia <ja...@spamsink.net>
> 3. See if there is some way to get the compiler to not generate the
> 'library' directives (does it not do so for certain other .c sources

That -library directive is produced by the
#pragma lib <foo.lib>

found in certain lcc headers. It instructs the compiler to produce a comment section in the object file that will tell the linker to include
that library in the link.


In this way, I avoid the thousands of questions of newbees that tell me

"I included the header file but now the compiler tells me:
   undefined symbol _SomeLibraryCall. What do I do now?"

WORKAROUND: (Bad solution)

Eliminate all the #pragma lib istructions form the header files.


SECOND WORKAROUND: (Better solution)

Fix your linker so that follows the -library comments in object files
and includes transparently a library in the link from the .h file.


Title: Re: BxbAsm
Post by: SteveA on May 15, 2012, 04:03:53 PM
Here is my complete Bxbasm project directory.
The exe is named BxbAsm5_10.exe with BxbAsm5_10.c the main source file compiled with gcc.

James,
I ran Test48x2 using BxbAsm5_10.exe.
It functioned exactly like my compile, (using lcc), it translated and executed.
It stores the correct values to test.txt and it stalls, just like mine does, at the end of the program.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 16, 2012, 06:26:03 AM

That is what confused me, even tho' I could find no error in the code.
That prompted me to try assembling with Masm.
Which succeeded, without error of any kind and executed without error.


Steve,
  Did you try jwasm with -Zg ?

James
Title: Re: BxbAsm
Post by: SteveA on May 16, 2012, 05:19:56 PM
Did you try jwasm with -Zg ?

No, but I'll give it a try.

Another thing I'm interested in, is looking at the assembly listing file.
That might reveal something I've missed.
Title: Re: BxbAsm
Post by: SteveA on May 17, 2012, 09:52:23 AM
James,
In an effort to find out what is broken, I've gone back to recent, older versions of bxbasm.
Since the compile from January worked without producing any error, I wanted to narrow down the possibilities.
It looks like bxbasm worked when only a minimum of functions resided in bxblib.lib and most of bxb's functions were in file: Afunct.c.

So, what that tells me is, that somewhere along the line, I introduced an error when I converted functions from .C to .asm and constructed the new bxblib.lib.
At this point, I need to back-step that process and re-test each function that goes into bxblib.lib.
That is what I will be working on until I get this thing figured out.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 17, 2012, 09:58:20 AM
Steve,
  I am having pretty good luck with the port but found an issue with the translation process of the bas -> asm.
Test46 is throwing an exception. If I comment out the PUT 1,1 it will not throw an exception. Note that the asm file IS created.

I ran valgrind against it and this is the report it gave.
Code: [Select]
==8105== 1 errors in context 1 of 2:
==8105== Conditional jump or move depends on uninitialised value(s)
==8105==    at 0x805AF59: Do_field (AFile.c:865)
==8105==    by 0x806299C: parser (Bxbasm.c:177)
==8105==    by 0x8062828: pgm_parser (Bxbasm.c:86)
==8105==    by 0x80627E7: main (Bxbasm.c:67)
==8105==  Uninitialised value was created by a stack allocation
==8105==    at 0x804D4A7: find_strng (Utility.c:388)
==8105==



James
Title: Re: BxbAsm
Post by: SteveA on May 17, 2012, 05:23:55 PM
James,
I've made at least one discovery.
There are a few functions that need to be put back into Bxbasm.inc

Code: [Select]
;/* Bxbasm.INC */
;
; *************BxbAsm Compiler*************
; Copyright: sarbayo (c) 2004-2012
; =========================================================================
    .386
    .code

; лллллллллллл FUNCTIONS лллллллллл FUNCTIONS лллллллллл FUNCTIONS лллллллл
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
StdIn proc lpszBuffer:DWORD,bLen:DWORD
    LOCAL hInput :DWORD
    LOCAL bRead  :DWORD
;
    invoke GetStdHandle,STD_INPUT_HANDLE
    mov hInput, eax
;
    invoke SetConsoleMode,hInput,ENABLE_LINE_INPUT or ENABLE_ECHO_INPUT or ENABLE_PROCESSED_INPUT
    invoke ReadFile,hInput,lpszBuffer,bLen,ADDR bRead,NULL
    mov eax, bRead
    ret
StdIn endp
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
StrLen proc item:DWORD
    push    ebx
    push item
    call strlen
    pop     ebx
    ret
StrLen endp
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл
StdOut proc lpszText:DWORD
    LOCAL hOutPut  :DWORD
    LOCAL bWritten :DWORD
    LOCAL sl       :DWORD
;
    invoke GetStdHandle, STD_OUTPUT_HANDLE
    mov hOutPut, eax
    invoke StrLen, lpszText
    mov sl, eax
    invoke WriteFile, hOutPut, lpszText, sl, ADDR bWritten, NULL
    mov eax, bWritten
    ret
StdOut endp
; ллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллллл


They will need to be removed from bxblib.lib, as well.
For some odd reason, this fixes the problem with: Test48X2.bas.

I don't know if it will fix the other issues, but, let's see what effect it has.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 21, 2012, 06:48:11 AM
Steve,
  While waiting for you to get your new computer :) I decided to convert your Bxbasic tutor source to MinGW gcc. I think I got it from the QDepartment file section?
First problem was global var omissions in Engine.c of Chapter04.


I added:
    char var_type;           /* current variable type             */
    double *dv_stack;          /* stack:double float values         */
    char **dn_stack;         /* stack:double float names          */
    int dmax_vars=0;        /* stack:double float counter        */

and it compiled fine

James

 
Title: Re: BxbAsm
Post by: SteveA on May 22, 2012, 06:45:15 PM
Hey James,
Okay,... it's taking me forever to get Win7 setup....
Boy, I hate when Microsoft feel the need to constantly re-invent the wheel.

Anyway...the first thing I've done, is to copy over my working directories for Lcc and Jwasm.
So far, as far as I can tell, I am having no problems getting bxbasm to work.

I took the same bxbasm, compiled with Lcc and had it translate and assemble with jwasm.
Executable appears to be working without errors.
Zero warnings, zero errors.
(just the same old lcc caused linker warning: "unknown directive -library..."


edit:
not saying it's all good, just that I have only just started testing.

Title: Re: BxbAsm
Post by: SteveA on May 23, 2012, 08:35:15 AM
James,
I played around with some of the scripts that have been troublesome.
I have narrowed down that "clear" is adversely affected by the strings that contain floating point numbers.
Like: LSET mystr$ = MKD$(floatVal#)
For some reason, this causes an exception.

However, if I go in (right-click on: test#?.exe) and set the Compatibility Mode for either Win-95 or Win-98, then no errors are generated.
The executable executes and terminates normally. This I don't understand.

I am not having any troubles with the Bxbasm executable, as to failing to translate the scripts or hanging in the process.
Bxbasm seems to be working as expected.

What I've got to figure out is what makes clearing the above mentioned strings throw an exception.
Maybe I've got to redesign that procedure.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 23, 2012, 09:50:35 AM
Steve,
  Would there be any free/reallocate involved? I can't track it down but I believe Win7 is very fussy on free, maybe even to the point of an actual bug?? I did a number of searches but couldn't come up with a definitive answer.

James
Title: Re: BxbAsm
Post by: SteveA on May 24, 2012, 06:18:59 AM
Would there be any free/reallocate involved?
I can't track it down but I believe Win7 is very fussy on free, maybe even to the point of an actual bug??
I did a number of searches but couldn't come up with a definitive answer.

Yes.
I spent all day yesterday trying to figure out exactly what is going on.
I spent a good amount of time single-stepping thru Ollydebug, monitoring the registers and memory locations.

When a crash occurs, it's never while in the bxbasm module, but, rather in the ntdll.dll module.
I have become quite familiar with the breaking point, but, don't know what the exact cause is.
I can see everything is fine and then all of a sudden, a call to "free" goes off to never-never land.
It's the same everytime. Quite interesting.

It isn't as tho I have the wrong instruction, a mov, a push, a pop, etc., out of place.
The bxbasm code is correct.

Steve
Title: Re: BxbAsm
Post by: SteveA on May 24, 2012, 11:03:06 AM
Okay,
I think I have it figured out.
It turns out that when "clear" is called, it is attempting to "free" some pointers.

For instance, this statement:     FIELD #1, 4 AS A$, 4 AS B$, 8 AS C1$, 8 AS D$, 10 AS E$
sets up an I/O buffer and the string-var names point to segments within the buffer.

Example:
    OPEN "R", #1, "test.txt", 34
establishes that the buffer is 34 bytes in size.

And, this statement:
    FIELD #1, 4 AS A$, 4 AS B$, 8 AS C1$, 8 AS D$, 10 AS E$
divides the buffer into segments,
where:
A$ points to byte 0 in the buffer:    [aaaa..............................]
B$ points to bytes 4 in the buffer:   [....bbbb..........................]
C1$ points to bytes 8 in the buffer: [........cccccccc..................]
D$ points to bytes 16 in the buffer: [................dddddddd..........]
E$ points to bytes 24 in the buffer: [........................eeeeeeeeee]

Unfortunately, the buffer is malloc'd else where.
When "free" is called (via clear), Clear indiscriminately attempts to "free" individual segments of the buffer.
Which it can't do.
Huh!

Now, I need to develop a work-around.

Steve
Title: Re: BxbAsm
Post by: SteveA on May 24, 2012, 02:11:09 PM
James,
Okay, I've got it figured out, (I think).
The solution was, to not "free" (clear) the strings associated with the I/O buffer, but, to simply zero them out when they are no longer needed.
This required inventing another keyword, but, I see no other way of doing it.
Since the keywords FIELD and LSET/RSET directly pertain to the buffer and associated string names, I figured it was going to either be UNFIELD or UNSET.
So I decided on UNSET.
Here is an example of it's usage:
Code: [Select]
    FIELD #1, 4 AS A$, 4 AS B$, 8 AS D$, 10 AS E$
        LSET A$ = MKI$(dz)
        LSET B$ = MKI$(cz%)
        LSET D$ = MKD$(az#)
        RSET E$ = w$
        PUT 1, rec
    CLOSE 1
    UNSET A$, B$, D$, E$
    CLEAR


UNSET must be used after CLOSE and prior to a CLEAR command.

Here is what that snippet of asm code looks like:
Code: [Select]
  mov  eax, 0
  call closeafile
  mov  A, 0 ; release string from I/O buffer
  mov  B, 0 ; release string from I/O buffer
  mov  D, 0 ; release string from I/O buffer
  mov  E, 0 ; release string from I/O buffer
; --------------------------------------------------
  call clear_allvars


I have attached the new sources and executable.

Thanks,
Steve
Title: Re: BxbAsm
Post by: John on May 24, 2012, 02:57:04 PM
Quote
So I decided on UNSET.

undef might work as well.
Title: Re: BxbAsm
Post by: jcfuller on May 25, 2012, 03:11:13 AM
Steve,
  Don't I also need the new (changed) library sources as it still fails with test48.


James
Title: Re: BxbAsm
Post by: jcfuller on May 25, 2012, 03:35:25 AM
Never mind! tried it before my second cup :)
All is fine.

James
Title: Re: BxbAsm
Post by: SteveA on May 25, 2012, 06:16:20 AM
Never mind! tried it before my second cup :)
All is fine.

Okay.

I'm getting ready to install Linux.
I do have some questions, maybe John and Air can weigh in on this too.

I'd like to setup minimal partitions (disk size) for more than one version of Linux.
I assume you can do that and select which OS you want to boot from.
I know you used to be able to do that with Windows: Win-95::Win-98::OS2.

I'd like to be able to test bxbasm on various popular versions.
I assume Ubuntu is a given.
What other flavors should I also consider ?
I don't need to set up a Linux server, at this time, so just basic OS's.

Thanks,
Steve

Title: Re: BxbAsm
Post by: jcfuller on May 25, 2012, 07:22:21 AM
Steve,
  A lot of Ubuntu users are jumping ship because of the Unity interface. I switched (not because of Unity) to Linux Mint (12). I see there is a (13) out but I'm not sure at this juncture if I'll upgrade.

  Another alternative is VirtualBox. It's a lot easier to try different OS's. You can even install XP along with several different flavors of 'nix.

James
Title: Re: BxbAsm
Post by: jcfuller on May 25, 2012, 07:52:44 AM
Steve,
Another plus for VirtualBox is you can set up drives that can be shared. Dual booting can be a real pain when you are developing an app for windows and Linux with no easy way to share code.
I don't dual boot anymore at all (well I don't have to with all the boxes I have). I do have one system with Win7 and Virtualbox which has several XP configs and 5 different Linux setups. All can share data with the main win7 system.

James
Title: Re: BxbAsm
Post by: AIR on May 25, 2012, 08:29:35 AM
Steve,

As James mentioned, virtualization is the way to go here.  The three main reasons are:

1- You don't have to mess around with multi-boot/partitioning and associated headaches
2- You can have multiple virtual machines running simultaneously along with your core os (depending on system and resources)
3- Most valuable reason:  Snapshots.  You can take a snapshot of an OS before any changes, and revert easily if those changes mess things up.

Several years ago when I was working on porting Hotbasic to Linux, I used the Distrowatch (http://distrowatch.com/) site to determine which Linux distributions I should use to check the port against.  I continued that approach when I worked on the various BCX ports. 

As of this morning, the top 3 Linux distributions listed on Distrowatch are Mint, Ubuntu, and Fedora.  I would also recommend a Debian install, since it's the Grand-daddy of Ubuntu and the dozens of Ubuntu derivatives.

Two more things I should mention:  If you have a 64bit machine, you can virtualize both 32 and 64 bit Linux versions, which if you have the space I highly recommend because of the differences in library locations between the two.  Lastly, if space becomes a concern you can simply archive the virtual machines to external storage to clear up drive space.

A.
Title: Re: BxbAsm
Post by: SteveA on May 25, 2012, 10:03:26 AM
As James mentioned, virtualization is the way to go here.

Thanks for your advice, James and Armando.

Quote
If you have a 64bit machine, you can virtualize both 32 and 64 bit Linux versions, which if you have the space I highly recommend because of the differences in library locations between the two. 
Lastly, if space becomes a concern you can simply archive the virtual machines to external storage to clear up drive space.

Okay, my machine is 64-bit and has a 500 GB drive, with only Win-7 installed.
So space is no major issue.
Let's say I want all three (or four) of those distros, (VM), how do I get started ?
What do I need to download ?

Yesterday, after reading an article, I downloaded "GParted-Live":
http://gparted.sourceforge.net/livecd.php

supposed to be a tool that helps linux-partition the drive.

I have links for Fedora, Ubuntu, Mint and Debian.

Steve
Title: Re: BxbAsm
Post by: SteveA on May 25, 2012, 10:09:18 AM
undef might work as well.

Yes it would, but, I thought it might confuse people who have used 'undef' in other languages.
While deciding, I looked through my BASIC Reference Manual, searching for either a keyword that might fit or making sure I wasn't using  one that is already in use for some other purpose.

I'm still open to suggestion.
As far as I'm concerned, "UNSET" is only an expedient, waiting for something better.
Title: Re: BxbAsm
Post by: John on May 25, 2012, 12:02:43 PM
Quote
Yes it would, but, I thought it might confuse people who have used 'undef' in other languages.

That's why they call it Traditional BASIC.  ;)
Title: Re: BxbAsm
Post by: jcfuller on May 25, 2012, 01:03:59 PM
Steve,
  You won't need any partitioning software if you choose VirtualBox.
First get and install VitrualBox. Take the time to really give the instructions a good read.
https://www.virtualbox.org/

Then go to Distrowatch ( http://distrowatch.com/ )and check out the Rankings.
I'm going to check out both new Linux Mint 13 versions.

A word of warning re 32/64. If you opt for 64 you will also have to find and install all the needed 32bit libraries. For now I think 32 bit is in order especially as all your jwasm code is 32bit. I don't know how well versed you are in 64asm??? or even if you intend to expand Bxbasm
to 64bit???

James
Title: Re: BxbAsm
Post by: SteveA on May 25, 2012, 01:21:53 PM
You won't need any partitioning software if you choose VirtualBox.
First get and install VitrualBox. Take the time to really give the instructions a good read.
https://www.virtualbox.org/

Okay, good to know that.
Thanks for the links.
I was googling "linux VM" and stubled across a forum that mentioned VirtualBox.

Quote
Then go to Distrowatch ( http://distrowatch.com/ )and check out the Rankings.

Right.

Quote
If you opt for 64 you will also have to find and install all the needed 32bit libraries.
For now I think 32 bit is in order especially as all your jwasm code is 32bit.
I don't know how well versed you are in 64asm??? or even if you intend to expand Bxbasm to 64bit???

Yeh, for the immediate, I will work with 32 bit.
I'm not ready for 64 bit asm.
I will work on that after we have a working 32 bit version running.
"Skin one cat at a time."

Thanks James,
Steve
Title: Re: BxbAsm
Post by: SteveA on May 25, 2012, 07:19:34 PM
Okay guys,
I have installed VirtualBox.

I have a question about what exactly to do next.
I downloaded some .iso files for Fedora, Ubuntu and Mint.
At this point, what am I supposed to do with them ?

I read thru the VirtualBox PDF docs, but, I don't see where it mentions the .iso's.

Steve

Title: Re: BxbAsm
Post by: John on May 25, 2012, 07:24:43 PM
Quote
Use Settings -> Storage -> IDE Controller to setup the Virtual DVD (i.e. ISO DVD Image)

Then use the green + sign to add a new device. When prompted to, during the add, browse to the bootable ISO file that is to be used as the Virtual DVD (DVD image) to install. Then make sure the ISO is assigned as the Primary Master for the Virtual DVD. The Storage Form, right panel has the drop-down box to configure devices.

You can setup several ISO files and the Host CD drive as primary and secondary virtual devices. By configuring the Primary and Secondary Drive assignments, you can boot from any image or from a physical Host drive.
Title: Re: BxbAsm
Post by: SteveA on May 25, 2012, 08:14:08 PM
Thanks John,
I think I got it.

Title: Re: BxbAsm
Post by: SteveA on May 28, 2012, 08:32:25 AM
Hey Guys,
I installed each of these in the VM: Fedora, Ubuntu, Mint and Debian.
They each bootup into their respective GUIs and seem to work okay.

Question:
How do I modify them so that they boot up into the console, instead of the GUI ?
Or, should I just leave them as they are and open the terminal ?

Steve

edit:
Thanks for suggesting the VirtualBox.
It turns out to be a lot easier than creating  multi-boot system.
So far I don't see any down-side that would affect what I'm doing.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 28, 2012, 09:25:46 AM

Question:
How do I modify them so that they boot up into the console, instead of the GUI ?
Or, should I just leave them as they are and open the terminal ?

Steve



I don't know if there is a way but opening a terminal is not that difficult :)

For an IDE I use Geany. I've only tried Ubuntu and Mint12, and it is available in the software repositories.

If you want I can post my current BXB.INC and my library directory. I don't think I needed to make any changes to Bxbasm.c and friends.

James
Title: Re: BxbAsm
Post by: SteveA on May 28, 2012, 11:26:44 AM
I don't know if there is a way but opening a terminal is not that difficult :)

I've only ever used Linux from the console, so the GUI is a new experience for me.
When I've used Linux, I was accessing a server (Slackware) via a terminal connection.

Quote
If you want I can post my current BXB.INC and my library directory.
I don't think I needed to make any changes to Bxbasm.c and friends.

Sure, that would be great.

I have noticed that the four distros do not all include the same GNU tools.
I was looking for gcc and I think I found it on only one, (so far).
From the terminal, on Debian, I typed "whereis gcc" and got no response.
It's like the bash commands are different, or something isn't setup right.

Steve
Title: Re: BxbAsm
Post by: jcfuller on May 28, 2012, 01:36:57 PM
I just do a gcc --version from the terminal prompt.
I installed Bacon from the Mint12 software manager and it added all the -dev packages I think I'll need.

James

Title: Re: BxbAsm
Post by: jcfuller on May 28, 2012, 01:58:49 PM
Steve,
  Here is my LibSource directory. It includes a makefile to make things easier.

James

Edit: forgot bxb.inc
I also include my build script
Title: Re: BxbAsm
Post by: AIR on May 30, 2012, 11:24:18 PM
On Debian-based distros, issue the command "sudo apt-get install build-essential" to install gcc etc.

Under Ubuntu, "sudo update-rc.d -f gdm remove" will disable the display manager (you'll need to restart afterwards).  Not sure if that works on Debian, worth a shot though...the other distros may have other ways of disabling the display manager (if you're running Gnome on all of them, it will be "gdm").  You should be able to manually start the Gui from the commandline if needed by running "startx".

A.

Title: Re: BxbAsm
Post by: SteveA on June 01, 2012, 09:24:45 AM
On Debian-based distros, issue the command "sudo apt-get install build-essential" to install gcc etc.

Under Ubuntu, "sudo update-rc.d -f gdm remove" will disable the display manager (you'll need to restart afterwards).  Not sure if that works on Debian, worth a shot though...the other distros may have other ways of disabling the display manager (if you're running Gnome on all of them, it will be "gdm").  You should be able to manually start the Gui from the commandline if needed by running "startx".

Hey, thanks for the info Armando.

I've been buried in Debian for the past 2+ days.
Boy, was it a hassle.
Fedora, Mint and Ubuntu completely installed and updated properly and in a very short time.
Got all the GNU tools and everything I will (n)ever need.

Debian was a very different story.
Getting the updates and all the GNU stuff that I needed was really like pulling teeth.
I read and reread the specific docs and googled, but, nothing was working.
I mean, what took 10 minutes to do in each of the other three, was taking me days to figure out on debian.
Being a complete noob to debian and very little helpful information from the debian forum (jerks) guys, finally this morning I got it all done.

You know, when you spend 2 days doing google searches, reading and re-reading the docs (and nothing makes any sense) and you search forum posts, all before you post a question in a forum and a guy's reply is "STFW" and "RTFM", (Search The F*ing Web) and (Read The F*ing Manual), that kind of leaves a bad taste.

I once thought Forums and User Groups were there for the purpose of aiding in the persuit of finding solutions.

Steve
Title: Re: BxbAsm
Post by: SteveA on June 11, 2012, 08:42:26 PM
Hey James,
I think I've finally got Linux in a usable state.

I have what might be a stupid question...,
what does jwasm/jwlink (linux) use for header and library files ?

I looked through the docs and the downloads and I don't see what I'm supposed to use.
How does this work ?

Title: Re: BxbAsm
Post by: jcfuller on June 12, 2012, 02:56:52 AM
Steve,
  I don't think there are any. I think I used the h to inc app on windows with the linux gcc headers to get some of the basic ones.
I'll take a look later today.

James
Title: Re: BxbAsm
Post by: jcfuller on June 12, 2012, 05:09:23 AM
Steve,
  Here is my jwasm linux include directory. There is probably junk in there as well as needed include files.

James
Title: Re: BxbAsm
Post by: SteveA on June 14, 2012, 03:00:39 PM
Hey james,

I studied your linux console functions.
I was reminded that years ago I did quite a bit of terminal programming using escape sequences.
VT100 type terminals and some others too.

Until now, I didn't really have a good grasp of how linux worked and how it differed from windows, or even from DOS.
So, now I understand that aspect considerably better.

I've been studying up on Linux programming, regarding ncurses.
I don't know how familiar you are with ncurses, but, it's like an entire API for terminal programming.
So much more can be done using ncurses than with escape sequences.
Once again, it would not be cross platform compatible with windows, but, it would be with any flavor of *nix.
ncurses is very interesting stuff.

Steve
Title: Re: BxbAsm
Post by: jcfuller on June 15, 2012, 05:37:37 AM
Steve,
  The functions I believe are mostly Armando's MBC/UBX that I borrowed.
I am aware of but have not studied ncurses very much. I may have done jwasm demo borrowed from FreeBasic.

James
Title: Re: BxbAsm
Post by: SteveA on June 15, 2012, 08:01:44 AM
Hey James,
ncurses has functions that do everything on the console that you would expect, like windows/dos does.
As an example, functions that duplicate: beep, locate, color, cls, inkey, and many many more.

There appears to be nothing that windows/dos does that ncurses isn't capable of duplicating.
There are things that ncurses can do that windows/dos doesn't, or, does them in a much simpler way.


edit:
...still not really liking Win-7.
Boy it's really annoying, especially how it opens folders.

I generally open each folder in it's own window.
That way I can view more than one folder's contents at one time.

I can find no way to get them to anchor to one side of the screen or the other.
They just open (tile) anywhere they want to, all over the screen and in any size they want.
I waste more time moving and resizing folders before I can use them.

Fortunately, I'm only using it for launching VirtualBox and Linux.

Like I told my wife: "MS has only ever gotten a few things right; DOS, Win-3.x, Win-98 and Win-XP".
Title: Re: BxbAsm
Post by: SteveA on June 19, 2012, 08:01:22 PM
Hey James,
I'm having difficulty getting anything to compile and link, using gcc, as your samples files illustrate.
I have tried using the ".sh" files as an example, but, linking by using gcc just gives me errors.
The error messages are:
"undefined reference to '_Do_initialize@0'
"undefined reference to '_stdout'

I must not be providing the correct information regarding libbxblib.a.
I'm unable to copy it to /usr/lib, and it looks like it's not finding it in my local .lib folder either.

I do have this in my command line:
.... -L/home/steve/jwasm206/lib -lbxblib

Any suggestions on how to make that work ?

My basic script is really simple:
   Print "hello world"
   END

bxbasm is working, jwasm is (or seems to be) working, just can't produce an executable.

Steve
Title: Re: BxbAsm
Post by: jcfuller on June 20, 2012, 04:04:26 AM
Steve,
  I think this is the script I am using?
James


Code: [Select]
#!/bin/bash
INCLUDE=/home/james/jwasm/include
export INCLUDE
../Bxbasm $1
jwasm -elf -zcw -Fo $1.o $1.asm
# jwasm -elf -Fo $1.o $1.asm
gcc -s -nostartfiles -o $1 $1.o \
    -L/home/james/BxbAsm5_10/LibSource \
    -L/home/james/jwasm/fpulib \
    -lbxblib -lm -lfpu
#gcc -s -nostartfiles -o $1 $1.o ClearScreen.o

Title: Re: BxbAsm
Post by: SteveA on June 20, 2012, 04:05:56 PM
James,
I'm having quite a bit of difficulty getting the simplest program to properly link when I use libbxblib.a.

I have examined all the files you provided and just can't figure out what the issue is.
Here is the error message I get when I use "ld" alone:
Quote
steve@steve-VirtualBox:~/Jwasm206/bxbasm$ ld -o test2 test2.o -L/home/steve/Jwasm206/lib -lbxblib
test2.o: In function `_start':
test2.asm:(.text+0x8): undefined reference to `exit'
test2.o: In function `_Main@0':
test2.asm:(.text+0x11): undefined reference to `_Do_initialize@0'
test2.asm:(.text+0x1b): undefined reference to `_StdOut@4'
test2.asm:(.text+0x25): undefined reference to `_StdOut@4'
/home/steve/Jwasm206/lib/libbxblib.a(getch.o): In function `initTermios':
getch.c:(.text+0x16): undefined reference to `tcgetattr'
getch.c:(.text+0xf4): undefined reference to `tcsetattr'
/home/steve/Jwasm206/lib/libbxblib.a(getch.o): In function `resetTermios':
getch.c:(.text+0x118): undefined reference to `tcsetattr'
/home/steve/Jwasm206/lib/libbxblib.a(getch.o): In function `getch_':
getch.c:(.text+0x130): undefined reference to `getchar'
steve@steve-VirtualBox:~/Jwasm206/bxbasm$

here is the command line:
Quote
ld -o test2 test2.0 -L/home/steve/Jwasm206/lib -lbxblib

Despite all the errors, I actually get more information from "ld" that if I just use "gcc".

When I use gcc, as illustrated in your above post, all I get is:
Quote
steve@steve-VirtualBox:~/Jwasm206/bxbasm$ gcc -s -nostartfiles -o test2 test2.o -L/home/steve/Jwasm206/bxbasm/lib/ -llibbxblib.a
/usr/bin/ld: cannot find -llibbxblib.a
collect2: ld returned 1 exit status
steve@steve-VirtualBox:~/Jwasm206/bxbasm$

It seems to matter not how I spell the lib name: -llibbxblib.a, -lbxblib, -lbxblib.a, ...etc.
The error is always the same.

Here is my path layout:
/home/steve/Jwasm206/bin
/home/steve/Jwasm206/bxbasm
/home/steve/Jwasm206/include
/home/steve/Jwasm206/lib

I work from within
/home/steve/Jwasm206/bxbasm/

there resides: test2.bas and test2.o.

My basic script is:
    PRINT "hello world"
    END

It translates and assembles fine.
I just can't figure what the problem with linking is, with gcc or ld.

Do you have any ideas ?

Steve
Title: Re: BxbAsm
Post by: jcfuller on June 20, 2012, 05:06:11 PM
Steve,
  ld/gcc auto adds the "lib" and the ".a"
 gcc -s -nostartfiles -o test2 test2.o -L/home/steve/Jwasm206/bxbasm/lib/ -lbxblib

James
Title: Re: BxbAsm
Post by: SteveA on June 20, 2012, 05:26:17 PM
Steve,
  ld/gcc auto adds the "lib" and the ".a"
 gcc -s -nostartfiles -o test2 test2.o -L/home/steve/Jwasm206/bxbasm/lib/ -lbxblib

James



Yes, that's what i read.
But, this is what I get:

steve@steve-VirtualBox:~/Jwasm206/bxbasm$ gcc -s -nostartfiles -o test2 test2.o -L/home/steve/Jwasm206/bxbasm/lib -lbxblib
/usr/bin/ld: cannot find -lbxblib
collect2: ld returned 1 exit status
steve@steve-VirtualBox:~/Jwasm206/bxbasm$

(??)

Steve
Title: Re: BxbAsm
Post by: SteveA on June 21, 2012, 03:44:30 PM
Hey James,

Yeh, I'm about ready to throw in the towel on Jwasm and linux.
I can't seem to get anything JWASM related to build an executable.
That is, where it concerns using a static library.

Question:
that last set of library files and "includes", that you uploaded, do they actually work ?
I mean, if used, do they actually build a working program from start to finish: translate-assemble-compile-link ?
Because that is what I've been using and all I get are errors.
I can never get the linker to produce an executable.

I don't know enough about linux to even begin to guess what could possibly be wrong.
If I get that far, the best I can hope for is a series of "undefined reference" messages.

Steve
Title: Re: BxbAsm
Post by: jcfuller on June 22, 2012, 04:52:07 AM
Steve,
  It appears my old noggin is failing me again.
I don't think I ever got the 5-24 version working???
Attached is my directory for the 5-10 version.
I just tried test1 in the examples directory with build.sh (make sure you change your jwasm paths) and it translated,compiled,link and ran.

One thing to note for jwasm on linux you can't use
Code: [Select]
system_time tm<> ;current date & time
Has to be:
Code: [Select]
system_time tm<?,?,?,?,?,?,?,?,?,?,?> ;current date & time

James
Title: Re: BxbAsm
Post by: SteveA on June 22, 2012, 07:51:40 AM
Attached is my directory for the 5-10 version.
I just tried test1 in the examples directory with build.sh (make sure you change your jwasm paths) and it translated,compiled,link and ran.

Okay, I'll give this a try.

Quote
One thing to note for jwasm on linux you can't use
Code: [Select]
system_time tm<> ;current date & time

Yeh, I just commented that part out, for the time being.
Until I get something working, I just want to keep things real simple.

I like the work you did on constructing the (.INC) files.
I just don't know how people are using Jwasm on linux without .INC files.
Plus the fact that Jwlink (for linux) doesn't seem to work on Linux, either.

Thanks, Steve
Title: Re: BxbAsm
Post by: SteveA on June 22, 2012, 01:09:48 PM
Oh,
I wanted to mention, when I compiled your code, before I commented out the system_time thing, it generated a compiler error.

I've got bxbasm producing a clean .bas to .asm translation, ...
jwasm it producing an .o file with out errors, ...
but, when I go to link, I consistantly get: "undefined reference" errors.
Here is the build command:
Code: [Select]
#!/bin/bash
INCLUDE=/home/steve/Jwasm206/include
export INCLUDE

../bin/Bxbasm $1
../bin/jwasm -elf -Fo $1.o $1.asm
gcc -s -nostartfiles -o $1 $1.o -L/home/steve/Jwasm206/bxbasm \
                                -L/home/steve/Jwasm206/include \
                                -lbxblib


Here is the output:
Quote
steve@steve-VirtualBox:~/Jwasm206/bxbasm$ sh build2.sh test2
Copyright: Blunt_Axe_Basic, BxbAsm, Bxbasic (c) sarbayo, 2004-2012
Alpha Release: 1.06.3, Bxbasm Compiler

** stripped down version for Linux

Destination file: test2.asm
Lines compiled: 1
Done.


JWasm v2.06e, Jul 22 2011, Masm-compatible assembler.
Portions Copyright (c) 1992-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.

test2.asm: 80 lines, 2 passes, 1 ms, 0 warnings, 0 errors
test2.o: In function `Main':
test2.asm:(.text+0x11): undefined reference to `_Do_initialize'
collect2: ld returned 1 exit status
steve@steve-VirtualBox:~/Jwasm206/bxbasm$


I don't get it.
Nothing has changed or improved.
Title: Re: BxbAsm
Post by: jcfuller on June 22, 2012, 01:21:04 PM
Steve,
  It's a c decoration thingy.
  Try:
Code: [Select]
jwasm -elf -zcw -Fo $1.o $1.asm

James
Title: Re: BxbAsm
Post by: SteveA on June 22, 2012, 03:34:20 PM
James,

Solved.
I had to play around with the build commands a bit.
Took me forever to find a google search result that had a similar "undefined reference" issue.
There are quite a lot.
I'm guessing that "undefined reference" is a common problem with linux programming.
You have to get it just right.

Steve
Title: Re: BxbAsm
Post by: SteveA on June 27, 2012, 03:21:08 PM
Hey James,
Okay, I've got two versions of Bxbasm C sources setup.
One is the current state, with all the functions in libbxblib.a.
The other is an older version, just prior to stripping all the functions out of file: funct.c.
I want to make sure the recent errors are not a product of the conversion process.

I'll be testing the samples and see what I can find.
Maybe I can finally figure out what is going on.

Steve
Title: Re: BxbAsm
Post by: SteveA on June 28, 2012, 02:39:03 PM
James,
do you have a linux version of math.inc file for jwasm ?
The zip file you uploaded has a MATH.INC file, but, it appears to be windows file, as jwasm (linux ver.) does not like it.

On Linux, where are the header files that gcc uses ?
Are they the files in: /usr/include/ ?
Also, the CRT library files ?

I was looking for something specifically that might identify them as the CRT.

Thanks,
Steve


edit:
I was also wondering if you know what other .inc files other assemblers use on linux ?
Title: Re: BxbAsm
Post by: jcfuller on June 29, 2012, 04:54:40 AM
Steve,
Re: MATH.INC
  I believe I just grabbed the ones needed to compile from MATH.INC and put them in math.inc (files are case sensitive) on linux.

Yes I think you will find all gcc headers in usr/include.

Most distros have a file find app that can help you locate files.

I have done nothing with assembler on linux other than jwasm. You might try a google search on nasm or fasm.

James
Title: Re: BxbAsm
Post by: SteveA on June 29, 2012, 06:39:07 AM
I have done nothing with assembler on linux other than jwasm. You might try a google search on nasm or fasm.

I have nasm installed (never used it) from a long time ago, but, I don't see any headers anywhere.
Okay, I'll play around with what I've got.
See what I can make work.
Title: Re: BxbAsm
Post by: jcfuller on June 29, 2012, 01:21:16 PM
Steve,
  What do you need math.inc for anyway?
You have Raymond's fpu  library. Just roll your own math functions :)

James
Title: Re: BxbAsm
Post by: SteveA on June 29, 2012, 05:09:10 PM
 What do you need math.inc for anyway?
You have Raymond's fpu  library. Just roll your own math functions :)

That's not the point.
The crt has a full set of standard math functions, of which bxbasm already uses most.
I've taken MATH.INC and stripped it down of what it looks like it doesn't need, so that it's just function prototypes.
Now, I can't figure how to link to the gcc math library.
What's it called ?
They don't make it obvious.

A very odd thing, when I looked inside: /usr/include/math.h,  it was devoid of any function names.
So, where are they keeping them ?

Steve

edit:
I found it, well..., I should say I found the libraries:
/usr/lib/i386-linux-gnu/libc.a
/usr/lib/i386-linux-gnu/libm.a

Took me forever.
I still haven't found where the function are defined.

Title: Re: BxbAsm
Post by: SteveA on July 11, 2012, 03:14:44 PM
Well,...
it's been nearly two weeks and I'm still plugging away at jwasm-linux.

With jwasm having not been supplied with at least a minimal set of functioning linux header (.inc) files, I can hardly say that jwasm-linux is "ready for primetime".
I asked, at Andreas' sourceforge site, about headers and nobody seems to have anything or offer any useful suggestions.
I can only assume that no one is really using jwasm on linux, (possibly not even Andreas).
Despite the fact that jwasm does in fact seem to work well on linux, (as far as I can tell),  it doesn't look like anyone is interested in using it.

I tried using Wininc, but, it does not work with linux headers.

I've made small progress, due to the fact that I have to figure out what headers I need and where they and the library files might be on the linux system.
Having to construct one's own headers for linux is a grinding, slow process.
Without some sort of automated process, I can't imagine the task ever being completed.

I have progressed up to Bxb code example #30.
Things seem to be working as expected.

Steve
Title: Re: BxbAsm
Post by: AIR on July 11, 2012, 04:04:28 PM
I have done nothing with assembler on linux other than jwasm. You might try a google search on nasm or fasm.

I have nasm installed (never used it) from a long time ago, but, I don't see any headers anywhere.
Okay, I'll play around with what I've got.
See what I can make work.


You may want to take a look a the perl scripts at http://rudy.mif.pg.gda.pl/~bogdro/inne/#cconv

They will convert C header files to nasm,fasm, and GAS. Probably will need more tinkering with the converted file(s).

From what I know of nasm, referencing C functions  is usually done like: 

extern  acos
extern  acosf

extern  asin
extern  asinf

extern  atan
extern  atanf

In this case, using libm for the math functions as an example.

To find out what parameters need to be passed, or for info on a given function, just 'man' the function:

Quote
[riveraa@blossom ~] $ man atan

ATAN(3)                  BSD Library Functions Manual                  ATAN(3)

NAME
     atan -- arc tangent function of one variable

SYNOPSIS
     #include <math.h>

     double
     atan(double x);

     long double
     atanl(long double x);

     float
     atanf(float x);

DESCRIPTION
     The atan() function computes the principal value of the arc tangent of x.
     The result is in the range [-pi/2, +pi/2].

I'm assuming that Jwasm also has an extern directive, in which case you can just stuff those externs into an include and call it a day.

HTH,

A.
Title: Re: BxbAsm
Post by: AIR on July 11, 2012, 04:17:32 PM

I've made small progress, due to the fact that I have to figure out what headers I need and where they and the library files might be on the linux system.


Use the 'man' command I mentioned previously for a given function to find out which header file you need to look at.

For libc6, take a look here (http://packages.ubuntu.com/hardy/i386/libc6/filelist) to see what is installed where on an Ubuntu Hardy system for example.

On a given Debian-based distro, you can use dpkg -L <packagename> to get a listing of the contents of a package.  Other distribution package managers should also have this ability.

A.
Title: Re: BxbAsm
Post by: SteveA on July 12, 2012, 07:30:43 AM
Hey AIR,
thanks for the info.
Might be just what I was looking for.

I'll try the header converter and see what it produces.
At this point, it cant hurt anything.

I appreciate the help.
Steve
Title: Re: BxbAsm
Post by: SteveA on July 12, 2012, 01:40:41 PM
I've attempted to use different methods for converting gcc headers into assembler style '.inc' files.
Below are some examples that illustrate the resulting code.
I used 'h2incx', konw-fasm.pl and manual conversion of the gcc header 'term.h'.
Below is a snippet of a code section from the source file, followed by the resulting conversion of the same code section.

This is the source fragment:
Code: [Select]
/* term.h */

/* internals */
extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);
extern NCURSES_EXPORT(int) _nc_get_tty_mode (TTY *buf);
extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);
extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE *);
extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE *, char *, int);
extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);
extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);
extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);

/* entry points */
extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);
extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);

/* miscellaneous entry points */
extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);
extern NCURSES_EXPORT(int) setupterm (NCURSES_CONST char *,int,int *);

This is a h2incx converted fragment of the above:
Code: [Select]
/* h2incx generated: term.inc */

;NCURSES_EXPORT proto  :DWORD
_nc_set_tty_mode proto  :ptr TTY
;NCURSES_EXPORT proto  :DWORD
_nc_get_tty_mode proto  :ptr TTY
;NCURSES_EXPORT proto  :DWORD
_nc_read_entry proto  :ptr SBYTE, :ptr SBYTE, :ptr TERMTYPE
;NCURSES_EXPORT proto  :DWORD
_nc_read_file_entry proto  :ptr SBYTE, :ptr TERMTYPE
;NCURSES_EXPORT proto  :DWORD
_nc_read_termtype proto  :ptr TERMTYPE, :ptr SBYTE, :DWORD
;NCURSES_EXPORT proto  :ptr SBYTE
_nc_first_name proto  :ptr SBYTE
;NCURSES_EXPORT proto  :DWORD
_nc_name_match proto  :ptr SBYTE, :ptr SBYTE, :ptr SBYTE
;NCURSES_EXPORT proto  :ptr TERMTYPE
_nc_fallback proto  :ptr SBYTE
;NCURSES_EXPORT proto  :ptr TERMINAL
set_curterm proto  :ptr TERMINAL
;NCURSES_EXPORT proto  :DWORD
del_curterm proto  :ptr TERMINAL
;NCURSES_EXPORT proto  :DWORD
restartterm proto  :ptr NCURSES_CONST, :DWORD, :ptr DWORD
;NCURSES_EXPORT proto  :DWORD
setupterm proto  :ptr NCURSES_CONST, :DWORD, :ptr DWORD
The comments were added by me. It appears that h2incx misunderstood the declaration and converted the return type as well.
The header does not compile without errors.


This is a konw-fasm.pl converted fragment:
Code: [Select]
/* konw-fasm.pl generated term.inc */

/* internals */


/* entry points */


/* miscellaneous entry points */

konw-fasm.pl (as well as the -nasm.pl and -gas.pl) could not understand the declaration and therefore completely omitted the section.


This was converted manually:
Code: [Select]
/* hand generated: term.inc */

;/* internals */
_nc_set_tty_mode proto c :DWORD
_nc_get_tty_mode proto c :DWORD
_nc_read_entry proto c :DWORD,:DWORD,:DWORD
_nc_read_file_entry proto c :DWORD,:DWORD
_nc_read_termtype proto c :DWORD,:DWORD,:DWORD
_nc_first_name proto c :DWORD
_nc_name_match proto c :DWORD,:DWORD,:DWORD
_nc_fallback proto c :DWORD

;/* entry points */
set_curterm proto c :DWORD
del_curterm proto c :DWORD

;/* miscellaneous entry points */
restartterm proto c :DWORD,:DWORD,:DWORD
setupterm proto c :DWORD,:DWORD,:DWORD

The manually generated header compiles without errors, but, does not execute properly.
I have to tinker with it some more.
Title: Re: BxbAsm
Post by: SteveA on July 12, 2012, 08:23:34 PM
Can anyone figure out why this code sample does not function correctly on Linux ? 

Code: [Select]
/* cls.c:
    Simulate Win32 ClearScreen() and Win32 C library _kbhit() function.
    Both are excerpts from: Beginning Linux Programming, 4th ed.
*/
/*
    compile using: gcc -o cls cls.c -lncurses
    execute using: ./cls
*/

#include <stdio.h>
#include <stdlib.h>
#include <termios.h>
#include <term.h>
#include <curses.h>
#include <unistd.h>


static struct termios initial_settings, new_settings;
static    int peek_character = -1;

void init_keyboard(void);
void close_keyboard(void);
int _kbhit(void);
int kb_hit(void);
int readch(void);
void ClearScreen(void);

int _kbhit()                 /* this tests if a key has been pressed */
{   int ch = 0;
   
    init_keyboard();

    if(kb_hit())
    {
        ch = readch();
        ch = 1;
    }

    close_keyboard();
    return ch;
}


void init_keyboard()         /* initialize console keyboard */
{
    tcgetattr(0, &initial_settings);
    new_settings = initial_settings;
    new_settings.c_lflag &= ~ICANON;
    new_settings.c_lflag &= ~ECHO;
    new_settings.c_lflag &= ~ISIG;
    new_settings.c_cc[VMIN] = 1;
    new_settings.c_cc[VTIME] = 0;
    tcsetattr(0, TCSANOW, &new_settings);
}


int kb_hit()               /* if kb press, then return TRUE, else */
{   char ch;               /* reset parameters and return FALSE */
    int nread;
   
    if(peek_character != -1)
    {
        return 1;
    }
   
    new_settings.c_cc[VMIN] = 0;
    tcsetattr(0, TCSANOW, &new_settings);
    nread = read(0, &ch, 1);
    new_settings.c_cc[VMIN] = 1;
    tcsetattr(0, TCSANOW, &new_settings);
   
    if(nread == 1)
    {
        peek_character = ch;
        return 1;
    }
    return 0;
}


int readch()                 /* if keypress = TRUE, then put char back in buffer */
{   char ch;
   
    if(peek_character != -1)
    {
        ch = peek_character;
        ungetc(ch, stdin);
        peek_character = -1;
        return 1;
    }
    return 0;
}


void close_keyboard()        /* reset console to original settings */
{
    tcsetattr(0, TCSANOW, &initial_settings);
}


void ClearScreen()      /* this function clears the console screen. */
{   char *clear;
   
    setupterm(NULL, fileno(stdout), (int *)0);
    clear = tigetstr("clear");
    putp(clear);
}


int main()                    /* now test these functions */
{   char ch;
    int ich = 0;

    ClearScreen();

    while(ich == 0)           /* this routine will behave like INKEY$ */
    {                         /* waiting for a keypress */
        ich = _kbhit();
    }

    ch = getchar();           /* this will capture the keypress character */
    printf("char = %c\n", ch);
    return 0;
}


It performs 2 Basic routines: CLS and INKEY$.
Each function performs correctly when run independently.
However, when the two are combined, as in the above example, it does not behave as expected.

The "main" function represents this BASIC program:
Code: [Select]
   CLS
   WHILE a$ = ""
       a$ = INKEY$
   WEND
   PRINT a$
   END

The CLS part does not clear the screen until after the keypress event has occurred.  ???
Title: Re: BxbAsm
Post by: jcfuller on July 14, 2012, 05:26:23 AM
Steve,
  I know very little of ncurses but replacing your ClearScreen with this one works:
James

Code: [Select]
void ClearScreen()      /* this function clears the console screen. */

 system("clear");
}

Title: Re: BxbAsm
Post by: jcfuller on July 14, 2012, 06:35:19 AM
Steve,
  In the ncurses examples I remember (yeah right:)) I think the library was initialized in main before any calls?
It probably is not a good idea to mix term and ncurses calls? If you commit to ncurses just use them.

James
 
Title: Re: BxbAsm
Post by: SteveA on July 14, 2012, 12:15:44 PM
  I know very little of ncurses but replacing your ClearScreen with this one works:

Code: [Select]
void ClearScreen()      /* this function clears the console screen. */

 system("clear");
}


Hey James,

Yeh, that does work.
However, I wanted to avoid using system().
It is claimed that using system() is a weak point and leaves the operating system open to vulnerabilities.
That's why I wanted to use the API functions as much as possible.
Title: Re: BxbAsm
Post by: SteveA on July 14, 2012, 12:25:04 PM
Steve,
  In the ncurses examples I remember (yeah right:)) I think the library was initialized in main before any calls?
It probably is not a good idea to mix term and ncurses calls? If you commit to ncurses just use them.

James
 

Huh...!
can't mix term and ncurses....hmm.
I suppose that could explain the unusual behaviour.

But,...
in the book they seem to do just that.
The examples given use term.h, termios.h and curses.h in the same sample programs.
I don't think I've made a mistake in the code, but, something clearly isn't right.

BTW, did you happen to compile the sample I posted ?
If so, did it behave strangely, as I indicated ?
Title: Re: BxbAsm
Post by: jcfuller on July 14, 2012, 01:21:15 PM
BTW, did you happen to compile the sample I posted ?
If so, did it behave strangely, as I indicated ?

Yes
Yes

James
Title: Re: BxbAsm
Post by: jcfuller on July 14, 2012, 02:08:32 PM
Steve,
Ubx basic code:
Code: [Select]
DIM a$
CLS
   WHILE a$ = ""
       a$ = INKEY$
   WEND
   PRINT a$


c++ translation:

Code: [Select]
// *********************************************************************
//   Created with Ubx 311.40 (2011/10/19)by James C. Fuller
//   Based on OSX port by Armando Rivera
//   Ported from BCX32 BASIC To C/C++ Translator (V) 5.12
//   BCX (c) 1999 - 2009 by Kevin Diggins
// *********************************************************************
//   Translated for compiling with the g++ Compiler
//   g++ -Os -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$.c -ldl -o $FILE$
// *********************************************************************
#include <stdbool.h>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <setjmp.h>
#include <time.h>
#include <stdarg.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <dlfcn.h>
#include <term.h>


// ***************************************************
// Compiler Defines
// ***************************************************
  #define C_EXPORT extern "C"
  #define C_IMPORT extern "C"

#ifndef stat
  #define lstat stat
#endif
#ifndef _fcloseall
  #define _fcloseall _fcloseall
#endif
#ifndef MAX_PATH
  #define MAX_PATH 2048
#endif
#ifndef CALLBACK
  #define CALLBACK
#endif
  typedef unsigned int HINSTANCE;
  typedef const char CCHAR;
  typedef char* PCHAR;
  typedef unsigned char byte;
  typedef unsigned int  UINT;
  typedef unsigned char UCHAR;
  typedef unsigned long ULONG;
  typedef unsigned long DWORD;

#ifndef TRUE
  #define TRUE 1
#endif

#ifndef FALSE
  #define FALSE 0
#endif

#define BOOL bool

// *************************************************
//                System Variables
// *************************************************

char    ESC [2]={27,0};  // Escape

// *************************************************
//            User Global Variables
// *************************************************

static PCHAR   *G_argv;
static int     G_argc;
static char    a[2048];



// *************************************************
//               Standard Macros
// *************************************************



// *************************************************
//               Standard Prototypes
// *************************************************

void    cls(void);
char*   BCX_TmpStr(size_t);
char*   inkey (void);
int     _getch_(int);


// *************************************************
//            User Global Initialized Arrays
// *************************************************


// *************************************************
//                  Main Program
// *************************************************

int main(int argc, char *argv[])
{
  G_argc = argc;
  G_argv = argv;
  cls();
  while(a[0]==0)
    {
      strcpy(a,inkey());
    }
  printf("%s\n",a);
  return 0;   //  End of main program
  }

// *************************************************
//                 Runtime Functions
// *************************************************

char *BCX_TmpStr (size_t Bites)
{
  static int   StrCnt;
  static char *StrFunc[2048];
  StrCnt=(StrCnt + 1) & 2047;
  if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
    #if defined BCX_MAX_VAR_SIZE
  if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)
  {
  printf("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\n",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);
  abort();
  }
  #endif
  return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
}


char* inkey(void)
{
  char *strtmp = BCX_TmpStr(2);
  strtmp[0] = _getch_(FALSE);
  if(strtmp[0] == -1) strtmp[0] = 0;
  return strtmp;
}


int _getch_(int waitkey)
{
  struct termios initial_settings, new_settings;
  unsigned char ch;

  tcgetattr(0,&initial_settings);
  new_settings = initial_settings;
  new_settings.c_lflag &= ~ICANON;
  new_settings.c_lflag &= ~ECHO;
  new_settings.c_lflag &= ~ISIG;
  new_settings.c_cc[VMIN] = waitkey;
  new_settings.c_cc[VTIME] = 0;
  tcsetattr(0, TCSANOW, &new_settings);

    //read(0,&ch,1);
    ch = getchar();
  tcsetattr(0, TCSANOW, &initial_settings);
  return ch;
}


void cls (void)
{
  printf("%s%s%s%s",ESC,"[2J",ESC,"[H");
}


James
Title: Re: BxbAsm
Post by: SteveA on July 14, 2012, 08:50:52 PM
Most interesting !

c++ translation:

Code: [Select]
// *********************************************************************
//   Created with Ubx 311.40 (2011/10/19)by James C. Fuller
//   Based on OSX port by Armando Rivera
//   Ported from BCX32 BASIC To C/C++ Translator (V) 5.12
//   BCX (c) 1999 - 2009 by Kevin Diggins
// *********************************************************************
//   Translated for compiling with the g++ Compiler
//   g++ -Os -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings $FILE$.c -ldl -o $FILE$
// *********************************************************************
#include <stdbool.h>
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string.h>
#include <stddef.h>
#include <stdlib.h>
#include <setjmp.h>
#include <time.h>
#include <stdarg.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <unistd.h>
#include <dlfcn.h>
#include <term.h>


// ***************************************************
// Compiler Defines
// ***************************************************
  #define C_EXPORT extern "C"
  #define C_IMPORT extern "C"

#ifndef stat
  #define lstat stat
#endif
#ifndef _fcloseall
  #define _fcloseall _fcloseall
#endif
#ifndef MAX_PATH
  #define MAX_PATH 2048
#endif
#ifndef CALLBACK
  #define CALLBACK
#endif
  typedef unsigned int HINSTANCE;
  typedef const char CCHAR;
  typedef char* PCHAR;
  typedef unsigned char byte;
  typedef unsigned int  UINT;
  typedef unsigned char UCHAR;
  typedef unsigned long ULONG;
  typedef unsigned long DWORD;

#ifndef TRUE
  #define TRUE 1
#endif

#ifndef FALSE
  #define FALSE 0
#endif

#define BOOL bool

// *************************************************
//                System Variables
// *************************************************

char    ESC [2]={27,0};  // Escape

// *************************************************
//            User Global Variables
// *************************************************

static PCHAR   *G_argv;
static int     G_argc;
static char    a[2048];



// *************************************************
//               Standard Macros
// *************************************************



// *************************************************
//               Standard Prototypes
// *************************************************

void    cls(void);
char*   BCX_TmpStr(size_t);
char*   inkey (void);
int     _getch_(int);


// *************************************************
//            User Global Initialized Arrays
// *************************************************


// *************************************************
//                  Main Program
// *************************************************

int main(int argc, char *argv[])
{
  G_argc = argc;
  G_argv = argv;
  cls();
  while(a[0]==0)
    {
      strcpy(a,inkey());
    }
  printf("%s\n",a);
  return 0;   //  End of main program
  }

// *************************************************
//                 Runtime Functions
// *************************************************

char *BCX_TmpStr (size_t Bites)
{
  static int   StrCnt;
  static char *StrFunc[2048];
  StrCnt=(StrCnt + 1) & 2047;
  if(StrFunc[StrCnt]) free (StrFunc[StrCnt]);
    #if defined BCX_MAX_VAR_SIZE
  if(Bites*sizeof(char)>BCX_MAX_VAR_SIZE)
  {
  printf("Buffer Overflow caught in BCX_TmpStr - requested space of %d EXCEEDS %d\n",(int)(Bites*sizeof(char)),BCX_MAX_VAR_SIZE);
  abort();
  }
  #endif
  return StrFunc[StrCnt]=(char*)calloc(Bites+128,sizeof(char));
}


char* inkey(void)
{
  char *strtmp = BCX_TmpStr(2);
  strtmp[0] = _getch_(FALSE);
  if(strtmp[0] == -1) strtmp[0] = 0;
  return strtmp;
}


int _getch_(int waitkey)
{
  struct termios initial_settings, new_settings;
  unsigned char ch;

  tcgetattr(0,&initial_settings);
  new_settings = initial_settings;
  new_settings.c_lflag &= ~ICANON;
  new_settings.c_lflag &= ~ECHO;
  new_settings.c_lflag &= ~ISIG;
  new_settings.c_cc[VMIN] = waitkey;
  new_settings.c_cc[VTIME] = 0;
  tcsetattr(0, TCSANOW, &new_settings);

    //read(0,&ch,1);
    ch = getchar();
  tcsetattr(0, TCSANOW, &initial_settings);
  return ch;
}


void cls (void)
{
  printf("%s%s%s%s",ESC,"[2J",ESC,"[H");
}


Thanks James.
That explains a lot.

Steve
Title: Re: BxbAsm
Post by: John on July 14, 2012, 09:53:10 PM
Code: [Select]
void cls (void)
{
  printf("%s%s%s%s",ESC,"[2J",ESC,"[H");
}

@James - I thought your version of BCX was using ncurses for console screen control. I had to take a similar approach with direct ANSI ESC codes to get it to work on both Android and Ubuntu Linux. ( SB example (http://www.scriptbasic.org/forum/index.php/topic,249.msg919.html#msg919) )

Code: [Select]
SUB CLS
  PRINT "\033[2J\033[1;1H"
END SUB

I noticed in your example that you didn't home the cursor with x/y values. I'll give that a try.

 
Title: Re: BxbAsm
Post by: jcfuller on July 15, 2012, 03:08:41 AM

Just to give credit where it's due this is Armando's code from MBC -> UBX.

James
Title: Re: BxbAsm
Post by: jcfuller on July 15, 2012, 03:11:35 AM
Note that clearing the screen on linux with the ubx code is not the same as Windows. It just scrolls the existing text off screen where windows does a complete clear.

James
Title: Re: BxbAsm
Post by: AIR on July 15, 2012, 08:55:47 AM
Note that clearing the screen on linux with the ubx code is not the same as Windows. It just scrolls the existing text off screen where windows does a complete clear.

James


That's pretty much how it works with the "clear" terminal command also.  If you clear the screen, and then scroll the window up you'll see what I mean.

BTW, functions in term.h actually utilize curses.  That's why you need to link -lncurses.

@Steve:  Can you try this for your ClearScreen()?
Code: [Select]
void ClearScreen()      /* this function clears the console screen. */
{   
    if (!cur_term) {
        int result;
        setupterm( NULL, STDOUT_FILENO, &result );
        if (result <= 0) return;
    }
    putp(tigetstr("clear"));
    fflush(stdout);
}

The "cur_term" variable is set when you call setupterm.  What I believe was missing was flushing your buffer via "fflush", so the "putp" call wasn't actually completed until "getchar" was called.

A.
Title: Re: BxbAsm
Post by: AIR on July 15, 2012, 09:47:34 AM
Interesting tidbit:  Busybox uses the terminal codes like mbc/ubx do:

Code: [Select]
int clear_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int clear_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
{
/* home; clear to the end of screen */
return full_write1_str("\033[H""\033[J") != 6;
}

"full_write1_str" is a wrapper around the write() api call.

There is a wealth of good stuff contained in the Busybox source.  I recommend downloading it for study...

A.
Title: Re: BxbAsm
Post by: SteveA on July 15, 2012, 02:59:55 PM
Steve:  Can you try this for your ClearScreen()?

Code: [Select]
void ClearScreen()      /* this function clears the console screen. */
{   
    if (!cur_term) {
        int result;
        setupterm( NULL, STDOUT_FILENO, &result );
        if (result <= 0) return;
    }
    putp(tigetstr("clear"));
    fflush(stdout);
}

The "cur_term" variable is set when you call setupterm. 
What I believe was missing was flushing your buffer via "fflush", so the "putp" call wasn't actually completed until "getchar" was called.

Excellent !
This works perfectly.
Flushing the buffer makes a lot of sense.

Thanks for the help guys.
I'm way, still at the early learning stages of linux.
Too much to learn in a very short time.

Steve
Title: Re: BxbAsm
Post by: SteveA on July 17, 2012, 06:33:03 PM
Here are some NCurses tutorials I found.
Save them locally and open them in your browser.

The .tar.gz file has some code samples.

I'm finding NCurses to be really quite interesting.

Steve
Title: Re: BxbAsm
Post by: SteveA on July 21, 2012, 09:28:05 AM
James,
I'm beginning to understand what you were referring to, when you suggested making a choice between term and ncurses.
From what I can make out so far, ncurses just about has to be treated as an API unto itself.
Unlike windows, which only has one main API, (the win32 API), with the addition of the C Library, Linux has numerous (what can be called) API's.

It is unfortunate, I am learning, that when using the nucurses API, not even a simple printf statement can be used without using the ncurses version of the function.
If you use it, you have to use it almost exclusively.
Not all CLib functions have their compliments in ncurses, just enough to be annoying.

steve
Title: Re: BxbAsm
Post by: jcfuller on August 07, 2012, 01:08:49 PM
Steve,
  Just read the linux inc file discussion on sourceforge; I would still go with invoke and flesh out your protos as you go along.
You still need to know the parameters to write your push/call so it's no biggie to write a proto.

James
 
Title: Re: BxbAsm
Post by: SteveA on August 07, 2012, 03:00:07 PM
  Just read the linux inc file discussion on sourceforge;
I would still go with invoke and flesh out your protos as you go along.
You still need to know the parameters to write your push/call so it's no biggie to write a proto.

Yeh,
funny thing, after my exchange with japheth, I came to that same conclusion.
I still need the parameter. I prefer to use invoke and I still need the protos anyway.

I'm working on constructing something (h2inc like) that will at least get me the protos and defines.

I wonder, just how much of the variables declarations I really need.
Like the #define's, typedef's and struct's ?

Searching around, it looks like others (besides japheth) have tried to craft something similar (to h2inc/h2incx) in the past, without ever completeing the task.

Anyway, I'm still working on it. I haven't stalled or anything yet.
Steve
Title: Re: BxbAsm
Post by: John on September 25, 2012, 08:30:33 PM
Things have been pretty quite here on the developer forum. Any news to share Steve or James?

Title: Re: BxbAsm
Post by: SteveA on September 29, 2012, 01:15:48 PM
Things have been pretty quite here on the developer forum. Any news to share Steve or James?

Hey guys,...
thanks for the kick in the pants John...,
sorry, I've been taking a little time to work on a few things and have not been keeping up with regular posts.

I actually have done quite a bit of work of trying to understand the Linux/GCC headers.
I've written a little program (using Bxbasic) that ports the headers to an ".inc" type of format.
Altho' it's not a complete port, as it makes no attempt to actually translate the conditional statements contained in the headers.
I find that to be way too complicated, at this time.
It simply performs an extraction of "#define" statements and function prototypes and kind of dumps them into an ".inc" file for use with the assembler.
I haven't tested the results yet. I'm just about to.
One main problem I've encountered is that nearly each header file has it's own set of rules, you might say.
Many have very little in common.

Once I get them tested and working I will provide more information.









Title: Re: BxbAsm
Post by: John on September 29, 2012, 05:27:12 PM
Thanks Steve for the update. It's good to see you still interested in your project. James is BCXing so you are going to have to give him a ping.
Title: Re: BxbAsm
Post by: SteveA on October 05, 2012, 08:57:36 AM
Attached is what I have accomplished so far, in my effort to construct a program that will produce a list of function prototypes for the Linux GCC LIBC headers.
It is not complete, but it's a good start.
Here is my preface to the program:


' h2incz.bas [Copyright (C) 2012, sarbayo]
' using:  Bxbasic v20.3.1   --   Win32 executable
'
' The original h2inc program is designed to translate GCC C header files
' into ".inc" include files, more or less usable by Masm and other
' assemblers.
' This program functions similar to h2inc, with a number of exception.
'
' Presently, the primary goal of this program is to extract the #define
' and extern statements and produce clean and uncluttered variable
' definitions and function prototypes and not to attempt to parse the
' conditional #if statements, typically found in header files.
'
' As stated, conditional statements are ignored, entirely.
' Instead, each line is parsed and tested for a valid and understandable
' variable definition that can be translated into an assembly language
' equate statement.
'
' How to run this program:
' ========================
' 1) First, by default, this program is designed to read the contents of a
' text file, (named header.txt), in the working directory, which contains
' a list of the header file names to be translated.
' The header.txt file must be formated in a specific way.
' The first line of the file must contain the number of headers to be
' processed. The second and subsequent lines must contain the names of the
' header files, without the ".h" extension and must appear between quotes,
' like so:
'                          __________
'                         |10
'                         |"a.out"
'                         |"aio"
'                         |"alloca"
'                         |"ar"
'                         |"argp"
'                         |"argz"
'                         |...etc
'
'
' 2) Copies of the headers to be translated must be placed in a sub-
' directory of the current working directory, named "Linux-Headers".
' As an example, assume the working directory is named h2incz somewhere on
' the current drive: i.e.:
'      c:\..\h2incz
'
' the files required to reside in the working directory would be:
'  bxbasic.exe,
'  h2incz.bas and
'  headers.txt.
'
' 3) Next, create a subdirectory named: "Linux-Headers"
'      c:\..\h2incz\Linux-Headers
'
' Store copies of the gcc headers to be processed into that subdirectory.
'
' 4) Create a second subdirectory and name it: "Linux-Inc".
' This is where the translated files will be stored.
'      c:\..\h2incz\Linux-Inc
'
' 5) To run, from the command-line, type:
'      bxbasic h2incz
'
'
' Anywhere from 1 to 100 (or more) header files may be processed this way.
'
' The resulting output files will be usable, but, not in their entirety in
' the outputted format. Many items, will be commented-out, with the
' exception of function prototypes. Includes, defines and possibly other
' things will be commented-out. Since the main objective of this program
' is to provide usable function prototypes, that is where the main focus of
' the output files will be placed.
'
' Those items which are commented-out can be un-commented and tested
' individually. The reason for this is that many define statements are
' subject to conditional statements and in some cases do not apply in a
' given context.
'
' It should be understood, (by the user), that GCC (as do most C compilers)
' uses a preprocessor to read, parse and interpret the C header files. This
' small program is in no way a preprecessor and falls far short of
' interpreting the meaning and context of the statements contained in the
' header files. This simple program simply strips-out and dumps what
' information may be useful to the Assembly Language programmer.
'
' **NOTE:
' The prototypes and equate statements generated are purely theoretical.
' Most of the files generated by this program are untested. There are just
' too many header files contained in the GCC LIBC to be able to test them
' all in the time I have available.
' Should you find errors (and I am sure there will be several), in the
' output files, please let me know, so that I can make corrections to the
' program.
' Thanks, Steve.
'