Recently I updated (slimmed down) my calendar program. but there was 0 interest.
I think I spent nearly a month trying various tricks to get a really compact nonjmp 'n'teenth routine. jmp version still won. Perhaps a bit obsessive.
...
;;; ax=day num [1-31] want 1st 2nd 3rd but 11th 12th 13th, then 21st 22nd 23rd ... 31st
call put2dec ;' dD'
;; put nth [21+2] ; ah | al
; 30 31 32 33 | 30 31 32 33 34-39
xor ah,0x01 ; 31 30 33 32 [3]
add ax,0x4FCC ; 80 7F 82 81 | FC FD FE FF 00-05
cwd ; dh=FF/00
isz:
and bl,dh ; scrap teens
cbw ; flag 0-3 in ah
and bl,ah ; scrap 9-4
; shl bx,1 ; *2
lea si,[bx+thstrs] ; pt to st etc
add si,bx ; si+2*bx
movsw ; 'th/st/nd/rd'
;; end put nth
...
put2dec: ; I: al=2dig num; uses ax, di inc by 1 or 2
aam ; zr if al=0, not ah, bah.
mov bl,al ; save ix (bh=0) [2]
or ax,0x3030 ; to disp
cmp ah,0x30
jz noldz1
mov [di],ah ; put tens
inc di
noldz1:
stosb ; put digit
do_ret: ret
thstrs db 'thstndrd'