Blame | Last modification | View Log | Download
# file opened: lua_sin_table.asm1 00002 0000 ; Sinus table generator - using lua script, because sjasmplus itself does not have3 0000 ; floating point arithmetics and sin/cos/... functions.4 00005 0000 org $80006 80007 8000 sin_table: ; check listing file to see resulting table bytes8 8000 lua allpass ; EVERY pass must emit the machine code to not affect following labels9 8000 ~ -- 256 bytes (index 0..255):10 8000 ~ for i = 0, 255, 1 do11 8000 ~12 8000 ~ -- index 0..255 will cover angle range < 0, 2Pi )13 8000 ~ -- i.e. going in sinus values 0 -> +1 -> 0 -> -1 -> 014 8000 ~ -- For different range, the /128.0 must be modified:15 8000 ~ -- /256.0 is 0..Pi, /512.0 is 0..Pi/2, etc16 8000 ~17 8000 ~ -- The *15.5 is amplitude of final values18 8000 ~ -- to be -15 .. +15 (+0.5 for "floor" compensation)19 8000 ~ -- in this example values are signed byte (-15 == 241 == 0xF1)20 8000 ~21 8000 ~ sj.add_byte(math.floor(math.sin(math.pi * i / 128.0) * 15.5))22 8000 ~ end23 8000 00 00 00 01 endlua23 8004 01 01 02 0223 8008 03 03 03 0423 800C 04 04 05 0523 8010 05 06 06 0623 8014 07 07 07 0823 8018 08 08 09 0923 801C 09 0A 0A 0A23 8020 0A 0B 0B 0B23 8024 0B 0C 0C 0C23 8028 0C 0D 0D 0D23 802C 0D 0D 0E 0E23 8030 0E 0E 0E 0E23 8034 0E 0E 0F 0F23 8038 0F 0F 0F 0F23 803C 0F 0F 0F 0F23 8040 0F 0F 0F 0F23 8044 0F 0F 0F 0F23 8048 0F 0F 0F 0E23 804C 0E 0E 0E 0E23 8050 0E 0E 0E 0D23 8054 0D 0D 0D 0D23 8058 0C 0C 0C 0C23 805C 0B 0B 0B 0B23 8060 0A 0A 0A 0A23 8064 09 09 09 0823 8068 08 08 07 0723 806C 07 06 06 0623 8070 05 05 05 0423 8074 04 04 03 0323 8078 03 02 02 0123 807C 01 01 00 0023 8080 00 FF FF FE23 8084 FE FE FD FD23 8088 FC FC FC FB23 808C FB FB FA FA23 8090 FA F9 F9 F923 8094 F8 F8 F8 F723 8098 F7 F7 F6 F623 809C F6 F5 F5 F523 80A0 F5 F4 F4 F423 80A4 F4 F3 F3 F323 80A8 F3 F2 F2 F223 80AC F2 F2 F1 F123 80B0 F1 F1 F1 F123 80B4 F1 F1 F0 F023 80B8 F0 F0 F0 F023 80BC F0 F0 F0 F023 80C0 F0 F0 F0 F023 80C4 F0 F0 F0 F023 80C8 F0 F0 F0 F123 80CC F1 F1 F1 F123 80D0 F1 F1 F1 F223 80D4 F2 F2 F2 F223 80D8 F3 F3 F3 F323 80DC F4 F4 F4 F423 80E0 F5 F5 F5 F523 80E4 F6 F6 F6 F723 80E8 F7 F7 F8 F823 80EC F8 F9 F9 F923 80F0 FA FA FA FB23 80F4 FB FB FC FC23 80F8 FC FD FD FE23 80FC FE FE FF FF24 810025 8100 18 00 jr start26 8102 start:27 8102# file closed: lua_sin_table.asmValue Label------ - -----------------------------------------------------------0x8000 X sin_table0x8102 start