Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

hugi compo #29- random mazes - how reduce size of this

2 views
Skip to first unread message

io_x

unread,
Oct 2, 2009, 5:36:20 AM10/2/09
to
http://www.frontiernet.net/~fys/hugi/hcompo.htm
This for other information

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
-----------------------


Rod Pemberton

unread,
Oct 2, 2009, 6:20:43 AM10/2/09
to

"io_x" <a...@b.c.invalid> wrote in message
news:4ac5c7f6$0$1106$4faf...@reader4.news.tin.it...
> http://www.frontiernet.net/~fys/hugi/hcompo.htm

>
> This is my 182 bytes entry, but there are people say enought 135bytes
> and some other 96bytes
>

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


Esra Sdrawkcab

unread,
Oct 2, 2009, 2:38:13 PM10/2/09
to
On Fri, 02 Oct 2009 10:36:20 +0100, io_x <a...@b.c.invalid> wrote:

>


> 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!

io_x

unread,
Oct 3, 2009, 3:13:16 AM10/3/09
to

"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

io_x

unread,
Oct 3, 2009, 3:23:30 AM10/3/09
to

"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

Esra Sdrawkcab

unread,
Oct 3, 2009, 3:37:52 AM10/3/09
to

To match the example competition results!
--
Nuns! Reverse!

io_x

unread,
Oct 3, 2009, 4:49:56 AM10/3/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u07rhes0hswpfo@dell3100...

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!


io_x

unread,
Oct 3, 2009, 5:02:16 AM10/3/09
to

"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

> ; *******************************************
> ; *** 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

Esra Sdrawkcab

unread,
Oct 3, 2009, 7:46:44 PM10/3/09
to
On Sat, 03 Oct 2009 08:23:30 +0100, io_x <a...@b.c.invalid> wrote:

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

unread,
Oct 3, 2009, 7:51:14 PM10/3/09
to
On Sat, 03 Oct 2009 08:13:16 +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:
>>
>>> 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!

io_x

unread,
Oct 4, 2009, 1:41:17 AM10/4/09
to

"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
> This for other information
>
> 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
> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
> ? | | | | | | | | |
> +--+--+--+ + + + + +--+ + + + +--+ +--+ + +--+ + + + + + +
> | | | | | | | | | | | | | | | | | | |
> + + + + + + +--+ +--+--+--+ +--+ +--+ +--+ + + + +--+--+ +--+
> | | | | | | | | | | | | | | | |
> +--+--+ +--+--+--+ +--+ + + +--+ + + +--+ +--+--+ + + + +--+ +
> | | | | | | | | | | | |
> + +--+--+ +--+--+--+ +--+ + + +--+--+ + +--+--+--+--+ + +--+--+ +
> | | | | | | | | | | | | |
> + + + +--+ +--+ +--+--+--+ +--+--+--+--+--+--+--+ + + + + +--+ +
> | | | | | | | | | | | | |
> + + +--+ + + +--+ + + + +--+--+--+--+--+--+--+--+--+--+--+--+ +--+
> | | | | | | | | | | | |
> + +--+ +--+--+ +--+ + + + +--+ + +--+ +--+ + +--+ +--+ + + +
> | | | | | | | | | | | | | | | |
> +--+ +--+ +--+--+ +--+--+--+--+ + +--+--+--+ +--+--+--+ + + +--+ +
> | | | | | | | | | | | | |
> + +--+ +--+ + +--+--+--+ +--+ + + +--+ + +--+ + + + +--+ + +
> | | | | | | | | ?
> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

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

io_x

unread,
Oct 4, 2009, 4:22:45 AM10/4/09
to

