|
Prev: I pee in the open
Next: New Getline in assembly
From: Rod Pemberton on 9 Jul 2008 20:56 "Evenbit" <nbaker2328(a)charter.net> wrote in message news:578482e9-b022-4dea-99d1-4d621fa449ac(a)m45g2000hsb.googlegroups.com... > Yes, I've discovered the nifty gcc 'popen' function 'popen' is not GCC C, not ANSI C, but POSIX. http://www.opengroup.org/onlinepubs/009695399/functions/popen.html > which can be used > from ASM to do stuff like this: > Like what? Dude, I'm not running *nix. Why do you always want me to guess? Freakin waste of my time... > ; nasm -f elf -o tellmore.o tellmore.asm > ; gcc -o tellmore tellmore.o > section .data > cmd db 'more', 10, 0 > mod db 'w', 0 > fmt db '%d', 10, 0 > > section .bss > cnt resd 1 > fid resd 1 > > section .text > global main > extern popen > extern pclose > extern fprintf > > main: > push mod > push cmd > call popen > add esp, 8 > mov [fid], eax > mov ecx, 50 > mov [cnt], ecx > loop: > push DWORD [cnt] > push fmt > push DWORD [fid] > call fprintf > add esp, 12 > dec DWORD [cnt] > jnz loop > > mov eax, [fid] > push eax > call pclose > add esp, 4 > > xor eax, eax > ret > Okay, you connected a stream to a *nix "more" and read and printed who knows what... > Okay, the reason I am playing with this > is that I've been investigating the use of zenity (and > other "interactive scripting widgets") from ASM. > WOAH! Widget Over Asm Huh? > ( I'm sure you were wondering ) Honestly, I wasn't... Should I have been? > zenity is GUI and is default installed in Ubunty. An example of its > use: > [code snip] > > And, no, you don't exactly have to be "burnt" to catch the irony. What are you talking about? I got the "burnt" - burnt.sh part, but where's the irony? > Also, long before zenity, there were dialog, Xdialog, etc... and all > Debians have a smaller CUI thingy called whiptail. > What is CUI? Character UI, Command line UI, or TUI? > This ncurses-based thingy downloaded with a 2008 tag, but my tests > show it isn't even Y2K compliant, amoung other things. TUI... > Anyway, I've learned how to get text input from zenity: > I'm all out of awards. [snip code] > > But, my question is, how does one go about obtaining a number value > result?? > Well... You're calling C's fgets() to get a string. Why can't you call C's scanf() to get a number? Do I need to RTFM you? > $ zenity --question; echo $? > > Gives 0 if I click 'Okay' > Gives 1 if I click 'Cancel' > Point and click assembly? Hmm, someone around here, well from France, promotes that... Rod Pemberton
From: Evenbit on 11 Jul 2008 02:04 On Jul 10, 6:21 am, "Rod Pemberton" <do_not_h...(a)nohavenot.cmm> wrote: > > Good point. I thought 'less' killed 'more' on *nix... > Like so many other things, it still needs to be there for "backwards compatibility" reasons. Linux is in the same boat as Windows... Does your Cygwin have 'more'? Did you try compiling/running my Nasm code under Cygwin? Did the piping part work? > Yes, the pipe is the key feature. The command line *nix pipe '|' > implementation is well used... and understood. But, p* function use, > AFAICT, seems uncommon both on *nix and elsewhere. I would certainly have to disagree. Piping to/from a spawned process is a common question in forums. One doesn't always have the source code for the process you want to use -- therefore, you can't use other forms of interprocess communication. Nathan.
From: Rod Pemberton on 11 Jul 2008 02:51 "Evenbit" <nbaker2328(a)charter.net> wrote in message news:b756df3f-6807-4d4a-ae73-872d77d2c739(a)26g2000hsk.googlegroups.com... > On Jul 10, 2:28 am, Frank Kotler <fbkot...(a)verizon.net> wrote: > > > > Perhaps a place to try out Nasm's shiny new back-apostrophe strings: > > Ewwww, I missed that Frank. Just where is 'back-apostrophe' on my keyboard? Sigh... another awkward key to type. I've got enough problems trying to get a keyboard the backslash and forward slash in typable locations. I wonder how non-US keyboards will do that one. > > fmt db `%d/n`, 0 > > > > Isn't '/n' a high-level *C* thing?? Bitloss, If it's '/n', then "No." C uses a backslash... You could claim the preprocessor is C-like. #if %if, #else %else etc. but NASM has a bunch a C preprocessor directives that a C preprocessor wouldn't be able to process. RP PS. Who's crabby?
From: Rod Pemberton on 11 Jul 2008 02:52 "Evenbit" <nbaker2328(a)charter.net> wrote in message news:3d517bc1-0295-4223-a60a-6553a0975632(a)56g2000hsm.googlegroups.com... > On Jul 10, 6:21 am, "Rod Pemberton" <do_not_h...(a)nohavenot.cmm> wrote: > > > > Good point. I thought 'less' killed 'more' on *nix... > > Like so many other things, it still needs to be there for "backwards > compatibility" reasons. Linux is in the same boat as Windows... > > Does your Cygwin have 'more'? > My DOS has 'more'. But, it's not *nix. My DJGPP has 'less'. > Did you try compiling/running my Nasm code under Cygwin? No. Sorry, I don't currently have Cygwin, MinGW, Pelles C, or LCC-Win32 installed. I wasn't using them enough. And, I left Cygwin installed for a few extra years since it's installation/package manager was _so_ messed up... > Did the > piping part work? popen etc. is emulated via files for DOS with DJGPP, but the asm isn't likely to work for DOS, etc., due to incompatible interrupt calls. > > Yes, the pipe is the key feature. The command line *nix pipe '|' > > implementation is well used... and understood. But, p* function use, > > AFAICT, seems uncommon both on *nix and elsewhere. > > I would certainly have to disagree. With? There's like five to seven things you could disagree with... > Piping to/from a spawned process > is a common question in forums. Which would indicate it's not well understood or commonly used... (But, don't take my word for it. Search for code with popen()...) > One doesn't always have the source > code for the process you want to use -- therefore, you can't use other > forms of interprocess communication. ANSI freopen() and system(), anyone? RP
From: Wolfgang Kern on 11 Jul 2008 04:20
Rod Pemberton mentioned: .... >... I've got enough problems trying to get a keyboard the > backslash and forward slash in typable locations. > I wonder how non-US keyboards will do that one. .... When I started coding there were only US-keyboards on tools, so I kept the advantage of having square brackets and backslash as primary single finger keys and use US-keyboards only. It's hard for me too to get US-keyboards here in Europe, so I always have a few on stock to avoid several weeks waiting. I have this: "`/~" on the key left-next to the "one/!"-key. Right, German and French keyboards may really have problems with the 'accent'-behaviour of the 'backwards apostrophe'. __ wolfgang |