Skip to content

Instantly share code, notes, and snippets.

View Zeda's full-sized avatar

Zeda Thomas Zeda

  • Western NY, USA
View GitHub Profile
@Zeda
Zeda / sine-approx.py
Last active February 4, 2022 13:45
8-bit Sine Approximation using bit twiddling
#!/usr/bin/python3
# This is ported from:
# https://www.omnimaga.org/asm-language/sine-approximation-(z80)/
# (Xeda112358 a.k.a. Zeda a.k.a. ZedaZ80)
#
from math import sin
def sineb(x):
int16_to_float80:
; DE points to where the output float is copied
; HL is the signed int
ld bc,0x8014
add hl,hl
rr b
jp p,uint16_to_float+3
xor a
sub l
ld l,a