"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4ac833e4$0$1114$4faf...@reader1.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
>> This for other information
>>
>> 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
>> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
>> ? | | | | | | | | |
>> +--+--+--+ + + + + +--+ + + + +--+ +--+ + +--+ + + + + + +
>> | | | | | | | | | | | | | | | | | | |
>> + + + + + + +--+ +--+--+--+ +--+ +--+ +--+ + + + +--+--+ +--+
>> | | | | | | | | | | | | | | | |
>> +--+--+ +--+--+--+ +--+ + + +--+ + + +--+ +--+--+ + + + +--+ +
>> | | | | | | | | | | | |
>> + +--+--+ +--+--+--+ +--+ + + +--+--+ + +--+--+--+--+ + +--+--+ +
>> | | | | | | | | | | | | |
>> + + + +--+ +--+ +--+--+--+ +--+--+--+--+--+--+--+ + + + + +--+ +
>> | | | | | | | | | | | | |
>> + + +--+ + + +--+ + + + +--+--+--+--+--+--+--+--+--+--+--+--+ +--+
>> | | | | | | | | | | | |
>> + +--+ +--+--+ +--+ + + + +--+ + +--+ +--+ + +--+ +--+ + + +
>> | | | | | | | | | | | | | | | |
>> +--+ +--+ +--+--+ +--+--+--+--+ + +--+--+--+ +--+--+--+ + + +--+ +
>> | | | | | | | | | | | | |
>> + +--+ +--+ + +--+--+--+ +--+ + + +--+ + +--+ + + + +--+ + +
>> | | | | | | | | ?
>> +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
>
> this is 164 bytes using the Esra way for to get the integer;
> i not think i could do better of this

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

io_x

unread,
Oct 4, 2009, 5:50:00 AM10/4/09
to
"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u07rhes0hswpfo@dell3100...

What is this result?

for the program that test mazes "mazetest -v"
all is ok

Benjamin David Lunt

unread,
Oct 4, 2009, 1:40:39 PM10/4/09
to

"io_x" <a...@b.c.invalid> wrote in message
news:4ac833e4$0$1114$4faf...@reader1.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
>> This for other information

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

io_x

unread,
Oct 5, 2009, 1:54:19 AM10/5/09
to

"Benjamin David Lunt" <zf...@frontiernet.net> ha scritto nel messaggio
news:w65ym.24806$tG1....@newsfe22.iad...

>
> "io_x" <a...@b.c.invalid> wrote in message
> news:4ac833e4$0$1114$4faf...@reader1.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
>>> This for other information
>
> 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

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

unread,
Oct 5, 2009, 4:11:29 AM10/5/09
to
On Sun, 04 Oct 2009 10:50:00 +0100, io_x <a...@b.c.invalid> wrote:

> "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!

io_x

unread,
Oct 5, 2009, 4:25:33 AM10/5/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u080b62hhswpfo@dell3100...

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!

Esra Sdrawkcab

unread,
Oct 5, 2009, 4:08:38 AM10/5/09
to

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

unread,
Oct 5, 2009, 5:01:07 AM10/5/09
to
On Mon, 05 Oct 2009 09:25:33 +0100, io_x <a...@b.c.invalid> wrote:

>
> "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!

io_x

unread,
Oct 5, 2009, 6:29:59 AM10/5/09
to
"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u1bh8op8hswpfo@dell3100...

yes, it seems i follow the rules of http://temet.es/hcompo/
i stop to 156 byte for entry.com now.
156-86= 70


Benjamin David Lunt

unread,
Oct 5, 2009, 11:14:08 AM10/5/09
to

"io_x" <a...@b.c.invalid> wrote in message
news:4ac9886b$0$828$4faf...@reader5.news.tin.it...

>
>> example n > x.txt
>> entry n > e.txt
>> fc e.txt x.txt
>> where n is a number from 0 to 100
>
> 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??

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


io_x

unread,
Oct 5, 2009, 1:15:58 PM10/5/09
to

"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4ac833e4$0$1114$4faf...@reader1.news.tin.it...


; 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

Benjamin David Lunt

unread,
Oct 5, 2009, 1:24:55 PM10/5/09
to

"io_x" <a...@b.c.invalid> wrote in message
news:4aca2836$0$1102$4faf...@reader3.news.tin.it...

>
> "io_x" <a...@b.c.invalid> ha scritto nel messaggio
> news:4ac833e4$0$1114$4faf...@reader1.news.tin.it...
>
>

Sorry. Still doesn't pass the test.bat test.

Thanks,
Ben


io_x

