Question about assembly language

simonpro

Beta Tester
Beta Tester
Joined
Feb 10, 2008
Messages
1,042
Reaction score
7
Points
0
Hey, I'm looking at this simple assembly code:

loop: beq r0,r0,loop

Which keeps looping whilst the processor is idle. Will this code perform read operations on the memory, or does it simply involve loading from on-processor registers?
 

Eagle

The Amazing Flying Tuna Can
Joined
Feb 11, 2008
Messages
1,105
Reaction score
3
Points
0
Looks like its only using register zero... and that it will loop infinitely.
 

simonpro

Beta Tester
Beta Tester
Joined
Feb 10, 2008
Messages
1,042
Reaction score
7
Points
0
Yeah, it's supposed to be an infinite loop. It gets broken by a reset switch elsewhere.
the memory issue was what was worrying me, but if it's read from a register then all is good.
 

Eagle

The Amazing Flying Tuna Can
Joined
Feb 11, 2008
Messages
1,105
Reaction score
3
Points
0
generally speaking, busy waiting isn't the best idea. Its usually better to block the thread and have another thread unblock it. But thread concepts become rather difficult to do at the assembly level.
 

Artlav

Aperiodic traveller
Addon Developer
Beta Tester
Joined
Jan 7, 2008
Messages
5,790
Reaction score
780
Points
203
Location
Earth
Website
orbides.org
Preferred Pronouns
she/her
loop: beq r0,r0,loop
Um. Which CPU?

Why should it read from memory?
It compares r0 register to itself (if the thing uses standard notation of rx being registers), and does a branching back to itself.
No memory reads, as far as i understand.
 

simonpro

Beta Tester
Beta Tester
Joined
Feb 10, 2008
Messages
1,042
Reaction score
7
Points
0
Why should it read from memory?

I don't know, I don't use assembly language (I'm an engineer, not a computer scientist). Hence why I posted here to check that it didn't.

generally speaking, busy waiting isn't the best idea.

Yeah, this is supposed to be an example of an inefficient system. Hence why it doesn't use the best methods.
 
Top