I am part of the Vera project, and we are hoping for some optimizations, and possibly new coders. I thought I would post a couple of sets of code for possible optimizations.

Code:
;; === system_random ===
;;
;; Generate a pseudo random number between 0 and 255
;;
;; Authors:
;;   Joe Wingbermuehle for Ion
;;   Adapted slightly for Vera by Tim Franssen (mail@timendus.com)
;;
;; Post:
;;   a = random number between 0 and 255 inclusive

system_random:
   push    hl
   push    de
   ld      hl,(SEED)
   ld      a,r
   ld      d,a
   ld      e,(hl)
   add     hl,de
   add     a,l
   xor     h
   ld      (SEED),hl
   pop     de
   pop     hl
   ret


Code:
;; === system_sleep ===
;;
;; Sleep for hl * 10.000 + 69 clockcycles
;;
;; Authors:
;;   Tim Franssen (mail@timendus.com)
;;
;; Pre:
;;   hl = number of clockcycles / 10.000 to sleep
;;
;; Example:
;;     ld hl,SECS2SLEEP(30)
;;     call system_sleep
;;     ; About 30 seconds have passed

system_sleep:                   ; call = 17 cc
   push af                 ; 11 cc
   push bc                 ; 11 cc
system_sleep_loop1:
   ld b,181                ; 7 cc
system_sleep_loop2:      
   push hl                 ; 11 cc
   pop hl                  ; 10 cc
   push hl                 ; 11 cc
   pop hl                  ; 10 cc
   djnz system_sleep_loop2 ; 13/8 cc
                           ; total: 55 cc per iteration
                           ; times 181 = 9955 cc
   
   in b,(c)      ; 12 cc
   dec hl                  ; 6 cc
   ld a,h                  ; 4 cc
   or l                    ; 4 cc
   jr nz,system_sleep_loop1; 12/7 cc
                           ; total overhead per hl: 45 cc
   
   pop bc                  ; 10 cc
   pop af                  ; 10 cc
   ret                     ; 10 cc
                           ; call overhead: 69 cc
It's my understanding that that project hasn't gone anywhere for a very long time. You can't write a third-party OS without people extremely experienced in the language and the peculiarities of the calculator itself, and a lot of time and motivation. I'm not sure the project has any of that.

There's nothing wrong with Joe's ionRandom routine, which that basically is, but as far as your other routine, you don't want to be reading from some random port like that. Simply reading from certain ports can throw off the hardware (link assist, USB counter and 0Axh ports, etc.). You never set C, so there's no telling what effect that code is going to have.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
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

 

Advertisement