aboutsummaryrefslogtreecommitdiff
path: root/entries/nwoeanhinnogaehr
diff options
context:
space:
mode:
Diffstat (limited to 'entries/nwoeanhinnogaehr')
-rw-r--r--entries/nwoeanhinnogaehr/fib.asm59
1 files changed, 22 insertions, 37 deletions
diff --git a/entries/nwoeanhinnogaehr/fib.asm b/entries/nwoeanhinnogaehr/fib.asm
index 729958f..76ef7c8 100644
--- a/entries/nwoeanhinnogaehr/fib.asm
+++ b/entries/nwoeanhinnogaehr/fib.asm
@@ -1,7 +1,8 @@
-; assembles with nasm to an 81-byte ELF binary that works on x86 Linux
+; assembles with nasm to an 70-byte ELF binary that works on x86 Linux
+; is 64 bytes possible???
bits 32
-org $25430000
+org $0d470000
db $7F,"ELF" ; e_ident
dd 1 ; p_type
dd 0 ; p_offset
@@ -12,48 +13,32 @@ org $25430000
dw (entry-$$)&0xffff ; e_entry, p_memsz
entry:
- inc ebx
- and eax,strict dword 4 ;nop
- inc esi ; 1
- inc edi ; 1
- ; 2
- ; 3
- ; 5
- ; 8
- ; ...
+ inc edi
+main:
+ ; print
+ or eax, strict dword 4
+ mov edx,esp
+ sub edx,ecx
+ inc edx
+ mov bl,1
+ int 0x80
-loop:
- mov eax,esi
- push 10
+ push $00010020
mov ecx,esp
- jmp skip
- dw $20 ; e_phentsize
- dw 1 ; e_phnum
-skip:
- pop ebp
+ mov eax,edi
+
+ ; update fibbo
+ add edi,esi
+ xchg esi,eax
+ mov bl,10
format:
cdq
- div ebp
- inc ebx
- dec ecx
+ div ebx ; SIGFPE on overflow
or edx,'0'
+ dec ecx
mov [ecx],dl
test eax,eax
jnz format
-print:
- mov al,4
- mov edx,ebx
- mov bl,1
- int 0x80
-
- ;update fibbo
- mov eax,edi
- add edi,esi
- xchg esi,eax
-
- ;exit on overflow
- jno loop
- xchg eax,ebx
- int 0x80
+ jmp main