diff options
author | Lily Lin | 2022-10-26 23:30:06 +0000 |
---|---|---|
committer | Lily Lin | 2022-10-26 23:30:06 +0000 |
commit | af03b3cd051a8a8b1442147136156f271f07ac5c (patch) | |
tree | 6239bbd269f8c682fcd2bd1aecd29cc8b2edf6b5 /entries/nwoeanhinnogaehr | |
parent | 66fdac7a5ab7040a29fdd6a49cb0123db5ea916a (diff) | |
parent | 18d17f9fb578df5f20e689481ed06f44fcf4b80c (diff) |
Merge branch 'main' into lily
Diffstat (limited to 'entries/nwoeanhinnogaehr')
-rw-r--r-- | entries/nwoeanhinnogaehr/fib.asm | 59 |
1 files changed, 59 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 |