LDI variable,' '

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Encontré esta instrucción LDI rmp,'  ' , en la linea de comentario dice "overwrite with blank", esta instrucción esta dentro de una subrutina que detecta un cero(0).

 he ejecutado el código y lo que hace es cargar el valor de 0x20 a la variable " rmp =0x20"

, deseo saber porque se hace esta instrucción, esta instrucción se encuentra antes de enviarlo como ASCII a un LCD. 

Anexo el código:

 

 

Bin2ToAsc5:
    rcall Bin2ToBcd5 ; convert binary to BCD
    ;ldi rmp,4 ; Counter is 4 leading digits
    ;mov rBin2L,rmp
Bin2ToAsc5a:
    ldi r16,0
    mov r0,r16

    ld rmp,z ; read a BCD digit
    tst rmp ; check if leading zero
    brne Bin2ToAsc5b ; No, found digit >0
   ;-------------------------------------------
    ldi rmp,' ' ; overwrite with blank
    st z+,rmp ; store and set to next position
    dec rBin2L ; decrement counter
    brne Bin2ToAsc5a ; further leading blanks
    ld rmp,z ; Read the last BCD
    

Bin2ToAsc5b:
    rcall Bin2ToBcd5 ; Subrutina convertir de binario a BCD
    ;ldi rmp,5 ; Contador
    ldi contador,5; Contador
    ldi r25,0x30

    -

    -

    -

This topic has a solution.
Last Edited: Mon. Jun 10, 2019 - 08:12 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Please do not cross post or post duplicates!

 

Also, English is the board language.

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Mon. Jun 10, 2019 - 06:41 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found this LDI instruction rmp, '', in the comment line it says "overwrite with blank", this instruction is inside a subroutine that detects a zero (0).

  I have executed the code and what it does is load the value of 0x20 to the variable "rmp = 0x20"

, I want to know why this instruction is done, this instruction is found before sending it as ASCII to an LCD.

Attach the code:

 

Bin2ToAsc5:
    rcall Bin2ToBcd5 ; convert binary to BCD
    ;ldi rmp,4 ; Counter is 4 leading digits
    ;mov rBin2L,rmp
Bin2ToAsc5a:
    ldi r16,0
    mov r0,r16

    ld rmp,z ; read a BCD digit
    tst rmp ; check if leading zero
    brne Bin2ToAsc5b ; No, found digit >0
   ;-------------------------------------------
    ldi rmp,' ' ; overwrite with blank
    st z+,rmp ; store and set to next position
    dec rBin2L ; decrement counter
    brne Bin2ToAsc5a ; further leading blanks
    ld rmp,z ; Read the last BCD
    

Bin2ToAsc5b:
    rcall Bin2ToBcd5 ; Subrutina convertir de binario a BCD
    ;ldi rmp,5 ; Contador
    ldi contador,5; Contador
    ldi r25,0x30

    -

    -

    -

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

rmp is a 'name' given to 'something....in this case it's most likely a register

 

The hex value 0x20 in ASCII is the SPACE character, so by putting a SPACE between to apostrophe's its the same as writing

ldi rmp,0x20 ; overwrite with blank

 

Why they elected to call it a 'blank' is something I cannot explain

 

Est coast Jim

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ldi instruction loads a constant (value) into the specified register (only register numbers r0 to r15 allowed).   "blank" character is often used as a poor wording choice for "space" character, which is 0x20, or $20.

somewhere rmp has been defined as the name of some register (r0 to r15)

 

like:

.def rmp=r12    ;rmp is now same as typing r12

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

avrcandies wrote:
ldi instruction loads a constant (value) into the specified register (only register numbers r0 to r15 allowed)

 

You sure?

I have been using R16 as my 'working' register and perform the LDI instruction to it, and any other register.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When writing to an LCD, it's pretty common to write the full width of the display, and you want to pad the part that doesn't contain your values with spaces.

Otherwise, if you write "Booting up now", followed by "ADC reads 12", you might see "ADC reads 12ow"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

first it's r16 to r31 you can use LDI on.

 

I have only looked shortly at it but it looks like it's so they get "   345" instead of "00345"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

sparrow2 wrote:
first it's r16 to r31 you can use LDI on.

 

Correct.  I looked it up after I hit post and realised my answer was rather vague.

 

JIm

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

thank you very much, now I find it was obvious to send a space to the HMI

Last Edited: Mon. Jun 10, 2019 - 08:15 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You sure?

I have been using R16 as my 'working' register and perform the LDI instruction to it, and any other register.

Oops I was hanging upside down when I wrote that...it is indeed the 16 higher registers!!

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!