unread,
Oct 6, 2009, 3:54:24 AM10/6/09
to

"Benjamin David Lunt" <zf...@frontiernet.net> ha scritto nel messaggio
news:%2oym.93874$u76....@newsfe10.iad...

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


io_x

unread,
Oct 6, 2009, 3:57:03 AM10/6/09
to

"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4acaf615$0$830$4faf...@reader5.news.tin.it...

> 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)

and to read the code in the example.asm :)


io_x

unread,
Oct 6, 2009, 4:38:28 AM10/6/09
to

"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4acaf615$0$830$4faf...@reader5.news.tin.it...

> ; *******************************************
> ; *** Fa il labirinto
> ; *******************************************
> ; suppone all'ingresso che cx==0
xor cx, cx ; +2?

Esra Sdrawkcab

unread,
Oct 6, 2009, 5:14:40 PM10/6/09
to


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!

Esra Sdrawkcab

unread,
Oct 6, 2009, 5:40:32 PM10/6/09
to
On Tue, 06 Oct 2009 22:14:40 +0100, Esra Sdrawkcab <ad...@127.0.0.1> wrote:


>
> 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!

Benjamin David Lunt

unread,
Oct 6, 2009, 6:48:53 PM10/6/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> wrote in message
news:op.u1edaqyxhswpfo@dell3100...

> On Tue, 06 Oct 2009 08:54:24 +0100, io_x <a...@b.c.invalid> wrote:
>
>
> It passes!
>
>

Yep, it does. I have added it to the list at
http://www.frontiernet.net/~fys/hugi/hcompo.htm

Thanks,
Ben


io_x

unread,
Oct 7, 2009, 3:04:12 AM10/7/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u1edaqyxhswpfo@dell3100...

> On Tue, 06 Oct 2009 08:54:24 +0100, io_x <a...@b.c.invalid> wrote:
>> ; ****************************
>> ; *** 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!

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

io_x

unread,
Oct 7, 2009, 3:04:18 AM10/7/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u1edaqyxhswpfo@dell3100...

> On Tue, 06 Oct 2009 08:54:24 +0100, io_x <a...@b.c.invalid> wrote:
>> lea si, [di+sopra]
> this isn't needed until later, and can be a direct address, i.e .
> mov si, arr+sopra

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

io_x

unread,
Oct 7, 2009, 6:08:12 AM10/7/09
to

"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

;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


Benjamin David Lunt

unread,
Oct 7, 2009, 8:17:06 PM10/7/09
to

"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


io_x

unread,
Oct 8, 2009, 2:15:09 AM10/8/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u1bh8op8hswpfo@dell3100...

> On Mon, 05 Oct 2009 06:54:19 +0100, io_x <a...@b.c.invalid> wrote:

backwardS arsE

> --
> Nuns! Reverse!

Esra Sdrawkcab

unread,
Oct 8, 2009, 3:18:49 AM10/8/09
to

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!

Esra Sdrawkcab

unread,
Oct 8, 2009, 3:43:52 PM10/8/09
to

Bigger (just). curses!

--
Nuns! Reverse!

io_x

unread,
Oct 9, 2009, 2:43:32 AM10/9/09
to

"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

;;

%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

Esra Sdrawkcab

unread,
Oct 10, 2009, 6:23:58 AM10/10/09
to
On Fri, 09 Oct 2009 07:43:32 +0100, io_x <a...@b.c.invalid> wrote:

>
> "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!

Espineter

unread,
Oct 10, 2009, 9:20:07 PM10/10/09
to
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

unread,
Oct 11, 2009, 2:39:00 AM10/11/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u1kxt8ckhswpfo@dell3100...

> On Fri, 09 Oct 2009 07:43:32 +0100, io_x <a...@b.c.invalid> wrote:
>
>>
>> "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?

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

Rod Pemberton

unread,
Oct 11, 2009, 3:57:34 AM10/11/09
to
"Espineter" <espi...@gmail.com> wrote in message
news:1a005d17-caf2-4af5...@a32g2000yqm.googlegroups.com...

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


Esra Sdrawkcab

