OUT SPH asm

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

I'm learning asm through a tutorial, so at this point I'm clueless. The tutorial uses a Butterfly m169, but I'm writing for a tiny 2313 and I have run into a roadblock with "SPH". I understand that the 2313 does not have enough sram to use that, and simply commenting out the "OUT SPH"  line allows the source to compile/assemble.

 What I don't understand though, is  all I have to do to solve the problem is simply comment out that line and all is well, or should I use other instructions to compensate for commented out the line.

<code>

.nolist
.include "tn2313adef.inc" ; Define device ATtiny2313A
.list

.DEF A = R16
.DEF I = R21
.DEF J = R22

.ORG $0000

START:
     LDI A,LOW(RAMEND)
     OUT SPL,A
     LDI A,HIGH(RAMEND)
     ;OUT SPH,A                   ;comment out line and it assembles
     LDI A,0b11111111
     OUT DDRB,A

;MAIN ROUTINE

BEEP: CLR I
BLUPE:
      SER A
      OUT PORTB,A
      RCALL PAUSE
      CLR A
      OUT PORTB,A
      RCALL PAUSE
      DEC I
      BRNE BLUPE
LOOP: RJMP LOOP

PAUSE:
      CLR J
PLUPE:
      NOP
      DEC J
      BRNE PLUPE
      RET
</code>

This topic has a solution.
Last Edited: Thu. Dec 27, 2018 - 12:07 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

all I have to do to solve the problem is simply comment out that line and all is well,

Correct.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Have you looked in the data sheet to see if the tiny2313 has an SPH register?

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

Technically you could comment out the preceding LDI instruction as well.  S.

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

And if we go to the real detail: comment out all the RAMEND code (4 instructions), a tiny 2313 will init the stack at boot.

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

And you're right.  You sent me down to the spec sheet to look at that, and I've been doing my 2313s wrong all this time.  On reset, sayeth the spec, it will initialize to RAMEND.  Learn new things every day...

 

Including possibly bad habits.  I checked the spec for a mega8535 and a mega168; they do NOT initialize to RAMEND, SP(H:L) initializes to zeros across the board.  Which will blow a collywobble the moment it's used unless you do something about it.  Initializing the stack pointer is practically boilerplate code that I put into all my projects.  Leaving it out would frighten me, but according to the spec, it'll work - on a 2313.

 

I did not know that the 2313 would do that before, now I do.  Thanks.  S.

 

Edited to add:  Oh, ouch!  A tiny2313 A will do that, but a tiny2313 w/o suffix won't!  Yikes!  Talk about learning a bad habit, leaving out stack pointer code...  S.

Last Edited: Thu. Dec 27, 2018 - 02:02 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

No all tiny2313's will do the RAMEND init it's the org. 2313 that don't.

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

sparrow2 wrote:

No all tiny2313's will do the RAMEND init it's the org. 2313 that don't.

 

I checked an old .pdf spec I had for the "not A" tiny2313, and it does say it's 'preliminary', but it is an 'ATtiny2313 [/V]' that initializes its stack pointer to zero.  See attached, page 10:

 

Thanks, S.

Attachment(s): 

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

I leave the stack pointer init code anyway, never been that desperate for a few bytes. wink and of course if for some reason things go bad and the code goes to start having the stack properly initialised that may save the bacon.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Scroungre wrote:
On reset, sayeth the spec, it will initialize to RAMEND.
js wrote:
I leave the stack pointer init code anyway, never been that desperate for a few bytes. wink and of course if for some reason things go bad and the code goes to start having the stack properly initialised that may save the bacon.

 

!!!  Indeed.

 

Scroungre wrote:
Edited to add: Oh, ouch! A tiny2313 A will do that, but a tiny2313 w/o suffix won't! Yikes! Talk about learning a bad habit, leaving out stack pointer code... S.

Strange--no mention in the migration app note:  http://ww1.microchip.com/downloa...

 

