flat assembler
Message board for the users of flat assembler.

Index > DOS > Binary Clock

Author
Thread Post new topic Reply to topic
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
A simple binary clock. that works on Windows XP console and DosBox emulator.
191 bytes, my code sucks, i know that.
But i'm learning..or at least i'm trying..Razz
Code:
    org 100h
    mov ax,0003h         ;clear screen 
 int 10h
     mov ax,0103h
        mov cx,2000h
        int 10h
     int3 
       
    push 0b800h
 pop es
      
main:      
 mov si,04dbh          ;dark red color box 
  mov di,1126           ;first led position 
  call timee          
        mov ah,1
    int 16h
     jz main
     int 20h
     
timee:
      mov ah,02h          ;time in bcd
    int 1ah
     mov bl,ch             ;hour
 call split
  mov bl,cl              ;minutes
     call split
  mov bl,dh             ;seconds
      call split
  ret
  
split:                  
   push bx              ;split bcd value
       shr bl,4
    call status
 pop bx
      and bl,0fh
  call status
 ret 
        
status:
     push cx dx
  xor dx,dx      
     mov al,bl
   mov cx,2
    div cx
      cmp dx,1               ;case 1
      jne @f
      mov si,0cdbh         ;light red color box
  @@: 
     call led                  ;show led
 cmp bl,2                ;case 2-3-6-7
       jb @f
       cmp bl,4
    je @f
       cmp bl,5
    je @f
       cmp bl,7
    ja @f
       mov si,0cdbh
  @@:  
 call led
    cmp bl,7                ;case <=7  >=4
        ja @f
       cmp bl,4
    jb @f
       mov si,0cdbh
  @@:  
 call led     
       cmp bl,8                ;case >=8
        jb @f
       mov si,0cdbh
  @@:
   call led
    add di,1286            ;next row
    pop dx cx
   ret
 
led:
        cmp di,486            ;non visible leds
     je off
      cmp di,166
  je off
      cmp di,178
  je off
      cmp di,190
  je off
  show:
       xchg ax,si
  stosw
       stosw
       sub di,324             ;next led pos 
       mov si,04dbh
        ret
  off:
   xor si,si
   jmp show
    


Here is a help image:

Image
Post 16 Sep 2007, 14:07
View user's profile Send private message Reply with quote
rugxulo



Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)
rugxulo
Nice job, thimis! I tweaked it for 8086 compatibility and added it to my FreeDOS disk #2. Smile

Code:
; BINCLOCK.ASM -- by thimis (tweaked a bit for 8086 by Rugxulo, 200 bytes)
;
; http://board.flatassembler.net/topic.php?t=7628

        org 100h

        call cls
         
        mov ax,0b800h
        mov es,ax
         
main:       
        mov si,04dbh          ;dark red color box  
        mov di,1126           ;first led position  
        call timee           
        mov ah,1 
        int 16h 
        jz main 
        call cls            ; clear screen at exit
        ret
         
timee: 
        mov ah,02h          ;time in bcd 
        int 1ah 
        mov bl,ch             ;hour 
        call split 
        mov bl,cl              ;minutes 
        call split 
        mov bl,dh             ;seconds 
        call split 
        ret 
          
split:                   
        push bx              ;split bcd value
        push cx
        mov cl,4
        shr bl,cl
        pop cx
        call status 
        pop bx 
        and bl,0fh 
        call status
        ret
         
status: 
        push cx dx 
        xor dx,dx       
        mov al,bl 
        mov cx,2 
        div cx 
        cmp dx,1               ;case 1 
        jne @f 
        mov si,0cdbh         ;light red color box 
  @@:  
        call led                  ;show led 
        cmp bl,2                ;case 2-3-6-7 
        jb @f 
        cmp bl,4 
        je @f 
        cmp bl,5 
        je @f 
        cmp bl,7 
        ja @f 
        mov si,0cdbh 
  @@:   
        call led 
        cmp bl,7                ;case <=7  >=4 
        ja @f 
        cmp bl,4 
        jb @f 
        mov si,0cdbh 
  @@:   
        call led      
        cmp bl,8                ;case >=8 
        jb @f 
        mov si,0cdbh 
  @@: 
        call led 
        add di,1286            ;next row 
        pop dx cx 
        ret 
         
led: 
        cmp di,486            ;non visible leds 
        je off 
        cmp di,166 
        je off 
        cmp di,178 
        je off 
        cmp di,190 
        je off 
  show: 
        xchg ax,si 
        stosw 
        stosw 
        sub di,324             ;next led pos  
        mov si,04dbh 
        ret 
  off: 
        xor si,si 
        jmp show

cls:
        mov ax,3         ;clear screen
        int 10h 
        mov ax,0103h 
        mov cx,2000h 
        int 10h
        ret
    
Post 07 Oct 2007, 03:04
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
hey that's very nice, thanks rugxulo! Very Happy
Post 08 Oct 2007, 19:11
View user's profile Send private message Reply with quote
mikegonta



Joined: 20 Nov 2005
Posts: 99
mikegonta
[ Post removed by author. ]


Last edited by mikegonta on 28 Jan 2009, 09:12; edited 2 times in total
Post 20 May 2008, 23:54
View user's profile Send private message Reply with quote
rCX



Joined: 29 Jul 2007
Posts: 166
Location: Maryland, USA
rCX
Cool! Have you guys considered submitting these to 256b?
Post 21 May 2008, 03:18
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4242
Location: 2018
edfed
ok, it's pretty good, then, i decided to make it in fool 16bits.
Image
and it works. Very Happy

it compiles in 345 bytes, waste ~ 200 bytes, but is very modular and evolutive.

includes only the needed functions, and halts to save cpu time.


Description: fool for 16 bits, no call field, just needed datas.
Download
Filename: binclock.zip
Filesize: 2.94 KB
Downloaded: 140 Time(s)



Last edited by edfed on 25 May 2008, 21:34; edited 1 time in total
Post 21 May 2008, 18:28
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
Works nice edfed!

rCX wrote:
Cool! Have you guys considered submitting these to 256b?

hmm i guess not, it's a simple script and there are some really amazing demos inside there Razz
Post 25 May 2008, 21:11
View user's profile Send private message Reply with quote
JN
Guest




JN
nice code, thimis !! it looks cool Very Happy
Post 30 Sep 2008, 13:45
Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: Paradise Falls
Picnic
thanks JN Smile
Post 04 Oct 2008, 12:19
View user's profile Send private message Reply with quote
Coddy41



Joined: 18 Jan 2009
Posts: 384
Location: Ohio, USA
Coddy41
Nice, their is some goodies in there Smile
Post 22 Jan 2009, 11:54
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.