August 2010 Archives

Sat Aug 21 13:22:08 CEST 2010


Posted by Jan Wagemakers | Permanent link | File under: Dutch/Nederlands

Sun Aug 8 10:07:51 CEST 2010

SMS script updated

I have updated my send free sms script using googlecl, because sometimes, googlecl fails with a Moved Temporarily error.

This new script will try again and again for a while.
 pts/8  jan ~$ cat sms
#!/bin/sh
# ---------------------------------------------------------
# Send free (gratis) SMS using google Calendar.
#             - Jan Wagemakers -
#         Donated to the Public Domain
#
# More info at:
# http://www.janwagemakers.be/nanoblogger/
#      archives/2009/05/index.html#e2009-05-31T09_35_46.txt
#      archives/2010/07/index.html#e2010-07-31T10_35_58.txt
#      archives/2010/08/index.html#e2010-08-08T10_07_51.txt
# ---------------------------------------------------------
export LANG=C
counter=0

TEXT=$@

# Send SMS using date and googlecl
# -------------------------------- 
send() {
DATE=`date -d "5 min" +%H:%M%p`
echo "$DATE $TEXT"
google calendar add "$DATE $TEXT" --reminder=3m
}

# send SMS
# --------
send

# Errors? Yes -> Try again
# ------------------------
while [ $? -ne 0 ] 
do
        # count how many times we try again
        # ---------------------------------
        counter=$(($counter+1))
        # and stop when it keeps failing
        # ------------------------------
        if [ $counter -gt 50 ] ; then 
                break
        fi
        
        echo failed... try again : $counter
        sleep 20s
        send
done
And this is what the new script looks like when googlecl fails.

Posted by Jan Wagemakers | Permanent link | File under: GNU/Linux

Sat Aug 7 06:11:46 CEST 2010

My first AMD64 assembler program

At http://www.janwagemakers.be/eng.html you can read about my experiments with Linux and x86-32-Assembly. On that page you can find a small Hello, World! program.

Today I have converted this Hello, World! program to x86-64 (amd64) assembly.

First, it is important to note that there are some differences in making syscall requests between x86-32 and x86-64 :

x86-32 x86-64
int $0x80 syscall
%eax %rax
%ebx %rdi
%ecx %rsi
%edx %rdx


Also the syscall numbers are not the same on x86-32 and x86-64, take a look at :

x86-32 x86-64
/usr/include/asm/unistd_32.h /usr/include/asm/unistd_64.h


With this information, I have converted this x86-32 program
.text
message:
 .ascii "Hello, World!\12\0"
 .align 4
.globl _hw               
_hw:
 movl $4, %eax           
 movl $1, %ebx           
 movl $message, %ecx     
 movl $15, %edx          
 int $0x80               
 movl $1, %eax           
 movl $0, %ebx           
 int $0x80               

as hello.s -o hello.o
ld hello.o -e _hw -o hello
        (_hw = entry-point)
to a working x86-64 program
 pts/3  jan ~/assembler64$ cat hello.s
.text
message:
 .ascii "Hello, World!\12\0"
 .align 4
.globl _hw               
_hw:
 movq $1, %rax           
 movq $1, %rdi           
 movq $message, %rsi     
 movq $15, %rdx          
 syscall            
 movq $60, %rax           
 movq $0, %rdi     
 syscall             
 pts/3  jan ~/assembler64$ as hello.s -o hello.o
 pts/3  jan ~/assembler64$ ld hello.o -e _hw -o hello
 pts/3  jan ~/assembler64$ ./hello
Hello, World!
 pts/3  jan ~/assembler64$ 
Nice :)

Posted by Jan Wagemakers | Permanent link | File under: amd64-asm, GNU/Linux