unread,
Oct 11, 2009, 6:10:34 AM10/11/09
to

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!

io_x

unread,
Oct 11, 2009, 12:49:48 PM10/11/09
to

"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4aced9f9$0$1107$4faf...@reader1.news.tin.it...

>
> "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

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


Espineter

unread,
Oct 11, 2009, 6:05:10 PM10/11/09
to

> 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...
>

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

Espineter

unread,
Oct 11, 2009, 6:11:34 PM10/11/09
to
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. 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!

Espineter

unread,
Oct 11, 2009, 6:19:33 PM10/11/09
to
On Oct 11, 6:49 pm, "io_x" <a...@b.c.invalid> wrote:
> "io_x" <a...@b.c.invalid> ha scritto nel messaggionews:4aced9f9$0$1107$4faf...@reader1.news.tin.it...
> .a:       ; ** caso vi è una casella non visitata

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

Rod Pemberton

unread,
Oct 11, 2009, 7:24:32 PM10/11/09
to
"Espineter" <espi...@gmail.com> wrote in message
news:c98502bf-294d-44cb...@k33g2000yqa.googlegroups.com...

>
> It's a pity that you can't complete your entry. As I can see you are
> very close to finish.

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


Esra Sdrawkcab

unread,
Oct 12, 2009, 9:45:07 AM10/12/09
to

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!

Espineter

unread,
Oct 12, 2009, 1:28:16 PM10/12/09
to
On Oct 12, 1:24 am, "Rod Pemberton" <do_not_h...@nohavenot.cmm> wrote:
> Is your random routine smaller or larger?

http://hcompo.temet.es/forum/viewtopic.php?f=5&t=19&start=0#p94

Esra Sdrawkcab

unread,
Oct 15, 2009, 1:56:30 PM10/15/09
to

I've thought of a different way of represnting the grid - but my code is
now
260 bytes. Oops.
>
>>
>> --
>> Nuns! Reverse!
>


--
Nuns! Reverse!

io_x

unread,
Oct 16, 2009, 4:31:09 AM10/16/09
to

"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"

Esra Sdrawkcab

unread,
Oct 16, 2009, 4:34:18 AM10/16/09
to
On Fri, 16 Oct 2009 09:31:09 +0100, io_x <a...@b.c.invalid> wrote:

>
> "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!

io_x

unread,
Oct 17, 2009, 2:16:15 AM10/17/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u1vwrg1phswpfo@dell3100...

> On Fri, 16 Oct 2009 09:31:09 +0100, io_x <a...@b.c.invalid> wrote:
> I had another idea last night but it saved -18 bytes (i.e. increased size).

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


Esra Sdrawkcab

unread,
Oct 17, 2009, 3:46:07 AM10/17/09
to

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!

io_x

unread,
Oct 17, 2009, 1:10:08 PM10/17/09
to
"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u1xo65c7hswpfo@dell3100...

no; i not agree on what Sir Espineter says


io_x

unread,
Oct 17, 2009, 1:13:21 PM10/17/09
to

"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4ad9f8c7$0$1095$4faf...@reader3.news.tin.it...

> "Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
>> 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?
>
> no; i not agree on what Sir Espineter says

it is all right all remain one secret until the end of the competition


io_x

unread,
Oct 17, 2009, 1:17:28 PM10/17/09
to

"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4ad9f988$0$1107$4faf...@reader3.news.tin.it...

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.


Esra Sdrawkcab

unread,
Oct 17, 2009, 4:27:31 PM10/17/09
to

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!

io_x

unread,
Oct 18, 2009, 3:48:37 AM10/18/09
to
"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u1yof5r5hswpfo@dell3100...

> On Sat, 17 Oct 2009 18:17:28 +0100, io_x <a...@b.c.invalid> wrote:
>> "io_x" <a...@b.c.invalid> ha scritto nel messaggio
>> news:4ad9f988$0$1107$4faf...@reader3.news.tin.it...
>>>
>>> "io_x" <a...@b.c.invalid> ha scritto nel messaggio
>>> news:4ad9f8c7$0$1095$4faf...@reader3.news.tin.it...
>>>> "Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
>>>>> 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?
>>>>
>>>> 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.
>>
> 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

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

