In few words the hugi size competition #29 is about
to write a .com program, the few bytes is possible,
that return in the dos screen pseudo random mazes.
The generated mazes are of the kind
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
? | | | | | | | | |
+--+--+--+ + + + + +--+ + + + +--+ +--+ + +--+ + + + + + +
| | | | | | | | | | | | | | | | | | |
+ + + + + + +--+ +--+--+--+ +--+ +--+ +--+ + + + +--+--+ +--+
| | | | | | | | | | | | | | | |
+--+--+ +--+--+--+ +--+ + + +--+ + + +--+ +--+--+ + + + +--+ +
| | | | | | | | | | | |
+ +--+--+ +--+--+--+ +--+ + + +--+--+ + +--+--+--+--+ + +--+--+ +
| | | | | | | | | | | | |
+ + + +--+ +--+ +--+--+--+ +--+--+--+--+--+--+--+ + + + + +--+ +
| | | | | | | | | | | | |
+ + +--+ + + +--+ + + + +--+--+--+--+--+--+--+--+--+--+--+--+ +--+
| | | | | | | | | | | |
+ +--+ +--+--+ +--+ + + + +--+ + +--+ +--+ + +--+ +--+ + + +
| | | | | | | | | | | | | | | |
+--+ +--+ +--+--+ +--+--+--+--+ + +--+--+--+ +--+--+--+ + + +--+ +
| | | | | | | | | | | | |
+ +--+ +--+ + +--+--+--+ +--+ + + +--+ + +--+ + + + +--+ + +
| | | | | | | | ?
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
so 25x10 cells mazes, where each line begin with a wall or a + end with \r\n.
The enter of maze should be the char 02h the exit should be the char 07fh.
(that here are print with a '?')
Each cell of maze has to be connected from one other cell with
only one path (so there is always a path that goes from enter of maze
to exit of maze; and there are not part in the maze
closed [that can not be visit])
Then the programme has to deal with one input number where the allowed
values goes from 0 to 100 and it has to deal with no argument at all too.
If for example the name of .com file name is "entry"
than
entry
entry 0
have to result in the print in the dos box the same 25x10 cells
pseudo random maze
the same for
entry 88
entry 88
the same maze
The program has to print in the screen using the Dos routines.
This is my 182 bytes entry, but there are people say enought 135bytes
and some other 96bytes
How i can reduce its size?
Than i not understand why for maze to much big the program not give
the correct result.
Thank you
---------------------------
;com file
;nasmw -o m.com m.asm
;;
; Ho applicato il seguente metodo ricorsivo:
; 1) Prima si costruisce una griglia dentro un rettangolo
; in cui tutte le caselle della suddivisione sono marcate
; non visitate ['N'],
; mentre il bordo della griglia e' marcato: visitato.
; 2) Si sceglie una casella di detto rettangolo da cui partire
;
; 3) Si marca tale casella con 'visitata'
; 4) Se tale casella non ha una casella confinante marcata non visitata
; Se lo stack e' vuoto
; esci
; altrimenti
; pop dallo stack la posizione della precedente casella
; si rende tale casella la casella attuale
; goto 4
; altrimenti
; scegliere casualmente una casella confinante non visitata
; si leva il muro tra tale casella confinante e la casella iniziale
; push nello stack la posizione della casella iniziale
; si rende tale casella confinante la casella attuale
; goto 3
;
; Una casella e' la seguente scrittura
; +--
; |XY
; quindi e' formata da 6 chars.
; N significa *non visitato*, se a posto di N ci sta un qualsiasi altro
; carattere significa visitato.
; +--+--+--+
; | |1 | |
; +--+--+--+
; | 3|NN|2 |
; +--+--+--+
; | |0 | |
; +--+--+--+
; Per levare il muro da:
; W muro 1 W*i-162/2=" "
; B muro 2 B*i+2=' '
; W muro 0 W*i+162/2=" "
; B muro 3 B*i-1=' '
; L == lunghezza in caselle del rettangolo del labirinto
; H == altezza in caselle del rettangolo del labirinto
; Discussione sui valori limite
; Per la *corretta* rappresentazione in un Box Dos
; L_Max=26 L_Min=1, H_Max=20 H_Min=1.
; Utilizzando "> programma > file.txt"
; ho provato i valori fino a (L_Max,H_Max)=(97,97) ottenendo
; un labirinto di 56 Kb nel file.txt
; da (L,H)=(98, 97) il programma non funziona;
; sospetto che cio' sia dovuto all'array "arr" in .bss
; vicino a o maggiore ai 64kb (0..0FFFFh oppure 0..65535)
; che non puo' essere gestito dal programma oppure
; non puo' essere gestito dalla routine DOS che stampa
; tale array nello schermo.
; per il corrente file "arr" ha size
; BytesMemory(L,H)=((L+1)*(H+2)*6)
; BytesMemory(98,97)=99*99*6=58806 non funziona
; mentre
; BytesMemory(97,97)=98*99*6=58212 funziona
; Sospetto che il programma funzioni per ogni L ed H
; tali che BytesMemory(L,H)<=58212
; Infatti
; BytesMemory(10,850)=(11*852*6)=56232 e qui funziona
;;
%define L 25
%define H 10
;%define L 10
;%define H 850
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
%define sopra (L+1)*6
%define sopra2 (L+1)*3
%define LineareMax 3*((L-1)+2*(L+1)*H)+1
%define passi (LineareMax-sopra-1)/3
org 100h
Start:
pusha
; ****************************
; *** Prende il numero
; ****************************
mov si, 080h
xor ax, ax ; punta alla size riga comando
cmp byte[si], 0
je .6 ; nessun argomento ritorna 0
.2: inc si ; va all'inizio dell'array
.3: lodsb ; preleva il primo carattere
cmp al, ' '
jbe .3 ; leva gli spazi iniziali
.4: sub al, '0'
jl .5 ; finisce quando incontra uno spazio
; o un char minore di '0'
aad 10 ; al=al+ah*10 and ah=0
mov ah, al
lodsb
jmp short .4
.5: mov al, ah ; ritorna numeri del tipo al:ah=n:n
.6: mov [seed], ax ; inizializza il seed per rand
; *******************************************
; *** Fa la griglia
; *******************************************
mov di, arr
mov cx, BytesMemory
mov al, 10
lea si, [di+sopra]
rep stosb ; tutto 10 [visitato] qui cx=0
lea di, [si-sopra2]
mov bx, H21
mov ax, "+-"
mov dx, "|N" ; le caselle NN: non visitate
.7: mov cl, L ; altrimenti visitate
.8: stosw
mov byte[di], ah
inc di
loop .8
stosb
mov byte[di], 0Dh ; fa la linea
inc di
inc di
xchg ax, dx
dec bx
jnz .7 ; passa alla linea successiva
mov byte[di], '$'
mov byte[di-sopra2-3], 07fh
mov byte[si], 02h ; ritorna in si la casella iniziale
; *******************************************
; *** Fa il labirinto
; *******************************************
; parte dalla casella puntata da si
inc si ; punta all'interno della casella, dove c'e' 'N'
mov di, sp ; salva lo stack per l'uscita
.9: mov word[si], " " ; " " significa visitata
.9a: mov ax, [seed]
mul word[val] ; rand()
inc ax
mov [seed], ax
add al, ah ; valore casuale in al
and ax, 03h ; al=0[sotto],1[alto],2[sinistra],3[destra]
mov cx, 4 ; le caselle confinanti sono 4
.9b: mov bx, ax
add bx, ax
mov bp, [conv+bx] ; in bp l'offset
cmp byte[si+bp], 'N' ; si+bp punta alla casella confinante
je .a ; vede se tale casella � visitata, se si' va in .a
inc ax
and al, 3
loop .9b ; va alla prossima casella
; ** caso le caselle sono tutte visitate
cmp di, sp
jbe .z ; se lo stack e' vuoto esci[ e'in casella iniziale]
pop ax ; altrimenti prende la casella precedente
add si, ax ; ax=-162,+3,+162,-3 passa alla casella precedente
jmp short .9a
.a: ; ** caso vi � una casella non visitata
mov bx, [muro+bx] ; si+bx punta al muro (oppure a un char precedente)
mov word[si+bx], " " ; leva il muro di divisione [ed eventualemente una N]
; che verra' in ogni caso levata in .9
add si, bp
neg bp ; neg bp poiche' trova la casella precedente
push bp
jmp short .9 ; quando fa il pop e ritrova la strada
.z: ; usa la casella iniziale in si e la ritorna
; ******************************
; *** Stampa sullo schermo
; ******************************
lea dx, [si-sopra2-1] ; usa si per stampare l'array
mov ah, 09h
int 21h
popa
ret
align 2
val dw 32581
; 0 1 2 3
conv dw sopra, -sopra, 3, -3
muro dw sopra2, -sopra2, 2, -1
Section .bss
seed resw 1
arr resb BytesMemory
fine resb 512 ; for to be sure
-----------------------
Who's at 96? I've got 102 so far but no "ConFrom" in example.asm which
could be +50, +80, +120, or easily more...
> How i can reduce its size?
Hey, I can't give specifics, since I'm trying to compete... But, you might
look at:
1) hidden features of opcodes, like aaa, aad, aam
2) single byte opcodes, like lodsb, stosb, cbw, cdq, inc, dec, xchg
Rod Pemberton
> http://www.frontiernet.net/~fys/hugi/hcompo.htm
> This for other information
>
> This is my 182 bytes entry, but there are people say enought 135bytes
> and some other 96bytes
>
No, the current leader is 134 bytes. 96 seems *very* ambitious!
> How i can reduce its size?
> Than i not understand why for maze to much big the program not give
> the correct result.
You don't set the initial cell using the random number generator.
Thanks for the code; I'm going to see what can be shortened, but it needs
to get bigger first to add the RNG to locate the initial cell.
My attempt at a program was also a big display array with another one of
steps to next cell and wall.
But it was too large.
--
Nuns! Reverse!
why i have to set the initial cell?
> Thanks for the code; I'm going to see what can be shortened, but it needs to
> get bigger first to add the RNG to locate the initial cell.
yes all you is allow to use it in competition too
why have i to set the initial cell *random*?
i choose the first one of the maze
To match the example competition results!
--
Nuns! Reverse!
they want pseudo random mazes:
i give the pseudo random mazes
(that seems it is ok for the test program);
there is in no place in the rules text that the
initial cell for begin the algo should be random too
> --
> Nuns! Reverse!
> ; *******************************************
> ; *** Fa il labirinto
> ; *******************************************
> ; parte dalla casella puntata da si
> inc si ; punta all'interno della casella, dove c'e'
> 'N'
> mov di, sp ; salva lo stack per l'uscita
> .9: mov word[si], " " ; " " significa visitata
> .9a: mov ax, [seed]
> mul word[val] ; rand()
> inc ax
> mov [seed], ax
> add al, ah ; valore casuale in al
> and ax, 03h ; al=0[sotto],1[alto],2[sinistra],3[destra]
> mov cx, 4 ; le caselle confinanti sono 4
> .9b: mov bx, ax
> add bx, ax
> mov bp, [conv+bx] ; in bp l'offset
> cmp byte[si+bp], 'N' ; si+bp punta alla casella confinante
> je .a ; vede se tale casella � visitata, se si' va in .a
^^^^
; vede se tale casella � visitata, *se non visitata* va in .a
It's a fine maze generator, but it's in the rules; the generated maze has
to match exactly that made by Example.com
--
Nuns! Reverse!
>
> "Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
> news:op.u06rdzmrhswpfo@dell3100...
>> On Fri, 02 Oct 2009 10:36:20 +0100, io_x <a...@b.c.invalid> wrote:
>>
>>> http://www.frontiernet.net/~fys/hugi/hcompo.htm
>>> This for other information
>>
>>>
>>> This is my 182 bytes entry, but there are people say enought 135bytes
>>> and some other 96bytes
>>>
>> No, the current leader is 134 bytes. 96 seems *very* ambitious!
>>
>>> How i can reduce its size?
>>> Than i not understand why for maze to much big the program not give
>>> the correct result.
>>
>> You don't set the initial cell using the random number generator.
>
> why i have to set the initial cell?
>
>> Thanks for the code; I'm going to see what can be shortened, but it
>> needs to
>> get bigger first to add the RNG to locate the initial cell.
>
> yes all you is allow to use it in competition too
>
No I wouldn't enter anything based on your code; it would hardly be mine,
and as I said my previous attempts were too large, so I won't be
submitting anything. I was going to see if I could suggest some shortening
of your code, and if *you* want you could enter it under your name, but
I'm not looking to take any credit.
--
Nuns! Reverse!
this is 164 bytes using the Esra way for to get the integer;
i not think i could do better of this
--------------------------
;com file
;nasmw -o m.com m.asm
;>nasmw -v
; NASM version 0.98.38 compiled on Sep 12 2003
;;
; xx-10-2009
; Hugi compo 29 - random mazes
; che non puo' essere gestito dal programma.
; per il corrente file "arr" ha size
; BytesMemory(L,H)=((L+1)*(H+2)*6)
; qui
; BytesMemory(98,97)=99*99*6=58806 non funziona
; mentre
; BytesMemory(97,97)=98*99*6=58212 funziona
;;
%define L 25
%define H 10
;%define L 97
;%define H 97
;%define L 50
;%define H 23
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
%define sopra (L+1)*6
%define sopra2 (L+1)*3
%define LineareMax 3*((L-1)+2*(L+1)*H)+1
%define passi (LineareMax-sopra-1)/3
org 100h
Start:
; ****************************
; *** Prende il numero with the help by Esra Sdrawkcab
; ****************************
; assumo che ax==0
mov di, 080h ; punta alla size riga comando
scasb
jz .1 ; nessun argomento ritorna 0
xchg di, si
inc si ; elimina l'unico spazio
; assicurato dalle regole e unico
.0: aad 10 ; al+=10*ah e ah=0
; nel primo giro qui al=ah=0
mov ah, al ; risultato in ah
lodsb
sub al, '0' ; finisce quando incontra uno spazio
jge .0 ; o un char minore di '0'
mov al, ah ; ritorna numeri del tipo al:ah=n:n
.1: mov [seed], ax ; inizializza il seed per rand
; *******************************************
; *** Fa la griglia
; *******************************************
mov di, arr
mov cx, BytesMemory
mov al, 10
lea si, [di+sopra]
rep stosb ; tutto 10 [visitato] qui cx=0
lea di, [si-sopra2]
mov bx, H21
mov ax, "+-"
mov dx, "|N" ; le caselle NN: non visitate
.2: mov cx, L ; altrimenti visitate
.3: stosw
mov byte[di], ah
inc di
loop .3
stosb
mov byte[di], 0Dh
inc di
inc di ; fa la linea
xchg ax, dx
dec bx
jnz .2 ; passa alla linea successiva
mov byte[di], '$'
mov byte[di-sopra2-3], 07fh
mov byte[si], 02h ; ritorna in si la casella iniziale
; *******************************************
; *** Fa il labirinto
; *******************************************
; suppone all'ingresso che cx==0
; parte dalla casella puntata da si
inc si ; punta all'interno della casella, dove c'e' 'N'
.4: mov word[si], " " ; " " significa visitata
.5: mov ax, [seed]
mul word[318] ; rand()
inc ax
mov [seed], ax
aad 1 ; al=al+ah ed ah=0; valore casuale in al
and al, 03h ; al=0[sotto],1[alto],2[sinistra],3[destra]
mov cl, 4 ; le caselle confinanti sono 4
.6:
mov di, ax
mov bp, ax
mov bx, [muro+di+bp] ; in bx offset del muro; se bp=2*bx-(al/2)
shr di, 1 ; => in bp offset della prossima casella
mov bp, bx
add bp, bx
sub bp, di
cmp byte[si+bp], 'N'
je .a ; se tale casella non e' visitata va in .a
inc ax
and al, 3
loop .6 ; vai alla prossima casella
; ** caso le caselle sono tutte visitate
cmp sp, 0FFFEh
jae .z ; se lo stack e' vuoto esci[ e'in casella iniziale]
pop ax ; altrimenti prende la casella precedente
add si, ax ; ax=-162, +3, +162, -3 passa alla casella
precedente
jmp short .5
.a: ; ** caso vi � una casella non visitata
; leva il muro di divisione [ed eventualemente una N]
mov word[si+bx], " "
; che verra' in ogni caso levata dall'istruzione in .4
add si, bp
neg bp ; neg bp poiche' trova la casella precedente
%if BytesMemory>24000
cmp sp, fine
jb .z ; lo stack non puo' invadere questo file in
memoria
%endif
push bp ; quando fa il pop ritrova la strada
jmp short .4
.z: ; usa la casella iniziale in si e la ritorna
; ******************************
; *** Stampa sullo schermo
; ******************************
lea dx, [si-sopra2-1]
mov ah, 09h
int 21h ; usa si per stampare l'array
ret ; ritorna al chiamante
align 2
; val dw 32581
; 0 1 2 3
always 164
is it ok that for mazes too much big (if error => no print)?
Are problems or error i not see?
;%define L 10
;%define H 749
%if BytesMemory>24000
.e: mov sp, 0FFFEh
ret ; nel caso di errore non stampa proprio niente:
; ritorna al DOS
%endif
.a: ; ** caso vi � una casella non visitata
; leva il muro di divisione [ed eventualemente una N]
mov word[si+bx], " "
; che verra' in ogni caso levata dall'istruzione in .4
add si, bp
neg bp ; neg bp poiche' trova la casella precedente
%if BytesMemory>24000
cmp sp, fine
jbe .e ; lo stack non puo' invadere la memoria
; dati o code di questo programma
%endif
push bp ; quando fa il pop ritrova la strada
jmp short .4
.z: ; usa la casella iniziale in si e la ritorna
; ******************************
; *** Stampa sullo schermo
; ******************************
lea dx, [si-sopra2-1]
mov ah, 09h
int 21h ; usa si per stampare l'array
ret ; ritorna al Dos
align 2
; 0 1 2 3
muro dw sopra2, -sopra2, 2, -1
Section .bss
seed resw 1
arr resb BytesMemory
fine resb 512 ; for to be sure
-------------------------------------------
j=arr|c=BytesMemory
al=10|i=&*j+sopra|rep stosb ; tutto 10 [visitato] qui cx=0
j=&*i-sopra2|b=H21 |a="+-"|r="|N" ; le caselle NN: non visitate
.2: c=L ; altrimenti visitate
.3: stosw|B*j=ah|++j|loop .3|stosb|B*j=0Dh|++j|++j ; fa la linea
a<->r|--b#.2 ; passa alla linea successiva
B*j='$'|B*j-sopra2-3=07fh|B*i=02h ; ritorna in si la casella iniziale
What is this result?
for the program that test mazes "mazetest -v"
all is ok
Hi,
The code below does not pass the test. The test.bat file
included in the rules does similar to the following:
example n > x.txt
entry n > e.txt
fc e.txt x.txt
where n is a number from 0 to 100
if e.txt and x.txt are not equal, then the entry does not
pass. After looking at your entry, I think you don't get
the correct random number.
Ben
Are you saying that the program "entry n" has to be the same output
of the "example n" for n from 0 to 100 ?
but where it is written in the rules??
> "Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
> news:op.u07rhes0hswpfo@dell3100...
>> On Sat, 03 Oct 2009 08:23:30 +0100, io_x <a...@b.c.invalid> wrote:
>>
>>>
>>> "Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
>>> news:op.u06rdzmrhswpfo@dell3100...
>>>> On Fri, 02 Oct 2009 10:36:20 +0100, io_x <a...@b.c.invalid> wrote:
>>>> You don't set the initial cell using the random number generator.
>>>
>>> why have i to set the initial cell *random*?
>>> i choose the first one of the maze
>>>
>> To match the example competition results!
>
> What is this result?
>
> for the program that test mazes "mazetest -v"
> all is ok
>
Ah, sorry, I didn't realise you had tested it; Hmm
D:\asm\hcompo29>m 0
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
☻ | | | | | |
|
+--+ +--+ +--+ + +--+--+ +--+ + +--+--+ +--+ + + + + + +--+
+
| | | | | | | | | | | | | | |
|
+ +--+ +--+ +--+--+ +--+--+ +--+ +--+--+--+ + +--+--+ + +
+--+--+
| | | | | | | | | | | |
|
+ +--+--+ + +--+ +--+--+ +--+ +--+--+ +--+ + + +--+ +--+ +--+
+
| | | | | | | | | | | | |
|
+--+--+ + + + +--+--+ + + +--+--+ + + +--+--+--+ +--+ +--+ +
+
| | | | | | | | | | | | | | | | |
|
+ + + + +--+ + + + + + + +--+--+--+ + +--+--+ + +--+ +--+
+
| | | | | | | | | | | | | | | |
|
+ +--+ +--+ + + +--+--+--+--+--+ + + + + + +--+--+ + +--+ +
+
| | | | | | | | | | |
|
+ +--+--+--+--+--+ +--+--+--+--+--+--+ + + + + +--+--+--+ +--+--+
+
| | | | | | | | |
|
+ +--+--+--+--+ + + + +--+--+ + + +--+--+ +--+--+--+--+--+
+--+--+
| | | | | | | | | | |
|
+ +--+ +--+ + + + +--+--+ +--+--+ + +--+--+--+--+--+--+ + + +
+
| | | | | | |
⌂
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
yet
D:\asm\hcompo29>example 0
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
☻ | | | |
|
+ +--+ + + +--+ + +--+--+--+--+--+--+--+ +--+ +--+--+--+--+ +--+
+
| | | | | | | | | | | | | |
|
+ + + + + + +--+--+ + + +--+ +--+--+--+ + +--+ +--+--+ +
+--+
| | | | | | | | | | | | | |
|
+ + + + + +--+--+--+ + + +--+--+ +--+ +--+--+ + + +--+--+--+
+
| | | | | | | | | | | | | |
|
+ + + + + + +--+ +--+--+ + + +--+ +--+--+ +--+--+--+ + + +
+
| | | | | | | | | | | | |
|
+ +--+ +--+--+--+ +--+--+ +--+--+--+ +--+ +--+ + + +--+--+--+--+
+
| | | | | | | | | | | | |
|
+ + +--+--+ + + + + +--+ +--+--+--+ +--+ +--+ + + + +
+--+--+
| | | | | | | | | | | | | | |
|
+ +--+--+ + +--+--+--+ + +--+ + + +--+ +--+ + + + +--+--+ +
+
| | | | | | | | | | | | | |
|
+--+ +--+--+--+ + +--+--+ + + +--+--+ + + + + +--+--+--+ +--+
+
| | | | | | | | | | | | |
|
+ + + + + +--+--+ +--+--+--+--+--+--+--+--+--+--+ + +--+ +--+ +
+
| | | | |
⌂
+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
are different
D:\asm\hcompo29>nasmw -o entry.com m2.asm
D:\asm\hcompo29>tester -v
Starting standard test...
Testing seeds:
ERROR: Output on line 2 column 7 differs when no seed given.
Failing command: "entry > tested.maz"
Entry failed a standard test.
>
--
Nuns! Reverse!
where is "in the rules"?
Then, if that is really in the rules the entry.com file
has to use the same algo, the same all of Example.com
for doing the same output for n 0...100
then why use the program "mazetest -v" if the output
from 0..100 is the same of the example.com?
> --
> Nuns! Reverse!
This is the official one - the rules say it has to (at least) pass the
test program - which does exactly the above (that is compare your result
with that from example.com for n=0 to 100)
You could enter the relaxed unofficail competition, which doesn't require
exact match of output, just random mazes:
http://temet.es/hcompo/
but 86 bytes is the current leader!
--
Nuns! Reverse!
>
> "Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
> news:op.u080b62hhswpfo@dell3100...
>> On Sat, 03 Oct 2009 08:23:30 +0100, io_x <a...@b.c.invalid> wrote:
>>
>>>
>>> "Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
>>> news:op.u06rdzmrhswpfo@dell3100...
>>>> On Fri, 02 Oct 2009 10:36:20 +0100, io_x <a...@b.c.invalid> wrote:
>>>> You don't set the initial cell using the random number generator.
>>>
>>> why have i to set the initial cell *random*?
>>> i choose the first one of the maze
>>
>> It's a fine maze generator, but it's in the rules;
>
>> the generated maze has to match exactly that made by Example.com
>
> where is "in the rules"?
> Then, if that is really in the rules the entry.com file
> has to use the same algo, the same all of Example.com
>
> for doing the same output for n 0...100
>
> then why use the program "mazetest -v" if the output
> from 0..100 is the same of the example.com?
>
I think that's for the relaxed rules compo.
Current leader is 86 bytes.
http://temet.es/hcompo/
--
Nuns! Reverse!
yes, it seems i follow the rules of http://temet.es/hcompo/
i stop to 156 byte for entry.com now.
156-86= 70
Sorry. The rules may not specifically say that. We have
been doing this for many years, and it has just been a
given. Each compo much pass a test suite of some kind.
We have always had a test suite.
Also, we have had many discussion about the current and
previous compos on the forum and email list. Again,
sorry about that, but we usually don't get many new entrants.
However, I would bet that if you change your code to produce
the same random number as the example, it will pass the test.
Thanks,
Ben
; Costruttore di Labirinti
%define L 25
%define H 10
;%define L 97
;%define H 97
;%define L 10
;%define H 749
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
%define sopra (L+1)*6
%define sopra2 (L+1)*3
%define LineareMax 3*((L-1)+2*(L+1)*H)+1
%define passi (LineareMax-sopra-1)/3
org 100h
Start:
; ****************************
; *** Prende il numero with the help by Esra Sdrawkcab
; ****************************
; assumo che ax==0
i=081h|bl=' ' ; punta alla size riga comando
.0: aad 10 ; al+=10*ah e ah=0
ah=al
lodsb|al-=bl
bl='0' ; prima ' ' poi '0'
>=?#.0 ; o un char minore di '0'
al=ah ; ritorna numeri del tipo al:ah=n:n
*seed=a ; inizializza il seed per rand
; 21
; *******************************************
; *** Fa la griglia
; *******************************************
j=arr|c=BytesMemory
al=10|i=&*j+sopra|rep stosb ; tutto 10 [visitato] qui cx=0
j=&*i-sopra2|b=H21 |a="+-"|r="|N" ; le caselle NN: non visitate
.2: c=L ; altrimenti visitate
.3: stosw|B*j=ah|++j|loop .3|stosb|B*j=0Dh|++j|++j ; fa la linea
a<->r|--b#.2 ; passa alla linea successiva
B*j='$'|B*j-sopra2-3=07fh|B*i=02h ; ritorna in si la casella iniziale
; *******************************************
; *** Fa il labirinto
; *******************************************
; suppone all'ingresso che cx==0
; parte dalla casella puntata da si
++i ; punta all'interno della casella, dove c'e' 'N'
.4: W*i=" " ; " " significa visitata
.5: a=*seed|mul W*298 ; rand()
--a|*seed=a
aad 1 ; al=al+ah ed ah=0; valore casuale in al
cl=4 ; le caselle confinanti sono 4
.6: al&=03h ; al=0[sotto],1[alto],2[sinistra],3[destra]
j=a |k=a|b=*muro+j+k ; in bx offset del muro; se bp=2*bx-(al/2)
j>>=1|k=b|k+=b|k-=j ; => in bp offset della prossima casella
B*i+k=='N'#.a ; se tale casella non e' visitata va in .a
++a|loop .6 ; vai alla prossima casella
; ** caso le caselle sono tutte visitate
s>=0FFFEh#.z ; se lo stack e' vuoto esci[ e'in casella iniziale]
pop i ; altrimenti prende la casella precedente
#.5
%if BytesMemory>24000
.e: s=0FFFEh|ret ; nel caso di errore non stampa proprio niente:
; ritorna al DOS
%endif
.a: ; ** caso vi � una casella non visitata
W*i+b=" " ; leva il muro di divisione [ed eventualemente una N]
; che verra' in ogni caso levata dall'istruzione in .4
%if BytesMemory>24000
s<=fine#.e ; lo stack non puo' invadere questo file in memoria
%endif
push i
i+=k
#.4
.z: ; usa la casella iniziale in si e la ritorna
; ******************************
; *** Stampa sullo schermo
; ******************************
r=&*i-sopra2-1|ah=09h|int 21h ; usa si per stampare l'array
ret ; to Dos
align 2
; 0 1 2 3
muro dw sopra2, -sopra2, 2, -1
Section .bss
seed resw 1
arr resb BytesMemory
fine resb 512 ; for to be sure
-----------------
%define L 25
%define H 10
;%define L 97
;%define H 97
;%define L 10
;%define H 749
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
%define sopra (L+1)*6
%define sopra2 (L+1)*3
%define LineareMax 3*((L-1)+2*(L+1)*H)+1
%define passi (LineareMax-sopra-1)/3
org 100h
Start:
; ****************************
; *** Prende il numero with the help by Esra Sdrawkcab
; ****************************
; assumo che ax==0
mov si, 081h ; punta a fine riga o spazio
mov bl, ' '
.0: aad 10 ; al+=10*ah e ah=0
mov ah, al
lodsb
sub al, bl
mov bl, '0' ; prima ' ' poi '0'
jge .0 ; o un char minore di '0'
mov al, ah ; ritorna numeri del tipo al:ah=n:n
mov [seed], ax ; inizializza il seed per rand
; 21
; suppone all'ingresso che ch==0
; parte dalla casella puntata da si
inc si ; punta all'interno della casella, dove c'e' 'N'
.4: mov word[si], " " ; " " significa visitata
.5: mov ax, [seed]
mul word[298] ; rand()
dec ax
mov [seed], ax
aad 1 ; al=al+ah ed ah=0; valore casuale in al
mov cl, 4 ; le caselle confinanti sono 4
.6: and al, 03h ; al=0[sotto],1[alto],2[sinistra],3[destra]
mov di, ax
mov bp, ax
mov bx, [muro+di+bp] ; in bx offset del muro; se bp=2*bx-(al/2)
shr di, 1
mov bp, bx
add bp, bx
sub bp, di ; => in bp offset della prossima casella
cmp byte[si+bp], 'N'
je .a ; se tale casella non e' visitata va in .a
inc ax
loop .6 ; vai alla prossima casella
; ** caso le caselle sono tutte visitate
cmp sp, 0FFFEh
jae .z ; se lo stack e' vuoto esci[ e'in casella
iniziale]
pop si ; altrimenti prende la casella precedente
jmp short .5
%if BytesMemory>24000
.e: mov sp, 0FFFEh
ret ; nel caso di errore non stampa proprio niente:
; ritorna al DOS
%endif
.a: ; ** caso vi � una casella non visitata
; leva il muro di divisione [ed eventualemente una N]
mov word[si+bx], " "
; che verra' in ogni caso levata dall'istruzione in .4
%if BytesMemory>24000
cmp sp, fine
jbe .e ; lo stack non puo' invadere questo file in
memoria
%endif
push si
add si, bp
jmp short .4
.z: ; usa la casella iniziale in si e la ritorna
; ******************************
; *** Stampa sullo schermo
; ******************************
lea dx, [si-sopra2-1]
mov ah, 09h
int 21h ; usa si per stampare l'array
ret
align 2
Sorry. Still doesn't pass the test.bat test.
Thanks,
Ben
what to change for to past test0.bat?
change the random number generator, the association cell numbers 0..4,
the function that calculate from the wall the position,
and push/pop the current cell number (it should be 204 byte)
%define L 25
%define H 10
;%define L 97
;%define H 97
;%define L 10
;%define H 749
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
%define sopra (L+1)*6
%define sopra2 (L+1)*3
%define LineareMax 3*((L-1)+2*(L+1)*H)+1
%define passi (LineareMax-sopra-1)/3
org 100h
Start:
; ****************************
; *** Prende il numero with the help by Esra Sdrawkcab
; ****************************
; assumo che ax==0
mov si, 081h
mov bl, ' '
.0: aad 10 ; al+=10*ah e ah=0
mov ah, al
lodsb
sub al, bl
mov bl, '0' ; prima ' ' poi '0'
jge .0 ; o un char minore di '0'
mov [seed], ah ; inizializza il seed per rand
; *** Trova una casella casuale
; **************************************
; P(x,y)=i_inz+y*(L+1)*6+x*3
mov cx, L
call ran
mov di, dx
add di, dx
add di, dx ; x*3
mov cx, H
call ran
mov ax, sopra
mul dx ; y*(L+1)*6
add ax, di
add si, ax ; in si la casella iniziale del labirinto
; *******************************************
; *** Fa il labirinto
; *******************************************
; suppone all'ingresso che cx==0
; parte dalla casella puntata da si
inc si ; punta all'interno della casella, dove c'e' 'N'
.4: mov word[si], " " ; " " significa visitata
.5: mov cl, 4
call ran ; le caselle confinanti sono 4
.6: and dx, 03h ; dl=0[destra],1[basso],2[sinistra],3[alto]
mov di, dx
mov bp, dx
mov bx, [muro+di+bp] ; in bx offset del muro
not di
and di, 1
mov bp, bx
add bp, bx ; se bp=2*bx-(not(di)&1)
sub bp, di ; => in bp offset della prossima casella
cmp byte[si+bp], 'N'
je .a ; se tale casella non e' visitata va in .a
.7: inc dx
loop .6 ; vai alla prossima casella
; ** caso le caselle sono tutte visitate
cmp sp, 0FFFEh
jae .z
; se lo stack e' vuoto esci[ e'in casella iniziale]
pop dx
pop si ; altrimenti prende la casella precedente
mov cl, 4
jmp short .7
%if BytesMemory>24000
.e: mov sp, 0FFFEh
ret ; nel caso di errore non stampa proprio niente:
; ritorna al DOS
%endif
.a: ; ** caso vi � una casella non visitata
; leva il muro di divisione [ed eventualemente una N]
mov word[si+bx], " "
; che verra' in ogni caso levata dall'istruzione in .4
%if BytesMemory>24000
cmp sp, limite
jbe .e ; lo stack non puo' invadere questo file in memoria
%endif
push si
push dx
add si, bp
jmp short .4
.z:
; ******************************
; *** Stampa sullo schermo
; ******************************
lea dx, [arr+sopra2]
mov ah, 09h
int 21h ; usa si per stampare l'array
ret
; ritorna un numero 0..cx in dx
ran:
mov ax, 04e35h
imul word[seed]
inc ax
mov [seed], ax
shr ax, 8
xor dx, dx
idiv cx
ret
align 2
seed dw 0
;;
; +--+--+--+
; | |3 | |
; +--+--+--+
; | 2|NN|0 |
; +--+--+--+
; | |1 | |
; +--+--+--+
; dl=0[destra],1[basso],2[sinistra],3[alto]
;;
; 0 1 2 3
muro dw 2, sopra2, -1, -sopra2
Section .bss
arr resb BytesMemory
fine resb 512 ; for to be sure
limite resb 4
and to read the code in the example.asm :)
It passes!
A few simple savings given below
> %define L 25
> %define H 10
>
you don't need to worry that sp overflows, the mazes are all fixed and you
don't need to cater for large L and H
where you use LEA reg, [address]
use Mov reg, address
saves 1 byte each time
can mov cl,limit (limit<256) rather than mov cx,limit if ch=0 from
previous use.
saves 1
> ;%define L 97
> ;%define H 97
>
> ;%define L 10
> ;%define H 749
>
> %define BytesMemory ((L+1)*(H+2)*6)
> %define H21 (2*H+1)
>
> %define sopra (L+1)*6
> %define sopra2 (L+1)*3
>
> %define LineareMax 3*((L-1)+2*(L+1)*H)+1
> %define passi (LineareMax-sopra-1)/3
>
> org 100h
> Start:
> ; ****************************
> ; *** Prende il numero with the help by Esra Sdrawkcab
> ; ****************************
In the Rules it says we can't assume a cr at end of commandline, but in
General it does!
> ; assumo che ax==0
> mov si, 081h
> mov bl, ' '
> .0: aad 10 ; al+=10*ah e ah=0
> mov ah, al
> lodsb
> sub al, bl
> mov bl, '0' ; prima ' ' poi '0'
> jge .0 ; o un char minore di '0'
> mov [seed], ah ; inizializza il seed per rand
> ; *******************************************
> ; *** Fa la griglia
> ; *******************************************
> mov di, arr
> mov cx, BytesMemory
> mov al, 10
> lea si, [di+sopra]
this isn't needed until later, and can be a direct address, i.e .
mov si, arr+sopra
> rep stosb ; tutto 10 [visitato] qui cx=0
> lea di, [si-sopra2]
lea -> mov
this amount can be calculated at assembly time:
mov di, arr+sopra2, I think
> mov bx, H21
can we assume bh=0? I think so
mov bl,H21
> mov ax, "+-"
> mov dx, "|N" ; le caselle NN: non visitate
> .2: mov cx, L ; altrimenti visitate
as cx was 0 from above, you need only mov cl,L
> .3: stosw
> mov byte[di], ah
> inc di
> loop .3
> stosb
> mov byte[di], 0Dh
> inc di
> inc di ; fa la linea
> xchg ax, dx
> dec bx
> jnz .2 ; passa alla linea successiva
> mov byte[di], '$'
> mov byte[di-sopra2-3], 07fh
can be a direct memory address
> mov byte[si], 02h ; ritorna in si la casella iniziale
> ; **************************************
> ; *** Trova una casella casuale
> ; **************************************
> ; P(x,y)=i_inz+y*(L+1)*6+x*3
> mov cx, L
again cl rather than cx
> call ran
> mov di, dx
> add di, dx
> add di, dx ; x*3
> mov cx, H
cl not cx
is there no tidier way to exit?
> ; se lo stack e' vuoto esci[ e'in casella iniziale]
> pop dx
> pop si ; altrimenti prende la casella precedente
> mov cl, 4
> jmp short .7
> %if BytesMemory>24000
> .e: mov sp, 0FFFEh
> ret ; nel caso di errore non stampa proprio
> niente:
> ; ritorna al DOS
> %endif
%if.. %endif can be removed
> .a: ; ** caso vi ᅵ una casella non visitata
> ; leva il muro di divisione [ed eventualemente una N]
> mov word[si+bx], " "
> ; che verra' in ogni caso levata dall'istruzione in
> .4
> %if BytesMemory>24000
> cmp sp, limite
> jbe .e ; lo stack non puo' invadere questo file in
> memoria
> %endif
%if.. %endif can be removed
> push si
> push dx
> add si, bp
> jmp short .4
> .z:
> ; ******************************
> ; *** Stampa sullo schermo
> ; ******************************
> lea dx, [arr+sopra2]
mov
> mov ah, 09h
> int 21h ; usa si per stampare l'array
> ret
>
> ; ritorna un numero 0..cx in dx
> ran:
> mov ax, 04e35h
> imul word[seed]
> inc ax
> mov [seed], ax
> shr ax, 8
> xor dx, dx
> idiv cx
> ret
>
> align 2
is there a need to align?
> seed dw 0
> ;;
> ; +--+--+--+
> ; | |3 | |
> ; +--+--+--+
> ; | 2|NN|0 |
> ; +--+--+--+
> ; | |1 | |
> ; +--+--+--+
> ; dl=0[destra],1[basso],2[sinistra],3[alto]
> ;;
>
> ; 0 1 2 3
> muro dw 2, sopra2, -1, -sopra2
>
> Section .bss
> arr resb BytesMemory
> fine resb 512 ; for to be sure
> limite resb 4
>
>
>
>
--
Nuns! Reverse!
>
> where you use LEA reg, [address]
> use Mov reg, address
> saves 1 byte each time
I think this maybe a tiny bit of a lie.
Sorry.
--
Nuns! Reverse!
Yep, it does. I have added it to the list at
http://www.frontiernet.net/~fys/hugi/hcompo.htm
Thanks,
Ben
the below code assume that in 081h there is one
0dh (if the program has no argument)
or one space ' ' (if the program has some argument
and this is trust by the rules)
(it seems in the example.com there is some near to it)
if there is some arg, begin to read 082h
it end when find ' ' or 0dh
if that is the number < 255 it gets it right
if it is some other (eg. "entry w123") is UB
yes this is true because "lea si, [di+sopra]" seems here 4
but "mov si, arr+sopra" should be 3
>> rep stosb ; tutto 10 [visitato] qui cx=0
>> lea di, [si-sopra2]
> lea -> mov
> this amount can be calculated at assembly time:
> mov di, arr+sopra2, I think
this instead here have no gain
>> mov bx, H21
> can we assume bh=0? I think so
> mov bl,H21
>
>> mov ax, "+-"
>> mov dx, "|N" ; le caselle NN: non visitate
>> .2: mov cx, L ; altrimenti visitate
> as cx was 0 from above, you need only mov cl,L
>> .3: stosw
>> mov byte[di], ah
>> inc di
>> loop .3
>> stosb
>> mov byte[di], 0Dh
>> inc di
>> inc di ; fa la linea
>> xchg ax, dx
>> dec bx
>> jnz .2 ; passa alla linea successiva
>> mov byte[di], '$'
>> mov byte[di-sopra2-3], 07fh
> can be a direct memory address
and where is the gain?
thank you
it is 200 byte
;for hugi compo #29 - random mazes
;nasmw -o m.com m.asm
;>nasmw -v
; NASM version 0.98.38 compiled on Sep 12 2003
;;
; Una casella e' la seguente scrittura
; +--
; |XY
; quindi e' formata da 6 chars.
; N significa *non visitato*, se a posto di N ci sta un qualsiasi altro
; carattere significa visitato.
; +--+--+--+
; | |3 | |
; +--+--+--+
; | 2|NN|0 |
; +--+--+--+
; | |1 | |
; +--+--+--+
; L == lunghezza in caselle del rettangolo del labirinto
; H == altezza in caselle del rettangolo del labirinto
;;
%define L 25
%define H 10
; massimi valori
;%define L 85
;%define H 86
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
%define sopra (L+1)*6
%define sopra2 (L+1)*3
%define LineareMax 3*((L-1)+2*(L+1)*H)+1
%define passi (LineareMax-sopra-1)/3
org 100h
Start:
; ****************************
; *** Prende il numero with the help by Esra Sdrawkcab
; ****************************
; assumo che ax==0
mov si, 081h
mov bl, ' '
.0: aad 10 ; al+=10*ah e ah=0
mov ah, al
lodsb
sub al, bl
mov bl, '0' ; prima ' ' poi '0'
jge .0 ; o un char minore di '0'
mov [seed], ah ; inizializza il seed per rand
; *******************************************
; *** Fa la griglia
; *******************************************
mov di, arr
mov cx, BytesMemory
mov al, 10
rep stosb ; all\a
mov di, (arr+sopra2)
mov bx, H21
mov ax, "+-"
mov dx, "|N" ; le caselle NN: non visitate
.2: mov cx, L ; altrimenti visitate
.3: stosw
mov byte[di], ah
inc di
loop .3
stosb
mov byte[di], 13
inc di
inc di ; fa la linea
xchg ax, dx
dec bx
jnz .2 ; passa alla linea successiva
mov byte[di], '$'
mov byte[di-sopra2-3], 07fh
mov si, (arr+sopra)
mov byte[si], 02h ; ritorna in si la casella iniziale
; **************************************
; *** Trova una casella casuale
; **************************************
; P(x,y)=i_inz+y*(L+1)*6+x*3
mov cx, L
call ran
mov bx, dx
add bx, dx
add bx, dx ; x*3
mov cx, H
call ran
mov ax, sopra
mul dx ; y*(L+1)*6
add bx, ax
lea di, [si+bx] ; in di la casella iniziale del labirinto
; *******************************************
; *** Fa il labirinto
; *******************************************
; parte dalla casella puntata da di
inc di ; punta all'interno della casella, dove c'e' 'N'
.4: mov word[di], " " ; " " significa visitata
.5: mov cx, 4
call ran ; le caselle confinanti sono 4
.6: and dx, 03h ; dl=0[destra],1[basso],2[sinistra],3[alto]
mov si, dx
mov bp, dx
mov bx, [muro+si+bp]
; in bx offset del muro
; se bp=2*bx-(--(si&1)) => in bp offset della prossima casella
and si, 1
dec si
lea bp, [bx+si]
add bp, bx
cmp byte[di+bp], 'N'
je .a ; se tale casella non e' visitata va in .a
.7: inc dx
loop .6 ; vai alla prossima casella
; ** caso le caselle sono tutte visitate
cmp sp, 0FFFEh
jae .z ; se lo stack e' vuoto esci[ e'in casella iniziale]
pop dx
pop di ; altrimenti prende la casella precedente
mov cl, 4
jmp short .7
%if BytesMemory>24000
.e: mov sp, 0FFFEh
ret ; nel caso di errore non stampa esce al dos
; ritorna al DOS
%endif
.a:
; ** caso vi � una casella non visitata
mov word[di+bx], " "
; leva il muro di divisione [ed eventualemente una N]
; che verra' in ogni caso levata dall'istruzione in .4
%if BytesMemory>24000
cmp sp, limite
jbe .e
; lo stack non puo' invadere questo file in memoria
%endif
push di
push dx
add di, bp
jmp short .4
.z:
; ******************************
; *** Stampa sullo schermo
; ******************************
lea dx, [arr+sopra2]
mov ah, 09h
int 21h ; usa si per stampare l'array
ret
; ritorna un numero 0..cx in dx
ran:
mov ax, 04e35h
imul word[seed]
inc ax
mov [seed], ax
shr ax, 8
cwd
idiv cx
ret
align 2
seed dw 0
;;
; +--+--+--+
; | |3 | |
; +--+--+--+
; | 2|NN|0 |
; +--+--+--+
; | |1 | |
; +--+--+--+
; dl=0[destra],1[basso],2[sinistra],3[alto]
;;
; 0 1 2 3
muro dw 2, sopra2, -1, -sopra2
Section .bss
arr resb BytesMemory
fine resb 4
limite resb 4
Got it. It passes the test. Thanks.
Ben
backwardS arsE
> --
> Nuns! Reverse!
Indeed! The clue is in the sig!
I can hack your code down to 194 by using the dodgy number input that I
first posted:
mov si, 082h
gnpsp:
aad
mov ah, al
lodsb
sub al, '0'
jge gnpsp
mov [seed], ah ; 4 bytes
I had an idea last night, I'll see if it makes the code smaller or bigger.
--
Nuns! Reverse!
Bigger (just). curses!
--
Nuns! Reverse!
188
;;
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
; assumo che ax==0 bx=0
mov si, 081h
mov bl, ' '
.0: aad 10 ; al+=10*ah e ah=0
mov ah, al
lodsb
sub al, bl
mov bl, '0' ; prima ' ' poi '0'
jge .0 ; o un char minore di '0'
mov bl, ah ; inizializza il seed==bx per rand
; *******************************************
; *** Fa la griglia
; *******************************************
mov di, arr
mov cx, BytesMemory
mov al, 10
rep stosb ; all\a cx==0
mov di, (arr+sopra2)
mov bp, H21
mov ax, "+-"
mov dx, "|N"
.2: mov cl, L ; altrimenti visitate
.3: stosw
mov byte[di], ah
inc di
loop .3
stosb
mov byte[di], 13
inc di
inc di ; fa la linea
xchg ax, dx
dec bp
jnz .2 ; passa alla linea successiva
mov byte[di], '$'
mov byte[di-sopra2-3], 07fh
mov si, (arr+sopra)
mov byte[si], 02h ; ritorna in si la casella iniziale
; **************************************
; *** Trova una casella casuale
; **************************************
; P(x,y)=i_inz+y*(L+1)*6+x*3
mov cl, L
call ran
mov bp, dx
add bp, dx
add bp, dx ; x*3
mov cl, H
call ran
mov ax, sopra
mul dx ; y*(L+1)*6
add bp, ax
lea di, [si+bp] ; in di la casella iniziale del labirinto
; *******************************************
; *** Fa il labirinto
; *******************************************
; parte dalla casella puntata da di
inc di ; punta nella casella, dove c'e' 'N'
.4: mov word[di], " " ; " " significa visitata
.5: mov cl, 4
call ran ; le caselle confinanti sono 4
.6: and dx, byte 03h ; dl=0[dest.],1[basso],2[sini.],3[alto]
mov si, dx
mov bp, dx
mov bp, [muro+si+bp]
and si, byte 1
dec si
add si, bp
lea ax, [bp+di]
add si, ax ; B[k+k+j+i]=='N'
cmp byte[si], 'N'
je .a ; se tale casella non e' visitata va in .a
.7: inc dx
loop .6 ; vai alla prossima casella
; ** caso le caselle sono tutte visitate
cmp sp, 0FFFEh
jae .z ; se lo stack e' vuoto esci
pop dx
pop di ; altrimenti prende la casella precedente
mov cl, 4
jmp short .7
%if BytesMemory>24000
.e: mov sp, 0FFFEh
ret ; nel caso di errore non stampa proprio niente:
; ritorna al DOS
%endif
.a: ; ** caso vi � una casella non visitata
mov word[di+bp], " " ; leva il muro di divisione [ed forse una
N]
; che verra' in ogni caso levata in .4
%if BytesMemory>24000
cmp sp, limite
jbe .e ; lo stack non puo' invadere la memoria
%endif
push di
push dx
mov di, si
jmp short .4
.z:
; ******************************
; *** Stampa sullo schermo
; ******************************
mov dx, (arr+sopra2)
mov ah, 09h
int 21h
ret
; ritorna un numero 0..cx in dx
ran:
mov ax, 04e35h
imul bx
inc ax
mov bx, ax
shr ax, 8
cwd
idiv cx
ret
align 2
;;
; +--+--+--+
; | |3 | |
; +--+--+--+
; | 2|NN|0 |
; +--+--+--+
; | |1 | |
; +--+--+--+
; dl=0[destra],1[basso],2[sinistra],3[alto]
;;
; 0 1 2 3
muro dw 2, sopra2, -1, -sopra2
Section .bss
arr resb BytesMemory
fine resb 128
limite resb 4
>
> "io_x" <a...@b.c.invalid> ha scritto nel messaggio
> news:4acc66f1$0$1100$4faf...@reader3.news.tin.it...
>>
>> "io_x" <a...@b.c.invalid> ha scritto nel messaggio
>> news:4ac5c7f6$0$1106$4faf...@reader4.news.tin.it...
>>> http://www.frontiernet.net/~fys/hugi/hcompo.htm
>>
>> it is 200 byte
>
> 188
[snipped]
> ; *******************************************
> ; *** Fa la griglia
> ; *******************************************
Could you save some here by not filling the maze at start, but adding crlf
as you go?
(add 3 bytes)
mov si,0A0dh
(delete these 4 lines, 10 bytes)
> mov di, arr
> mov cx, BytesMemory
> mov al, 10
> rep stosb ; all\a cx==0
> mov di, (arr+sopra2)
> mov bp, H21
> mov ax, "+-"
> mov dx, "|N"
> .2: mov cl, L ; altrimenti visitate
> .3: stosw
> mov byte[di], ah
> inc di
> loop .3
> stosb
(delete these 3 lines 4 bytes)
> mov byte[di], 13
> inc di
> inc di ; fa la linea
but adding crlf here?
(add 3 lines 3 bytes)
xchg ax,si ; si not used yet, make it crlf
stosw ; add crlf, 2*inc di
xchg ax,si ;put back
> xchg ax, dx
> dec bp
> jnz .2 ; passa alla linea successiva
> mov byte[di], '$'
> mov byte[di-sopra2-3], 07fh
> mov si, (arr+sopra)
> mov byte[si], 02h ; ritorna in si la casella iniziale
initialise maze is now 2C bytes =44d
Nuns! Reverse!
arr
x----------------------------+
x-------------------------+ |
arr+sopra | |
| |
| |
--------------------------+ |
-----------------------------+
what you say is right if and ony if
in the border of that rectangle
there is no 'N' char [that mean "not visit"]
If it is certain that in a .bss section
memory there is no 'N' all is ok
for example "debug" show that all memory in .bss
section are only \0s
3+3=6
this should be 6 too:
mov word [di], 0a0dh ; +4
inc di ; +1
inc di ; +1
Aw...
I have two issues with that.
The first was how I can submit my entry without having email access, which
Ben and I discussed, but didn't completely resolve...
The second was that due to life and time constraints, I'm not sure if I'm
going to complete my entry. So, I was considering posting the smallest of
what I did do here so that perhaps io_x and Esra could team up and use it to
come up with a slightly smaller entry. I'm not going to post the 30+
display routines I've attempted, even though one of them may optimize
better... I'm missing the central ConFrom and ChkCell routines. So, it's
only likely they'll be able to shave a few bytes, if any. Even with my
code, I think it's very unlikely anyone will approach the size you currently
have... And, of course, you could use to keep your lead, if necessary...
Current size 98+(unknown):
40 bytes display routine
10 bytes entry + exit character
17 bytes random routine
13 bytes parameter routine
3 bytes move parameter to seed
15 bytes to setup initial x and y
(unknown) ConFrom
(unknown) ChkCell
Any takers? Comments from the judge?
Rod Pemberton
io_x has published all (AFAIK) his code here, I've chipped in a few not
very ground-breaking suggestions. He's still a long way from 150 bytes let
alone 130 odd.
--
Nuns! Reverse!
179
%define L 25
%define H 10
; massimi valori
;%define L 85
;%define H 86
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
%define sopra (L+1)*6
%define sopra2 (L+1)*3
org 100h
Start:
mov di, arr
mov ch, (BytesMemory>>8)
rep stosb ; all 0 cx==0 [7]
; ****************************
; *** Prende il numero with the help by Esra Sdrawkcab
; ****************************
; assumo che ax==0 bx=0
mov si, 081h
mov bl, ' '
.0: aad 10 ; al+=10*ah e ah=0
mov ah, al
lodsb
sub al, bl
mov bl, '0' ; prima ' ' poi '0'
jge .0 ; o un char minore di '0'
mov bl, ah ; inizializza il seed==bx per rand
; *******************************************
; *** Fa la griglia
; *******************************************
mov di, (arr+sopra2)
mov bp, H21
mov ax, "+-"
mov dx, "|N"
push di ; conserva per la stampa
.2: mov cl, L ; altrimenti visitate
.3: stosw
mov byte[di], ah
inc di
loop .3
stosb
mov word[di], 0a0dh
inc di
inc di ; fa la linea
xchg ax, dx
dec bp
jnz .2 ; passa alla linea successiva
mov byte[di], '$'
mov byte[di-sopra2-3], 07fh
mov di, (arr+sopra)
mov byte[di], 02h ; ritorna in si la casella iniziale
; **************************************
; *** Trova una casella casuale
; **************************************
; P(x,y)=j_inz+y*(L+1)*6+x*3
mov cl, L
call ran
imul bp, dx, byte 3 ; x*3
mov cl, H
call ran
imul si, dx, sopra ; y*(L+1)*6
add di, si
add di, bp ; in di la casella iniziale
; *******************************************
; *** Fa il labirinto
; *******************************************
; parte dalla casella puntata da di
inc di ; punta nella casella, dove c'e' 'N'
.4: mov word[di], " " ; " " significa visitata
.5: mov cl, 4
call ran ; le caselle confinanti sono 4
.6: mov si, 3 ; dl=0[destra],1[basso], 2[sinistra],3[alto]
and dx, si
test dl, 1
jz .6a
mov si, sopra ; 3 ,sopra ,-3 ,-sopra
.6a: mov bp, si
shr bp, 1 ; pb=offset muro, si=offset next
cmp dl, 1
jbe .6b
neg bp
neg si
.6b: add si, di
cmp byte[si], 'N'
je .a ; se tale casella non e' visitata va in .a
.7: inc dx
loop .6 ; vai alla prossima casella
; ** caso le caselle sono tutte visitate
cmp sp, 0FFFCh
pop dx
mov ah, 09h
int 21h
ret
; ritorna un numero 0..cx in dx
ran:
mov ax, 04e35h
imul bx
inc ax
xchg ax, bx
movzx ax, bh
cwd
idiv cx
ret
Section .bss
arr resb BytesMemory
fine resb 128 ; stack riservato al MSDOS
limite resb 4
Hi Rod
You can use a FTP server, web upload, etc... but I think the easy
way is open a free account at gmail.com, yahoo.com or hotmail.com. Or
use the email of a friend.
> The second was that due to life and time constraints, I'm not sure if I'm
> going to complete my entry. So, I was considering posting the smallest of
> what I did do here so that perhaps io_x and Esra could team up and use it to
> come up with a slightly smaller entry. I'm not going to post the 30+
> display routines I've attempted, even though one of them may optimize
> better... I'm missing the central ConFrom and ChkCell routines. So, it's
> only likely they'll be able to shave a few bytes, if any. Even with my
> code, I think it's very unlikely anyone will approach the size you currently
> have... And, of course, you could use to keep your lead, if necessary...
It's a pity that you can't complete your entry. As I can see you are
very close to finish. Also you can participate as a group, in earlier
compos there was a common way.
But if you, io_x and company post all your code here it's a free
help for the other participants. Perhaps doesn't affect to the top 4
or 5 in the ranking, but I think It's a good entry and making
optimizations can squeeze easily 10 or 20 bytes. The aim of this compo
is mantain the code secret until ends.
>
> Current size 98+(unknown):
> 40 bytes display routine
> 10 bytes entry + exit character
> 17 bytes random routine
> 13 bytes parameter routine
> 3 bytes move parameter to seed
> 15 bytes to setup initial x and y
> (unknown) ConFrom
> (unknown) ChkCell
>
> Any takers? Comments from the judge?
Good size. Excelent 13 bytes parameter routine, mine is 15.
>
> Rod Pemberton
Yes. I know it's an "amateur" entry. It's only a suggestion.
Probably it's difficult that the rest of the participants read this
group. I have found googling "hugi compo 29". So I think with some
easy improvements can be under 160 bytes.
>
> --
> Nuns! Reverse!
Good job io_x. A basic optimization is that you can sum 2 to di with
one byte, by scasw (or cmpsw). I suggest you create a group and
discussing by email or in a private forum. You have a good structure
with many possibilies of saving bytes, so your code can reach 160
bytes.
Regards
Antonio Villena
I'm not so sure about that. The equivalent of a ConFrom routine as I'm
trying to implement it is huge. And, it will radically change the display
routine I need... more bloat. I'll have to come up with something
different. I just coded another display routine that works by a different
method. It's adds few bytes currently but isn't fully optimized. It may be
more suitable for use with the ConFrom routine. If I can ever get that
routine working and finished... I may have spent too much time working on
the display routines.
> > Current size 98+(unknown):
> > 40 bytes display routine
> > 10 bytes entry + exit character
> > 17 bytes random routine
> > 13 bytes parameter routine
> > 3 bytes move parameter to seed
> > 15 bytes to setup initial x and y
> > (unknown) ConFrom
> > (unknown) ChkCell
> >
> > Any takers? Comments from the judge?
>
> Good size. Excelent 13 bytes parameter routine, mine is 15.
Hmm, ok, let me recheck my count. Yes, 13 bytes parameter + 3 bytes move
result to "seed". Except for the move to seed, it's basically the same
routine as posted by io_x in the "first argument for a .com program" on
9/29. It's slightly different as mentioned in that thread. The 13 byte
version has one change that developed due to other code... Is your random
routine smaller or larger?
Rod Pemberton
io_x's (179) entry is
18 getseed
45 set full maze
+7 clear display area
21 set initial posn
68 DFE
6 print & exit
14 RNG
--
Nuns! Reverse!
http://hcompo.temet.es/forum/viewtopic.php?f=5&t=19&start=0#p94
I've thought of a different way of represnting the grid - but my code is
now
260 bytes. Oops.
>
>>
>> --
>> Nuns! Reverse!
>
--
Nuns! Reverse!
< Yes. I know it's an "amateur" entry.
yes "amateur"
>
> "Espineter" <espi...@gmail.com> ha scritto nel messaggio
> news:82ef3ca7-45dc-44e8...@g31g2000yqc.googlegroups.com...
> <On Oct 11, 12:10 pm, "Esra Sdrawkcab" <ad...@127.0.0.1> wrote:
>> On Sun, 11 Oct 2009 02:20:07 +0100, Espineter <espine...@gmail.com>
>> wrote:
>> > Hi
>> > Please don't reveal internal secrets of your entry. People can read
>> > this public group and:
>> > -They can rewrite this code, and position before you only with a byte
>> > improvement of this code.
>> > -Also is possible extract ideas that can be applied in his entries
>>
>> io_x has published all (AFAIK) his code here, I've chipped in a few not
>> very ground-breaking suggestions. He's still a long way from 150 bytes
>> let
>> alone 130 odd.
>
> < Yes. I know it's an "amateur" entry.
>
> yes "amateur"
>
Is this because it doesn't use 32bit registers?
> <It's only a suggestion.
> <Probably it's difficult that the rest of the participants read this
> <group. I have found googling "hugi compo 29". So I think with some
> <easy improvements can be under 160 bytes.
>
I had another idea last night but it saved -18 bytes (i.e. increased size).
--
Nuns! Reverse!
I had one idea too see the code and debug code
in hugi compo 11 (the maze solver) but all this
has allow me to gain only 2-4 bytes
thanks. I'll take a look. can I email you privately with the ideas I had?
to save the hardcore competition players from worrying that I'm giving too
much away?
>
--
Nuns! Reverse!
no; i not agree on what Sir Espineter says
it is all right all remain one secret until the end of the competition
it is all right each one of us has secrets until the end of the competition.
it is all right too, all goes to public so anyone can see.
I don't have a problem sharing.
> it is all right too, all goes to public so anyone can see.
>
I'm a bit confused as to your position on this; anyway for what it's
worth, my idea was to have a minimaze;
+-+-+...cr
|N|N|...cr
+-+-+...cr
then create path, this makes finding the wall and floor easier (cell is at
2x, wall/flr is at x)
(x=-1,+1,-row,+row), then print using
mov cx,(2*rows+1)*(cols+1)/2
expandmaze:
lodsw ; "+-" or "wall blank"
stosw
cmp al,cr ; expand cr to crlf
jne addone
mov al,lf
addone:
stosb ; otherwise duplicate floor or blank cell
loop expandmaze
but it didn't give enough saving in the find flr/wall
--
Nuns! Reverse!
this above way [maze like cell of 6 chars] seems too long; i now try:
a maze is one array where each cell is just one char
> then create path, this makes finding the wall and floor easier (cell is at
> 2x, wall/flr is at x)
> (x=-1,+1,-row,+row), then print using
yes
> mov cx,(2*rows+1)*(cols+1)/2
> expandmaze:
> lodsw ; "+-" or "wall blank"
> stosw
> cmp al,cr ; expand cr to crlf
> jne addone
> mov al,lf
> addone:
> stosb ; otherwise duplicate floor or blank cell
> loop expandmaze
don't know
I tried that but gave up when I found I was having too many bit
operations; such as:
lodsb
mov dl,al ; save
or al,3 ; test for connected
jnz
...
shr dl,1 ; for floor etc
still, good luck!
>
>> then create path, this makes finding the wall and floor easier (cell is
>> at
>> 2x, wall/flr is at x)
>> (x=-1,+1,-row,+row), then print using
>
> yes
>
>> mov cx,(2*rows+1)*(cols+1)/2
>> expandmaze:
>> lodsw ; "+-" or "wall blank"
>> stosw
>> cmp al,cr ; expand cr to crlf
>> jne addone
>> mov al,lf
>> addone:
>> stosb ; otherwise duplicate floor or blank cell
>> loop expandmaze
>
> don't know
>
>>
>> but it didn't give enough saving in the find flr/wall
>>
>> --
>> Nuns! Reverse!
>
>
--
Nuns! Reverse!
>
> "io_x" <a...@b.c.invalid> wrote in message
> news:4acc66f1$0$1100$4faf...@reader3.news.tin.it...
>>
>> "io_x" <a...@b.c.invalid> ha scritto nel messaggio
>> news:4ac5c7f6$0$1106$4faf...@reader4.news.tin.it...
>>> http://www.frontiernet.net/~fys/hugi/hcompo.htm
>>
>> it is 200 byte
>>
>
> Got it. It passes the test. Thanks.
> Ben
>
>
I haven't seen io_x post recently, so I'd like to submit a slight
improvement (174 bytes) on his behalf
(from the headers and his comments, I'm fairly sure he's from Italy)
is your email address the correct one to send entries to?
--
Nuns! Reverse!
Remove the zzzz's and it will be correct.
Thanks,
Ben
>
> "Esra Sdrawkcab" <ad...@127.0.0.1> wrote in message
> news:op.u2h8zln7hswpfo@dell3100...
>> On Thu, 08 Oct 2009 01:17:06 +0100, Benjamin David Lunt
>> <zf...@frontiernet.net> wrote:
[]
>> I haven't seen io_x post recently, so I'd like to submit a slight
>> improvement (174 bytes) on his behalf
I've trimmed it down a bit more, by risking that the unallocated space
doesn't have any 'N's in critical spots, and a couple of tweaks.
I've submitted it to Ben.
--
Nuns! Reverse!
15 bytes.
(seems I already registered my email address, but I can't remember my
name!)
169bytes is the limit for me
i tought that no one would compete with me in a game like
that instead it is all false ...
I was trying to help not compete!
I'm interested to see how the other guys squeeze it to <128 bytes!
--
Nuns! Reverse!
....
>> 169bytes is the limit for me
>> i tought that no one would compete with me in a game like
>> that instead it is all false ...
> I was trying to help not compete!
> I'm interested to see how the other guys squeeze it to <128 bytes!
Even I used BX=80h as a pointer into PSP (for variables) and also for
code offset 0100..017fh for selfmodified stuff, I gave up on this trial,
I'm perhaps always too much concerned about speed,
so I failed to create any short version in time.
A trick could be to reduce the algo routine to it's final behaviour ?
Anyway congrats to Rosario for he could reduce his first >380 bytes
to less than half.
__
wolfgang
http://www.frontiernet.net/~fys/hugi/hcompo.htm
Thank you,
Ben
Wow! io_x came in ninth. Congratulations!
Best,
Frank
here espineter enter print nothing ...
yes io_x is 169bytes all ok.
what about the Rosario last version?
(sent to f...@frontiernet.net on 31/10/2009 9:15 here time)
;for hugi compo #29 - random mazes - 169 bytes
;nasmw -o m.com m.asm
;>nasmw -v
; NASM version 0.98.38 compiled on Sep 12 2003
;;
; Una casella e' la seguente scrittura
; +--
; |XY
; quindi e' formata da 6 chars.
; A significa *non visitato*, se a posto di A ci sta un qualsiasi altro
; carattere significa visitato.
; +--+--+--+
; | |3 | |
; +--+--+--+
; | 2|AA|0 |
; +--+--+--+
; | |1 | |
; +--+--+--+
; L == lunghezza in caselle del rettangolo del labirinto
; H == altezza in caselle del rettangolo del labirinto
;;
%define L 25
%define H 10
; massimi valori
;%define L 40
;%define H 40
%define BytesMemory ((L+1)*(H+2)*6)
%define H21 (2*H+1)
%define sopra (L+1)*6
%define sopra2 (L+1)*3
org 100h
Start:
; ****************************
; *** Prende il numero with the help by Esra Sdrawkcab
; ****************************
mov si, 081h
mov bl, ' ' ; bx==0 and ax=0
.0: aad 10 ; al=al+10*ah e ah=0
mov ah, al
lodsb
sub al, bl
mov bl, '0' ; prima ' ' poi '0'
jge .0
mov bl, ah ; inizializza il seed==bx per rand
; *******************************************
; *** Fa la griglia
; *******************************************
mov di, arr
mov bp, H21
mov ax, "+-"
mov dx, "||"
push di ; conserva per la stampa
.2: mov cl, L ; altrimenti visitate
.3: stosw
mov byte[di], ah
inc di
loop .3
stosb
mov word[di], 0a0dh
scasw ; fa la linea
xchg ax, dx
dec bp
jnz .2 ; passa alla linea successiva
mov byte[di], '$'
mov byte[di-sopra2-3], 07fh
xchg ax, si
xchg ax, cx
inc di
rep stosw ; 40x2=80 < 082h
; **************************************
; *** Trova una casella casuale
; **************************************
; P(x,y)=j_inz+y*(L+1)*6+x*3
mov cl, L
call ran
imul bp, dx, byte 3 ; x*3
mov cl, H
call ran
imul ax, dx, sopra ; y*(L+1)*6
mov di, (arr+sopra2)
mov byte[di], 02h
add ax, bp
add di, ax
; *******************************************
; *** Fa il labirinto
; *******************************************
inc di
.4: mov word[di], " " ; " " significa visitata
.5: mov cl, 4
call ran ; le caselle confinanti sono 4
.6: and dl, 3 ; dl=0[destra],1[basso], 2[sinistra],3[alto]
mov bp, dx
mov al, [muro+bp]
cbw
imul bp, ax, byte 2
test dl, 1
jnz .6b
dec bp
.6b: cmp word[di+bp], si
je .a ; se tale casella non e' visitata va in .a
.7: inc dx
loop .6 ; vai alla prossima casella
; ** caso le caselle sono tutte visitate
cmp sp, 0FFFCh
jae .z ; se lo stack e' vuoto esci
pop dx
pop di ; altrimenti prende la casella precedente
mov cl, 4
jmp short .7
%if BytesMemory>24000
.e: int 20h ; nel caso di errore non stampa proprio niente:
; ritorna al DOS
%endif
.a: ; ** caso vi � una casella non visitata
xchg ax, bp
mov word[di+bp], " " ; leva il muro di divisione
%if BytesMemory>24000
cmp sp, limite
jbe .e ; lo stack non puo' invadere la memoria
%endif
push di
push dx
add di, ax
jmp short .4
.z:
; ******************************
; *** Stampa sullo schermo
; ******************************
pop dx
mov ah, 09h
int 21h
ret
; ritorna un numero 0..cx in dx
ran:
imul bx, bx, 04e35h
inc bx
movzx ax, bh
cwd
idiv cx
ret
muro db 2, sopra2, -1, -sopra2
Section .bss
arr resb BytesMemory
fine resb 128 ; stack riservato al MSDOS
limite resb 4
> --
> Nuns! Reverse!
120? 120! Wow. I guess I'll looking at his code as soon as I get a
chance. Congrats Espineter!
Rod Pemberton
Bah, pipped by Flyke at the last minute!
(and there was an easy "delete of the <re>" after printing" to be had.)
--
Nuns! Reverse!
>
> Esra Sdrawkcab in discussion with Rosario:
>
> ....
>
>>> 169bytes is the limit for me
>>> i tought that no one would compete with me in a game like
>>> that instead it is all false ...
>
>> I was trying to help not compete!
>
>> I'm interested to see how the other guys squeeze it to <128 bytes!
>
> Even I used BX=80h as a pointer into PSP (for variables) and also for
> code offset 0100..017fh for selfmodified stuff, I gave up on this trial,
> I'm perhaps always too much concerned about speed,
> so I failed to create any short version in time.
>
> A trick could be to reduce the algo routine to it's final behaviour ?
>
I can't see how you'd do that.
> Anyway congrats to Rosario for he could reduce his first >380 bytes
> to less than half.
>
Indeed.
So, the obvious next competition is to do Pacman!
--
Nuns! Reverse!
This one did not make it to my inbox. Was the 9:15 above
am or pm. Either way, it did not show in my inbox.
Ben
P.S. Please don't post valid email addresses. Obscure them
in one form or another. Thanks.
> I can't see how you'd do that.
Me neither :) it was just an idea because only two bits were used ...
>> Anyway congrats to Rosario for he could reduce his first >380 bytes
>> to less than half.
> Indeed.
> So, the obvious next competition is to do Pacman!
:) or have the ghost moving trough the maze.
Well done Esra, jump into instructions were my favorites as well.
__
wolfgang
>
> Esra wrote:
> ...
>>> A trick could be to reduce the algo routine to it's final behaviour ?
>
>> I can't see how you'd do that.
>
> Me neither :) it was just an idea because only two bits were used ...
>
Well yes for moving, but you still need it for setting the start position.
>>> Anyway congrats to Rosario for he could reduce his first >380 bytes
>>> to less than half.
>
>> Indeed.
>
>> So, the obvious next competition is to do Pacman!
>
> :) or have the ghost moving trough the maze.
>
> Well done Esra, jump into instructions were my favorites as well.
Eh? Don't think it was me doing that.
>
> __
> wolfgang
>
>
>
--
Nuns! Reverse!
it is 9:15 am
in my sent box (directory of "posta inviata") in outlool express
result 4 post i sent to that address
in what i see/remember
30/09/2009 19:01 (this was an error .com file because not past the test0)
01/10/2009 10:53
29/10/2009 13:15
31/10/2009 9:15
> Ben
>
> P.S. Please don't post valid email addresses. Obscure them
> in one form or another. Thanks.
sorry i forget about it; hope this is not a big problem
Sorry, for some reason, this email did not make it to my
inbox. Maybe it didn't pass my spam blocker.
Anyway, I have now included it with the results.
Sorry about that,
Ben
just disassemble your own entry.com to see what I mean :)
__
wolfgang
Do you mean ye olde "debug" doesn't know about some newer opcodes?
"My" entry was io_x's "table-less" entry with a couple of minor savings.
--
Nuns! Reverse!
it is "Aphex" entry.com that do it, something like
add ax, 2989h ;ax=99C
org $-2
dfs: mov [bx+di], bp ;clear wall
rng: imul bx, [si], 4E35h ;*=4E35 (large prime)
inc bx ;+=1
...
mov cl, 2 ;cx=2 to continue DFS
je dfs ;if cell empty then move
in what i see in the disassembly it is like
mov ax, 2989h
contain
mov [bx+di], bp
in the last 2 bytes
and the "je dfs" jmp in the last 2 bytes of "mov ax, 2989h"
i think i'm not be smart enought for understand the 1 entry.com
it will be interesting a compo for the speed (because it seems it is
the speed the problem and not the size)
or someone could be get one OS break it in 20 - 30 parts
do 20 30 compo and glue them all for doing the smallest(fastest) OS
ever seen :)
the lesson for this compo is that
imul reg, reg, imm
is good because it does 2 operations:
1) does multiplication
2) assign to one register not [e]ax
>>>> Well done Esra, jump into instructions were my favorites as well.
>>> Eh? Don't think it was me doing that.
>> just disassemble your own entry.com to see what I mean :)
> Do you mean ye olde "debug" doesn't know about some newer opcodes?
> "My" entry was io_x's "table-less" entry with a couple of minor savings.
No, I meant:
db 0B5h
Label:
;followed by
PUSH imm16
;disassembles to
MOV CH,68h
; and there's more of this in your code ...
when you jump to 'Label', that's infact inside one instruction
meaning another one then.
this trick were often seen to confuse disassemblers,
but real hackers may figure this on a glimpse ...
__
wolfgang
I think you have the wrong guy; I'm not up to this kind of stuff!
see above; I just tweaked io_x's code a bit; it seems the code I submitted
was the last accepted, even though io_x submitted different code of the
same size later.
where is that?
there is no jump-call inside one instruction
(at last for what the disassembly show)
----------
00000000 BFAC01 mov di,0x1ac
00000003 B507 mov ch,0x7
00000005 F3AA rep stosb
00000007 BE5D00 mov si,0x5d
0000000A D50A aad
0000000C 88C4 mov ah,al
0000000E AC lodsb
0000000F 2C30 sub al,0x30
00000011 7DF7 jnl 0xa
00000013 88E3 mov bl,ah
00000015 BFFA01 mov di,0x1fa
00000018 BE1500 mov si,0x15
0000001B B82B2D mov ax,0x2d2b
0000001E BA7C4E mov dx,0x4e7c
00000021 57 push di
00000022 B119 mov cl,0x19
00000024 AB stosw
00000025 8825 mov [di],ah
00000027 47 inc di
00000028 E2FA loop 0x24
0000002A AA stosb
0000002B C7050D0A mov word [di],0xa0d
0000002F AF scasw
00000030 92 xchg ax,dx
00000031 4E dec si
00000032 75EE jnz 0x22
00000034 C60524 mov byte [di],0x24
00000037 C645AF7F mov byte [di-0x51],0x7f
0000003B BF4802 mov di,0x248
0000003E B002 mov al,0x2
00000040 AA stosb
00000041 B119 mov cl,0x19
00000043 E85500 call 0x9b
00000046 6BEA03 imul bp,dx,byte +0x3
00000049 01EF add di,bp
0000004B B10A mov cl,0xa
0000004D E84B00 call 0x9b
00000050 69EA9C00 imul bp,dx,word 0x9c
00000054 01EF add di,bp
00000056 C7052020 mov word [di],0x2020
0000005A B104 mov cl,0x4
0000005C E83C00 call 0x9b
0000005F BD0300 mov bp,0x3
00000062 21EA and dx,bp
00000064 F6C201 test dl,0x1
00000067 7403 jz 0x6c
00000069 BD9C00 mov bp,0x9c
0000006C 80FA01 cmp dl,0x1
0000006F 7602 jna 0x73
00000071 F7DD neg bp
00000073 803B4E cmp byte [bp+di],0x4e
00000076 740F jz 0x87
00000078 42 inc dx
00000079 E2E4 loop 0x5f
0000007B 81FCFCFF cmp sp,0xfffc
0000007F 7314 jnc 0x95
00000081 5A pop dx
00000082 5F pop di
00000083 B104 mov cl,0x4
00000085 EBF1 jmp short 0x78
00000087 57 push di
00000088 52 push dx
00000089 89E8 mov ax,bp
0000008B D1FD sar bp,1
0000008D C7032020 mov word [bp+di],0x2020
00000091 01C7 add di,ax
00000093 EBC1 jmp short 0x56
00000095 5A pop dx
00000096 B409 mov ah,0x9
00000098 CD21 int 0x21
0000009A C3 ret
0000009B B8354E mov ax,0x4e35
0000009E F7EB imul bx
000000A0 40 inc ax
000000A1 93 xchg ax,bx
000000A2 0FB6C7 movzx ax,bh
000000A5 99 cwd
000000A6 F7F9 idiv cx
000000A8 C3 ret
---------------------------
for the program "debug" seems it have some problem in
the disassembly of some code
for example the program "debug" print (using -u)
15AE:013E B002 MOV AL,02
15AE:0140 AA STOSB
15AE:0141 B119 MOV CL,19
15AE:0143 E85500 CALL 019B
15AE:0146 6B DB 6B
15AE:0147 EA0301EFB1 JMP B1EF:0103
15AE:014C 0AE8 OR CH,AL
15AE:014E 4B DEC BX
for the same piece of code "ndisasmw" says
0000003E B002 mov al,0x2
00000040 AA stosb
00000041 B119 mov cl,0x19
00000043 E85500 call 0x9b
00000046 6BEA03 imul bp,dx,byte +0x3
00000049 01EF add di,bp
0000004B B10A mov cl,0xa
0000004D E84B00 call 0x9b
00000050 69EA9C00 imul bp,dx,word 0x9c
00000054 01EF add di,bp
so it is like "debug" program not recognice the instruction
imul bp,dx,byte +0x3
only for print (it execute it good)
>>>>>> Well done Esra, jump into instructions were my favorites as well.
>>>>> Eh? Don't think it was me doing that.
>>>> just disassemble your own entry.com to see what I mean :)
>>> Do you mean ye olde "debug" doesn't know about some newer opcodes?
>>> "My" entry was io_x's "table-less" entry with a couple of minor savings.
Sorry for I assumed you 'are' Espineter :)
;Espineter from Spain 120 bytes official hc29 compo (nasm entry.asm -o
entry.com)
org 256
db -52+1 ;2nd table value, 1st at 00FF is -1+1=0
db 1+1 ;3rd table value, 4th is 52+1 (xor ax,imm
opcode)
xor ax,'-+' ;init AX to '+' and '-' chars
db 0B5h ;mov ch,68h
main0 push 0D0Ah ;reset some memory (with CRLF) before and after
the maze
loop main0
__
wolfgang
...
> so it is like "debug" program not recognice the instruction
> imul bp,dx,byte +0x3
> only for print (it execute it good)
Apparently, DEBUG still only knows 8086 instructions. Only the
single-operand form of imul was supported. The three-operand form (the
two-operand form is a special case of the three-operand form) was
apparently introduced in the 80186 (286, for practical purposes - 186's
are rare).
David Lindauer has written a debugger - like DEBUG, but (much!) brighter...
http://home.myfairpoint.net/fbkotler/grdbdl94.zip
Open source, too!
Best,
Frank
...
>> so it is like "debug" program not recognice the instruction
>> imul bp,dx,byte +0x3
>> only for print (it execute it good)
> Apparently, DEBUG still only knows 8086 instructions. Only the
> single-operand form of imul was supported. The three-operand form (the
> two-operand form is a special case of the three-operand form) was
> apparently introduced in the 80186 (286, for practical purposes - 186's
> are rare).
Yeah.
> David Lindauer has written a debugger - like DEBUG, but (much!)
brighter...
>
> http://home.myfairpoint.net/fbkotler/grdbdl94.zip
>
> Open source, too!
Thanks Frank, I couldn't refuse to check on it, but this .zip
seems to be corrupted or I missed a rename-hint(tarball) ?
__
wolfgang
On Nov 6, 12:26 am, Frank Kotler <fbkot...@myfairpoint.net> wrote:
>
> Apparently, DEBUG still only knows 8086 instructions.
MS debug, yes. Other DOSes (DR-DOS, FreeDOS) have improved debuggers
that support much more. (I find it funny that MS hates DOS now but
still includes debug and edlin, heh, even in my Vista).
http://www.japheth.de/debxxf.html
> Only the single-operand form of imul was supported. The three-operand
> form (the two-operand form is a special case of the three-operand form)
> was apparently introduced in the 80186 (286, for practical purposes - 186's
> are rare).
I can only guess that NEC V20/V30 are more common.
> David Lindauer has written a debugger - like DEBUG, but (much!) brighter...
>
> http://home.myfairpoint.net/fbkotler/grdbdl94.zip
>
> Open source, too!
Even though development has halted, he still hosts a mirror online of
his files, both for CC386 and GRDB (whose latest version is 9.6,
BTW). ;-)
http://ladsoft.tripod.com/grdb.htm
http://members.tripod.com/~ladsoft/dos/grdbdl96.zip
http://ladsoft.tripod.com/grdb.htm
http://members.tripod.com/~ladsoft/dos/grdbdl96.zip
got that and I'll give it a try, thanks.
__
wolfgang