Discussion:
small asm code (compo?)
(too old to reply)
Kerr-Mudd,John
2020-08-22 11:44:41 UTC
Permalink
Spec is to show the day of week as a literal string;

given these DOS functions (maybe others?)

get daynum: DOS has int 0x21, fn 0x2A which returns al as 0-6 (Sun-Sat)

print: int 21, fn 2 with dl=char
or int 21, fn 9 with dx pointing to a string terminated with a $ (x24)

terminate with return code: int 0x21 fn 0x4C, code in al


Write shortest programs to show day string of the current day;

1) full string e.g. "Monday", "Saturday"
2) 3 letter e.g. "Mon", "Sat"
3) 2 letter e.g. "Mo", "Sa"


My current shortests are:
1) 67
2) 49
3) 40
--
Bah, and indeed, Humbug.
Terje Mathisen
2020-08-22 18:52:32 UTC
Permalink
Post by Kerr-Mudd,John
Spec is to show the day of week as a literal string;
given these DOS functions (maybe others?)
get daynum: DOS has int 0x21, fn 0x2A which returns al as 0-6 (Sun-Sat)
print: int 21, fn 2 with dl=char
or int 21, fn 9 with dx pointing to a string terminated with a $ (x24)
terminate with return code: int 0x21 fn 0x4C, code in al
Write shortest programs to show day string of the current day;
1) full string e.g. "Monday", "Saturday"
2) 3 letter e.g. "Mon", "Sat"
3) 2 letter e.g. "Mo", "Sa"
1) 67
2) 49
3) 40
That seems somewhat bogus:

If you can do Mo, Tu, We, Th etc in 40 bytes, then adding one more byte
to each string should only result in 7 more bytes?

OTOH, if you do all the two-letter abbreviations as two Dos calls and
the 3 and 6-8 letter versions with '$' terminated strings then it makes
more sense. :-)

For the two-letter case:

mov ah,2ah
int 21h
cbw
mov si,ax
mov dl,first_letter[si]
call print1
mov dl,second_letter[si]
print1:
mov ah,2
int 21h
ret ;; Return after first letter, exit after second
first_letter db "SMTWTFS"
second_letter db "uouehra"

Close to your own?

Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
wolfgang kern
2020-08-23 08:11:34 UTC
Permalink
Post by Terje Mathisen
Post by Kerr-Mudd,John
Spec is to show the day of week as a literal string;
given these DOS functions (maybe others?)
get daynum: DOS has int 0x21, fn 0x2A which returns al as 0-6 (Sun-Sat)
print: int 21, fn 2 with dl=char
   or int 21, fn 9 with dx pointing to a string terminated with a $ (x24)
terminate with return code: int 0x21 fn 0x4C, code in al
Write shortest programs to show day string of the current day;
1) full string e.g. "Monday", "Saturday"
2) 3 letter e.g. "Mon", "Sat"
3) 2 letter e.g. "Mo", "Sa"
1) 67
2) 49
3) 40
If you can do Mo, Tu, We, Th etc in 40 bytes, then adding one more byte
to each string should only result in 7 more bytes?
OTOH, if you do all the two-letter abbreviations as two Dos calls and
the 3 and 6-8 letter versions with '$' terminated strings then it makes
more sense. :-)
let me check

00 mov ah,2ah
02 int 21h
04 cbw
05 mov si,ax ;1 byte: xchg ax,si
07 mov dl,first_letter[si] ;
0a call print1 ;sure about si remain ?
0d mov dl,second_letter[si]
print1:
10 mov ah,2
12 int 21h
13 ret    ;; Return after first letter, exit after second
15 first_letter db "SMTWTFS"
1c second_letter db "uouehra"
23
Post by Terje Mathisen
Close to your own?
Terje
Not an A :) missing "$"
__
wolfgang
Kerr-Mudd,John
2020-08-23 09:43:21 UTC
Permalink
On Sun, 23 Aug 2020 08:11:34 GMT, wolfgang kern
Post by wolfgang kern
Post by Terje Mathisen
Post by Kerr-Mudd,John
Spec is to show the day of week as a literal string;
plain 8086 for me!
Post by wolfgang kern
Post by Terje Mathisen
Post by Kerr-Mudd,John
given these DOS functions (maybe others?)
get daynum: DOS has int 0x21, fn 0x2A which returns al as 0-6 (Sun-Sat)
print: int 21, fn 2 with dl=char
   or int 21, fn 9 with dx pointing to a string terminated with a $ (x24)
terminate with return code: int 0x21 fn 0x4C, code in al
I forgot that I 'up' the return code/errorlevel, I want 1 for Sun, 7 for
Saturday.
Post by wolfgang kern
Post by Terje Mathisen
Post by Kerr-Mudd,John
Write shortest programs to show day string of the current day;
1) full string e.g. "Monday", "Saturday"
2) 3 letter e.g. "Mon", "Sat"
3) 2 letter e.g. "Mo", "Sa"
1) 67
2) 49
3) 40
If you can do Mo, Tu, We, Th etc in 40 bytes, then adding one more
byte to each string should only result in 7 more bytes?
OTOH, if you do all the two-letter abbreviations as two Dos calls and
the 3 and 6-8 letter versions with '$' terminated strings then it
makes more sense. :-)
Yes.
Post by wolfgang kern
let me check
00 mov ah,2ah
02 int 21h
04 cbw
05 mov si,ax ;1 byte: xchg ax,si
07 mov dl,first_letter[si] ;
0a call print1 ;sure about si remain ?
yes, si same
Post by wolfgang kern
0d mov dl,second_letter[si]
10 mov ah,2
12 int 21h
13 ret    ;; Return after first letter, exit after second
15 first_letter db "SMTWTFS"
1c second_letter db "uouehra"
23
Post by Terje Mathisen
Close to your own?
Terje
Not an A :) missing "$"
__
wolfgang
No the $ is only used for the fn 9 call, it doesn't get printed.
But it fails as there's no errorlevel set by 'ret'.

Here's one of mine: (42)

cpu 8086 ; show 3^w 2 chr day str l42
org 0x100 ;

mov ah,0x2A ; get system date
int 0x21 ; al daynum, 0=sun; cx:dx
push ax
cbw
shl ax,1
xchg si,ax ; to ix reg
mov ah,2
pnc:
mov dl,[dystrs+si] ; getc
int 0x21 ; al lost
inc si
dec bx
jpe pnc ; prt twice
pop ax
mov ah,0x4C
inc ax
int 0x21 ; erl 1=Sun

dystrs db 'SuMoTuWeThFrSa'
--
Bah, and indeed, Humbug.
Kerr-Mudd,John
2020-08-23 10:07:01 UTC
Permalink
On Sun, 23 Aug 2020 09:43:21 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,John
On Sun, 23 Aug 2020 08:11:34 GMT, wolfgang kern
Post by wolfgang kern
Post by Terje Mathisen
Post by Kerr-Mudd,John
Spec is to show the day of week as a literal string;
plain 8086 for me!
Post by wolfgang kern
Post by Terje Mathisen
Post by Kerr-Mudd,John
given these DOS functions (maybe others?)
get daynum: DOS has int 0x21, fn 0x2A which returns al as 0-6 (Sun-Sat)
print: int 21, fn 2 with dl=char
   or int 21, fn 9 with dx pointing to a string terminated with a $ (x24)
terminate with return code: int 0x21 fn 0x4C, code in al
I forgot that I 'up' the return code/errorlevel, I want 1 for Sun, 7 for
Saturday.
Post by wolfgang kern
Post by Terje Mathisen
Post by Kerr-Mudd,John
Write shortest programs to show day string of the current day;
1) full string e.g. "Monday", "Saturday"
2) 3 letter e.g. "Mon", "Sat"
3) 2 letter e.g. "Mo", "Sa"
1) 67
2) 49
3) 40
If you can do Mo, Tu, We, Th etc in 40 bytes, then adding one more
byte to each string should only result in 7 more bytes?
OTOH, if you do all the two-letter abbreviations as two Dos calls and
the 3 and 6-8 letter versions with '$' terminated strings then it
makes more sense. :-)
Yes.
Post by wolfgang kern
let me check
00 mov ah,2ah
02 int 21h
04 cbw
05 mov si,ax ;1 byte: xchg ax,si
07 mov dl,first_letter[si] ;
0a call print1 ;sure about si remain ?
yes, si same
Post by wolfgang kern
0d mov dl,second_letter[si]
10 mov ah,2
12 int 21h
13 ret    ;; Return after first letter, exit after second
15 first_letter db "SMTWTFS"
1c second_letter db "uouehra"
23
Post by Terje Mathisen
Close to your own?
Terje
Not an A :) missing "$"
__
wolfgang
No the $ is only used for the fn 9 call, it doesn't get printed.
But it fails as there's no errorlevel set by 'ret'.
Here's one of mine: (42)
cpu 8086 ; show 3^w 2 chr day str l42
org 0x100 ;
mov ah,0x2A ; get system date
int 0x21 ; al daynum, 0=sun; cx:dx
push ax
cbw
shl ax,1
xchg si,ax ; to ix reg
mov ah,2
mov dl,[dystrs+si] ; getc
int 0x21 ; al lost
inc si
dec bx
jpe pnc ; prt twice
pop ax
mov ah,0x4C
inc ax
int 0x21 ; erl 1=Sun
dystrs db 'SuMoTuWeThFrSa'
I also forgot to state in the rules that we can assume std DOS startup
values:
ax=0, bx=0,cx=progsize (so ch=0 for small), dx=cs=ds=es, si=IP=0100,
di=FFFE, bp=09xx


