aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBraxton Hall2022-10-26 17:05:12 +0000
committerGitHub2022-10-26 17:05:12 +0000
commit01dbd3f3f0829f9bf33bd0c3f152a160218bf09d (patch)
treed751a98758446af8f6937c28bc26bf39304a7568
parent4573b5ae5c50856dafe88cbd1a795662faee041b (diff)
parentd7c513d8f7654ab61296be5aefbea4eadff69125 (diff)
Merge pull request #49 from nwoeanhinnogaehr/main
add x86 elf (81 bytes)
-rw-r--r--entries/nwoeanhinnogaehr/fib.asm59
-rw-r--r--people.json11
2 files changed, 70 insertions, 0 deletions
diff --git a/entries/nwoeanhinnogaehr/fib.asm b/entries/nwoeanhinnogaehr/fib.asm
new file mode 100644
index 0000000..26ccf11
--- /dev/null
+++ b/entries/nwoeanhinnogaehr/fib.asm
@@ -0,0 +1,59 @@
+; assembles with nasm to an 81-byte ELF binary that works on x86 Linux
+
+bits 32
+org $25430000
+ db $7F,"ELF" ; e_ident
+ dd 1 ; p_type
+ dd 0 ; p_offset
+ dd $$ ; p_vaddr
+ dw 2 ; e_type, p_paddr
+ dw 3 ; e_machine
+ dd entry ; e_version, p_filesz
+ 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
+ ; ...
+
+loop:
+ mov eax,esi
+ push 10
+ pop ebp
+ push ebp
+ jmp format
+ dw $20 ; e_phentsize
+ dw 1 ; e_phnum
+
+format:
+ cdq
+ div ebp
+ inc ebx
+ dec esp
+ or edx,'0'
+ mov [esp],dl
+ test eax,eax
+ jnz format
+
+print:
+ mov al,4
+ mov ecx,esp
+ 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
diff --git a/people.json b/people.json
index 102b326..38744c3 100644
--- a/people.json
+++ b/people.json
@@ -419,5 +419,16 @@
"link": "./entries/markusde/collatz/collatz.png"
}
]
+ },
+ {
+ "github": "nwoeanhinnogaehr",
+ "name": "Noah Weninger",
+ "title": "PhD Student, UWaterloo",
+ "entries": [
+ {
+ "name": "x86 ELF",
+ "link": "./entries/nwoeanhinnogaehr/fib.asm"
+ }
+ ]
}
]