diff options
-rw-r--r-- | entries/nwoeanhinnogaehr/fib.asm | 59 | ||||
-rw-r--r-- | people.json | 2 |
2 files changed, 23 insertions, 38 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 diff --git a/people.json b/people.json index 3652818..1f42862 100644 --- a/people.json +++ b/people.json @@ -535,7 +535,7 @@ { "github": "nwoeanhinnogaehr", "name": "Noah Weninger", - "title": "PhD Student, UWaterloo", + "title": "PhD Student, UWaterloo; MSc, UBC", "entries": [ { "name": "x86 ELF", |