Yes, I've discovered the nifty gcc 'popen' function which can be used
from ASM to do stuff like this:
; 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, the reason I am playing with this ( I'm sure you were
wondering ) is that I've been investigating the use of zenity (and
other "interactive scripting widgets") from ASM.
zenity is GUI and is default installed in Ubunty. An example of its
use:
Install surfraw, then run this:
burnt.sh
#!/bin/bash
ELVI=$(zenity \
--list \
--title="ELVI" \
--text "Pick an elvi service:" \
--radiolist \
--column "Pick" \
--column "Elvi" \
TRUE "sourceforge" \
FALSE "freshmeat" \
FALSE "slashdot");
TEXT=$(zenity \
--entry \
--title="TERM" \
--text "Enter the search term?");
echo ""
echo "searching" $ELVI "for" $TEXT
surfraw $ELVI $TEXT
And, no, you don't exactly have to be "burnt" to catch the irony.
Also, long before zenity, there were dialog, Xdialog, etc... and all
Debians have a smaller CUI thingy called whiptail.
This ncurses-based thingy downloaded with a 2008 tag, but my tests
show it isn't even Y2K compliant, amoung other things.
http://invisible-island.net/dialog/
Anyway, I've learned how to get text input from zenity:
; nasm -f elf -o result.o result.asm
; gcc -o result result.o
section .data
cmd db 'zenity --entry', 10, 0
mod db 'r', 0
section .bss
fid resd 1
buf resb 256
section .text
global main
extern popen
extern pclose
extern fgets
extern printf
main:
push mod
push cmd
call popen
add esp, 8
mov [fid], eax
push DWORD [fid]
push 256
push buf
call fgets
add esp, 12
push buf
call printf
add esp, 4
mov eax, [fid]
push eax
call pclose
add esp, 4
xor eax, eax
ret
But, my question is, how does one go about obtaining a number value
result??
$ zenity --question; echo $?
Gives 0 if I click 'Okay'
Gives 1 if I click 'Cancel'
Nathan.


|