aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBraxton Hall2022-11-01 06:10:41 +0000
committerGitHub2022-11-01 06:10:41 +0000
commitfcce49ee1b7e0eac3cbae4f4bff5029bb43dd2ee (patch)
tree171ca4b2b09c074fd097ea5d679cbc30a2a7d733
parent11be438aea968cf34f6e1d9dc4425ad2d76d0479 (diff)
parent3cc99fdcc68b96a93f1ad81f2dc89f16a67abcd0 (diff)
Merge pull request #77 from nwoeanhinnogaehr/main
Golf x86 elf to 70 bytes & add UBC affiliation
-rw-r--r--entries/nwoeanhinnogaehr/fib.asm59
-rw-r--r--people.json2
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",