Hey guys! There's big stuff going on behind the scenes! Follow
@UnSyntaxSoft on Twitter to keep up to date! (Registry is down again :( )
|
Posted: Fri Mar 21, 2008 6:05 pm
|
|
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
| _________________ "Mac's are the Perfect Computer", said the Perfect Idiot.
Testing for:
Vera
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
|
|
JoostinOnline
Senior

Posts: 428
Joined: 19 Aug 2007
Location: Behind You

|
|