On Fri, Feb 16, 2001 at 12:02:41AM +1100, Rick Welykochy wrote:
> output program using INTERCAL (see http://intercal.com).
You're a very disturbed individual ...
Must be time for a couple of assembler versions. The first one is a
whopping 1240 bytes. It cheats by hard-coding the length of the string
returned by ctime though:
; gcc -o tmp tmp.S -nostartfiles; strip tmp; objcopy -R .bss -R .data tmp
.global _start
.extern ctime
_start:
push $1000000000 ; time
push %esp ; &time
call ctime
mov %eax, %ecx
mov $25, %edx ; ctime always returns a 25 byte string
xor %ebx, %ebx
inc %ebx ; stdout
xor %eax, %eax
addb $4, %al ; write
int $0x80 ; syscall
mov %ebx, %eax ; exit
xor %ebx, %ebx ; status
int $0x80 ; syscall
By defining the time string as a constant, we can make this much
smaller - 320 bytes. I don't think it can be made any smaller
without hand-crafting the ELF file:
; gcc -o tmp tmp.S -nostartfiles -nostdlib; strip tmp; objcopy -R .bss -R .data tmp
.global _start
_start:
xor %edx, %edx
movb $(time_end - time), %dl ; length
mov $time, %ecx ; buffer pointer
xor %ebx ,%ebx
inc %ebx ; stdout
xor %eax, %eax
addb $4, %al ; write
int $0x80 ; syscall
mov %ebx, %eax ; exit
xor %ebx, %ebx ; status
int $0x80 ; syscall
time: .ascii "Sun Sep 9 11:46:18 2001\n"
time_end:
Cheers,
John
--
Object-[dis]oriented INTERCAL. I have seen the compiler, and it runs.
Why do I now feel like the hero in one of those H. P. Lovecraft stories
who has seen something no mortal man was ever meant to see, and who is
marginally less sane thereafter? - Charlie Stross
--
SLUG - Sydney Linux User Group Mailing List - http://slug.org.au/
More Info: http://slug.org.au/lists/listinfo/slug