6 Replies - 1968 Views - Last Post: 08 December 2013 - 11:37 PM

#1 streek405   User is offline

  • D.I.C Addict

Reputation: 15
  • View blog
  • Posts: 721
  • Joined: 10-March 13

ARM Assembly - How to Save a List of Number the User Enters

Posted 07 December 2013 - 11:53 PM

Im am writing a program that takes the values the enters, using the built in keypad plug in, but I do not know how to save a list of numbers. I have written everything else for this program, but I have no idea how to properly write that particular section. This is what I have:

@a previous code that takes the number the user enters

stmfd r9, {r0}@store the value the user entered, one at a time


but that does not work.

Is This A Good Question/Topic? 0
  • +

Replies To: ARM Assembly - How to Save a List of Number the User Enters

#2 turboscrew   User is offline

  • D.I.C Lover
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,113
  • Joined: 03-April 12

Re: ARM Assembly - How to Save a List of Number the User Enters

Posted 08 December 2013 - 10:19 AM

You are probably using some simulator? Which?

I don't really understand what the problem is.
You read numbers from a keypad plugin, and want to store the read numbers?
Where? In a file or in an array in memory?

This: "@a previous code that takes the number the user enters"
is where this:
"stmfd r9, {r0}@store the value the user entered, one at a time"
doesn't work as expected?

With the previous code you mean the one discussed in the thread
"ARM Assembly - Nothing Displays In The PlugIn"?

If so, you are using r6 as "user stack pointer", so how does it not work? Or how do you expect it to work?
Or what do you see that suggests that it doesn't work?
Or What is the problem that you observe?

This post has been edited by turboscrew: 08 December 2013 - 10:34 AM

Was This Post Helpful? 0
  • +
  • -

#3 streek405   User is offline

  • D.I.C Addict

Reputation: 15
  • View blog
  • Posts: 721
  • Joined: 10-March 13

Re: ARM Assembly - How to Save a List of Number the User Enters

Posted 08 December 2013 - 02:24 PM

View Postturboscrew, on 08 December 2013 - 10:19 AM, said:

You are probably using some simulator? Which?


The ARM Simulator from their website.

Quote

I don't really understand what the problem is.
You read numbers from a keypad plugin, and want to store the read numbers?
Where? In a file or in an array in memory?

Yes. Im trying to store it in an array of memory essentially.

Quote

This: "@a previous code that takes the number the user enters"
is where this:
"stmfd r9, {r0}@store the value the user entered, one at a time"
doesn't work as expected?

With the previous code you mean the one discussed in the thread
"ARM Assembly - Nothing Displays In The PlugIn"?

If so, you are using r6 as "user stack pointer", so how does it not work? Or how do you expect it to work?
Or what do you see that suggests that it doesn't work?
Or What is the problem that you observe?


No the previous code is this, I will list the sections that are relevant to this:

TryUnlocking:
	@you cant unlock it if nothings been programmed yet, so ignore if no previous code
	BL BlueLoop
        STMFD R6!, {R0} @store the value the user presses
	BL NextState
	@if the user presses left, then done
	SWI SWI_CheckBlack
	CMP R1, #LEFT_BLACK_BUTTON
	BXEQ LR @back to LeftButton
	B TryUnlocking @keep getting values until they are done coding
	
