Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Thread Closed: Off-topic

???
12/19/01 16:59
Read: times


 
#17821 - RE: Here is the code, Random Dice #'s
<pre>
;******************************************************************************
;$DEBUG
;$MOD762
;******************************************************************************
;Application Note: ROLLING A DICE PROGRAM
;Description: SIMULATE A DICE BEING ROLLED
;Controller: 8051
;Components: 7 Segment Display, Switch
;Name: Glenn Heard
;******************************************************************************
;Ports: All of port 1 is used to output the contents of the program to the 7
; Segment Display. Reset is Port 1.5. And the switch is on Port 0.3.
;******************************************************************************
org 0000 ;Start

msl data 2bh ;Unknown Entry Event
Roll: ;Roll Module
Jnb P0.3, ROLL ;Jump if the switch isn't set
ACALL RANDOMIZE ;GOTO the Randomize Module
ANL A, #07H ;Insted of 0-255 the ACC will read 0-7
JZ ROLL ;If jumped then goto zero
DEC A ;Decrement the accumulator
JZ ROLL ;If jumped then goto zero
ACALL LOOKUP ;GOTO the Lookup Module
MOV P1, A ;Move the contents of the ACC to Port 1
SJMP ROLL ;Jump Back to roll

LOOKUP: ;LOOKUP Module
MOVC A, @A+PC ;Add contents of ACC and ProgCounter

RET ;RETURN
DB 11111001B ;1
DB 10100100B ;2
DB 10110000B ;3
DB 10011101B ;4
DB 10010010B ;5
DB 10100010B ;6
DB 11111000B ;7

RANDOMIZE: push 7 ;PUSH 7 ONTO THE STACK
mov a, msl ;MOV MSL TO A
add a, acc ;ADD ACC TO ACC
add a, acc ;ADD ACC TO ACC
mov 7, a ;MOVE ACC TO MEM LOCATION 7
add a, acc ;ADD ACC TO ACC
add a, 7 ;ADD 7 TO ACC
mov 7, a ;MOVE ACC TO MEM LOCATION 7
mov a, msl ;MOVE MSL INTO ACCUMULATOR
add a, 7 ;ADD 7 INTO THE ACCUMULATOR
inc a ;INCREMENT THE ACCUMULATOR
mov msl, a ;MOVE THE ACC INTO MSL
pop 7 ;TAKE 7 OFF THE STACK
ret ;RETURN

END ;END
</pre>

List of 30 messages in thread
TopicAuthorDate
What Does The "MSL" Statement Do?!?            01/01/70 00:00      
RE: What Does The "MSL" Statement Do?!?            01/01/70 00:00      
RE: What Does The "MSL" Statement Do?!?            01/01/70 00:00      
RE: What Does The \\            01/01/70 00:00      
RE: MSL does exist cause i programmed it            01/01/70 00:00      
RE: MSL does exist cause i programmed it            01/01/70 00:00      
RE: MSL does exist cause i programmed it            01/01/70 00:00      
RE: MSL does exist cause i programmed it            01/01/70 00:00      
RE: What Does The \\            01/01/70 00:00      
RE: MSL does exist cause i programmed it            01/01/70 00:00      
RE: What Does The - J Guy            01/01/70 00:00      
RE: What Does The - J Guy            01/01/70 00:00      
RE: What Does The - J Guy            01/01/70 00:00      
RE: What Does The - J Guy            01/01/70 00:00      
RE: What Does The - Steve            01/01/70 00:00      
RE: What Does The - Steve            01/01/70 00:00      
RE: What Does The \            01/01/70 00:00      
RE: What Does The \            01/01/70 00:00      
The Ammsebler code            01/01/70 00:00      
RE: The Ammsebler (sic) code            01/01/70 00:00      
RE: The Ammsebler (sic) code            01/01/70 00:00      
RE: Here is the code, Random Dice #'s            01/01/70 00:00      
it's not a statement it's a variable            01/01/70 00:00      
A variable?            01/01/70 00:00      
RE: Here is the code, Random Dice #'s            01/01/70 00:00      
RE: Here is the code, Random Dice #'s            01/01/70 00:00      
RE: Here is the code, Random Dice #'s            01/01/70 00:00      
RE: Here is the code, Random Dice #'s            01/01/70 00:00      
RE: What Does The "MSL" Statement Do?!?            01/01/70 00:00      
RE: What Does The \\\\            01/01/70 00:00      

Back to Subject List