Hello.
I am an old clipper programmer. I am in the process of recompiling some of my programs we still use today on a Novell server.
I use to write functions in assembler for some of the functions clipper did not have. A typical assembler listing is below.
Is it possible to use pelles C (or any other C/C#/C++ compiler) to create a .LIB file I can link using xharbour (32 bit, clipper was 16 bit)
Could someone give me a 1,2,3 list of the steps and tools i need to use?
I still program microcontrollers in assembler but I have fiinally grasped the C language and now use C for most of my microcontroller programming. For my clipper programs I am converting, I still will not be using the new GUI type interfaces as xharbour is 100% compatible with the old clipper code and compiles the code for console.
typical old assembler listing
=====================
.MODEL LARGE
INCLUDE C:\EXTASM.INC
PUBLIC SHADEBOX
.DATA
LTOPD DB 201D
RTOPD DB 187D
LBOTD DB 200D
RBOTD DB 188D
HORZD DB 205D
VERTD DB 186D
LTOP DB 218D
RTOP DB 191D
LBOT DB 192D
RBOT DB 217D
HORZ DB 196D
VERT DB 179D
dispage db 0h
attbyte db 0h
shadow db 00001000b
tboxrow db 0h
bboxrow db 0h
lboxcol db 0h
rboxcol db 0h
vcount db 0h
hcount db 0h
vcount1 db 0h
hcount1 db 0h
row db 0h
col db 0h
.CODE
shadebox PROC FAR
PUSH SI
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSH BP
MOV BP,SP
PUSH DS
PUSH SI
PUSH DI
mov ax,1
push ax
call __parinfo ; get parm1
add sp,2
test ax, NUMERIC ;is it numeric
jz shadebye ;no - return
mov ax,2
push ax
call __parinfo
add sp,2
test ax, NUMERIC
jz shadebye
mov ax,3
push ax
call __parinfo
add sp,2
test ax, NUMERIC
jz shadebye
mov ax,4
push ax
call __parinfo
add sp,2
test ax, NUMERIC
jz shadebye
mov ax,5
push ax
call __parinfo
add sp,2
test ax, NUMERIC
jz shadebye
jnz shadeok
shadebye:
jmp shadex
shadeok:
mov ax,1
push ax
call __parni
add sp,2
mov [tboxrow],al
mov ax,2
push ax
call __parni
add sp,2
mov [lboxcol],al
mov ax,3
push ax
call __parni
add sp,2
mov [bboxrow],al
sub al,[tboxrow]
dec al
mov [vcount],al
mov ax,4
push ax
call __parni
add sp,2
mov [rboxcol],al
sub al,[lboxcol]
mov [hcount],al
mov ax,6
push ax
call __parni
add sp,2
mov cl,04h
shl al,cl
mov [attbyte],al
mov ax,5
push ax
call __parni
add sp,2
or [attbyte],al
mov ah,02h ;set cursor top left of box
mov bh,0h
mov dh,[tboxrow]
mov [row],dh
mov dl,[lboxcol]
mov [col],dl
int 10h
mov ah,09h ; draw horizontal line
mov al,[horzd]
mov bh,0h
mov bl,[attbyte]
mov ch,0h
mov cl,[hcount]
int 10h
mov ah,09h
mov al,[ltopd] ; draw top left corner
mov bh,0h
mov bl,[attbyte]
mov cx,01h
int 10h
mov al,[vcount]
mov [vcount1],al
vlp1:
mov ah,02h ; move cursor down 1 row
mov bh,0h
inc [row]
mov dh,[row]
mov dl,[col]
int 10h
mov ah,09h ; output vertical line
mov al,[vertd]
mov bh,0h
mov bl,[attbyte]
mov cx,01h
int 10h
dec [vcount1]
jne vlp1
mov ah,02h ;set cursor bottom left of box
mov bh,0h
mov dh,[bboxrow]
mov [row],dh
mov dl,[lboxcol]
mov [col],dl
int 10h
mov ah,09h ; draw horizontal line
mov al,[horzd]
mov bh,0h
mov bl,[attbyte]
mov ch,0h
mov cl,[hcount]
int 10h
mov ah,09h
mov al,[lbotd] ; draw bottom left corner
mov bh,0h
mov bl,[attbyte]
mov cx,01h
int 10h
mov ah,02h ;set cursor top right of box
mov bh,0h
mov dh,[tboxrow]
mov [row],dh
mov dl,[rboxcol]
mov [col],dl
int 10h
mov ah,09h ; draw top right corner
mov al,[rtopd]
mov bh,0h
mov bl,[attbyte]
mov cx,01h
int 10h
mov al,[vcount]
mov [vcount1],al
vlp2:
mov ah,02h ; move cursor down 1 row
mov bh,0h
inc [row]
mov dh,[row]
mov dl,[col]
int 10h
mov ah,09h ; output vertical line
mov al,[vertd]
mov bh,0h
mov bl,[attbyte]
mov cx,01h
int 10h
dec [vcount1]
jne vlp2
mov ah,02h ;set cursor bottom right of
box
mov bh,0h
mov dh,[bboxrow]
mov dl,[rboxcol]
int 10h
mov ah,09h ; draw bottom right corner
mov al,[rbotd]
mov bh,0h
mov bl,[attbyte]
mov cx,01h
int 10h
;get bottom row+1 , left col+1 in pointers
mov dh,[bboxrow]
inc dh
mov [row],dh
cmp dh,24d
ja nohshade
mov dl,[lboxcol]
inc dl
mov [col],dl
mov al,[hcount]
mov [hcount1],al
hshade:
mov ah,02 ; position cursor
mov bh,0h
mov dh,[row]
mov dl,[col]
int 10h
mov ah,08h ; read character and attribute
mov bh,0h
int 10h
mov bl,[shadow] ; reprint it with shadow
attribute
mov ah,09h
mov bh,0h
mov cx,01h
int 10h
inc [col]
dec [hcount1]
jne hshade
nohshade:
; get top right row+1 , top right col+1
mov dh,[tboxrow]
inc dh
mov [row],dh
mov dl,[rboxcol]
inc dl
mov [col],dl
mov al,[vcount]
inc al
inc al
mov [vcount1],al
vshade:
mov ah,02 ; position cursor
mov bh,0h
mov dh,[row]
mov dl,[col]
cmp dl,79d
ja noshade
int 10h
mov ah,08h ; read character and attribute
mov bh,0h
int 10h
mov bl,[shadow] ; reprint it with shadow
attribute
mov ah,09h
mov bh,0h
mov cx,01h
int 10h
inc [row]
dec [vcount1]
jne vshade
; get top right row+1 , top right col+2
mov dh,[tboxrow]
inc dh
mov [row],dh
mov dl,[rboxcol]
inc dl
inc dl
mov [col],dl
mov al,[vcount]
inc al
inc al
mov [vcount1],al
noshade:
jmp noshade1
vshade2:
mov ah,02 ; position cursor
mov bh,0h
mov dh,[row]
mov dl,[col]
cmp dl,79d
ja noshade
int 10h
mov ah,08h ; read character and attribute
mov bh,0h
int 10h
mov bl,[shadow] ; reprint it with shadow
attribute
mov ah,09h
mov bh,0h
mov cx,01h
int 10h
inc [row]
dec [vcount1]
jne vshade2
noshade1:
; get top row+1 , top left col+1
mov dh,[tboxrow]
inc dh
mov [row],dh
mov dl,[lboxcol]
inc dl
mov [col],dl
mov al,[vcount]
mov [vcount1],al
dec [hcount]
je shadex
fillbox:
mov ah,02 ; position cursor
mov bh,0h
mov dh,[row]
mov dl,[col]
int 10h
mov ah,09h ; fill horizontal line
mov al,32d
mov bh,0h
mov bl,[attbyte]
mov ch,0h
mov cl,[hcount]
int 10h
inc [row]
dec [vcount1]
jne fillbox
SHADEX:
POP DI
POP SI
POP DS
POP BP
POP DX
POP CX
POP BX
POP AX
POP SI
RET
shadebox ENDP
END
Quote from: metron9 on April 25, 2011, 08:00:01 AM
Is it possible to use pelles C (or any other C/C#/C++ compiler) to create a .LIB file I can link using xharbour (32 bit, clipper was 16 bit)
Could someone give me a 1,2,3 list of the steps and tools i need to use?
Pelles C has a library compiler built right in... when starting a new project simply choose win32 library or DLL and give it a name...
Of course you will have to do a compatibility test or three but I shouldn't think there would be a problem.
Hi metron9,
Welcome to the forum.
Pelles C does not support 16-bit DOS code.
Quote from: Vortex on April 26, 2011, 07:12:43 PM
Hi metron9,
Welcome to the forum.
Pelles C does not support 16-bit DOS code.
The OP says xHarbour is 32 bit... Check the first post.
Quote from: CommonTater on April 26, 2011, 09:02:12 PM
Quote from: Vortex on April 26, 2011, 07:12:43 PM
Hi metron9,
Welcome to the forum.
Pelles C does not support 16-bit DOS code.
The OP says xHarbour is 32 bit... Check the first post.
Yes but he posted 16-bit code.
Ok... now I'm thoroughly confused...
Quote from: metron9 on April 25, 2011, 08:00:01 AM
Hello.
I am an old clipper programmer. I am in the process of recompiling some of my programs we still use today on a Novell server.
I use to write functions in assembler for some of the functions clipper did not have. A typical assembler listing is below.
Is it possible to use pelles C (or any other C/C#/C++ compiler) to create a .LIB file I can link using xharbour (32 bit, clipper was 16 bit)
Could someone give me a 1,2,3 list of the steps and tools i need to use?
I still program microcontrollers in assembler but I have fiinally grasped the C language and now use C for most of my microcontroller programming. For my clipper programs I am converting, I still will not be using the new GUI type interfaces as xharbour is 100% compatible with the old clipper code and compiles the code for console.
xHarbour lists PellesC as one of the C compiler that can be used to compile the programs written with it. However, they are pretty unspecific about supported version and other details, no info on the web site or in the PellesC specific binaries download.
As for your assembler libraries, nowadays, there isn't much of use for them in 32bit compilers like xHarbour and with newer CPUs. You're probably better of to check if there are at least similar functions available in their (screen) libraries or write PRG's as wrappers to match your function names instead of relying on assembler routines for such tasks...
Ralf
xHarbour for PellesC , small package:
http://sourceforge.net/projects/xharbour/files/Binaries%20for%20Windows%20Pelles%20C/1.20.01/ (http://sourceforge.net/projects/xharbour/files/Binaries%20for%20Windows%20Pelles%20C/1.20.01/)
With source code v1.21
http://trim.bekz.net/direct/xHarbour.kr/free/6658/xHarbour-v1.21.6658-for-PellesC_v6.exe (http://trim.bekz.net/direct/xHarbour.kr/free/6658/xHarbour-v1.21.6658-for-PellesC_v6.exe)
From there you can find document doc\howtoext.txt that explains howto write extension for xharbour.
PS:
This small example hello.prg
function Main()
? "Hello xHarbour!"
return NIL
harbour.exe -n -gc3 hello.prg outputs this to hello.c:
/*
* xHarbour build 1.2.1 Intl. (SimpLex) (Rev. 6406)
* Generated C source code from <hello.prg>
* Command: hello.prg -n -gc3
* Created: 2011.04.29 15:13:10 (Pelles ISO C Compiler 5.0)
*/
#include "hbvmpub.h"
#include "hbxvm.h"
#include "hbapierr.h"
#include "hbinit.h"
#define __PRG_SOURCE__ "hello.prg"
HB_FUNC( MAIN );
HB_FUNC_EXTERN( QOUT );
#undef HB_PRG_PCODE_VER
#define HB_PRG_PCODE_VER 10
#include "hbapi.h"
HB_INIT_SYMBOLS_BEGIN( hb_vm_SymbolInit_HELLO )
{ "MAIN", {HB_FS_PUBLIC | HB_FS_LOCAL | HB_FS_FIRST}, {HB_FUNCNAME( MAIN )}, &ModuleFakeDyn },
{ "QOUT", {HB_FS_PUBLIC}, {HB_FUNCNAME( QOUT )}, NULL }
HB_INIT_SYMBOLS_END( hb_vm_SymbolInit_HELLO )
#if defined(__ICL)
#pragma warning(disable:177)
#endif
#if defined(HB_PRAGMA_STARTUP)
#pragma startup hb_vm_SymbolInit_HELLO
#elif defined(HB_MSC_STARTUP)
#if defined( HB_OS_WIN_64 )
#pragma section( HB_MSC_START_SEGMENT, long, read )
#endif
#pragma data_seg( HB_MSC_START_SEGMENT )
static HB_$INITSYM hb_vm_auto_SymbolInit_HELLO = hb_vm_SymbolInit_HELLO;
#pragma data_seg()
#endif
HB_FUNC( MAIN )
{
do {
hb_xvmBaseLine( 2 );
hb_xvmPushSymbol( symbols + 1 );
hb_xvmPushNil();
hb_xvmPushStringConst( "Hello xHarbour!", 15 );
if( hb_xvmDo( 1 ) ) break;
hb_xvmLineOffset( 1 );
hb_xvmPushNil();
hb_xvmRetValue();
/* *** END PROC *** */
} while ( 0 );
hb_xvmExitProc();
}
MakeHello.bat
bin\harbour hello.prg -n -q0 -gc3 -p -w
pocc.exe -Ze hello.c -Iinclude
polink.exe -libpath:lib hello kernel32.lib user32.lib advapi32.lib ole32.lib winspool.lib gtwin.lib vm.lib common.lib rtl.lib macro.lib rdd.lib pcrepos.lib hbsix.lib lang.lib dbfntx.lib dbffpt.lib