diff options
author | Braxton Hall | 2022-11-01 06:10:41 +0000 |
---|---|---|
committer | GitHub | 2022-11-01 06:10:41 +0000 |
commit | fcce49ee1b7e0eac3cbae4f4bff5029bb43dd2ee (patch) | |
tree | 171ca4b2b09c074fd097ea5d679cbc30a2a7d733 /entries | |
parent | 11be438aea968cf34f6e1d9dc4425ad2d76d0479 (diff) | |
parent | 3cc99fdcc68b96a93f1ad81f2dc89f16a67abcd0 (diff) |
Merge pull request #77 from nwoeanhinnogaehr/main
Golf x86 elf to 70 bytes & add UBC affiliation
Diffstat (limited to 'entries')
-rw-r--r-- | entries/nwoeanhinnogaehr/fib.asm | 59 |
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 |