wchrmas pattern, post-compo Author: Losso / AttentionWhore Category: Christmas Challenge System: Amiga Language: Assembler Len source code: 370 Len exe file: 92 Len code only: 56 Instructions: Execute the file in a CLI/Shell window on any Kickstart version. WinUAE will auto-run the file when passed as an argument. Or use the provided ADF disk image in any other Amiga emulator. Loops forever when done. Description: A compact pattern writer for all Amigas. Uses two counters that output a star every 6 chars that get shifted in different directions after each line. The AmigaDOS overhead for executable files is 36 bytes, so we have: 36 bytes overhead + 56 bytes code = 92 bytes Tricks used to keep it small: - Text output using the "wchr" BCPL call - Use initial register contents of d0, d4 - Lots of experiments with different constants, counting methods, compare-free abort conditions Tricks used to go from the compo version with 60 bytes to this version with 56 bytes: - Line-end check without counter reset: add.w #1724,d0 bvc.b .puts moveq #0,d0 Shortened to: add.w #3277,d0 bcc.b .puts - Counter-update code inlined, looped twice: bsr.b .mod bsr.b .mod [...] .mod (counter update code) rts Shortened to: .mod (counter update code) neg.l d0 blt.b .mod Here's a little write-up: https://heckmeck.de/demoscene/wchrmas-pattern/ Comments: File and code breakdown: ----- HEADER tag, table, CODE tag ----------- 0000: 0000 03f3 0000 0000 0000 0001 0000 0000 0010: 0000 0000 0000 000e 0000 03e9 0000 000e ----- Code ---------------------------------- 0020: 7c04 7e04 7220 5346 6c02 5c46 6606 722a 0030: 5404 65fe cd47 4480 6dec d07c 0ccd 6406 0040: 5246 5747 720a 48e7 fffe 7020 286a 00e0 0050: 4e95 4cdf 7fff 60cc ----- END tag ------------------------------- 0050: 0000 03f2 7c04 | moveq #4,d6 7e04 | moveq #4,d7 7220 | .loop moveq #32,d1 5346 | .mod subq.w #1,d6 6c02 | bge.b .norst 5c46 | addq #6,d6 6606 | .norst bne.b .nostr 722a | moveq #42,d1 5404 | addq.b #2,d4 65fe | .done bcs.b .done cd47 | .nostr exg d6,d7 4480 | neg.l d0 6dec | blt.b .mod d07c 0ccd | add.w #3277,d0 6406 | bcc.b .puts 5246 | addq.w #1,d6 5747 | subq.w #3,d7 720a | moveq #10,d1 48e7 fffe | .puts movem.l d0-a6,-(a7) 7020 | moveq #32,d0 286a 00e0 | move.l 224(a2),a4 4e95 | jsr (a5) 4cdf 7fff | movem.l (a7)+,d0-a6 60cc | bra.b .loop