home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 4,136 of 4,675   
   Kerr-Mudd,John to notsaying@nospicedham.127.0.0.1   
   Re: prt nth (was: Re: small asm code (co   
   07 Sep 20 14:07:51   
   
   From: notsaying@nospicedham.127.0.0.1   
      
   On Mon, 07 Sep 2020 09:52:16 GMT, "Kerr-Mudd,John"   
    wrote:   
      
   > On Fri, 04 Sep 2020 12:56:20 GMT, "Kerr-Mudd,John"   
   >  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.   
   >   
   Of course as soon as you post something you spot an improvement!   
   (still 1 too many!)   
   >   
    cpu 8086 ;nth2h l 87 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   
      
               lea si,[bx+thstrs]   
      
   >           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.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca