Author Topic: string and asm  (Read 5915 times)

0 Members and 1 Guest are viewing this topic.

Emil_halim

  • Guest
Re: string and asm
« Reply #15 on: March 30, 2013, 09:05:30 AM »

Charles , what do you think about this

Code: [Select]
function name() as string
     string s = "i am string variable"
     return s
end function

'low level handling
name
push eax
putfile "t.txt",cast bstring eax
call @freememory   ' we already pushed the argument

how to call freememory from asm ?

Peter

  • Guest
Re: string and asm
« Reply #16 on: March 30, 2013, 01:21:05 PM »
Quote
Would you like to create your own language Peter?

No, I have got one.

JRS

  • Guest
Re: string and asm
« Reply #17 on: March 30, 2013, 01:25:52 PM »
Peter is switching to SB from what I was told. :o

Peter

  • Guest
Re: string and asm
« Reply #18 on: March 30, 2013, 01:26:42 PM »
Quote
how to call freememory from asm ?

Code: [Select]
FreeMemory eax

Charles Pegge

  • Guest
Re: string and asm
« Reply #19 on: March 30, 2013, 09:07:37 PM »

Charles , what do you think about this

Code: [Select]
function name() as string
     string s = "i am string variable"
     return s
end function

'low level handling
name
push eax
putfile "t.txt",cast bstring eax
call @freememory   ' we already pushed the argument

how to call freememory from asm ?

No Emil, stdcall, will remove parameter from the stack on return from functions. but you can push eax onto the stack twice.

One warning, this asm stuff, you will have to rewrite for 64 bit compiling. The 64 bit calling conventions are not very friendly to programmers. Hence my interest in exposing the abstract assembly layer.


Emil_halim

  • Guest
Re: string and asm
« Reply #20 on: March 31, 2013, 07:04:13 AM »
Quote
Quote
how to call freememory from asm ?

Code:
FreeMemory eax

this is not what i asked for , my be i asked wrongly. any way i was asking for that is this legal
Code: [Select]
call freememory

or this
Code: [Select]
call @freememory

Quote
No Emil, stdcall, will remove parameter from the stack on return from functions. but you can push eax onto the stack twice.
why , i was thinking that this is good enough
Quote
putfile "t.txt",cast bstring eax
so oxygen will cast eax then push it as an argument ,so stdcall will remove the pushed eax in putfil line
and the upper push will work with freememory.
« Last Edit: March 31, 2013, 07:20:36 AM by Emil_halim »

Emil_halim

  • Guest
Re: string and asm
« Reply #21 on: March 31, 2013, 07:23:43 AM »

Charles , i used this to know how things works.
Code: [Select]
#show     putfile  file, cast bstring eax

then i get this list which i did not undersatnd any thing.
Quote
$op 1 C1 eax
$op 60 C1
$go 0 [ebx+0x8B0]
$op 4 C1
$pa 1 0 4 [ebp+0x8]
$ch 1
$go 0[ebx+344]
$go 0 [ebx+0x838]

so what is this list?

Charles Pegge

  • Guest
Re: string and asm
« Reply #22 on: March 31, 2013, 08:43:01 AM »
Hi Emil,

You are seeing the machine-friendly / User-unfriendly OIL code for one line of basic. This gets converted to x86 assembly code. Should I turn this demon into an angel?  :)

Emil_halim

  • Guest
Re: string and asm
« Reply #23 on: March 31, 2013, 09:00:02 AM »

okay , what about the above previous post?

Peter

  • Guest
Re: string and asm
« Reply #24 on: March 31, 2013, 09:45:20 AM »
Quote
Should I turn this demon into an angel?

Yes, but 64bit.  :D
« Last Edit: March 31, 2013, 09:53:22 AM by peter »

JRS

  • Guest
Re: string and asm
« Reply #25 on: March 31, 2013, 09:48:38 AM »
Quote
Should I turn this demon into an angel?



Based on everything I've seen to date, that should be a walk in the park. You are truly amazing Charles!