line-break ( asm file )

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

is there a way to add a line-break in an .s ( asm ) file?

nop \n nop
vs
nop
nop

?

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

By .s are you talking about avr-as? (I bet you meant .S not .s or you are in for trouble!). Try:

nop $ nop

as described in the manual here:

http://sourceware.org/binutils/d...

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

clawson, my fault, you are correct. S.. Amazing I have been searching for days on that, thx for the manual link. I even tried the avr help files with no luck.

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

Personally I cannot think of anything worse than Asm with multiple statements per line though I guess one might make an exception for a large block of "nop"s. But at least do the read a favour and put a comment like "; 8 NOPs" to save them counting - perhaps, if F_CPU is known, also "1.3us delay or whatever.

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

Agreed. In this case that is the problem, two pages of nops is not my cup of tee.

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

You may well be able to write a MACRO or use a REPT block. I agree with Cliff, avoid using any special gcc "make this unreadable" features.

Why do two pages of NOPs? You can just loop for the required number of cycles.

The only possible reason for a large number of single-cycle operations is so that an intervening IRQ will be serviced one cycle sooner than if it just happened to occur at the beginning of a 2 cycle opcode.

Anyway. How have you got on with your SEGA bit-stream decoding?

David.

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

Quote:
You may well be able to write a MACRO or use a REPT block. I agree with Cliff, avoid using any special gcc "make this unreadable" features.
- I started out that way but the word length was getting too great.

Quote:
Why do two pages of NOPs? You can just loop for the required number of cycles.
I'm trying to count every thing exact. I know loops can be counted just as well but its easier counting nops. Once I have the timing I will replay with loops.

Quote:
Anyway. How have you got on with your SEGA bit-stream decoding?
- Did you happen to read the conclusion(on that post)? Since I have not worked on it, but will in the next day or so.

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

Quote:

I know loops can be counted just as well but its easier counting nops.

Eh? Tell me how many cycles are used in each of the folllowing:

nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop $ nop
 ldi r24,31
loop:
 dec r24
 brne loop

I know which I find easier to count: a quick glance at the manual says that ldi is 1, dec is 1 and brne is 2 while the condition (NE) is true else 1. So this will take 1+(3*30)+1+1 = 93 cycles. The cycle counter in the simulator confirms this.

Cliff

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

I dont mean its easier to count in that sense . I'm involved in a project where I need to add 2 here and test, 3 here and test, take one out here test. Add a block of 20 here to skip ahead and check. So for pages of nops it gets confusing, also adding and tracking loops and how many they use is getting cumbersome. I just wanted an easy way to add/remove nops without having lines and lines to deal with. And I could do 10 per line to make things easier.

for me its a lot easier to see 5 nops above and take one out from below and add it above. I see its 5. 5+1 is 6.. Other wise I'd have to , think what the loops have and figure ok I need to add one to it to get 6.

I dont know maybe its just me.. To each there own, right?

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

Quote:

I'm involved in a project where I need to add 2 here and test, 3 here and test, take one out here test.

Not a great way to do design.

But my point was that:

 ldi r24,N 
loop: 
 dec r24 
 brne loop 

is simply easier than pages and pages of NOPs. If you then need to make a further 1/2/3.. cycle adjustment to the N*3 cycle loop then, yes:

 ldi r24,N 
loop: 
 dec r24 
 brne loop 
 nop
 ldi r24,N 
loop: 
 dec r24 
 brne loop 
 nop
 nop

and so on...

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

its not a design, its a test. I see your point, but from my point of view I find it easier to see the nops lied out in this case. Copy and pasting nops as apposed to adding and subtracting works better for me in this case.

Are we just arguing for the sake of arguing here?

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

Quote:
Are we just arguing for the sake of arguing here?

Yes. But in years to come you will also come to that conclusion.

Now in terms of an arbitrary # of NOPs

     .rept 299
     NOP
     .endr
     .macro NOPS howmany
     .rept  \howmany
     NOP
     .endr
     .endm

...

; call with

     NOPS 299
     ...

Untested. But you get the idea. Anyway I still think you should measure your incoming signal.

David.

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

Quote:
But you get the idea. Anyway I still think you should measure your incoming signal.
- no argument there.

I like the code example btw.

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

david.prentice wrote:

     .rept 299
     NOP
     .endr

Is this example for AVRAsm ?

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

LightHouser wrote:
david.prentice wrote:

     .rept 299
     NOP
     .endr

Is this example for AVRAsm ?

No. The macro is for avr-as.

AVRasm can do macros after a fashion but I do not think it can do a .REPT directive.

David.

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

Is avr-as a part of AVR Studio ? This is AVRStudio forum...

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

It is if you add WinAVR to your PC. You then get the option on Project creation with Studio of "Atmel assembler" (as before) or "GCC" (then added). If you choose the latter you can choose to write in just C, C+Asm or just Asm. The Asm in this case is avr-as and it's all integrated inside Studio as an alternative to Atmel's rather watered down offering.

Cliff

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

avr-as is the GCC gas assembler.

I suppose that strictly speaking this discussion should be on the GCC forum. On the other hand many people "drive" GCC via Studio4.

Many of the Atmel tools like AVRAsm2 get installed with the Studio4 installation.

David.