Esra Sdrawkcab

unread,
Oct 18, 2009, 6:17:18 AM10/18/09
to

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!

Esra Sdrawkcab

unread,
Oct 28, 2009, 6:05:34 AM10/28/09
to
On Thu, 08 Oct 2009 01:17:06 +0100, Benjamin David Lunt
<zf...@frontiernet.net> wrote:

>
> "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!

Benjamin David Lunt

unread,
Oct 28, 2009, 10:14:24 AM10/28/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> wrote in message
news:op.u2h8zln7hswpfo@dell3100...

Remove the zzzz's and it will be correct.

Thanks,
Ben


Esra Sdrawkcab

unread,
Oct 29, 2009, 3:19:02 PM10/29/09
to
On Wed, 28 Oct 2009 14:14:24 -0000, Benjamin David Lunt
<zf...@frontiernet.net> wrote:

>
> "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!

Esra Sdrawkcab

unread,
Oct 30, 2009, 5:32:17 PM10/30/09
to
ref:
http://temet.es/hcompo/forum/viewtopic.php?f=8&t=32
[reverse input and print to stdio]

15 bytes.

(seems I already registered my email address, but I can't remember my
name!)

io_x

unread,
Oct 31, 2009, 5:37:20 AM10/31/09
to

"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u2ks90oohswpfo@dell3100...

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 ...


Esra Sdrawkcab

unread,
Oct 31, 2009, 6:01:39 AM10/31/09
to

I was trying to help not compete!

I'm interested to see how the other guys squeeze it to <128 bytes!


--
Nuns! Reverse!

wolfgang kern

unread,
Oct 31, 2009, 7:22:18 AM10/31/09
to

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 ?

Anyway congrats to Rosario for he could reduce his first >380 bytes
to less than half.

__
wolfgang


Benjamin David Lunt

unread,
Nov 1, 2009, 5:25:33 PM11/1/09
to
Just for your information and interest, the compo is
now over and the source code is released.

http://www.frontiernet.net/~fys/hugi/hcompo.htm


Thank you,
Ben


Frank Kotler

unread,
Nov 1, 2009, 6:01:22 PM11/1/09
to
Benjamin David Lunt wrote:
> Just for your information and interest, the compo is
> now over and the source code is released.
>
> http://www.frontiernet.net/~fys/hugi/hcompo.htm

Wow! io_x came in ninth. Congratulations!

Best,
Frank

io_x

unread,
Nov 2, 2009, 3:46:55 AM11/2/09
to
"Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
news:op.u2nss1v5hswpfo@dell3100...

> On Sat, 31 Oct 2009 09:37:20 -0000, io_x <a...@b.c.invalid> wrote:
>>> I've submitted it to Ben.
>>
>> 169bytes is the limit for me

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!


Rod Pemberton

unread,
Nov 2, 2009, 4:33:20 AM11/2/09
to
"Benjamin David Lunt" <zf...@frontiernet.net> wrote in message
news:pVnHm.2747$%U3....@newsfe21.iad...

> Just for your information and interest, the compo is
> now over and the source code is released.
>
> http://www.frontiernet.net/~fys/hugi/hcompo.htm
>
>

120? 120! Wow. I guess I'll looking at his code as soon as I get a
chance. Congrats Espineter!


Rod Pemberton


Esra Sdrawkcab

unread,
Nov 2, 2009, 7:15:36 AM11/2/09
to

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

unread,
Nov 2, 2009, 9:24:31 AM11/2/09
to
On Sat, 31 Oct 2009 11:22:18 -0000, wolfgang kern <now...@never.at> wrote:

>
> 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!

Benjamin David Lunt

unread,
Nov 2, 2009, 11:29:37 AM11/2/09
to

"io_x" <a...@b.c.invalid> wrote in message
news:4aee9ad3$0$1414$4faf...@reader4.news.tin.it...

