RunProgram() exmaple in ASM Linux.

Linux specific forum
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by pbdep.


Hi,

Because it seems PB v3.30 does have RunProgram defined but is
not executed you could workout with the following example I
mixed it in 2 minutes.. Im lazy :) but its usefull. If you want the
Arguments and Environment settings You have to point them out
to and Array and end with a Null-byte. Hope its usefull. Pbdep.


;------------------------------------------------------
; execute program
;------------------------------------------------------
; You can extent by passing Environment and Arguments
; for returned errors see also /errno.h
;------------------------------------------------------
Procedure NewRunProgram(fname$)

FILENAME.s = FNAME$+chr(0)
ENVP.s = chr(0)
ARGV.s = chr(0)
RESULT = 0

MOV EAX,11 ; execve
MOV EBX,FILENAME ; filename
MOV ECX,ARGV ; arguments
MOV EDX,ENVP ; environment
INT 0X80 ; syscall
MOV RESULT,EAX ; result, if errors

ProcedureReturn RESULT
EndProcedure

printn (str( NewRunprogram("./file") ))


;------------------------------------------------------
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

FILENAME.s = FNAME$+chr(0)

just for your info, all string in pb are null terminated. Nice snippet anyway :).

Fred - AlphaSND
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by pbdep.
Originally posted by fred

FILENAME.s = FNAME$+chr(0)

just for your info, all string in pb are null terminated. Nice snippet anyway :).

Fred - AlphaSND
Heee i did not know that :wink: I thought only the ones
with PokeS ..

Thanks for the tip !

Norman.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by boop64.

Thanks for the info pbdep ^_^!
I knew it could be done it's just I didn't know how to do it in asm.


Boop64
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Rings.

Let the good old times roll...

i see heavy INT Calls next time.....

i just should read some api- and system decriptions..


Its a long way to the top if you wanna .....CodeGuru
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by pbdep.


Woow I can tell you, I did a lot of programming on the 6502 and 8086
in my early IceAges :wink: for some years, but It took me 3 hours to understand how linux handels Assembly, coding the NewRunprogram() was
done in 2 minutes but befor I had the clue on linux :wink: hahaha..
Thats the trouble with those higher languages dies day, you dont have
to bother anymore about whats beneath it...
Well i learned form reading my Eyesout the last few days that the
32/64-bits are pritty changed compared to the 16 bits I used to do in
Asm coding... okay the basic are the same but i cant find my way in
the registers anymore :wink:...

For those who are intrested in more Mind failuers :wink: Have a look
at -> http://www.muppetlabs.com/~breadbox/bf/

That for sure will turn you upsidedown :wink:

Funny world... And the above all happens in 15 years :wink:

Have a nice day...
Post Reply