Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
08/16/02 19:27
Read: times


 
#27362 - What Nic didn't say
is that in the code, right above the "ugly" part, there was the following:

; push r0 ;
; mov r0,#0x40 ; |
; mov a,#0x00 ; |
;loop1: ; |____ this block will zero out 0x40 through 0x47
; mov @r0,a ; | / as this will store the final result
; inc r0 ; |
; cjne r0,#0x48,loop1 ; |
; pop r0 ; /

I originally had the above code, I guess it is not quite as ugly, but commented it out and put the 8 MOV's, for better readability. But I left it in the source file! Having both in there, one commented, shows the reader what a section of code does, by presenting an alternative method. Please keep in mind, that if there were only four or maybe five bytes to be zeroed out, it might be more efficient to NOT use a loop. Sometimes a C compiler will find it efficient to "unroll" a loop. Especially where there are nested loops, and the inner loop executes only a few times. The compiler will duplicate the inner loop body. Man, that will be ugly!

I like Peter's algorithm that doesn't use ACC, but more efficiently uses R0. I will definitely use his suggestion, and re-write the code as:

; push r0 ;
; mov r0,#0x40 ; |
;loop1: ; |____ this block will zero out 0x40 through 0x47
; mov @r0,#0x00 ; | / as this will store the final result
; inc r0 ; |
; cjne r0,#0x48,loop1 ; |
; pop r0 ; /

It is not that I won't use a good suggestion. But there's no need to be ugly, while pointing out code that is supposedly "ugly".

As far as suspending the site for a while. Why Not? Maintaining it is nothing but work. Ok, maybe it's a little bit fun. But if all I get are negative comments, then why should I leave it online? No one has emailed me with any useful kind of comment.

I offered to put an 8051 online, for benefit of those who study the 8051 but don't have access to the hardware. It is better than relying on a simulator. But I guess no one has use for that. That's Ok, because it was going to require writing a cgi interface. At least I have not wasted any time on that yet, before knowing it wasn't needed.

List of 32 messages in thread
TopicAuthorDate
What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembl            01/01/70 00:00      
RE: What is ugly and what not in assembl            01/01/70 00:00      
RE: What is ugly and what not in assembl            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
Useage of nops            01/01/70 00:00      
RE: Useage of nops            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
Nic, sorry you don't like my            01/01/70 00:00      
RE: Nic, sorry you don't like my            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
What Nic didn't say            01/01/70 00:00      
RE: What Nic didn't say            01/01/70 00:00      
RE: Nic, sorry you don't like my            01/01/70 00:00      
RE: What is ugly and what not in assembly?            01/01/70 00:00      
RE: What is ugly and what not in assembl            01/01/70 00:00      
Apology gladly accepted            01/01/70 00:00      
RE: Apology gladly accepted            01/01/70 00:00      
RE: What Nic didn't say, keith            01/01/70 00:00      
RE: What is ugly and what not in assembl            01/01/70 00:00      
RE: John Deans            01/01/70 00:00      
RE: What is ugly and what not in assembl            01/01/70 00:00      
RE: Erik            01/01/70 00:00      
RE: Ijaz            01/01/70 00:00      

Back to Subject List