BlueLoop: @check what blue button the user pressed and save it, wait until they press a blue button
	MOV R0, #0
	SWI SWI_CheckBlue

	cmp r0,#BLUE_KEY_15
	BXEQ LR @go back to TryUnlocking and store the value one at a time

	cmp r0,#BLUE_KEY_14
	BXEQ LR 

	cmp r0,#BLUE_KEY_13
	BXEQ LR 

	cmp r0,#BLUE_KEY_12
	BXEQ LR 

	cmp r0,#BLUE_KEY_11
	BXEQ LR 
	
	cmp r0,#BLUE_KEY_10
	BXEQ LR 

	cmp r0,#BLUE_KEY_09
	BXEQ LR 

	cmp r0,#BLUE_KEY_08
	BXEQ LR 

	cmp r0,#BLUE_KEY_07
	BXEQ LR 

	cmp r0,#BLUE_KEY_06
	BXEQ LR 

	cmp r0,#BLUE_KEY_05
	BXEQ LR 

	cmp r0,#BLUE_KEY_04
	BXEQ LR 

	cmp r0,#BLUE_KEY_03
	BXEQ LR 

	cmp r0,#BLUE_KEY_02
	BXEQ LR 

	cmp r0,#BLUE_KEY_01
	BXEQ LR 

	cmp r0,#BLUE_KEY_00
	BXEQ LR 
	
	cmp r0, #0 @nothing was pressed, keep trying
	beq BlueLoop

	
NextState:@updates the next value the user presses
	STMFD SP!, {LR}
	LDMFD SP!, {LR}
	BX LR




To be honest with you, I dont quite understand if NextState is supposed do I what I think it does; my professor wrote this down on the board for the class but I guess I copied something down wrong. Also, I believe that my professor stated that this code
STMFD R6!, {R0}
does allow you to store many values, but you need change the bit value by 4 or something, which I think (but I could be wrong) is what the nextState method is supposed to do.

So in short, TryUnlocking is supposed to get the value the user entered from the BlueLoop and then branch off to NextState, which I think will change the bit value, so the next button can be store, and then branch back to the TryUnlocking loop, until the user is done by pressing the left button.

EDIT** The BLUE_KEY's are just the values that the user presses from the keypad.

This post has been edited by streek405: 08 December 2013 - 02:25 PM

Was This Post Helpful? 0
  • +
  • -

#4 turboscrew   User is offline

  • D.I.C Lover
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,113
  • Joined: 03-April 12

Re: ARM Assembly - How to Save a List of Number the User Enters

Posted 08 December 2013 - 04:46 PM

The STMFD and LDMFD are stack operations. The STMFD can push multiple registers in stack and the LDMFD can pop multiple registers from stack.

See this - page 58.
Was This Post Helpful? 1
  • +
  • -

#5 streek405   User is offline

  • D.I.C Addict

Reputation: 15
  • View blog
  • Posts: 721
  • Joined: 10-March 13

Re: ARM Assembly - How to Save a List of Number the User Enters

Posted 08 December 2013 - 05:24 PM

View Postturboscrew, on 08 December 2013 - 04:46 PM, said:

The STMFD and LDMFD are stack operations. The STMFD can push multiple registers in stack and the LDMFD can pop multiple registers from stack.

See this - page 58.

Thank you, I wish I knew about this link when I first started this class lol. One last question though: since there is no fixed amount of buttons that the user can save, is it possible to save multiple values into just one register? There are only 13 registers, I think, so if the user presses 20 buttons there are not enough registers. Is there a way that I can store these values if the user presses X amount of buttons?
Was This Post Helpful? 0
  • +
  • -

#6 turboscrew   User is offline

  • D.I.C Lover
  • member icon

Reputation: 171
  • View blog
  • Posts: 1,113
  • Joined: 03-April 12

Re: ARM Assembly - How to Save a List of Number the User Enters

Posted 08 December 2013 - 11:00 PM

It's possible to "pack" 4 bytes into 32-bit register, but it's not advisable here.
You could use normal LDR/STR or put the beginning address of the storage to r6 and
store with STMEA R6!, {R0}
Was This Post Helpful? 1
  • +
  • -

#7 streek405   User is offline

  • D.I.C Addict

Reputation: 15
  • View blog
  • Posts: 721
  • Joined: 10-March 13

Re: ARM Assembly - How to Save a List of Number the User Enters

Posted 08 December 2013 - 11:37 PM

View Postturboscrew, on 08 December 2013 - 11:00 PM, said:

It's possible to "pack" 4 bytes into 32-bit register, but it's not advisable here.
You could use normal LDR/STR or put the beginning address of the storage to r6 and
store with STMEA R6!, {R0}

Ok thanks!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1