> "Esra Sdrawkcab" <ad...@127.0.0.1> ha scritto nel messaggio
> news:op.u2nss1v5hswpfo@dell3100...
>> On Sat, 31 Oct 2009 09:37:20 -0000, io_x <a...@b.c.invalid> wrote:
>>>> I've submitted it to Ben.
>>>
>>> 169bytes is the limit for me
>
> here espineter enter print nothing ...
>
> yes io_x is 169bytes all ok.
>
> what about the Rosario last version?
> (sent to fys@......net on 31/10/2009 9:15 here time)

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.


wolfgang kern

unread,
Nov 2, 2009, 11:50:43 AM11/2/09
to

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 ...

>> 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 Sdrawkcab

unread,
Nov 2, 2009, 1:02:42 PM11/2/09
to
On Mon, 02 Nov 2009 16:50:43 -0000, wolfgang kern <now...@never.at> wrote:

>
> 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!

Rosario P.

unread,
Nov 2, 2009, 2:09:38 PM11/2/09
to

"Benjamin David Lunt" ha scritto nel messaggio
news:gRDHm.11359$zr....@newsfe04.iad...

>> what about the Rosario last version?
>> (sent to fys@......net on 31/10/2009 9:15 here time)
>
> 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.

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


Benjamin David Lunt

unread,
Nov 2, 2009, 3:12:11 PM11/2/09
to

"Rosario P." <a...@b.c.invalid> wrote in message
news:4aef2cc2$0$1102$4faf...@reader3.news.tin.it...

>
> "Benjamin David Lunt" ha scritto nel messaggio
> news:gRDHm.11359$zr....@newsfe04.iad...
>>> what about the Rosario last version?
>>> (sent to fys@......net on 31/10/2009 9:15 here time)
>>
>> 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.
>
> 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

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

wolfgang kern

unread,
Nov 3, 2009, 9:36:24 AM11/3/09
to

Esra wrote:
...

>> 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 :)
__
wolfgang


Esra Sdrawkcab

unread,
Nov 3, 2009, 10:15:58 AM11/3/09
to

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!

io_x

unread,
Nov 3, 2009, 2:14:26 PM11/3/09
to
"wolfgang kern" <now...@never.at> ha scritto nel messaggio
news:hcpfnu$e2a$1...@newsreader2.utanet.at...

>
> Esra wrote:
> ...
>>> Well done Esra, jump into instructions were my favorites as well.

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

io_x

unread,
Nov 3, 2009, 2:14:31 PM11/3/09
to
"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4ad9fa86$0$1418$4faf...@reader4.news.tin.it...
it is sad in the university people not study how program in assembly
especially the old 16 bit registers one.

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 :)

io_x

unread,
Nov 3, 2009, 2:17:51 PM11/3/09
to

"io_x" <a...@b.c.invalid> ha scritto nel messaggio
news:4af07f69$0$1105$4faf...@reader2.news.tin.it...

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


wolfgang kern

unread,
Nov 4, 2009, 8:22:25 AM11/4/09
to

Esra wrote:

>>>> 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


Esra Sdrawkcab

unread,
Nov 4, 2009, 1:11:57 PM11/4/09
to

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.

io_x

unread,
Nov 5, 2009, 2:47:23 AM11/5/09
to
"wolfgang kern" <now...@never.at> ha scritto nel messaggio
news:hcrv8j$s7s$1...@newsreader2.utanet.at...

> Esra wrote:
>
>>>>> 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 ...

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)

wolfgang kern

unread,
Nov 5, 2009, 2:54:27 AM11/5/09
to

Esra wrote:

>>>>>> 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


Frank Kotler

unread,
Nov 6, 2009, 1:26:17 AM11/6/09
to
io_x wrote:

...


> 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

wolfgang kern

unread,
Nov 6, 2009, 10:05:33 AM11/6/09
to

Frank Kotler posted:

...
>> 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


Rugxulo

unread,
Nov 6, 2009, 1:20:38 PM11/6/09
to
Hi,

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

wolfgang kern

unread,
Nov 8, 2009, 6:29:40 AM11/8/09
to

Rugxulo posted:
[...]

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

got that and I'll give it a try, thanks.

__
wolfgang


0 new messages