And the reason is that an ATtiny2313 >>will<< set the stack pointer to RAMEND.

 

[Trivia:  Are there >>any<< models with Tiny in the part name that don't do that?  I'd say all "modern" Mega models as well (not Mega103, for sure...)]

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

theusch wrote:
[Trivia: Are there >>any<< models with Tiny in the part name that don't do that?

E.g, ATtiny13, first datasheet in 2003:

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Scroungre wrote:

I checked the spec for a mega8535 and a mega168; they do NOT initialize to RAMEND,

 

Dunno if they count as 'modern'.  S.

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

Eh? The 48/88/168 surely DO init SP?

EDIT not easy on a mobile but see attached! 

Attachment(s): 

Last Edited: Sat. Dec 29, 2018 - 02:11 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Eh? The 48/88/168 surely DO init SP?

Perhaps a typo and the scroungemonster meant '169?

 

Anyway, from above real 'Freaks agree that the ap should set the stack pointer, to guard against arriving at 0 from other than a clean reset.  If you need to save a couple words, then omit that knowing the choice you have made -- who needs those seatbelts anyway?

 

How many camels can fit through the eye of a needle?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Oops.  Something like that - or I had clicked on the '169 spec when I thought I had clicked on the '168.  They're adjacent in my 'spec sheet collection'.  My Bad.

Confirmed that the 169 and 8535 do not.  The 168 DOES.

 

How many camels can fit through the eye of a needle?

That depends on the reliability of your camel-grinding machine.  wink  S.

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

...or the size of the unspecified needle....

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

js wrote:
...or the size of the unspecified needle....

The size of the needle is well known; more on that later.

 

The question how many angels can dance on the head of a pin? has been used many times as a trite dismissal of medieval angelology in particular, of scholasticism in general, and of particular figures such as Duns Scotus and Thomas Aquinas.[1] Another variety of the question is How Many Angels Can Sit On The Head Of A Pin? In modern usage, this question serves as a metaphor for wasting time debating topics of no practical value.[2][3]

From e.g. https://answers.yahoo.com/questi...

 

The camels/eye/needle variant is often thought to be the same rhetorical question, from the New Testament of the Christian Bible; one translation

“It is easier for a camel to go through the eye of a needle, than for a rich man to enter into the kingdom of God.” (Matt. 19:24.)

But a somewhat different slant on the same quote, illustrated here:

 
Yesteryear  
Semantic enigmas  
The body beautiful  
Red tape, white lies  
Speculative science  
This sceptred isle  
Root of all evil  
Ethical conundrums  
This sporting life  
Stage and screen  
Birds and the bees  

 

  NOOKS AND CRANNIES

I recently read that one of the gates into Jerusalem was named "The Eye of the Needle," and was quite tricky to negotiate, since it was quite small. Does this mean that when Jesus said "It is easier for a camel to pass through the eye of a needle than for a rich man to enter the Kingdom of Heaven," He meant that, far from being impossible, it was merely tricky?

 

Dara O'Reilly, London, UK

  • The interpretation that seems to make sense is this. The "Eye of the Needle" was indeed a narrow gateway into Jerusalem. Since camels were heavily loaded with goods and riders, they would need to be un-loaded in order to pass through. Therefore, the analogy is that a rich man would have to similarly unload his material possessions in order to enter heaven.

     

    Rick, Brighton Uk

  • I was told that the point about the narrowness of the gate meant the camel had to be unloaded to pass through it. Thus a rich man would need to free himself of his possesions in order to enter paradise.

     

    chris, bristol england

  • The eye of the needle used to be in Damascus and was a side gate alongside the main gate of the "street called straight" Being a side gate it was not intended for passage by animals especially camels carrying side loads. So it was nigh impossible for the act to happen.

     

    Jack Hill, St Albans England

  • When i was at school one of the masters, a devout Christian, was given to explain aspects of the bible to doubters like myself. His explanation of Jesus's parable implied that a rich man wanting to enter the Kingdom of Heaven had to unload a lot of baggage, like a camel going through the "Eye of the Needle" gate in Jerusalem

     

    John Spiers, Borehamwood England

  • ...

https://www.theguardian.com/note...

 

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

This is when it pays to be a lawyer devil (or not) the camel's size or age was not specified, a baby camel could easily go trough the "eye of a needle" then even with some small load.

 

And what about a camel cigarette? cheeky or even an entire packet! ("whatever you do just don't smoke")

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

There is no historical evidence of any reliability stating that any city had any gates called 'The Eye of the Needle' or anything like it in any language.  The idea that Jesus was talking about a real city entrance is entirely fiction.  As T. Heusch pointed out, it was meant rhetorically then, and it still is now.  But I still want a camel-grinding machine.  S.

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

js wrote:

...the camel's size or age was not specified, a baby camel could easily go trough the "eye of a needle" then even with some small load.

 

Some scholars believe this to be a mistranslation; the Aramaic word for camel was 'gamla' which may have been confused with the word for sturdy rope, which was 'gamta'.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

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

This particular scholar believes that in the service of and attempting to become one of the wealthy many have grasped at the faintest of straws in order to reconcile their own worldly ambitions and material goods with Biblical teaching.  Of course, we've gone a bit OT here...  S.

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

One of the most entertaining things on Freaks over the years are the myriad ways folks interpret Lee Theuch's name. Admittedly an unusual surname but intriguing nonetheless :-)

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

Scroungre wrote:
There is no historical evidence of any reliability stating that any city had any gates called 'The Eye of the Needle' or anything like it in any language.

Yeah, this photo clip is Fake News, done by the same crew as the lunar landing(s): https://www.youtube.com/watch?v=...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

I don't think Jesus had YouTube.

 

That there is one today isn't very surprising.  It's exactly the sort of thing an enterprising revisionist (and tourist-hunter) would build.

 

That it actually dates back 2000 years is highly questionable, particularly given the total lack of documentation thereof before the 15th century.  I'm sure plenty of archaeologists could give you a lecture on the stonework, as well.  S.

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

Scroungre wrote:
particularly given the total lack of documentation thereof before the 15th century.

Jewish Talmadic literature postdates that?

Indeed, Jewish Talmudic literature uses a similar aphorism about an elephant passing through the eye of a needle as a figure of speech implying the unlikely or impossible:

"They do not show a man a palm tree of gold, nor an elephant going through the eye of a needle."4

This first instance concerned dreams and their interpretation and suggested that men only dream that which is natural or possible, not that which is unlikely ever to have occurred to them.

"… who can make an elephant pass through the eye of a needle."5

In this case, the illustration concerns a dispute between two rabbis, one of whom suggests that the other is speaking "things which are impossible".

The camel was the largest animal seen regularly in Israel, whereas in regions where the Babylonian Talmud was written, the elephant was the biggest animal. Thus the aphorism is culturally translated from a camel to an elephant in regions outside of Israel.

The aim is not, then, to explain away the paradox and make the needle a huge carpet needle for, elsewhere, the Jewish writings use the "eye of the needle" as a picture of a very small place, "A needle's eye is not too narrow for two friends, but the world is not wide enough for two enemies."6 . The ludicrous contrast between the small size of the needle's eye and the largest indigenous animal is to be preserved for its very improbability.

From #17 above:

theusch wrote:
The question how many angels can dance on the head of a pin?

and

theusch wrote:
In modern usage, this question serves as a metaphor for wasting time debating topics of no practical value.
  ;)

 

[my summary would be somewhat of a translation artifact, as outlined in the source quoted in this post http://www.biblicalhebrew.com/nt... .  Depending on your particular tenets, it could be something "impossible", or [[as with the city gate and the camel]] "difficult"]

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.