tiny "red" challenge (msdos)
category: code [glöplog]
Recent conversation with trixter had the following:
The code for six bytes:
you can test it online here (just paste and hit "run")
So, can you do it in five? ;)
Quote:
Looking at the honoring sizecoding logo again, i remembered a recent finding:
When goblinish was doing his "red screen" in 14 bytes, i did the same for Msdos, but in 6 bytes
https://www.pouet.net/prod.php?which=78397#c838457
To my surprise, it's doable in *five* bytes, and being cleaner and more elegant at the same time.
So far i didn't "make use" of that trick ... can you spot it? ;)
The code for six bytes:
Code:
X les cx,[si]
inc sp
stosb
jmp short X+1
you can test it online here (just paste and hit "run")
So, can you do it in five? ;)
Quote:
The code for six bytes:
Code:X les cx,[si] inc sp stosb jmp short X+1
Releasen, und den Release "Rot in Hell" nennen ;)
Cool name =) but i won't release that ;)
Anyway, i'll spoil the SHA256 for the solution already ^^
Anyway, i'll spoil the SHA256 for the solution already ^^
Code:
7841bf3816cec52b3df54621eacf03c31f4540bd4ac535b4486519ba1978080d
I also made that a code-golf stackexchange challenge. I guess people over there are not exactly happy that it's restricted to DOS, but it is what it is ;)
It's probably not really suitable for the code-golf format too because you have essentially restricted the number of valid answers to maybe... one? two? three?
Yes, that is probably true. I can't however open the challenge to other languages "just for fun" (so i have been told), in that case i would have to accept any 5 bytes answer as winner which i don't want. I just expect that otherwise a (new era code golf) language i never heard of does it in 1 or 2 bytes, just because these languages are specifically designed that way ... So, closed MSDOS challenge it is ^^
for ZX Spectrum 7 bytes:
without red border - 5 bytes. In some cases - 4
Code:
; to compile: pasmo --tapbas red.asm red.tap label.txt huj.txt --listing
org #9012
start
ld a,c;18
OUT ($FE), A
X: ld (hl),c
inc hl
jr X
END start
without red border - 5 bytes. In some cases - 4
oops - 4 bytes
Impressive, especially that you're pulverizing your own 14b with this ;)
What does "in some cases" mean?
What always bugs me a little is that "org..." term at the start
as far as i understand, that means you can inject your code
somewhere -arbitrarily- into the memory
If you leave that out, would the code still work? If not, wouldn't
that count towards the total byte count? ;)
And where are all the dos coders ^^ Is this too boring? Too hard?
What does "in some cases" mean?
What always bugs me a little is that "org..." term at the start
as far as i understand, that means you can inject your code
somewhere -arbitrarily- into the memory
If you leave that out, would the code still work? If not, wouldn't
that count towards the total byte count? ;)
And where are all the dos coders ^^ Is this too boring? Too hard?
"some cases" - I've put another code
again, 4 bytes, but it doesn't work (
ORG is an old trick: after USR(Adr) BC=Adr
Code:
org #fffc
start
ld (hl),$12;fffc
inc hl ;fffe
db $18 ;ffff
END start
again, 4 bytes, but it doesn't work (
ORG is an old trick: after USR(Adr) BC=Adr
wasn't too hard..
if you like this kind of shit then you can play here:
http://golf.shinh.org/
not really demoscene related challenges :-|
Code:
PUSH SI
LES AX,[SI]
STOSW
RET
if you like this kind of shit then you can play here:
http://golf.shinh.org/
not really demoscene related challenges :-|
And we have a winner =)
Nah, it wasn't too hard, but more fun to make it a challenge, right? ;)
I'm mostly interested to make DOS codes shorter,
and finding that the "split jump" (push si/ret) actually
is the solution to a problem was quite nice =)
For completeness, the solution that generates the SHA256
Nah, it wasn't too hard, but more fun to make it a challenge, right? ;)
I'm mostly interested to make DOS codes shorter,
and finding that the "split jump" (push si/ret) actually
is the solution to a problem was quite nice =)
For completeness, the solution that generates the SHA256
Code:
les ax,[bx+si]
push si
stosb
ret
;salt it good!
;40987rthfgzsi
;98vhsp0ycb373
;29387fg27fb3b
hey, stosb doesn't work, only stosw!
:-)
:-)
Not sure if you're kidding ^^ It works (first two instructions are exchanged!)
Also, waiting for g0blinish to crush us all with the 4 bytes version ^^
Also, waiting for g0blinish to crush us all with the 4 bytes version ^^
(ok, at least in my code)
gosh, i forgot add post about stack xD
maybe this link says more...
DOS challenges
DOS challenges
Quote:
for ZX Spectrum [...] without red border - 5 bytes.
This is a solution for ZX Spectrum with red border in 5 bytes:
Code:
ORG #9212
begin: out (#70),a
x: EQU $-1
inc hl
jr x
I give up. That moment then nuffing to add
Quote:
Well, since my 5b solution for ZX Spectrum (with border) is simply an improvement on g0blinish's 7b solution, you can say that the equivalent solution WITHOUT border is kinda his too:Not sure if you're kidding ^^ It works (first two instructions are exchanged!)
Also, waiting for g0blinish to crush us all with the 4 bytes version ^^
Code:
This is 4 bytes only. ORG #9012
begin:
x: ld (hl),c
inc hl
jr x
I also wanted to make a remark regarding the use of ORG. You are correct that this trick feels a bit unfair, but this is the tradition that goes way back due to the lack of binary executable file format on ZX Spectrum.
HellMood means x86 4bytes
Code:
; Expects: AX 1010H
; BX color register to set (0-255)
; CH green value (00H-3fH)
; CL blue value (00H-3fH)
; DH red value (00H-3fH)
; Expects: AX 1012H
; BX first DAC register to set (0-00ffH)
; CX number of registers to set (0-00ffH)
; ES:DX addr of a table of R,G,B values (it will be CX*3 bytes long)
mov ax,1010h
int 10h
ret
with ax=1010h I got blue background, with 1012h -black one. and again 6 bytes
Actually I meant what goblinish was referring to: the possibility to inject code whereever you want on zx. that is quite a feat :) I welcome the 4 byte solution anyway :)
Anyway I would argue that the six bytes solution for DOS is actually also five bytes, RET is not required.
Anyway I would argue that the six bytes solution for DOS is actually also five bytes, RET is not required.
6 byte Amstrad CPC BASIC version (no border and shows READY prompt over the red):
(type the special chars with control N, control C, control L)
Code:
1?"\x0E\x03\x0C
(type the special chars with control N, control C, control L)
I tried to do this on the SNES, stripping to the bare necessities but failed :) I'll give it another whirl later.