please dont rip this site

Microchip Seepicsrc Psbpix Random.asm

; 
; ***************************************************************************
; ***  Bubble Software Parallax to PIC Source Converter. Copyright 1999.  ***
; ***  http://www.picnpoke.com                 email: sales@picnpoke.com  ***
; ***************************************************************************
;
; <B style="color:black;background-color:#ffff66">random</B>
; Generates a pseudo<B style="color:black;background-color:#ffff66">random</B> number. Works best if called from a loop so that
; the value of its workspace variable (consisting of lowB and hiB) is
; constantly stirred.	

	P = pic16c55
	#include <16c55.inc>   ; processor assembler definitions
	_CONFIG _xt_osc & _wdt_off & _protect_off
 reset start

 org 8
hiB Res d'1' ; MSB of 16-bit <B style="color:black;background-color:#ffff66">random</B> number.
lowB Res d'1' ; LSB of 16-bit <B style="color:black;background-color:#ffff66">random</B> number.
temp Res d'1' ; Temporary counter for delay.
temp2 Res d'1' ; Temporary counter for delay.

; Device data and reset vector
 org 0

start mov !rb,#0  ; Output to show sequ onence LEDs.
             MOVLW d'13'                ; Arbitrary starting values
             MOVWF lowB
             MOVLW d'99'                ; for the shift register.
             MOVWF hiB
start_loop   CALL <B style="color:black;background-color:#ffff66">random</B>                
             MOVF lowB,w                ; Display 8-bit <B style="color:black;background-color:#ffff66">random</B> numbers
             MOVWF 6h
             CALL delay                 ; on LEDs connected to RB.
             GOTO start_loop            ; Endless loop
; <B style="color:black;background-color:#ffff66">random</B> number generator.
<B style="color:black;background-color:#ffff66">random</B>       MOVF hiB,w                 ; First, ensure that hiB and lowB aren't
             IORWF lowB,w               ; all zeros. If they are, NOT hiB to FFh.
             BTFSC status,z             ; Otherwise, leave hiB and lowB as is.
             COMF hiB                   
             MOVLW 0x80                 ; We want to XOR hiB.7, hiB.6, hiB.4
             BTFSC hiB,d'6'             ; and lowB.3 together in W. Rather than
             XORWF hiB                  ; try to line up these bits, we just
             BTFSC hiB,d'4'             ; check to see whether a bit is a 1. If it
             XORWF hiB                  ; is, XOR 80h into hiB. If it isn't,
             BTFSC lowB,d'3'            ; do nothing. When we're done, the
             XORWF hiB                  ; XOR of the 4 bits will be in hiB.7.
             RLF hiB,w                  ; Move hiB.7 into carry. 
             RLF lowB                   ; Rotate c into lowB.0, lowB.7 into c. 
             RLF hiB                    ; Rotate c into hiB.0. 
             RETLW 0h                   ; Delay loop for program demo. Remove when using just <B style="color:black;background-color:#ffff66">random</B>. 
delay        DECFSZ temp                
             GOTO delay
             DECFSZ temp2               
             GOTO delay
             RETLW 0h                   

             
             
             end


file: /Techref/microchip/seepicsrc/psbpix/random.asm, 2KB, , updated: 2000/7/17 18:09, local time: 2024/6/17 03:33,
TOP NEW HELP FIND: 
18.191.225.220:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://www.piclist.com/techref/microchip/seepicsrc/psbpix/random.asm?from=%2Ftechref%2Fmicrochip%2Fmath%2Fbasic.htm&key=random"> microchip seepicsrc psbpix random</A>

Did you find what you needed? From: "/techref/microchip/math/basic.htm" "random"

  PICList 2024 contributors:
o List host: MIT, Site host massmind.org, Top posters @none found
- Page Editors: James Newton, David Cary, and YOU!
* Roman Black of Black Robotics donates from sales of Linistep stepper controller kits.
* Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters.
* Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated!
* Contributors: Richard Seriani, Sr.
 

Welcome to www.piclist.com!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .