6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Sep 29, 2024 6:27 pm

All times are UTC




Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3
Author Message
PostPosted: Tue Apr 08, 2014 10:25 am 
Offline

Joined: Sat Mar 27, 2010 7:50 pm
Posts: 149
Location: Chexbres, VD, Switzerland
I understand, all of instruction sets have their shortcommings, which are especially annoying if you code in assembly and can't figure out a clean and efficient way to implement something. I'm not experienced with PIC assembly so I can't tell how often this happens on PIC. However, on 6502, it sometimes happened to me that I badly needed a third Z index register or something to do some function, but instead I had to constantly save/restore X/Y to different values, which is a bit annoying and wastes a lot of instructions.

Quote:
with memory read delay!! You can't use a value read from memory in the next instruction

This sound painful to code for in assembly !! Why didn't they add the hardware to detect such cases and delay the next instruction ? Especially since this is needed anyway even for non-memory instructions.


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 08, 2014 2:40 pm 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
You're supposed to use the following instruction slot to do something useful, so you don't want to delay it. In the case where you can't figure out anything to fill the slot with you insert a NOP. At least I believe that's how it's done on MIPS (PIC32) too, as it's quite common with pipelined architectures. What I have more problems with understanding is how MIPS can get away with not having a carry flag..

-Tor


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 08, 2014 6:38 pm 
Offline
User avatar

Joined: Sun Dec 29, 2002 8:56 pm
Posts: 452
Location: Canada
Tor wrote:
What I have more problems with understanding is how MIPS can get away with not having a carry flag..


Carry flag isn't needed much in a 32 bit machine and it's possible to calculate it. I wish they had an instruction to calculate the carry and place it in a register though.

_________________
http://www.finitron.ca


Top
 Profile  
Reply with quote  
PostPosted: Tue Apr 08, 2014 7:17 pm 
Offline

Joined: Sat Mar 27, 2010 7:50 pm
Posts: 149
Location: Chexbres, VD, Switzerland
Quote:
You're supposed to use the following instruction slot to do something useful, so you don't want to delay it.

You only delay the instruction if it uses the same register that just got loaded. Not only this makes the pipeline transparent to the programmer, but it also minimizes ROM usage for your program, as if you can't fit anything useful, you don't have to insert a NOP.

Quote:
At least I believe that's how it's done on MIPS (PIC32) too

I'm no expert, I think MIPS exposes delay slots after branches, but I'm pretty sure instructions dependencies are handled correctly. I might be wrong though.

Quote:
What I have more problems with understanding is how MIPS can get away with not having a carry flag

For shift/rotates just check the value before the shift/rotate operation.

For additions, if and only if the result is smaller than any of the operands (unsigned comparison) then a carry has happened.


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 09, 2014 12:40 am 
Offline

Joined: Sun Apr 10, 2011 8:29 am
Posts: 597
Location: Norway/Japan
I calculate carry in my emulators but it's an expensive operation.. but if there are only 32-bit additions to worry about then the impact isn't that big presumably. Anyway we're heading over into anycpu.org territory.

-Tor


Top
 Profile  
Reply with quote  
PostPosted: Wed Apr 09, 2014 11:15 am 
Offline
User avatar

Joined: Tue Mar 02, 2004 8:55 am
Posts: 996
Location: Berkshire, UK
Tor wrote:
I calculate carry in my emulators but it's an expensive operation.. but if there are only 32-bit additions to worry about then the impact isn't that big presumably. Anyway we're heading over into anycpu.org territory.

-Tor

In my PIC32 emulators for the 8080, 6800 and 65C02 I use lookup tables as I have loads of emply flash program memory. Saves a lot of time computing overflow and half-carry

_________________
Andrew Jacobs
6502 & PIC Stuff - http://www.obelisk.me.uk/
Cross-Platform 6502/65C02/65816 Macro Assembler - http://www.obelisk.me.uk/dev65/
Open Source Projects - https://github.com/andrew-jacobs


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 36 posts ]  Go to page Previous  1, 2, 3

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: