1. ver 4.0 call_back question ?

Why isn't a call_back allowed in DOS32 ??

If you can write, define and use assembler in a Euphoria DOS program
you have no way of doing a call_back from assembler code to
a Euphoria routine DIRECTLY FROM ASSEMBLER.

Yet routine_id is allowed; which was originally added for
using in forward references but It doesn't solve any thing
with out call_back.

new topic     » topic index » view message » categorize

2. Re: ver 4.0 call_back question ?

call_back is to pass routine_id's of euphoria source to C DLL's, apps. routine_id has many uses far beyond call_backs, far beyond forward referencing as well. i.e.

procedure log_to_file(sequence message) 
    -- do something 
end procedure 
 
procedure log_to_stderr(sequence message) 
    -- do something 
end procedure 
 
procedure log_to_database(sequence message) 
    -- do something 
end procedure 
 
procedure log_to_tcpip(sequence message) 
    -- do something 
end procedure 
 
procedure log(sequence message) 
    call_proc(log_rid, { message }) 
end procedure 
 
integer log_rid = routine_id("log_to_stderr") 
 
log("Hello") 
log("Goodbye") 

i.e. dynamic programming. As for callback's in DOS, the conventional purpose for call backs, being DLLs, doesn't work in DOS. I don't know about ASM based code, I'm an ASM dummy.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

3. Re: ver 4.0 call_back question ?

jeremy said...

As for callback's in DOS, the conventional purpose for call backs, being DLLs, doesn't work in DOS. I don't know about ASM based code, I'm an ASM dummy.

Jeremy

If we allow define_c_func(), etc on DOS, we should probably allow call_back() as well.

Actually, call_back() is more important for DOS machine code/ASM programming then define_c_func(). If you don't have a define_c_func(), you can emulate it with some assembly and the call(). However, emulating call_back() is a lot harder.

new topic     » goto parent     » topic index » view message » categorize

4. Re: ver 4.0 call_back question ?

I know what routine_id is used for.
I want to be able to use call_back in DOS
just the same as when using euiw.exe

-- This works with euiw.exe I want it to work with euid.exe 
-- excerpt from my assembler code 
"push eax "& 
"mov eax, &sprintf("%d ",{call_back(routine_id("some_eu_function"))& 
"call near eax "&    
-- etc. 
new topic     » goto parent     » topic index » view message » categorize

5. Re: ver 4.0 call_back question ?

bernie said...

I know what routine_id is used for.
I want to be able to use call_back in DOS
just the same as when using euiw.exe

-- This works with euiw.exe I want it to work with euid.exe 
-- excerpt from my assembler code 
"push eax "& 
"mov eax, &sprintf("%d ",{call_back(routine_id("some_eu_function"))& 
"call near eax "&    
-- etc. 

Support is added in svn rev 2191 for using call_back() on DOS, at least in be_machine.c

new topic     » goto parent     » topic index » view message » categorize

6. Re: ver 4.0 call_back question ?

jimcbrown said...

Support is added in svn rev 2191 for using call_back() on DOS, at least in be_machine.c

Jim: I just tried to build SVN2191 but it crashs during DOS build.

Thanks for trying

It looks like it is more involved than just changing the back end.

new topic     » goto parent     » topic index » view message » categorize

7. Re: ver 4.0 call_back question ?

bernie said...

I just tried to build SVN2191 but it crashs during DOS build.

I've just uploaded SVN 2192 that does a DOS build again. I haven't tested the call_back for it though, but it does build now.

new topic     » goto parent     » topic index » view message » categorize

8. Re: ver 4.0 call_back question ?

DerekParnell said...
bernie said...

I just tried to build SVN2191 but it crashs during DOS build.

I've just uploaded SVN 2192 that does a DOS build again. I haven't tested the call_back for it though, but it does build now.

Derek: svn 2192 builds ok now; but using DOS call_back crashes with
causeway error.

CauseWay DOS Extender v3.45 Copyright 1992-99 Michael Devore. 
All rights reserved. 
 
Exception: 0E, Error code: 0006 
 
EAX=84C65910 EBX=84C85A10 ECX=84C65920 EDX=02000004 ESI=85188F88 
EDI=85188F88 EBP=84003A20 ESP=84C85A18 EIP=84C7F02E EFL=00010202 
 
CS=018F-7B507000 DS=0197-7B507000 ES=0197-7B507000 
FS=0000-xxxxxxxx GS=019F-xxxxxxxx SS=0197-7B507000 
 
CR0=00000000 CR2=00000000 CR3=00000000 TR=0000 
 
Info flags=00008018 
 
Writing CW.ERR file.... 
 
CauseWay error 09 : Unrecoverable exception. Program terminated. 

new topic     » goto parent     » topic index » view message » categorize

9. Re: ver 4.0 call_back question ?

bernie said...

svn 2192 builds ok now; but using DOS call_back crashes ...

Can I see the code that you used to test this. It will be handy to have a test case to help us fix the problem.

new topic     » goto parent     » topic index » view message » categorize

10. Re: ver 4.0 call_back question ?

DerekParnell said...
bernie said...

svn 2192 builds ok now; but using DOS call_back crashes ...

Can I see the code that you used to test this. It will be handy to have a test case to help us fix the problem.

Hi Derek. Sorry for the delay in replying to you but we are in different time zones.

It would be very difficult to send you an example of my code
without sending you my complete library which is far from finished.

What happens is when I run a windows program my library dynamically
compiles assembler routines that are written in both assembler
and Euphoria. These routines run and call other routines using
call_backs to do some parsing.

This works fine in windows.

If I run a DOS program the same library code is executed but
because DOS interpreter will not provide a good call_back the
crashed occurs.

The DOS program does not use call_backs but the library that it is using does.

I guess I can just forget about DOS call_backs and work around it with conditional code.

I hope that call_backs work in Linux because I am hoping
to use assembler there.

This is a sample of what the library code looks like:

export function strlen(atom str) -- tested 
Asm("strlen_", 
"prolog4eu "& 
"cld "& 
"mov edi, [ebp+8] "& 
"xor eax, eax "& 
"or ecx, -1 "& 
"repne scasb "& 
"not ecx "& 
"dec ecx "& 
"mov eax, ecx "& 
"epilog4eu "& 
"ret 0 ",1,u) 
return f("strlen_",{str}) 
end function 
-- 
export function strspn(atom str1, atom str2) -- tested 
Asm("strspn_", 
"prolog4eu "& 
"cld "& 
"xor eax, eax "& 
"mov ecx, [ebp+8] "& 
"jmp ssp004 "& 
"ssp001: "& 
"inc ecx "& 
"mov edi, [ebp+12] "& 
"ssp002: "& 
"mov dh, [edi] "& 
"or dh, dh "& 
"jz ssp005 "& 
"cmp dl, dh "& 
"je ssp003 "& 
"inc edi "& 
"jmp ssp002 "& 
"ssp003: "& 
"inc eax "& 
"ssp004: "& 
"mov dl, [ecx] "& 
"or dl, dl "& 
"jnz ssp001 "& 
"ssp005: "& 
"epilog4eu "& 
"ret 0 ",2,u) 
return f("strspn_",{str1,str2}) 
end function 
-- 
export function strpbrk(atom str1, atom str2) -- tested 
Asm("strpbrk_", 
"prolog4eu "& 
"cld "& 
"mov eax, [ebp+8] "& 
"jmp sb004 "& 
"sb001: "& 
"mov ecx, [ebp+12] "& 
"sb002: "& 
"mov dh, [ecx] "& 
"or dh, dh "& 
"jz sb003 "& 
"cmp dl, dh "& 
"je sb005 "& 
"inc ecx "& 
"jmp sb002 "& 
"sb003: "& 
"inc eax "& 
"sb004: "& 
"mov dl, [eax] "& 
"or dl, dl "& 
"jnz sb001 "& 
"xor eax, eax "& 
"sb005: "& 
"epilog4eu "& 
"ret 0 ",2,u) 
return f("strpbrk_",{str1,str2}) 
end function 
-- 
export function strtok(atom buff, atom delim) -- tested 
Asm("strtok_", 
"prolog4eu         "& --  -- 
"mov esi, [ebp+8]  "& --  get buffer 
"test esi esi      "& --  first call ? 
"jz nexttok        "& --  no 
"mov [@ptr], esi   "& --  save buffer 
"nexttok:          "& -- 
"mov edi, [ebp+12] "& --  yes get delimit 
"mov esi, [@ptr]   "& --  get current ptr 
"cmp esi, 0        "& -- 
"je near endtok    "& --  bail out 
"push edi          "& --  delimit 
"push esi          "& --  buffer 
"mov eax, "&AGet("strspn")& -- << ---- <<  THIS IS A CALL BACK 
"call near eax "& --  find start of token 
"add [@ptr], eax   "& --  goto first token 
"mov edi, [ebp+12] "& --  get delimit 
"mov esi, [@ptr]   "& --  get current ptr 
"cmp esi, 0        "& -- 
"je near endtok    "& --  bail out 
"cmp [esi], 0      "& --  pointing to zero ? 
"je near endtok    "& --  bail out 
"push edi          "& --  delimit 
"push esi          "& --  buffer 
"mov eax, "&AGet("strpbrk")& -- << ---- <<  THIS IS A CALL BACK 
"call near eax     "& --  find the end of the token 
"mov esi, [@ptr]   "& --  get current ptr 
"cmp eax, esi      "& -- 
"je near endtok    "& -- 
"cmp eax, 0        "& -- 
"je exact          "& -- 
"mov [@ptr], eax   "& -- 
"mov edi, eax      "& -- 
"mov eax, 0        "& -- 
"mov [edi], al     "& -- 
"mov eax, esi      "& -- 
"add [@ptr], 1     "& -- 
"epilog4eu         "& -- 
"ret 0             "& -- 
"exact:            "& -- 
"mov esi, [@ptr]   "& --  get current ptr 
"push esi          "& -- 
"mov eax, "&AGet("strlen")& -- << ---- <<  THIS IS A CALL BACK 
"call near eax     "& -- 
"cmp eax, 0        "& -- 
"jne lasttok       "& -- 
"jmp endtok        "& -- 
"lasttok:          "& -- 
"mov ecx, 0        "& -- 
"mov eax, [@ptr]   "& --  get current ptr 
"mov [@ptr], ecx   "& --  block next call 
"epilog4eu         "& -- 
"ret 0             "& -- 
"endtok:           "& -- 
"mov eax, 0        "& -- 
"epilog4eu         "& -- 
"ret 0             "& -- 
"ptr: dd 0 ",2,u) 
return f("strtok_",{buff,delim}) 
end function 
 
new topic     » goto parent     » topic index » view message » categorize

11. Re: ver 4.0 call_back question ?

bernie said...
export function strlen(atom str) -- tested 
Asm("strlen_", 
"prolog4eu "& 
"cld "& 
"mov edi, [ebp+8] "& 
"xor eax, eax "& 
"or ecx, -1 "& 
"repne scasb "& 
"not ecx "& 
"dec ecx "& 
"mov eax, ecx "& 
"epilog4eu "& 
"ret 0 ",1,u) 
return f("strlen_",{str}) 
end function 

<snip>

Those that know assembler always amaze me. Hats off to you Bernie!

Jeremy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu