Created
November 25, 2012 01:18
-
-
Save thentenaar/4142008 to your computer and use it in GitHub Desktop.
Disassembly of the TI's GPL RAND command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RAND: | |
LI R4,>6FE5 ; R4 = >6fe5 | |
MPY @>83C0,R4 ; R4,R5 = R4 × @>83C0 (initially >3567 when BASIC loads) | |
AI R5,>7AB9 ; R5 += >7ab9 | |
MOV *R5,@>83C0 ; R5 -> @>83C0 | |
MOVB R13,R6 ; 'm' (>64 when called from BASIC) -> R6 | |
SRL R6,8 ; R6 & 0xff | |
INC R6 ; R6++ (prevent division by zero) | |
CLR R4 ; R4 = 0 | |
SWPB R5 ; Swap bytes in R5 | |
DIV R6,R4 ; R5 / R6 -> R4 (mod -> R5) | |
MOVB @>83EB,@>8378 ; Return pseudo-random number (R5 % R6) | |
JMP >02AA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment