Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
|
|
@ -0,0 +1,92 @@
|
|||
org 100h
|
||||
jmp demo
|
||||
|
||||
; Encode 0-terminated string at HL, store at DE
|
||||
encode: mov a,m
|
||||
ana a
|
||||
jz edone
|
||||
mvi b,1
|
||||
escan: inx h
|
||||
cmp m
|
||||
jnz ewrite
|
||||
inr b
|
||||
jnz escan
|
||||
dcr b
|
||||
ewrite: xchg
|
||||
mov m,b
|
||||
inx h
|
||||
mov m,a
|
||||
inx h
|
||||
xchg
|
||||
jmp encode
|
||||
edone: stax d
|
||||
ret
|
||||
|
||||
; Decode 0-terminated string at HL, store at DE
|
||||
decode: mov a,m
|
||||
ana a
|
||||
jz edone
|
||||
mov b,a
|
||||
inx h
|
||||
mov a,m
|
||||
dwrite: stax d
|
||||
inx d
|
||||
dcr b
|
||||
jnz dwrite
|
||||
inx h
|
||||
jmp decode
|
||||
|
||||
; Show two examples
|
||||
demo: lxi h,exampl
|
||||
call show
|
||||
lxi h,examp2
|
||||
show: push h
|
||||
call puts ; Show start string
|
||||
lxi h,nl
|
||||
call puts
|
||||
pop h
|
||||
lxi d,buf1 ; Encode string
|
||||
call encode
|
||||
lxi h,buf1 ; Show encoded result (as hexadecimal)
|
||||
call puthex
|
||||
lxi h,nl
|
||||
call puts
|
||||
lxi h,buf1 ; Decode string
|
||||
lxi d,buf2
|
||||
push d
|
||||
call decode
|
||||
pop h
|
||||
call puts ; Show decoded string
|
||||
lxi h,nl
|
||||
jmp puts
|
||||
|
||||
nl: db 13,10,0
|
||||
exampl: db 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWW'
|
||||
db 'WWWWWWWWWWWWWWBWWWWWWWWWWWWWW',0
|
||||
|
||||
; Test case with more than 255 repeated items
|
||||
examp2: db 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
db 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
db 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
db 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
db 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
db 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
db 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
db 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
||||
db 'XXXXXXX',0
|
||||
|
||||
; Print 0-terminated string at HL
|
||||
puts: mov a,m! ora a! rz
|
||||
push h! mvi c,2! mov e,a! call 5! pop h! inx h! jmp puts
|
||||
|
||||
; Print 0-terminated string at HL as hex
|
||||
puthex: mov a,m! ora a! rz
|
||||
push h! call hexout! pop h! inx h! jmp puthex
|
||||
|
||||
; Print A as hexadecimal
|
||||
hexout: push psw! rar! rar! rar! rar! call hexlo! pop psw
|
||||
hexlo: ani 0Fh! cpi 10! jc hexp! adi 7
|
||||
hexp: adi '0'! mvi c,2! mov e,a! jmp 5
|
||||
|
||||
buf1 equ $
|
||||
buf2 equ buf1+256
|
||||
19
Task/Run-length-encoding/Crystal/run-length-encoding.cr
Normal file
19
Task/Run-length-encoding/Crystal/run-length-encoding.cr
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
def rlencode (s)
|
||||
result = Array({Char, Int32}).new
|
||||
s.scan(/(.)\1*/) do |m|
|
||||
result << { m[1][0], m[0].size }
|
||||
end
|
||||
result
|
||||
end
|
||||
|
||||
def rldecode (enc)
|
||||
String.build do |s|
|
||||
enc.each do |char, length|
|
||||
s << char.to_s * length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
enc = rlencode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW")
|
||||
p enc
|
||||
puts rldecode(enc)
|
||||
106
Task/Run-length-encoding/MACRO-11/run-length-encoding.macro11
Normal file
106
Task/Run-length-encoding/MACRO-11/run-length-encoding.macro11
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
.TITLE RLE
|
||||
.MCALL .TTYOUT,.EXIT
|
||||
RLE:: JMP DEMO
|
||||
|
||||
; ENCODE 0-TERMINATED STRING AT (R0), STORE AT (R1)
|
||||
ENCODE: MOVB (R0),R2
|
||||
BEQ 3$
|
||||
MOVB #1,R3
|
||||
1$: INC R0
|
||||
CMPB (R0),R2
|
||||
BNE 2$
|
||||
INCB R3
|
||||
BNE 1$
|
||||
DECB R3
|
||||
2$: MOVB R3,(R1)+
|
||||
MOVB R2,(R1)+
|
||||
BR ENCODE
|
||||
3$: CLRB (R1)
|
||||
RTS PC
|
||||
|
||||
; DECODE 0-TERMINATED STRING AT (R0), STORE AT (R1)
|
||||
DECODE: MOVB (R0)+,R2
|
||||
BEQ 2$
|
||||
MOVB (R0)+,R3
|
||||
BIC #^C377,R2
|
||||
1$: MOVB R3,(R1)+
|
||||
SOB R2,1$
|
||||
BR DECODE
|
||||
2$: CLRB (R1)
|
||||
RTS PC
|
||||
|
||||
; TESTS
|
||||
DEMO: MOV #TEST1,R5
|
||||
JSR PC,1$
|
||||
MOV #TEST2,R5
|
||||
JSR PC,1$
|
||||
.EXIT
|
||||
1$: MOV R5,R1
|
||||
JSR PC,PRINT
|
||||
MOV #NL,R1
|
||||
JSR PC,PRINT
|
||||
MOV R5,R0
|
||||
MOV #BUFR1,R1
|
||||
JSR PC,ENCODE
|
||||
MOV #BUFR1,R1
|
||||
JSR PC,PRHEXS
|
||||
MOV #NL,R1
|
||||
JSR PC,PRINT
|
||||
MOV #BUFR1,R0
|
||||
MOV #BUFR2,R1
|
||||
JSR PC,DECODE
|
||||
MOV #BUFR2,R1
|
||||
JSR PC,PRINT
|
||||
MOV #NL,R1
|
||||
JSR PC,PRINT
|
||||
RTS PC
|
||||
|
||||
NL: .BYTE 15,12,0
|
||||
|
||||
TEST1: .ASCII /WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWW/
|
||||
.ASCIZ /WWWWWWWWWWWWWWBWWWWWWWWWWWWWW/
|
||||
|
||||
TEST2: .ASCII /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
|
||||
.ASCII /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
|
||||
.ASCII /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
|
||||
.ASCII /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
|
||||
.ASCII /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
|
||||
.ASCII /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
|
||||
.ASCII /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
|
||||
.ASCII /XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/
|
||||
.ASCIZ /XXXXXXX/
|
||||
|
||||
.EVEN
|
||||
|
||||
; PRINT STRING AT R1
|
||||
PRINT: MOVB (R1)+,R0
|
||||
.TTYOUT
|
||||
BNE PRINT
|
||||
RTS PC
|
||||
|
||||
; PRINT HEX BYTE R0
|
||||
PRHEXB: MOV R0,-(SP)
|
||||
ROR R0
|
||||
ROR R0
|
||||
ROR R0
|
||||
ROR R0
|
||||
JSR PC,1$
|
||||
MOV (SP)+,R0
|
||||
1$: BIC #^C17,R0
|
||||
CMP R0,#^D10
|
||||
BLO 2$
|
||||
ADD #7,R0
|
||||
2$: ADD #'0,R0
|
||||
.TTYOUT
|
||||
RTS PC
|
||||
|
||||
; PRINT HEX STRING R1
|
||||
PRHEXS: MOVB (R1)+,R0
|
||||
BEQ 1$
|
||||
JSR PC,PRHEXB
|
||||
BR PRHEXS
|
||||
1$: RTS PC
|
||||
|
||||
BUFR1: .BLKB 400
|
||||
BUFR2: .BLKB 400
|
||||
.END RLE
|
||||
18
Task/Run-length-encoding/Miranda/run-length-encoding.miranda
Normal file
18
Task/Run-length-encoding/Miranda/run-length-encoding.miranda
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
main :: [sys_message]
|
||||
main = [Stdout (lay [inp, show enc, dec])]
|
||||
where inp = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW"
|
||||
enc = rlencode inp
|
||||
dec = rldecode enc
|
||||
|
||||
rlencode :: [*]->[(num,*)]
|
||||
rlencode xs = [(#p, hd p) | p <- chunk xs]
|
||||
|
||||
rldecode :: [(num,*)]->[*]
|
||||
rldecode xs = concat [take n (repeat x) | (n,x) <- xs]
|
||||
|
||||
chunk :: [*]->[[*]]
|
||||
chunk = f []
|
||||
where f acc [] = [acc]
|
||||
f [] (a:as) = f [a] as
|
||||
f (a:acc) (a:as) = f (a:a:acc) as
|
||||
f acc (a:as) = acc:f [a] as
|
||||
44
Task/Run-length-encoding/Refal/run-length-encoding.refal
Normal file
44
Task/Run-length-encoding/Refal/run-length-encoding.refal
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
$ENTRY Go {
|
||||
, <Print <Example>>: e.In
|
||||
, <Print <RLEncode e.In>>: e.Enc
|
||||
= <Prout <RLDecode e.Enc>>;
|
||||
};
|
||||
|
||||
Example {
|
||||
= 'WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW';
|
||||
};
|
||||
|
||||
RLEncode {
|
||||
e.X = <Each (Count) <Chunk e.X>>;
|
||||
};
|
||||
|
||||
RLDecode {
|
||||
e.X = <Concat <Each (Repeat) e.X>>;
|
||||
};
|
||||
|
||||
Count {
|
||||
e.X, <Lenw e.X>: s.L s.C e.Y = s.L s.C;
|
||||
};
|
||||
|
||||
Repeat {
|
||||
0 s.C = ;
|
||||
s.N s.C = s.C <Repeat <Sub s.N 1> s.C>;
|
||||
};
|
||||
|
||||
Each {
|
||||
(e.F) = ;
|
||||
(e.F) (e.X) e.Y = (<Mu e.F e.X>) <Each (e.F) e.Y>;
|
||||
};
|
||||
|
||||
Chunk {
|
||||
= ;
|
||||
(e.I) = (e.I);
|
||||
(e.I t.I) t.I e.X = <Chunk (e.I t.I t.I) e.X>;
|
||||
(e.I) t.J e.X = (e.I) <Chunk (t.J) e.X>;
|
||||
t.I e.X = <Chunk (t.I) e.X>;
|
||||
};
|
||||
|
||||
Concat {
|
||||
= ;
|
||||
(e.X) e.Y = e.X <Concat e.Y>;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue