|
Gary Wheeler wrote: Mozilla did not consider the correct audience when they authored the prompt
You mean, a pessimist like myself?
|
|
|
|
|
Not that I have anything against that, but now I have a problem. I'm preparing to write some code for a 41 year old computer. Without an OS I will never be able to retain all oldschool features and at the same time slightly modernizing the hardware.
The problem is that the old processor has two types of branching instructions: Long branches and short branches. Long branches need three bus cycles to execute and have the full address which is copied into the program counter when the branch is executed.
Short branches take only two bus cycles, but have only the lower half of the address to jump to. This 8 bit address is copied into the lower half of the program counter, the upper half remains the same. This leads to a mild segmentation of the memory for your code, each segment 256 bytes long.
Problems come when your code runs over the boundary from one page to the next in the middle of a loop. You can't loop back to the previous page with a short branch. So I should just use a long branch instead, right? That's the easy way out which compilers like to use. They simply don't use short branches at all and generate long branches instead. Problem solved.
Or not. Of course there may be a performance problem when long branches are used, which take one bus cycle more. That's only a thing in very short loops which are executed very often.
The real problem comes from a different direction. The old graphics chip relies on carefully timed interrupts and DMA to get its video data for every frame. The one extra bus cycle when the video interrupt comes during the execution of a long branch causes the graphics to fall apart for the following frame. If the code is full of long branches, you don't get to see very much at all, because that happens all the time.
Now, how do I get the compiler to generate long branches only if it finds no other way. Relocating the code is the linker's job and not code generation. And I don't see any efficient way how the linker can stitch the code together in the optimal way to avoid loops running over page boundaries other than building a tree of solutions and then taking the one with the least problems. That's going to be slow.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Not that it helps, but this is why when I used to code on these 8 bit processors 35+ years ago, I wrote everything in assembly.
|
|
|
|
|
That's exactly what I do now, but relocating code manually can become tiresome when your program gets a little longer. You dare not to insert anything anymore without having to fear that everything that follows falls apart.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Most compilers let you mix code so you could write time sensitive stuff in asm and the rest in language of choice.
Technician
1. A person that fixes stuff you can't.
2. One who does precision guesswork based on unreliable data provided by those of questionable knowledge.
JaxCoder.com
|
|
|
|
|
That's very simple with this particular compiler. It does not really generate object code and links it afterwards. It generates assembly sources and lets the same assembler that I use at the moment do the hard work. Back to square one in this case, because the assembler is a cross assembler that does not deal in any way with this very processor specific problem. It just generates an assembly error. Replacing all long branches and then rearranging the C compiler's output file until the assembler finally takes it may become a chore.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Are you doing this for money, glory, or insanity?
|
|
|
|
|
Missing option: d) because I can!
Seriously, I will never give up that little computer. You want to get the idiots out of Q&A? Simple. Make them build such a simple thing and tell them to come back when they have comletely understood it.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I think that counts as insanity
|
|
|
|
|
Sander Rossel wrote: I think that counts as insanity
It does, but is insanity necessarily a bad thing?
Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain
|
|
|
|
|
Trust me. I know what I'm doing.[^]
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I really like the actress in the entirely appropriate 80's-style exercise outfit.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
sounds like a job for Super Assembly Man!
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
GOTO is like all tools, it has it's uses, don't blame the tool, blame the tool using the tool...
|
|
|
|
|
Good idea. Would you care to take over? I promise not to blame you too much.
That gives me an idea. let's not use branching instructions. I think I can emulate them with several other instructions. A little like having reflection at assembly level...
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
You say compiler, so that implies 'C' rather than assembly language. I would think a cross-compiler would at least provide #pragma 's for managing code 'segmentation' as you've described. If it doesn't it's because of difficulty/laziness on the part of the compiler developers.
The alternative is for you to write the tight-loop short-branch bits in assembly language, where you can control the segmentation and branch instruction types.
Software Zen: delete this;
|
|
|
|
|
C compilers never were a thing on 8 bit computers because of the limitations of memory, mass storage and also the bus width to some extent. All compilers for 8 bit computers I have seen are more or less homemade and run on far stronger computers, like a PC.
In this particular case the problem was avoided by letting the compiler generate only long branches and assuming that nobody will miss support for a graphics chip that has been obsolete and out of production for decades. It would be a little unfair to bash someone who took the time to write the compiler for a not so mainstream processor to make such a choice.
Ironically, the processor has been in production until a few years ago and people still build little computers with them. They are ideal for learning and often they are replica of the design from 1976. Adding the graphics chip was one of the first expansions that were published back then. Even such simple graphics were sensational at a time when homebrew computers still had no graphics at all. More so because it was accomplished by adding one IC, hooked up directly to the processor's bus. I have seen several replacements for it made with programmable logic on small boards that are designed to plug into the original's 24 pin socket.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I used a "BDS C Compiler" on a Z-80 project a long time ago (late 1980's). As I recall, I ran the compiler itself under a CP/M simulator that ran under MS-DOS.
Software Zen: delete this;
|
|
|
|
|
CP/M, Z80 and C sound like a good match. CP/M systems early on were mainstream enough to justify the effort to develop compilers for them and could support enough memory and storage devices to make it practical.
Of course I'm praising the 'enemy' in an old nerd war now. Heresy.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I programmed embedded projects on 8085, Z-80, 6800, and 1802 microprocessors back in the day. I don't think I ever did anything with a 6502, but that was a lack of opportunity rather than prejudice.
Software Zen: delete this;
|
|
|
|
|
I remember reading about a continued battle between two nerds who tried to prove that 'their' processor is the measure of all things. One of them had a Z80 and started the whole thing by proclaiming that that weird and slow CDP1802 has no chance at some task against that Z80. It went back and forth for a while, but I don't think they ever came to a conclusion. Still, I like the CDP1802's programming model much more than anything that has Intel in its ancestry. ARM processors appear to be similar, but I have not done anything with them yet. They called the 1802 weird, with the ARM processors they called it RISC.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
CodeWraith wrote: I like the CDP1802's programming model much more than anything that has Intel in its ancestry It's a major wonder Intel didn't kill themselves off with the whole memory model sh*t-show in the 8086 and its successors. I spent more brain cells than I could afford debugging segmentation issues in those days.
Software Zen: delete this;
|
|
|
|
|
Intel was excellent at only one thing: Expanding their architecture to 8 bits, then to 16 bits and beyond while maintaining backward compatibility. Motorola had a chance with their 68k processors, but they could never catch up to Intel by that time.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
And it pays off to be here.Reputation[^]
"It is easy to decipher extraterrestrial signals after deciphering Javascript and VB6 themselves.", ISanti[ ^]
|
|
|
|
|
Hypothetically (because I am definitely not offering), would you sell those 12.5 years (your CP account) for €99,999?
|
|
|
|