Gamegearguy 213 Member · Posted October 21 Share Posted October 21 I'm trying to make a random number from 0-255 change to between 48-127. And I can't. The computer just completely ignores my code and does its own thing. Why does it ignore my code? get_new_o mov r0,#seed mov a,@r0 mov r1,#letter_o_y_position rr a add a,#30h mov @r1,a call gfxon call waitvsync ret This SHOULD divide letter_o_y_position by 2 and then add 48 but it won't listen to me and the y position still is between 0-255, which I don't want it to be at! Link to comment Share on other sites More sharing options...
RH 4,552 Member · Posted October 21 Share Posted October 21 Try this and let me know if it helps. get_new_o mov r0, #seed ; Load seed address into R0 mov a, @r0 ; Load seed value into A swap a ; Swap nibbles anl a, #0x0F ; Mask higher nibble, this approximates /16 add a, #48 ; Add 48 to scale it between 48-127 mov r1, #letter_o_y_position ; Load y position address into R1 mov @r1, a ; Store new value at y position call gfxon call waitvsync ret Link to comment Share on other sites More sharing options...
Gamegearguy 213 Member · Posted October 21 Author Share Posted October 21 Thanks for the help! I got a working code now. I just changed one thing. get_new_o mov r0, #seed ; Load seed address into R0 mov a, @r0 ; Load seed value into A swap a ; Swap nibbles anl a, #63 add a, #48 ; Add 48 to scale it between 48-127 mov r1, #letter_o_y_position ; Load y position address into R1 mov @r1, a ; Store new value at y position call gfxon call waitvsync ret I just changed anl #15 to anl #63 because I noticed that with it set to #15, all the locations were near the top of the screen. Changing it to 63 made some more in the middle. Link to comment Share on other sites More sharing options...
RH 4,552 Member · Posted October 21 Share Posted October 21 FYI, if my post helped, I copied your post to ChatGPT. I have the paid tier which gets you access to the latest model. So I have no clue how that code helped. ChatGPT figured it out. Link to comment Share on other sites More sharing options...
RH 4,552 Member · Posted October 21 Share Posted October 21 This should be a link to the chat discussion, if you’re interested. The only thing I changed was I mentioned this was 4084 assembler, since you put that in the title. https://chat.openai.com/share/089f7731-d5a0-4894-8960-628bfd27f392 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now