This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; original facebook post in "Z80 Assembly Programming On The ZX Spectrum" group: | |
; Here's a challenge for your creativity. | |
; Create a Z80 assembly function with the following properties: | |
; Input in A: values in the range [1,32] | |
; Output in A: 1 for 1-8, 2 for 9-16, 4 for 17-32 | |
; No loops or other conditional jumps. | |
; No usage of ROM code. | |
; No comparisons. | |
; The function will map how many bits an integer needs to how many bytes it needs in a typical C style struct. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ZX SPECTRUM code, sjasmplus syntax: https://github.com/z00m128/sjasmplus | |
; alternative code for Allan Turvey post: https://www.facebook.com/groups/z80asm/posts/1982356728824612/ | |
ORG $8000-8 | |
DEVICE ZXSPECTRUM48, $ - 1 | |
size_start: | |
dg ...#.### | |
dg ....#### | |
dg ...##### | |
dg ...##### | |
dg ..###### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Author: Ped7g ; (C) 2022 ; license: MIT / GPL / Public Domain (pick whichever fits best for you) | |
; sort array of pointers to 64 char long strings (for example filenames) | |
; assembled with: https://github.com/z00m128/sjasmplus/ | |
DEFINE ORG_ADR $8080 ; using only uncontended faster memory, but smaller buffers | |
OPT --syntax=abf : CSPECTMAP "qsorts.map" | |
DEVICE ZXSPECTRUM48, ORG_ADR-1 | |
ORG ORG_ADR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ----- Colour palette (ULA) | |
BLACK equ 0 | |
BLUE equ 1 | |
RED equ 2 | |
MAGENTA equ 3 | |
GREEN equ 4 | |
CYAN equ 5 | |
YELLOW equ 6 | |
WHITE equ 7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; (C): copyright 2022 Peter Ped Helcmanovsky, license: MIT | |
; name: custom ZX Spectrum ROM to measure time until first /INT signal | |
; public gist somewhere at: https://gist.github.com/ped7g (search for it) | |
; | |
; to assemble (with z00m's sjasmplus https://github.com/z00m128/sjasmplus/ v1.20.1+) | |
; run: sjasmplus rom_first_int.asm | |
; | |
; history: 2022-08-23: v1.0 - initial version | |
; | |
; purpose: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Variations on Andrew's question from FB group, two possible entry points | |
; clear_box with HL as char-coordinates or clear_box_adr with HL as attribute address | |
clear_box: | |
; h = valid character y coordinate | |
; l = valid character x coordinate | |
; b = width | |
; c = height | |
; a = attribute to fill | |
push af | |
ld a,h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Author: Ped7g ; (C) 2022 ; license: MIT / GPL / Public Domain (pick whichever fits best for you) | |
; assembled with: https://github.com/z00m128/sjasmplus/ | |
; based on https://github.com/MartinezTorres/z80_babel project, written as comparison | |
; | |
; Notes for myself about debugging/verification: in CSpect debugger `SAVE "data.bin",from,length` | |
; Then `hexdump -v -e '/2 "%u\n"' DATA.BIN > data.txt`. Then compare with `sort -g data.txt` | |
DEFINE ORG_ADR $8080 ; using only uncontended faster memory, but smaller buffers | |
OPT --syntax=abf : CSPECTMAP "qsort.map" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Author: Ped7g ; (C) 2022 ; license: MIT / GPL / Public Domain (pick whichever fits best for you) | |
; assembled with: https://github.com/z00m128/sjasmplus/ | |
; based on https://github.com/MartinezTorres/z80_babel project, written as comparison | |
; | |
; This is second version of the sieve routine (asm-like asm, focusing on performance, hard-wired buffer, etc...) | |
; For first C-like version check: https://gist.github.com/ped7g/c55bfa0d55ca13ce029549636cdd1de5 | |
; | |
; sieve routine sieve_a_2 starts around line 110, below test harness | |
; comment/uncomment the case you wan to debug: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Author: Ped7g ; (C) 2022 ; license: MIT / GPL / Public Domain (pick whichever fits best for you) | |
; assembled with: https://github.com/z00m128/sjasmplus/ | |
; based on https://github.com/MartinezTorres/z80_babel project, written as comparison | |
; DEFINE ORG_ADR $5D01 ; using maximum memory in zx48 snapshot -> prime numbers: 4339, last prime number 41491 | |
; DEFINE DO_MAX_BUFFER_CASE ; (4339 primes was with shorter test-code, not last version) | |
DEFINE ORG_ADR $8080 ; using only uncontended faster memory, but smaller buffers | |
OPT --syntax=abf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- | |
; Author: Ped7g ; (C) 2022 ; license: https://opensource.org/licenses/MIT | |
; Z80N (ZX Next) assembly, sjasmplus syntax: https://github.com/z00m128/sjasmplus | |
; | |
; code-size optimisation based on facebook post with small example showcasing the usage of routines | |
; | |
; default config of example is doing the counter-clockwise rotation of buffer to screen, | |
; flip comment to get clock-wise variant: | |
computeULAFromVRamAddress EQU computeULAFromVRamAddressCCW |
NewerOlder