Search code examples
assemblyarmarmv7

How can I get an Input from a User with using CPUlator in ARM Assembly language


I am currently working on a new project. I need to get input from the user. How can I get input from the user using ARM assembly language in CPUlator?

The work I have done so far is as follows

.global _start
 _start:

LDR R11, =0xFF200100  // buttons adress
LDR R6, [R11] //adress to buttons for get value



 end: B end
 .end

CPUlator link: https://cpulator.01xz.net/?sys=arm-de1soc

Any help will be very helpful, Thank you.


Solution

  • Well, you're on the right track. The pushbuttons of CPUlator correspond to the bits in the word in memory at the fixed address of 0xFF200050. So the following will read the word into the r0 register:

    ldr r0, =0xFF200050  //Load the address into a register
    ldr r0, [r0] //Load the contents of that address
    //Now let's do something with that number...
    

    If you check, for example, pushbuttons 0 and 2, that'll give you 5 in r0. Will that do?

    The memory address that the button state can be read from is helpfully written in the panel header of CPUlator on the right. The switches panel corresponds to the word at 0xFF200040. I'm not sure what's at 0xFF200100. On a physical device, pushbuttons and switches are probably distinct, but in the CPUlator, I can't see any difference. Use the input source that you like better.

    There's also a keyboard panel in the devices, but the processing of that would be more involved.