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,116 of 4,675   
   Kerr-Mudd,John to aen@nospicedham.spamtrap.com   
   Re: small asm code (compo?)   
   26 Aug 20 11:32:27   
   
   From: notsaying@nospicedham.127.0.0.1   
      
   On Tue, 25 Aug 2020 05:34:01 GMT, aen@nospicedham.spamtrap.com wrote:   
      
   > On Mon, 24 Aug 2020 09:32:28 -0000 (UTC), "Kerr-Mudd,John"   
   >  wrote:   
   >>...   
   >>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.   
      
   --- 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