Terje style 41

cpu 8086 ; show 2 chr day str l41
org 0x100 ;

mov ah,0x2A ; get system date
int 0x21 ; al daynum, 0=sun; cx:dx
push ax
cbw
xchg bx,ax ; to ix reg
mov ah,2 ; dos prtc
mov dl,[first_letter+bx] ; get 1st
int 0x21 ; al lost
mov dl,[second_letter+bx] ; get 2nd
int 0x21
pop ax
mov ah,0x4C
inc ax
int 0x21 ; erl 1=Sun

first_letter db 'SMTWTFS'
second_letter db 'uouehra'
--
Bah, and indeed, Humbug.
a***@nospicedham.spamtrap.com
2020-08-23 16:27:48 UTC
Permalink
On Sat, 22 Aug 2020 20:52:32 +0200, Terje Mathisen
Post by Terje Mathisen
...
mov ah,2ah
int 21h
cbw
mov si,ax
mov dl,first_letter[si]
call print1
mov dl,second_letter[si]
mov ah,2
int 21h
ret ;; Return after first letter, exit after second
first_letter db "SMTWTFS"
second_letter db "uouehra"
Here's a different version:
mov ah,2ah
int 21h
mov bl,al ; bx 0 on entry
shl bl,1
mov ah,2
mov dx,[daystr+bx]
int 21h
mov dl,dh
int 21h
ret
daystr db "SuMoTuWeThFrSa"
--
aen
Rick C. Hodgin
2020-08-23 17:11:07 UTC
Permalink
Post by Kerr-Mudd,John
Spec is to show the day of week as a literal string;
given these DOS functions (maybe others?)
get daynum: DOS has int 0x21, fn 0x2A which returns al as 0-6 (Sun-Sat)
print: int 21, fn 2 with dl=char
or int 21, fn 9 with dx pointing to a string terminated with a $ (x24)
terminate with return code: int 0x21 fn 0x4C, code in al
Write shortest programs to show day string of the current day;
1) full string e.g. "Monday", "Saturday"
2) 3 letter e.g. "Mon", "Sat"
3) 2 letter e.g. "Mo", "Sa"
1) 67
2) 49
3) 40
17 bytes code, 32 bytes code + data.

; Open Watcom 16-bit DOS EXE small memory model:
.MODEL small
.8086

.data
days BYTE "SuMoTuWeThFrSa$"

.code
test_ PROC PUBLIC
mov ah,2ah
int 21h
cbw
mov bx,ax
add bx,offset days
mov byte ptr [bx+2],'$'
mov dx,bx
mov ah,9
int 21h
ret
test_ ENDP

END
--
Rick C. Hodgin
a***@nospicedham.spamtrap.com
2020-08-23 18:41:33 UTC
Permalink
On Sun, 23 Aug 2020 13:11:07 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
shl al,1
Post by Rick C. Hodgin
cbw
mov bx,ax
add bx,offset days
mov byte ptr [bx+2],'$'
mov dx,bx
mov ah,9
int 21h
ret
--
aen
Kerr-Mudd,John
2020-08-23 19:48:06 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Sun, 23 Aug 2020 13:11:07 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
shl al,1
Post by Rick C. Hodgin
cbw
mov bx,ax
add bx,offset days
mov byte ptr [bx+2],'$'
mov dx,bx
mov ah,9
int 21h
ret
Yup, that's about it; I forgot to put in the original spec that I want
the return code set to 1 for Sun etc, Otherwise the 'mov bx,ax' could
have been an 'xchg'.

Anyone want to try the long version? ('Monday' 'Tuesday' etc?)
--
Bah, and indeed, Humbug.
Rick C. Hodgin
2020-08-23 21:19:14 UTC
Permalink
Post by Kerr-Mudd,John
Anyone want to try the long version? ('Monday' 'Tuesday' etc?)
21 bytes code plus 47 bytes data = 68 bytes.

.MODEL small
.8086

.data
long_days BYTE 0,"Sun$"
BYTE 1,"Mon$"
BYTE 2,"Tues$"
BYTE 3,"Wednes$"
BYTE 4,"Thurs$"
BYTE 5,"Fri$"
BYTE 6,"Satur$"
day BYTE "day$"

.code
test2_ PROC PUBLIC
mov ah,2ah
int 21h
mov di,offset long_days
std
scasb
mov dx,di
inc dx
mov ah,9
int 21h
mov dx,offset day
int 21h
ret
test2_ ENDP

END
--
Rick C. Hodgin
a***@nospicedham.spamtrap.com
2020-08-24 03:43:58 UTC
Permalink
On Sun, 23 Aug 2020 17:19:14 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
mov di,offset long_days
std
scasb
mov dx,di
inc dx
mov ah,9
int 21h
mov dx,offset day
int 21h
ret
Try:
mov ah,2ah
int 21h
mov di,long_days
cld
repne scasb
mov dx,di
mov ah,9
int 21h
mov dx,day
int 21h
ret
long_days db 0,"Sun$",1,"Mon$",2,"Tues$",3,"Wednes$"
db 4,"Thurs$",5,"Fri$",6,"Satur$"
day db "day$"
--
aen
Kerr-Mudd,John
2020-08-24 09:28:15 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Sun, 23 Aug 2020 17:19:14 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
mov di,offset long_days
std
scasb
mov dx,di
inc dx
mov ah,9
int 21h
mov dx,offset day
int 21h
ret
mov ah,2ah
int 21h
mov di,long_days
cld
repne scasb
mov dx,di
mov ah,9
int 21h
mov dx,day
int 21h
ret
long_days db 0,"Sun$",1,"Mon$",2,"Tues$",3,"Wednes$"
db 4,"Thurs$",5,"Fri$",6,"Satur$"
day db "day$"
Yup needs the 'rep'; we can assume 'cld' to save 1.
--
Bah, and indeed, Humbug.
Rick C. Hodgin
2020-08-24 15:43:27 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Sun, 23 Aug 2020 17:19:14 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
mov di,offset long_days
std
scasb
mov dx,di
inc dx
mov ah,9
int 21h
mov dx,offset day
int 21h
ret
mov ah,2ah
int 21h
mov di,long_days
cld
repne scasb
I would've found that too on any day other than Sunday.
Post by a***@nospicedham.spamtrap.com
mov dx,di
mov ah,9
int 21h
mov dx,day
int 21h
ret
long_days db 0,"Sun$",1,"Mon$",2,"Tues$",3,"Wednes$"
db 4,"Thurs$",5,"Fri$",6,"Satur$"
day db "day$"
All of these were off the top of my head, with minimal testing. I find
Open Watcom somewhat difficult to wield as I'm used to Visual Studio.
One flaw is if CAPS LOCK is on, your function keys to step into and over
code doesn't work in the version I have.

I have Visual Studio 2003, and I tried to get it to compile a 16-bit
DOS application but it's not supported in that version. I think I have
to go back to VS98 for that.
--
Rick C. Hodgin
a***@nospicedham.spamtrap.com
2020-08-24 20:13:44 UTC
Permalink
On Mon, 24 Aug 2020 11:43:27 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
All of these were off the top of my head, with minimal testing. I find
Open Watcom somewhat difficult to wield as I'm used to Visual Studio.
One flaw is if CAPS LOCK is on, your function keys to step into and over
code doesn't work in the version I have.
I have Visual Studio 2003, and I tried to get it to compile a 16-bit
DOS application but it's not supported in that version. I think I have
to go back to VS98 for that.
...
For old DOS stuff I have TASM (with Turbo Debugger), MASM (with PWB
and CV), and NASM installed in my DOSBox.

If you replace the

org 100h in a nasm file with:

section .text
resb 100h
..start

you can do:
nasm -w-orphan-labels -g -f obj file.asm
tlink /v file.obj (you get a warning no stack here, but can ignore it)
tdstrip -s -c file.exe (that converts the exe to com and puts the
debug symbols in file.tds
td file.com

finally gives you Source level debbuging with a COM file.
--
aen
Kerr-Mudd,John
2020-08-25 09:29:36 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Mon, 24 Aug 2020 11:43:27 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
All of these were off the top of my head, with minimal testing. I find
Open Watcom somewhat difficult to wield as I'm used to Visual Studio.
One flaw is if CAPS LOCK is on, your function keys to step into and over
code doesn't work in the version I have.
I have Visual Studio 2003, and I tried to get it to compile a 16-bit
DOS application but it's not supported in that version. I think I have
to go back to VS98 for that.
...
For old DOS stuff I have TASM (with Turbo Debugger), MASM (with PWB
and CV), and NASM installed in my DOSBox.
If you replace the
section .text
resb 100h
..start
nasm -w-orphan-labels -g -f obj file.asm
tlink /v file.obj (you get a warning no stack here, but can ignore it)
tdstrip -s -c file.exe (that converts the exe to com and puts the
debug symbols in file.tds
td file.com
finally gives you Source level debbuging with a COM file.
In nasm I run (in a batch)
nasmw %1.asm -o %1.com -l %1.lst
then grdb to check it out; (setting SI DI and BP if reqd);
no debug symbols though.
--
Bah, and indeed, Humbug.
Kerr-Mudd,John
2020-08-24 09:27:52 UTC
Permalink
On Sun, 23 Aug 2020 21:19:14 GMT, "Rick C. Hodgin"
Post by Rick C. Hodgin
Post by Kerr-Mudd,John
Anyone want to try the long version? ('Monday' 'Tuesday' etc?)
21 bytes code plus 47 bytes data = 68 bytes.
.MODEL small
.8086
.data
long_days BYTE 0,"Sun$"
BYTE 1,"Mon$"
BYTE 2,"Tues$"
BYTE 3,"Wednes$"
BYTE 4,"Thurs$"
BYTE 5,"Fri$"
BYTE 6,"Satur$"
day BYTE "day$"
.code
test2_ PROC PUBLIC
mov ah,2ah
int 21h
mov di,offset long_days
std
scasb
mov dx,di
inc dx
mov ah,9
int 21h
mov dx,offset day
int 21h
ret
test2_ ENDP
END
All those extra '$'s! I can see no-one wants to set the return code on
exit, it adds to the fun of retaining the day number. 74 with rc

cpu 8086 ; show day str l74
org 0x100 ; lookup, dbl prt
mov ah,0x2A ; get system date
int 0x21 ; al daynum, 0=sun; cx:dx
push ax
mov di,long_days
repne scasb ; find daystr
mov dx,di
mov ah,9
int 0x21
mov dx,day ; prt 'day'
int 0x21
pop ax
; add ax,0x100*(0x4C-0x2A)+1
mov ah,0x4C ; exit with rc
inc ax
int 0x21

long_days db 0,"Sun$",1,"Mon$",2,"Tues$",3,"Wednes$"
db 4,"Thurs$",5,"Fri$",6,"Satur$"
day db "day$"
--
Bah, and indeed, Humbug.
a***@nospicedham.spamtrap.com
2020-08-24 12:45:12 UTC
Permalink
On Mon, 24 Aug 2020 09:27:52 -0000 (UTC), "Kerr-Mudd,John"
Post by Kerr-Mudd,John
...
All those extra '$'s! I can see no-one wants to set the return code on
exit, it adds to the fun of retaining the day number. 74 with rc
...
A return code is nice and shiny, but you need a way to see it. In
DOSBox that will do it:
; nasm -f bin geterror.asm -o geterror.com
cpu 8086
org 100h
mov ah,4dh
int 21h
mov bx,outstr+3
.1: dec bx
xor ah,ah
div byte [ten]
or ah,30h
mov [bx],ah
test al,al
jne .1
mov ah,9
mov dx,bx
int 21h
ret
ten db 10
outstr db " $"

Run it immediately after a program.
--
aen
Kerr-Mudd,John
2020-08-24 16:50:35 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Mon, 24 Aug 2020 09:27:52 -0000 (UTC), "Kerr-Mudd,John"
Post by Kerr-Mudd,John
...
All those extra '$'s! I can see no-one wants to set the return code on
exit, it adds to the fun of retaining the day number. 74 with rc
...
A return code is nice and shiny, but you need a way to see it. In
well I was wrapping stuff up in a DOS Batch, back then.
So it was "if it's Wednesday run a backup" style of thing.
Post by a***@nospicedham.spamtrap.com
; nasm -f bin geterror.asm -o geterror.com
cpu 8086
org 100h
mov ah,4dh
int 21h
mov bx,outstr+3
.1: dec bx
xor ah,ah
div byte [ten]
or ah,30h
mov [bx],ah
test al,al
jne .1
mov ah,9
mov dx,bx
int 21h
ret
ten db 10
outstr db " $"
Run it immediately after a program.
I get 0 every time under XP, but thanks.
--
Bah, and indeed, Humbug.
a***@nospicedham.spamtrap.com
2020-08-24 19:28:10 UTC
Permalink
On Mon, 24 Aug 2020 16:50:35 -0000 (UTC), "Kerr-Mudd,John"
Post by Kerr-Mudd,John
...
I get 0 every time under XP, but thanks.
...
Uh well, my old machine with an XP was gathering dust anyway.

I copied a program that returns 2 and the geterror prog over to XP.

Then I first ran the program in DOSBox on my machine and then

debug geterror.com
u (which showed 0772:0104 as the address after the int 21h function 4D
g 0772:0104 (which showed AX=0002)

Next I ran the same thing on the XP machine in cmd

u (which showed 0d35:0104 as the address after the int 21h function 4D
g 0d35:0104 (which showed AX=0000)

But XP has cmd and not the dos command (which has no %errorlevel%, but
cmd uses

echo %errorlevel%

to show the return code and when I ran the program and then

echo %errorlevel% I got the 2, so that's what you should use.
--
aen
Kerr-Mudd,John
2020-08-25 09:05:56 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Mon, 24 Aug 2020 16:50:35 -0000 (UTC), "Kerr-Mudd,John"
Post by Kerr-Mudd,John
...
I get 0 every time under XP, but thanks.
...
Uh well, my old machine with an XP was gathering dust anyway.
I copied a program that returns 2 and the geterror prog over to XP.
Then I first ran the program in DOSBox on my machine and then
debug geterror.com
u (which showed 0772:0104 as the address after the int 21h function 4D
g 0772:0104 (which showed AX=0002)
Next I ran the same thing on the XP machine in cmd
u (which showed 0d35:0104 as the address after the int 21h function 4D
g 0d35:0104 (which showed AX=0000)
But XP has cmd and not the dos command (which has no %errorlevel%, but
cmd uses
echo %errorlevel%
to show the return code and when I ran the program and then
echo %errorlevel% I got the 2, so that's what you should use.
Thanks again!
--
Bah, and indeed, Humbug.
Rick C. Hodgin
2020-08-25 02:54:35 UTC
Permalink
Post by Rick C. Hodgin
Post by Kerr-Mudd,John
Anyone want to try the long version? ('Monday' 'Tuesday' etc?)
21 bytes code plus 47 bytes data = 68 bytes.
.MODEL small
.8086
.data
    long_days BYTE 0,"Sun$"
              BYTE 1,"Mon$"
              BYTE 2,"Tues$"
              BYTE 3,"Wednes$"
              BYTE 4,"Thurs$"
              BYTE 5,"Fri$"
              BYTE 6,"Satur$"
    day BYTE "day$"
.code
    test2_ PROC PUBLIC
        mov     ah,2ah
        int     21h
        mov     di,offset long_days
        std
        scasb
        mov     dx,di
        inc     dx
        mov     ah,9
        int     21h
        mov     dx,offset day
        int     21h
        ret
    test2_ ENDP
END
I had an idea this evening to remove all those extra $ symbols.
Here's a version that uses CAPS characters as a delineator. It's
40 code bytes, 34 data bytes, 74 total.

matrix_days BYTE "SunMonTuesWednesThursFriSaturZ"
day BYTE "day$"

test3_ PROC PUBLIC
mov ah,2ah
int 21h
mov bx,offset matrix_days
top_loop:
cmp byte ptr [bx],'Z'
ja move_next
cmp al,0
jz found_it
dec al
move_next:
inc bx
jmp top_loop

found_it:
mov ah,2
show_next_char:
mov dl,byte ptr [bx]
int 21h
inc bx
cmp byte ptr [bx],'Z'
ja show_next_char

mov ah,9
mov dx,offset day
int 21h
ret
test3_ ENDP

It's been a long time since I've programmed in 8086 assembly. Usually
it's in 686 or later. These little small asm code challenges take me
back to the man who taught me MASM 1.0. Alan Earheart. A quadriplegic
who damaged his spine falling off a roof. He typed with a 30 inch stick
in his teeth touching a keyboard mounted on a special fixture holding
also the RGB monitor where he could see it, and the keyboard where he
could access it. We chatted over 300 baud modems and I learned how to
do assembly that way. I was introduced to him by an employer I had in
1987. That employer saw a spark in me, and sent me to Alan to learn
low-level coding, which I had no experience in before that save PEEKs
and POKEs on my 6502-based BASIC apps.

Alan died a few years later, but he left a legacy with me. Were it not
for his tutilege, I may never have had such a passion for low-level asm
code, ISAs or hardware in general. I've remembered Alan multiple times
over the years. Always a dual set of emotions there.

It's been almost 20 years since I've written extensively in assembly.
Now it's mostly nostalgia, and a requirement for compiler development,
but most of that is a reasoned application considering various models,
and not a real coding goal as for a task, but only a particular need of
processing data types in particular ways.

I'm thankful for CLAX and other low-level software and hardware groups.
--
Rick C. Hodgin
Kerr-Mudd,John
2020-08-25 09:33:28 UTC
Permalink
On Tue, 25 Aug 2020 02:54:35 GMT, "Rick C. Hodgin"
Post by Rick C. Hodgin
Post by Kerr-Mudd,John
Anyone want to try the long version? ('Monday' 'Tuesday' etc?)
[]
Post by Rick C. Hodgin
I had an idea this evening to remove all those extra $ symbols.
Here's a version that uses CAPS characters as a delineator. It's
40 code bytes, 34 data bytes, 74 total.
Yup, that's how I do it in one of my 67 byte programs.
Post by Rick C. Hodgin
matrix_days BYTE "SunMonTuesWednesThursFriSaturZ"
day BYTE "day$"
test3_ PROC PUBLIC
mov ah,2ah
int 21h
mov bx,offset matrix_days
cmp byte ptr [bx],'Z'
ja move_next
cmp al,0
jz found_it
dec al
inc bx
jmp top_loop
mov ah,2
mov dl,byte ptr [bx]
int 21h
inc bx
cmp byte ptr [bx],'Z'
ja show_next_char
mov ah,9
mov dx,offset day
int 21h
ret
test3_ ENDP
It's been a long time since I've programmed in 8086 assembly. Usually
it's in 686 or later. These little small asm code challenges take me
back to the man who taught me MASM 1.0. Alan Earheart. A quadriplegic
who damaged his spine falling off a roof. He typed with a 30 inch stick
in his teeth touching a keyboard mounted on a special fixture holding
also the RGB monitor where he could see it, and the keyboard where he
could access it. We chatted over 300 baud modems and I learned how to
do assembly that way. I was introduced to him by an employer I had in
1987. That employer saw a spark in me, and sent me to Alan to learn
low-level coding, which I had no experience in before that save PEEKs
and POKEs on my 6502-based BASIC apps.
Alan died a few years later, but he left a legacy with me. Were it not
for his tutilege, I may never have had such a passion for low-level asm
code, ISAs or hardware in general. I've remembered Alan multiple times
over the years. Always a dual set of emotions there.
It's been almost 20 years since I've written extensively in assembly.
Now it's mostly nostalgia, and a requirement for compiler development,
but most of that is a reasoned application considering various models,
and not a real coding goal as for a task, but only a particular need of
processing data types in particular ways.
I'm thankful for CLAX and other low-level software and hardware groups.
Fun still, for us few.
--
Bah, and indeed, Humbug.
Terje Mathisen
2020-08-24 08:57:30 UTC
Permalink
Post by Kerr-Mudd,John
Post by a***@nospicedham.spamtrap.com
On Sun, 23 Aug 2020 13:11:07 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
shl al,1
Post by Rick C. Hodgin
cbw
mov bx,ax
add bx,offset days
mov byte ptr [bx+2],'$'
mov dx,bx
mov ah,9
int 21h
ret
Yup, that's about it; I forgot to put in the original spec that I want
the return code set to 1 for Sun etc, Otherwise the 'mov bx,ax' could
have been an 'xchg'.
Anyone want to try the long version? ('Monday' 'Tuesday' etc?)
It seems obvious that you would print "day" separately from the leading
day name chars, since that would save ~18 data bytes.

One complication is that the names are different lengths, and we cannot
pad them all to fit "Wednes$", so maybe use XLAT to convert day number
to starting offset via a 7-byte table?

Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
Kerr-Mudd,John
2020-08-24 09:32:28 UTC
Permalink
On Mon, 24 Aug 2020 08:57:30 GMT, Terje Mathisen
Post by Terje Mathisen
Post by Kerr-Mudd,John
Post by a***@nospicedham.spamtrap.com
On Sun, 23 Aug 2020 13:11:07 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
shl al,1
Post by Rick C. Hodgin
cbw
mov bx,ax
add bx,offset days
mov byte ptr [bx+2],'$'
mov dx,bx
mov ah,9
int 21h
ret
Yup, that's about it; I forgot to put in the original spec that I want
the return code set to 1 for Sun etc, Otherwise the 'mov bx,ax' could
have been an 'xchg'.
Anyone want to try the long version? ('Monday' 'Tuesday' etc?)
It seems obvious that you would print "day" separately from the leading
day name chars, since that would save ~18 data bytes.
One complication is that the names are different lengths, and we cannot
pad them all to fit "Wednes$", so maybe use XLAT to convert day number
to starting offset via a 7-byte table?
One of my 'best' does a table lookup. I don't use xlat, as it changes al.
--
Bah, and indeed, Humbug.
a***@nospicedham.spamtrap.com
2020-08-25 05:34:01 UTC
Permalink
On Mon, 24 Aug 2020 09:32:28 -0000 (UTC), "Kerr-Mudd,John"
Post by Kerr-Mudd,John
...
One of my 'best' does a table lookup. I don't use xlat, as it changes al.
..
Something like that?
cpu 8086
org 100h
mov ah,2ah
int 21h
;push ax
mov bl,al
mov dx,long_days
add dl,[table+bx]
mov ah,9
int 21h
mov dx,day
int 21h
;pop ax
;add ax,2201h
;int 21h
ret
table db 0, 4, 8, 13, 20, 26, 30
long_days db "Sun$Mon$Tues$Wednes$Thurs$Fri$Satur$"
day db "day$"
--
aen
Kerr-Mudd,John
2020-08-26 11:32:27 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Mon, 24 Aug 2020 09:32:28 -0000 (UTC), "Kerr-Mudd,John"
Post by Kerr-Mudd,John
...
One of my 'best' does a table lookup. I don't use xlat, as it changes al.
..
Something like that?
cpu 8086
org 100h
mov ah,2ah
int 21h
;push ax
mov bl,al
mov dx,long_days
add dl,[table+bx]
mov ah,9
int 21h
mov dx,day
int 21h
;pop ax
;add ax,2201h
;int 21h
ret
table db 0, 4, 8, 13, 20, 26, 30
long_days db "Sun$Mon$Tues$Wednes$Thurs$Fri$Satur$"
day db "day$"
Ok, here's one of my earlier 'bests':

cpu 8086 ; show day str l70
org 0x100 ; Caps as delim; findcap cx=0 srch endday
; no pp ax ; movsw for day$
;; ignores nums, spaces as well
mov ah,0x2A ; get system date
int 0x21 ; al daynum, 0=sun; [cx=yr-1980,
dh=mth,dl=dom]
inc ax ; 1-7
cbw
mov cx,ax ; need ch=0
mov si,daystrs
mov di,si ; start early!
mov ah,0x4C ; exitwrc
finddaycap:
findcap: ; find a capstr [al untouched]
inc di
test byte [di],0x20
jnz findcap
jcxz endstr ; 2nd srch find end str
loop finddaycap ; found a day; today when cx=0
mov dx,di ; strg prt
jmp finddaycap ; redo find for end str, cx=0
; cant embed str as overwrites code on Sat!
endstr:
exitint: ; xchg as dlm?; extra movsb's on 2nd run ok
xchg ax,bp ; bp=09xx ; mov ah,09 ; pstr
movsw ; si->'day$' A5,no good as dlm
movsw
int 0x21 ; al=$ from prt
jmp exitint

daystrs equ $
db 'day$'
db 'Sun'
db 'Mon'
db 'Tues'
db 'Wednes'
db 'Thurs'
db 'Fri'
db 'Satur' ; next chr must be dlm without 0x20
db 'X'
--
Bah, and indeed, Humbug.
Benjamin David Lunt
2020-09-10 03:38:11 UTC
Permalink
Hi guys.
Post by Kerr-Mudd,John
cpu 8086
org 100h
mov ah,2ah
int 21h
;push ax
mov bl,al
mov dx,long_days
add dl,[table+bx]
mov ah,9
int 21h
mov dx,day
; you can save a byte here since you only have
; to update DL. DH is unchanged.
Post by Kerr-Mudd,John
int 21h
;pop ax
;add ax,2201h
;int 21h
ret
table db 0, 4, 8, 13, 20, 26, 30
long_days db "Sun$Mon$Tues$Wednes$Thurs$Fri$Satur$"
day db "day$"
These were the days. Reminds me of the Hugi Compo's
( http://www.hugi.scene.org/compo/hcompo.htm )

Good evening to all
Ben
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Forever Young Software
http://www.fysnet.net/index.htm
http://www.fysnet.net/osdesign_book_series.htm
To reply by email, please remove the zzzzzz's

Batteries not included, some Assembly required.
Kerr-Mudd,John
2020-09-10 09:13:34 UTC
Permalink
On Thu, 10 Sep 2020 03:38:11 GMT, "Benjamin David Lunt"
Post by Benjamin David Lunt
Hi guys.
[]
Post by Benjamin David Lunt
These were the days. Reminds me of the Hugi Compo's
( http://www.hugi.scene.org/compo/hcompo.htm )
Indeed; that's what I've been admiring.
--
Bah, and indeed, Humbug.
Kerr-Mudd,John
2020-09-15 19:52:09 UTC
Permalink
On Thu, 10 Sep 2020 09:13:34 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,John
On Thu, 10 Sep 2020 03:38:11 GMT, "Benjamin David Lunt"
Post by Benjamin David Lunt
Hi guys.
[]
Post by Benjamin David Lunt
These were the days. Reminds me of the Hugi Compo's
( http://www.hugi.scene.org/compo/hcompo.htm )
Indeed; that's what I've been admiring.
Finally!

20:51:03 Tuesday 15th September 2020

in 256 bytes.
--
Bah, and indeed, Humbug.
Rick C. Hodgin
2020-09-15 20:15:10 UTC
Permalink
Post by Kerr-Mudd,John
Finally!
20:51:03 Tuesday 15th September 2020
in 256 bytes.
Which one is that you have 256 bytes? I may throw my hat in the ring.
--
Rick C. Hodgin
Kerr-Mudd,John
2020-09-16 08:58:29 UTC
Permalink
On Tue, 15 Sep 2020 20:15:10 GMT, "Rick C. Hodgin"
Post by Rick C. Hodgin
Post by Kerr-Mudd,John
Finally!
20:51:03 Tuesday 15th September 2020
in 256 bytes.
Which one is that you have 256 bytes? I may throw my hat in the ring.
A DOS program to show time & date:
suppress leading zero for hour and day, colon separator for time, show
n'th' (or 'st' etc) of month name for day and month, AND setting
errorlevel to daynum+1 (Sun=1) on exit.
Though I don't add crlf to end the string.

9:58:06 Wednesday 16th September 2020

Does throwing your hat in mean you want to try, or are you giving up?
ah, that'd be the towel. Go on give it a go.
--
Bah, and indeed, Humbug.
Rick C. Hodgin
2020-09-16 20:38:03 UTC
Permalink
Post by Kerr-Mudd,John
suppress leading zero for hour and day, colon separator for time, show
n'th' (or 'st' etc) of month name for day and month, AND setting
errorlevel to daynum+1 (Sun=1) on exit.
Though I don't add crlf to end the string.
9:58:06 Wednesday 16th September 2020
Does throwing your hat in mean you want to try, or are you giving up?
ah, that'd be the towel. Go on give it a go.
Yes. I'll give it a go. It won't be for a few days, so if you need go
ahead and move forward with whatever plans you have. I'll submit a
legitimate original attempt despite any other source code or ideas posted.
--
Rick C. Hodgin
Kerr-Mudd,John
2020-09-21 19:08:21 UTC
Permalink
On Wed, 16 Sep 2020 20:38:03 GMT, "Rick C. Hodgin"
Post by Rick C. Hodgin
Post by Kerr-Mudd,John
suppress leading zero for hour and day, colon separator for time,
show n'th' (or 'st' etc) of month name for day and month, AND setting
errorlevel to daynum+1 (Sun=1) on exit.
Though I don't add crlf to end the string.
9:58:06 Wednesday 16th September 2020
Does throwing your hat in mean you want to try, or are you giving up?
ah, that'd be the towel. Go on give it a go.
Yes. I'll give it a go. It won't be for a few days, so if you need
go ahead and move forward with whatever plans you have. I'll submit a
legitimate original attempt despite any other source code or ideas posted.
Wolfgang? are you still here?
--
Bah, and indeed, Humbug.
wolfgang kern
2020-09-22 16:04:22 UTC
Permalink
On 21.09.2020 21:08, Kerr-Mudd,John wrote:
...
Post by Kerr-Mudd,John
Wolfgang? are you still here?
still alive, but a bit exhausted from too much gaming :)
__
wolfgang
Kerr-Mudd,John
2020-09-23 09:48:21 UTC
Permalink
On Wed, 16 Sep 2020 08:58:29 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,John
On Tue, 15 Sep 2020 20:15:10 GMT, "Rick C. Hodgin"
Post by Rick C. Hodgin
Post by Kerr-Mudd,John
Finally!
20:51:03 Tuesday 15th September 2020
in 256 bytes.
Which one is that you have 256 bytes? I may throw my hat in the ring.
suppress leading zero for hour and day, colon separator for time, show
n'th' (or 'st' etc) of month name for day and month, AND setting
errorlevel to daynum+1 (Sun=1) on exit.
Though I don't add crlf to end the string.
9:58:06 Wednesday 16th September 2020
Does throwing your hat in mean you want to try, or are you giving up?
ah, that'd be the towel. Go on give it a go.
10:47:35 Wednesday 23rd September 2020


How about a 1st Oct deadline?
--
Bah, and indeed, Humbug.
Rick C. Hodgin
2020-09-23 14:29:58 UTC
Permalink
Post by Kerr-Mudd,John
10:47:35 Wednesday 23rd September 2020
How about a 1st Oct deadline?
Works for me. I tried this past weekend but couldn't get a decent
design. Have too many other things on my mind I think.

I find these compos kind of exciting, even relaxing. I'll put in some
time, but if it's not in by Oct 1, no worries. Go forward.

I had an idea also that we could use a front-end loader to take a fixed
data payload and orient it in memory however we need to, allowing only
the data payload to be the actual size, using a common loader with
common abilities.

It might be an interesting way to setup things like POP CS to allow for
some interesting space savings by designing the code in a particular way.

We may be able to do some of that with an EXE loader and ORG statements,
but it would give us more options if we could use a common loader.
--
Rick C. Hodgin
Kerr-Mudd,John
2020-10-01 08:05:41 UTC
Permalink
On Wed, 23 Sep 2020 14:29:58 GMT, "Rick C. Hodgin"
Post by Rick C. Hodgin
Post by Kerr-Mudd,John
10:47:35 Wednesday 23rd September 2020
How about a 1st Oct deadline?
Works for me. I tried this past weekend but couldn't get a decent
design. Have too many other things on my mind I think.
I find these compos kind of exciting, even relaxing. I'll put in some
time, but if it's not in by Oct 1, no worries. Go forward.
I had an idea also that we could use a front-end loader to take a fixed
data payload and orient it in memory however we need to, allowing only
the data payload to be the actual size, using a common loader with
common abilities.
It might be an interesting way to setup things like POP CS to allow for
some interesting space savings by designing the code in a particular way.
We may be able to do some of that with an EXE loader and ORG
statements,
Post by Rick C. Hodgin
but it would give us more options if we could use a common loader.
I didn't try any of that; just tight code; here you are Wolfgang, get
typing!

today1a4.com 256 bytes

BF240957B42CCD215188E831C9E859005841BE9701E850004E88F0E84A00B42A
CD214089C55198E84F00BE8B01A5A55688D0E8340080FC3198740A2C303C0473
04D1E001C6A588F099BEB501E82A005E4E58B164F7F1E80F0092E80C005A89D0
AACD2195B44CCD21A4D40A08E1740680CC308825470C30AAC391B020AAE309AC
A82075F9E3F2E2F7AAEBF464617920746873746E6472643A53756E4D6F6E5475
65735765646E6573546875727346726953617475724A616E7561727946656272
756172794D61726368417072696C4D61794A756E654A756C7941756775737453
657074656D6265724F63746F6265724E6F76656D626572446563656D62657258
--
Bah, and indeed, Humbug.
Kerr-Mudd,John
2020-10-01 08:23:02 UTC
Permalink
On Thu, 01 Oct 2020 08:05:41 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,John
On Wed, 23 Sep 2020 14:29:58 GMT, "Rick C. Hodgin"
Post by Rick C. Hodgin
Post by Kerr-Mudd,John
10:47:35 Wednesday 23rd September 2020
How about a 1st Oct deadline?
Works for me. I tried this past weekend but couldn't get a decent
design. Have too many other things on my mind I think.
I find these compos kind of exciting, even relaxing. I'll put in some
time, but if it's not in by Oct 1, no worries. Go forward.
I had an idea also that we could use a front-end loader to take a fixed
data payload and orient it in memory however we need to, allowing only
the data payload to be the actual size, using a common loader with
common abilities.
It might be an interesting way to setup things like POP CS to allow for
some interesting space savings by designing the code in a particular
way.
Post by Rick C. Hodgin
We may be able to do some of that with an EXE loader and ORG
statements,
Post by Rick C. Hodgin
but it would give us more options if we could use a common loader.
I didn't try any of that; just tight code; here you are Wolfgang, get
typing!
today1a4.com 256 bytes
BF240957B42CCD215188E831C9E859005841BE9701E850004E88F0E84A00B42A
CD214089C55198E84F00BE8B01A5A55688D0E8340080FC3198740A2C303C0473
04D1E001C6A588F099BEB501E82A005E4E58B164F7F1E80F0092E80C005A89D0
AACD2195B44CCD21A4D40A08E1740680CC308825470C30AAC391B020AAE309AC
A82075F9E3F2E2F7AAEBF464617920746873746E6472643A53756E4D6F6E5475
65735765646E6573546875727346726953617475724A616E7561727946656272
756172794D61726368417072696C4D61794A756E654A756C7941756775737453
657074656D6265724F63746F6265724E6F76656D626572446563656D62657258
All right; to give you a head start here's a debug dump (may wrap)

-u100 l8a
16A6:0100 BF 24 09 mov di,0924
16A6:0103 57 push di
16A6:0104 B4 2C mov ah,2C
16A6:0106 CD 21 int 21
16A6:0108 51 push cx
16A6:0109 88 E8 mov al,ch
16A6:010B 31 C9 xor cx,cx
16A6:010D E8 59 00 call 0169
16A6:0110 58 pop ax
16A6:0111 41 inc cx
16A6:0112 BE 97 01 mov si,0197
16A6:0115 E8 50 00 call 0168
16A6:0118 4E dec si
16A6:0119 88 F0 mov al,dh
16A6:011B E8 4A 00 call 0168
16A6:011E B4 2A mov ah,2A
16A6:0120 CD 21 int 21
16A6:0122 40 inc ax
16A6:0123 89 C5 mov bp,ax
16A6:0125 51 push cx
16A6:0126 98 cbw
16A6:0127 E8 4F 00 call 0179
16A6:012A BE 8B 01 mov si,018B
16A6:012D A5 movsw
16A6:012E A5 movsw
16A6:012F 56 push si
16A6:0130 88 D0 mov al,dl
16A6:0132 E8 34 00 call 0169
16A6:0135 80 FC 31 cmp ah,31
16A6:0138 98 cbw
16A6:0139 74 0A jz 0145
16A6:013B 2C 30 sub al,30
16A6:013D 3C 04 cmp al,04
16A6:013F 73 04 jnb 0145
16A6:0141 D1 E0 shl ax,1
16A6:0143 01 C6 add si,ax
16A6:0145 A5 movsw
16A6:0146 88 F0 mov al,dh
16A6:0148 99 cwd
16A6:0149 BE B5 01 mov si,01B5
16A6:014C E8 2A 00 call 0179
16A6:014F 5E pop si
16A6:0150 4E dec si
16A6:0151 58 pop ax
16A6:0152 B1 64 mov cl,64
16A6:0154 F7 F1 div cx
16A6:0156 E8 0F 00 call 0168
16A6:0159 92 xchg ax,dx
16A6:015A E8 0C 00 call 0169
16A6:015D 5A pop dx
16A6:015E 89 D0 mov ax,dx
16A6:0160 AA stosb
16A6:0161 CD 21 int 21
16A6:0163 95 xchg ax,bp
16A6:0164 B4 4C mov ah,4C
16A6:0166 CD 21 int 21
16A6:0168 A4 movsb
16A6:0169 D4 0A aam 0A
16A6:016B 08 E1 or cl,ah
16A6:016D 74 06 jz 0175
16A6:016F 80 CC 30 or ah,30
16A6:0172 88 25 mov [di],ah
16A6:0174 47 inc di
16A6:0175 0C 30 or al,30
16A6:0177 AA stosb
16A6:0178 C3 ret
16A6:0179 91 xchg ax,cx
16A6:017A B0 20 mov al,20
16A6:017C AA stosb
16A6:017D E3 09 jcxzw 0188
16A6:017F AC lodsb
16A6:0180 A8 20 test al,20
16A6:0182 75 F9 jnz 017D
16A6:0184 E3 F2 jcxzw 0178
16A6:0186 E2 F7 loopw 017F
16A6:0188 AA stosb
16A6:0189 EB F4 jmp 017F

-d18b
16A6:018B 64 61 79 20-74 68 73 74-6E 64 72 64-3A 53 75 6E day
thstndrd:Sun
16A6:019B 4D 6F 6E 54-75 65 73 57-65 64 6E 65-73 54 68 75
MonTuesWednesThu
16A6:01AB 72 73 46 72-69 53 61 74-75 72 4A 61-6E 75 61 72
rsFriSaturJanuar
16A6:01BB 79 46 65 62-72 75 61 72-79 4D 61 72-63 68 41 70
yFebruaryMarchAp
16A6:01CB 72 69 6C 4D-61 79 4A 75-6E 65 4A 75-6C 79 41 75
rilMayJuneJulyAu
16A6:01DB 67 75 73 74-53 65 70 74-65 6D 62 65-72 4F 63 74
gustSeptemberOct
16A6:01EB 6F 62 65 72-4E 6F 76 65-6D 62 65 72-44 65 63 65
oberNovemberDece
16A6:01FB 6D 62 65 72-58 mberX
--
Bah, and indeed, Humbug.
wolfgang kern
2020-10-03 17:01:35 UTC
Permalink
On 01.10.2020 10:05, Kerr-Mudd,John wrote:
...
Post by Kerr-Mudd,John
I didn't try any of that; just tight code; here you are Wolfgang, get
typing!
today1a4.com 256 byte
I remember vague on a batch-file which printed date&time to screen, it
was much shorter than this :)
__
wolfgang

wouldn't BIOS calls instead of DOS-FN make it shorter ?

BF2409
57
B42C
CD21
51
88E8
31C9
E85900 ;call
58
41
BE9701
E85000 ;call
4E
88F0
E84A00 ;call
B42A
CD21 ;get
40
89C5
51
98
E84F00
BE8B01
A5A5 ;dup
56
88D0
E83400 ;call
80FC31
98
740A
2C30
3C04
7304
D1E0
01C6
A5
88F0
99
BEB501
E82A00 ;call
5E
4E
58
B164
F7F1
E80F00 ;call
92
E80C00 ;call
5A
89D0
AA
CD21 ;put
95
B44C
CD21 ;end

:SubroutineA
A4
D40A
08E1
7406
80CC30
882547
0C30
AA
C3

:SubroutineB
91
B020AA
E309
AC
A820
75F9
E3F2
E2F7
AA
EBF4

:text
64617920746873746E6472643A53756E4D6F6E5475
65735765646E6573546875727346726953617475724A616E7561727946656272
756172794D61726368417072696C4D61794A756E654A756C7941756775737453
657074656D6265724F63746F6265724E6F76656D626572446563656D62657258
Kerr-Mudd,John
2020-10-03 19:01:06 UTC
Permalink
On Sat, 03 Oct 2020 17:01:35 GMT, wolfgang kern
Post by wolfgang kern
...
Post by Kerr-Mudd,John
I didn't try any of that; just tight code; here you are Wolfgang, get
typing!
today1a4.com 256 byte
I remember vague on a batch-file which printed date&time to screen, it
was much shorter than this :)
__
wolfgang
wouldn't BIOS calls instead of DOS-FN make it shorter ?
not really, 4 bytes to get time, same for date; I set the
returncode/errorlevel so need int21 fn 4C for that, and that only leaves
1 DOS print: int21 fn9

there's a lot of call to 2 (ish) rtns as they do a lot of the work!
Post by wolfgang kern
BF2409
57
B42C
CD21
51
88E8
31C9
E85900 ;call
58
41
BE9701
E85000 ;call
4E
88F0
E84A00 ;call
B42A
CD21 ;get
40
89C5
51
98
E84F00
BE8B01
A5A5 ;dup ;### yup; prints 'day '
56
88D0
E83400 ;call
80FC31
98
740A
2C30
3C04
7304
D1E0
01C6
A5
88F0
99
BEB501
E82A00 ;call
5E
4E
58
B164
F7F1
E80F00 ;call
92
E80C00 ;call
5A
89D0
AA
CD21 ;put
95
B44C
CD21 ;end
:SubroutineA
A4
D40A
08E1
7406
80CC30
882547
0C30
AA
C3
:SubroutineB
91
B020AA
E309
AC
A820
75F9
E3F2
E2F7
AA
EBF4
:text
64617920746873746E6472643A53756E4D6F6E5475
65735765646E6573546875727346726953617475724A616E7561727946656272
756172794D61726368417072696C4D61794A756E654A756C7941756775737453
657074656D6265724F63746F6265724E6F76656D626572446563656D62657258
--
Bah, and indeed, Humbug.
Terje Mathisen
2020-09-16 10:09:35 UTC
Permalink
Post by Kerr-Mudd,John
On Thu, 10 Sep 2020 09:13:34 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,John
On Thu, 10 Sep 2020 03:38:11 GMT, "Benjamin David Lunt"
Post by Benjamin David Lunt
Hi guys.
[]
Post by Benjamin David Lunt
These were the days. Reminds me of the Hugi Compo's
( http://www.hugi.scene.org/compo/hcompo.htm )
Indeed; that's what I've been admiring.
Finally!
20:51:03 Tuesday 15th September 2020
I assume you will print 1st, 2nd, 3rd followed by 4th...20th, then 21st,
22nd, 23rd followed by 24th to 30th and finally 31st?

Basically exceptions for numbers ending in 1,2,3 except when the
previous letter is '1'?
Post by Kerr-Mudd,John
in 256 bytes.
Seems trivial except for the day names and numbers. :-)

Terje
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
Kerr-Mudd,John
2020-09-16 13:13:05 UTC
Permalink
On Wed, 16 Sep 2020 10:09:35 GMT, Terje Mathisen
Post by Terje Mathisen
Post by Kerr-Mudd,John
On Thu, 10 Sep 2020 09:13:34 GMT, "Kerr-Mudd,John"
["spec" in other branch of this thread]
Post by Terje Mathisen
Post by Kerr-Mudd,John
Finally!
20:51:03 Tuesday 15th September 2020
I assume you will print 1st, 2nd, 3rd followed by 4th...20th, then 21st,
22nd, 23rd followed by 24th to 30th and finally 31st?
Basically exceptions for numbers ending in 1,2,3 except when the
previous letter is '1'?
Well, of course. It has to be done properly.
Perhaps I should have waited a bit before going to press. (-:

[balances brackets]
Post by Terje Mathisen
Post by Kerr-Mudd,John
in 256 bytes.
Seems trivial except for the day names and numbers. :-)
Terje
I guess a really clever, small, text decoder might make it trivial to
come in under the size limit!

I'll publish a hexdump after a bit to allow Wolfgang a go at trimming it
down further (assuming he's still up for it).
--
Bah, and indeed, Humbug.
Kerr-Mudd,John
2020-09-26 20:28:54 UTC
Permalink
On Wed, 16 Sep 2020 13:13:05 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,John
On Wed, 16 Sep 2020 10:09:35 GMT, Terje Mathisen
Post by Terje Mathisen
Post by Kerr-Mudd,John
On Thu, 10 Sep 2020 09:13:34 GMT, "Kerr-Mudd,John"
["spec" in other branch of this thread]
Post by Terje Mathisen
Post by Kerr-Mudd,John
Finally!
20:51:03 Tuesday 15th September 2020
I assume you will print 1st, 2nd, 3rd followed by 4th...20th, then
21st,
Post by Terje Mathisen
22nd, 23rd followed by 24th to 30th and finally 31st?
Basically exceptions for numbers ending in 1,2,3 except when the
previous letter is '1'?
Well, of course. It has to be done properly.
[balances brackets]
Post by Terje Mathisen
Post by Kerr-Mudd,John
in 256 bytes.
Seems trivial except for the day names and numbers. :-)
Terje
I guess a really clever, small, text decoder might make it trivial to
come in under the size limit!
Bah; my text encoding saves c. [70-4C] 36 bytes (5bit 3-9,a-y), but the
decoder costs 55!
Post by Kerr-Mudd,John
I'll publish a hexdump after a bit to allow Wolfgang a go at trimming it
down further (assuming he's still up for it).
--
Bah, and indeed, Humbug.
Kerr-Mudd,John
2020-09-04 12:56:20 UTC
Permalink
On Mon, 24 Aug 2020 09:32:28 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,John
On Mon, 24 Aug 2020 08:57:30 GMT, Terje Mathisen
Post by Terje Mathisen
Post by Kerr-Mudd,John
Post by a***@nospicedham.spamtrap.com
On Sun, 23 Aug 2020 13:11:07 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
shl al,1
Post by Rick C. Hodgin
cbw
mov bx,ax
add bx,offset days
mov byte ptr [bx+2],'$'
mov dx,bx
mov ah,9
int 21h
ret
Yup, that's about it; I forgot to put in the original spec that I want
the return code set to 1 for Sun etc, Otherwise the 'mov bx,ax' could
have been an 'xchg'.
Anyone want to try the long version? ('Monday' 'Tuesday' etc?)
It seems obvious that you would print "day" separately from the leading
day name chars, since that would save ~18 data bytes.
One complication is that the names are different lengths, and we cannot
pad them all to fit "Wednes$", so maybe use XLAT to convert day number
to starting offset via a 7-byte table?
One of my 'best' does a table lookup. I don't use xlat, as it changes al.
Just for completeness this is one that tied for 67

cpu 8086 ; show day str l67
org 0x100 ; look bkwd, use caps as dlm saved extra dlm, but same lth
mov ah,0x2A ; get system date
int 0x21 ; al daynum, 0=sun; [cx=yr-1980, dh=mth,dl=dom]
inc ax ; 1-7
cbw ; 2A->0
mov cx,ax ; keep ax for exit
mov ah,0x4C ; exitwrc
mov si,daydollar ; to append
mov bx,si ;; save 1 here, 1 for noEOS, lose 2 in mov
dx,bx
nextday:
mov di,bx ; update day end ptr
backone:
dec bx
test byte [bx],0x20 ; al untouched
jnz backone
loop nextday
mov dx,bx ; prt start
movsw ; append 'day$'
movsw
exitint:
xchg ax,bp ; bp=09xx == mov ah,09 ; prtstr
int 0x21 ; al=$
jmp exitint ; have ax setup for exit

sSat db 'Satur'
sFri db 'Fri'
sThu db 'Thurs'
sWed db 'Wednes'
sTue db 'Tues'
sMon db 'Mon'
sSun db 'Sun'
daydollar db 'day$'
--
Bah, and indeed, Humbug.
a***@nospicedham.spamtrap.com
2020-09-05 03:20:43 UTC
Permalink
On Fri, 4 Sep 2020 12:56:20 -0000 (UTC), "Kerr-Mudd,John"
Post by Kerr-Mudd,John
...
Just for completeness this is one that tied for 67
nasm code snipped
...
And for those who want to do this in linux:
-----
day.s
-----
# as -o day.o day.s ; ld --nmagic --script=com.ld -o day.com day.o
.intel_syntax noprefix
.code16gcc

.text
.global _start
# show day str l67
# look bkwd, use caps as dlm saved extra dlm, but same lth
_start: mov ah,0x2A # get system date
int 0x21 # al daynum, 0=sun# [cx=yr-1980, dh=mth,dl=dom]
inc ax # 1-7
cbw # 2A->0
mov cx,ax # keep ax for exit
mov ah,0x4C # exitwrc
mov si,offset daydollar # to append
mov bx,si ## save 1 here, 1 for noEOS, lose 2 in mov dx,bx
nextday:
mov di,bx # update day end ptr
backone:
dec bx
test byte ptr [bx],0x20 # al untouched
jnz backone
loop nextday
mov dx,bx # prt start
movsw # append 'day$'
movsw
exitint:
xchg ax,bp # bp=09xx == mov ah,09 # prtstr
int 0x21 # al=$
jmp exitint # have ax setup for exit

sSat: .ascii "Satur"
sFri: .ascii "Fri"
sThu: .ascii "Thurs"
sWed: .ascii "Wednes"
sTue: .ascii "Tues"
sMon: .ascii "Mon"
sSun: .ascii "Sun"
daydollar: .ascii "day$"
------
com.ld
------
OUTPUT_FORMAT(binary)
SECTIONS
{
. = 0x0100;
.text :
{
*(.text);
}
.data :
{
*(.data);
*(.bss);
*(.rodata);
}
_heap = ALIGN(4);
}

Run with:
cp day.com /home/aen/DOS ; dosbox -c day.com
^^^^^^^^^^^^^
change to where you mounted c in DOSBox

Yes, GCC can produce com files:
<https://nullprogram.com/blog/2014/12/09/>
--
aen
a***@nospicedham.spamtrap.com
2020-09-05 13:14:41 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
...
.code16gcc
...
Should be replaced with:
.arch i8086
.code16
Post by a***@nospicedham.spamtrap.com
...
And if you prefer ATT syntax:
-----
day.s
-----
.arch i8086
.code16

.text
.global _start
# show day str l67
# look bkwd, use caps as dlm saved extra dlm, but same lth
_start: movb $0x2A, %ah # get system date
int $0x21 # al daynum, 0=sun; [cx=yr-1980, dh=mth,dl=dom]
incw %ax # 1-7
cbtw # 2A->0
movw %ax, %cx # keep ax for exit
movb $0x4C, %ah # exitwrc
movw $daydollar, %si # to append
movw %si, %bx # save 1 here, 1 for noEOS, lose 2 in mov dx,bx
nextday:
movw %bx, %di # update day end ptr
backone:
decw %bx
testb $0x20, (%bx) # al untouched
jnz backone
loop nextday
movw %bx, %dx # prt start
movsw # append 'day$'
movsw
exitint:
xchgw %bp, %ax # bp=09xx == mov ah,09 ; prtstr
int $0x21 # al=$
jmp exitint # have ax setup for exit

sSat: .ascii "Satur"
sFri: .ascii "Fri"
sThu: .ascii "Thurs"
sWed: .ascii "Wednes"
sTue: .ascii "Tues"
sMon: .ascii "Mon"
sSun: .ascii "Sun"
daydollar: .ascii "day$"
--
aen
Kerr-Mudd,John
2020-09-07 09:52:16 UTC
Permalink
On Fri, 04 Sep 2020 12:56:20 GMT, "Kerr-Mudd,John"
<***@nospicedham.127.0.0.1> wrote:
[Print "Monday"]


I'm now glacially coding "umpteenth"

Sadly I've got bit twiddling down to a mere 2 more that the plain jmp
version!

(This is my testing code; obviously I'll only print today's date in the
full prog) - the "put nth part is the one to concentrate on.


cpu 8086 ;nth2g l 88 works!
org 0x100 ; use cwd & cbw
;; via bl

blank equ 0x20
%define crlf 0x0D0A
start: mov di,prtarea
push di ; for prt at end
mov ax,0x4C00
mov bp,ax ; setup exit
mov cx,031d ; full mth test
nextday:
inc ax
push ax
call put2dec ;' dD' ; cx=0 flag for noldz
;; put nth ; ah | al
mov si,thstrs ; 30 31 32 33 | 30 31 32 33 34 35-39
xor ax,0x3130 ; 1 0 3 2 | 0 1 2 3 4 05-09
mov bl,al ; save ix (bh=0)
add ax,0x7FFC ; 80 7F 82 81 | FC FD FE FF 0 01-05
cwd ; flag non-teen in dx
cbw ; flag 0-3 in ah
and bl,dl ; scrap teens
and bl,ah ; scrap 4-9
shl bx,1 ; *2
add si,bx ; pt to 'st' etc
movsw ; 'th/st/nd/rd'
;; end put nth
mov al,blank ; space it out
stosb
pop ax ; get bin day num
push ax
aam 10 ; every 10th
jne nocrlf
mov ax,crlf ; new line
stosw
nocrlf:
pop ax
loop nextday

pop dx ; prt
mov ax,0x0924
stosb ; put eos chr
int 0x21 ; prtstr
xchg ax,bp ; exit
int 21h

;;Data
thstrs db 'thstndrd'

;;Subrtns
put2dec: ; I: al=2dig num; uses ax, cl di inc by 1 or 2
aam ; zr if al=0, not ah, bah.
; add cl,ah ; cl=0 ==> no ld zr
; jz noldz1
or ax,0x3030
cmp ah,0x30
jz noldz1
mov [di],ah
inc di
noldz1:
stosb
do_ret: ret

prtarea equ $
--
Bah, and indeed, Humbug.
Kerr-Mudd,John
2020-09-07 14:07:51 UTC
Permalink
On Mon, 07 Sep 2020 09:52:16 GMT, "Kerr-Mudd,John"
Post by Kerr-Mudd,John
On Fri, 04 Sep 2020 12:56:20 GMT, "Kerr-Mudd,John"
[Print "Monday"]
I'm now glacially coding "umpteenth"
Sadly I've got bit twiddling down to a mere 2 more that the plain jmp
version!
(This is my testing code; obviously I'll only print today's date in the
full prog) - the "put nth part is the one to concentrate on.
Of course as soon as you post something you spot an improvement!
(still 1 too many!)
cpu 8086 ;nth2h l 87 works!
Post by Kerr-Mudd,John
org 0x100 ; use cwd & cbw
;; via bl
blank equ 0x20
%define crlf 0x0D0A
start: mov di,prtarea
push di ; for prt at end
mov ax,0x4C00
mov bp,ax ; setup exit
mov cx,031d ; full mth test
inc ax
push ax
call put2dec ;' dD' ; cx=0 flag for noldz
;; put nth ; ah | al
; mov si,thstrs ; 30 31 32 33 | 30 31 32 33 34 35-39
Post by Kerr-Mudd,John
xor ax,0x3130 ; 1 0 3 2 | 0 1 2 3 4 05-09
mov bl,al ; save ix (bh=0)
add ax,0x7FFC ; 80 7F 82 81 | FC FD FE FF 0 01-05
cwd ; flag non-teen in dx
cbw ; flag 0-3 in ah
and bl,dl ; scrap teens
and bl,ah ; scrap 4-9
shl bx,1 ; *2
; add si,bx ; pt to 'st' etc

lea si,[bx+thstrs]
Post by Kerr-Mudd,John
movsw ; 'th/st/nd/rd'
;; end put nth
mov al,blank ; space it out
stosb
pop ax ; get bin day num
push ax
aam 10 ; every 10th
jne nocrlf
mov ax,crlf ; new line
stosw
pop ax
loop nextday
pop dx ; prt
mov ax,0x0924
stosb ; put eos chr
int 0x21 ; prtstr
xchg ax,bp ; exit
int 21h
;;Data
thstrs db 'thstndrd'
;;Subrtns
put2dec: ; I: al=2dig num; uses ax, cl di inc by 1 or 2
aam ; zr if al=0, not ah, bah.
; add cl,ah ; cl=0 ==> no ld zr
; jz noldz1
or ax,0x3030
cmp ah,0x30
jz noldz1
mov [di],ah
inc di
stosb
do_ret: ret
prtarea equ $
--
Bah, and indeed, Humbug.
Rick C. Hodgin
2020-08-23 21:14:13 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Sun, 23 Aug 2020 13:11:07 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
mov ah,2ah
int 21h
shl al,1
Post by Rick C. Hodgin
cbw
mov bx,ax
add bx,offset days
mov byte ptr [bx+2],'$'
mov dx,bx
mov ah,9
int 21h
ret
I would've found that bug yesterday or tomorrow. :-)
--
Rick C. Hodgin
a***@nospicedham.spamtrap.com
2020-08-23 22:51:17 UTC
Permalink
On Sun, 23 Aug 2020 17:14:13 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
I would've found that bug yesterday or tomorrow. :-)
Yeah, it isn't Sunday every day :-)

I like the approach though, and it can easily be adapted to 3 letters:

mov ah,2ah
int 21h
mul byte [multiplier]
mov bx,ax
add bx,days
mov byte [bx+3],'$'
mov dx,bx
mov ah,9
int 21h
ret
days db "SunMonTueWedThuFriSat"
multiplier db 3
--
aen
Kerr-Mudd,John
2020-08-24 09:39:35 UTC
Permalink
Post by a***@nospicedham.spamtrap.com
On Sun, 23 Aug 2020 17:14:13 -0400, "Rick C. Hodgin"
Post by Rick C. Hodgin
...
I would've found that bug yesterday or tomorrow. :-)
Yeah, it isn't Sunday every day :-)
mov ah,2ah
int 21h
mul byte [multiplier]
mov bx,ax
add bx,days
mov byte [bx+3],'$'
mov dx,bx
mov ah,9
int 21h
ret
days db "SunMonTueWedThuFriSat"
multiplier db 3
you can save 1 by inlining 'multiplier':

cpu 8086 ; show day str l52
org 0x100 ; mul inline num
mov ah,0x2A ; get system date
int 0x21 ; al daynum, 0=sun; cx:dx
push ax
mul byte [multiplier]
mov bx,ax
add bx,days
mov byte [bx+dylth],'$'

multiplier equ $-2

mov dx,bx
mov ah,9
int 21h
pop ax
inc ax
mov ah,0x4C
int 0x21

days db "SunMonTueWedThuFriSat"
dylth equ 3
--
Bah, and indeed, Humbug.
Loading...