tag:blogger.com,1999:blog-59473178502950446922024-03-12T21:15:21.855-07:00Bit RomancerlimaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.comBlogger14125tag:blogger.com,1999:blog-5947317850295044692.post-70154129245800273672015-12-29T11:42:00.003-08:002015-12-29T11:42:49.906-08:00Extra: A few good resources to get you started.<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/9hLGvLvTs1w/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/9hLGvLvTs1w?feature=player_embedded" width="320"></iframe></div>
<br />
Hello world in 6502 Assembler, by Ulf Hellström.<br />
<br />
A <a href="http://www.visual6502.org/JSSim/index.html" target="_blank">visual 6502 emulator</a>.<br />
<br />
The <a href="http://skilldrick.github.io/easy6502/#first-program" target="_blank">Easy 6502 Tutorial</a> which includes an html emulator.limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-31416142489594886582015-12-28T13:04:00.001-08:002015-12-28T13:19:24.830-08:00Day 11: Juventus supporters can't jump!!!! (Part 2)<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<div class="separator" style="clear: both; line-height: normal; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/4eGTQqI8zAo/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/4eGTQqI8zAo?feature=player_embedded" width="320"></iframe></div>
<div>
<br /></div>
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Today we will see briefly the conditional jumps, or branches. The name branch comes from the fact the code may or may not jump to a certain location in memory, depending if a condition is true or not. Branching is the equivalent of the Basic IF GOTO construct.</span></div>
<b id="docs-internal-guid-95cb9f03-ea64-5db3-e19c-77840db0c9ae" style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The Status Register </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">as I wrote yesterday, is the onboard cpu register which stores some flags. The flags are side-effects of instructions. Normally instructions will manipulate and store the data in the accumulator, but depending on the result the CPU will set (put to 1) or reset (put to 0) some bits in this register. </span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The most important bits of the Status Register are:</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Zero Flag</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Every instructions that results in a zero, including transfers to accumulator or the x and y registers, will set this flag to 1, while any other result will set it to 0.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Carry Flag</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Indicates if a mathematical instruction result in a situation where you will have to carry its most significant byte to another byte. It’s not the same as the overflow flag.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Overflow Flag</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Indicates when the result of the operation sets the 7th bit. It’s a more restricted case of the Carry Flag.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Negative Flag</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Indicates if the result is to be considered “negative”.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">There are three other flags that are not used with branching, but they are present in the Status Register.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Decimal Flag,</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Iit’s used to set the computer mathematical operations in “decimal” mode. Normally the 6510 will operate on bits with normal binary maths. If the decimal flag is set then the CPU will instead use the encoding and rules of Binary Coded Decimal, which trades off some ram (every byte coded in BCD will store only one out of 100 values instead of one out of 255, so it’s less compact) for getting more precise calculations.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Break Flag,</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">To be used to test if the processor returned from a BRK (break) instruction. I don’t know much about this flag yet.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Interrupt flag,</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">This indicates if the CPU is currently executing an interrupt sequence. Interrupts are special ways a machine has to hijack control from a central program to handle important events like input or output operations (for example, when the user presses a button or when the TV finishes rendering a screen).</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">How and why to test for the flags</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The Zero Flag</span></div>
<span style="font-family: Arial; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">Testing for the zero flag is useful, for example, in situations where you have to test a FOR-style loop or when you do comparisons on bytes.</span><br />
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BEQ</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with BEQ you test on the result of the previous operation being EQUAL to zero (Z = 1)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> LDX #$20</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LOOP</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> DEX</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> BEQ EXIT</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> JMP LOOP</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">EXIT</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> ...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BNE</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">with BNE you test on the result of the previous operation being NOT EQUAL to zero (Z = 0)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> LDX #$20</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LOOP</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> DEX</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> BNE LOOP</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> ...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Note that a comparison between two numbers can also set the zero flag if both numbers are equal.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">For </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BEQ:</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDX #$20</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDA #$20</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">STX $03FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">CMP $03FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BEQ OK</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">For </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BNE:</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDX #$20</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDA #$21</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">STX $03FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">CMP $03FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BNE OK</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The Negatifve Flag.</span></div>
<span style="font-family: Arial; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">The Negative flag is useful, again, for countdowns, or is useful too in mathematical operations or other comparisons. </span><span style="font-family: Arial; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">You can test the Negative Flag with the following operations:</span><br />
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BMI</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">You use this to test if the result is negative (N = 1)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDX #$20</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDA #$1F</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">STX $03FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">CMP $03FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BMI OK</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BPL</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">You use this to test if the result is positive (N = 0)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDX #$20</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDA #$21</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">STX $03FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">CMP $03FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BPL OK</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The Carry Flag.</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The Carry flag is useful with mathematical calculations. With an 8 bit computer you are not limited to work on 8 bit values, but you can chain those values to represent an higher precision number spending a bit more memory. Note that the Carry flag is automatically used by several mathematical operations as well. </span><a href="https://www.c64-wiki.com/index.php/Carry_Flag" style="line-height: 1.38;" target="_blank">You can also see a bit more info on the C64 Wiki.</a></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BCS</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">By now you can imagine that Branch on Carry Set branches when the Carry flag is set (C = 1)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDA #$FF</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">ADC #$01</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BCS OK</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BCC</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Branch on carry clear instead jumps only if the Carry flag is reset (C = 0)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDA #$FE</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">ADC #$01</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BCC OK</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The Overflow Flag</span></div>
<span style="font-family: Arial; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">There is a more limited number of instructions that will set the overflow flag, actually there are only two mathematical instructions (ADC and SBC) that will set this (and the BIT comparison instruction, but apparently BIT is rarely used). The Overflow flag is set when a 7-bit operation makes the number overflow in the 8th bit. If you add 1 to 127, you will obtain 128, which is represented like this: 10000000. In that case the ADC will remind you that, if you are using 7-bit precision numbers, to check the overflow flag if you need to test for SIGNED numbers, but you can ignore this flag instead if you are using UNSIGNED numbers. </span><a href="https://www.c64-wiki.com/index.php/Overflow_Flag" style="line-height: 1.38;" target="_blank">As usual, the C64 wiki explains stuff better than me.</a><br />
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BVS</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Branch on Overflow Set (V = 1)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDA #$7F</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">ADC #$01</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BVS OK</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 700; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BVC</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Branch on Overflow Clear (or “reset”) (V = 0)</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LDA #$7E</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">ADC #$01</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">BVC OK</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">...</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The following is the code I used to test the various snippets.</span></div>
<b style="font-weight: normal;"><br /></b>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">*=$0810</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">PREAMBLE</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> CLD</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">MAIN ; you can change the parts between MAIN and KO</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> LDA #$7F</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> ADC #$01</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> BVC OK</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">KO ; if your calculation is wrong the program should print two black @'s</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> LDA #$00</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> STA $0400 </span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> STA $0401</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> LDX #$00 </span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> STX $D800</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> STX $D801</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> RTS</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">OK ; if your calculation is correct the code should print two white A's</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> LDA #$01 </span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> STA $0400 </span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> STA $0401</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> LDX #$01 </span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> STX $D800</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> STX $D801</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> RTS</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; The following is how the machine stores the SYS 2080 command on</span></div>
<span style="font-family: 'Courier New'; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">; line 10 of the Basic interpreter</span><br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">; 10 SYS 2064</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">*=$801</span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br class="kix-line-break" /></span><span style="background-color: transparent; color: black; font-family: 'Courier New'; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> BYTE $0B, $08, $0A, $00, $9E, $20, $32, $30, $36, $34, $00, $00, $00</span></div>
limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-39488588944831538862015-12-27T13:37:00.000-08:002015-12-27T13:37:28.335-08:00Day 10: Juventus supporters can't jump!!!! (Part 1)<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">Code rarely goes in a straightforward motion. Actually to do something useful we must teach the code how to jump to the correct parts, to stop when it needs to, to call subroutines... </span><span style="font-family: Arial; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">Before seeing Jumps we need to know about three processor registers:</span></div>
<b id="docs-internal-guid-95cb9f03-e557-7060-86a2-6992946dc606" style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>The Program Counter (PC)</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> is a 16-bit register containing the address of the instruction the processor will read next.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">When the current instruction is read, the processor calculates (based on the current opcode and the operands it believes come next) the address of the following instruction. When the cpu finishes processing the current instruction then it will use the value in the program counter to continue the operation. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>The Stack Pointer (SP)</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> is an 8-bit register containing an index which points to the current top of a data structure called the stack. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The stack, on the 6510 cpu, is an area of memory reserved for keeping return addresses for subroutines, in case you need to make nested function calls. You can push data on the stack, and then get it back from it, or pop it, with a last-in-first-out precedence rule. The Stack Pointer only needs 8 bits, because it’s a fixed section of memory starting from $0100 and ending with $01FF.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The 6510 cpu reserves a very tiny space for its own stack because programming the 6510 you are expected to store the accumulator, the CPU status register and the CPU program counter. It’s a design choice that is sensible considering the era when it was created (its father, the 6502, was created in 1975) and the scarcity of RAM available for computer programmers. Modern CPUs allow programmers to keep complex data on the stack (function parameters, function results), and each process actually manages its own stack.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Note that the stack is built downwards, so the first value you will push (insert in it) will be in $01FF, the second $01FE.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>The Status Register</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> is an 8-bit register containing some flags. Several instructions will set or reset the single bits in the Status Register, and most jump instructions will test those bits to decide if to jump or not. We will see the Status Register more in detail with the next part, when we will talk about conditional jumps.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>JMP - Unconditional Jump</b></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;">JMP LABEL ; here we will use an assembler LABEL. </span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;">JMP $0820 ; here we will directly point to a certain address</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> ; in </span></span><span style="font-family: 'Courier New', Courier, monospace; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">memory. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">The unconditional jump resembles the </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>GOTO</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> instruction in basic. You are telling the CPU to set the Program Counter to the operand, either the label or the memory address.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Note that the assembler software calculates the correct memory address for a LABEL automatically. It’s better to use (and abuse) LABELs because if you need to amend your code you don’t need to calculate the memory area, or worse, the number of bytes you need to pass to the operand.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Example:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> LDA #$01</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> JMP <i>PRINT</i></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"><i>RETURN_LABEL</i></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> RTS</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-variant: normal; font-weight: 400; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"><i>PRINT</i></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> STA $0400</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> STA $D800</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> JMP <i>RETURN_LABEL</i></span></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>JSR - Jump to Subroutine</b></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Courier New, Courier, monospace;"><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">JSR</span><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">LABEL</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Courier New, Courier, monospace;"><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">JSR</span><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">$0820</span></span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Jump to Subroutine is an unconditional jump too, with a key difference from </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>JMP</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">: it’s used together with the </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>RTS</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> (return from subroutine) instruction.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>JSR</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>RTS</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> are conceptually equivalent to the basic </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>GOSUB</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> and </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>RETURN</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> statements.</span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Technically speaking, </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>JSR</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> will PUSH the current Program Counter on the stack, or better said record the two bytes of the PC on the stack and decrease the value in the SP register by two. </span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.6667px; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><b>RTS</b></span><span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"> instead will POP the PC from the Stack, or better said, increase the value in the SP register by 2 read from the stack the value of the last program counter recorded on it. </span></div>
<b style="font-weight: normal;"><br /></b>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Example:</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> LDA #$01</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> JSR <i>PRINT</i></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> RTS ; this RTS halts execution of your program and </span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> ; eventually </span></span><span style="font-family: 'Courier New', Courier, monospace; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;">gives the control back to the C64 </span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: 'Courier New', Courier, monospace; font-size: 14.6667px; line-height: 1.38; white-space: pre-wrap;"> ; operating system</span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"><i>PRINT</i></span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> STA $0400</span></span></div>
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> STA $D800</span></span></div>
<br />
<div dir="ltr" style="line-height: 1.38; margin-bottom: 0pt; margin-top: 0pt;">
<span style="background-color: transparent; color: black; font-size: 14.6667px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><span style="font-family: Courier New, Courier, monospace;"> RTS ; this RTS “returns” from the PRINT subroutine</span></span></div>
<div>
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"><br /></span></div>
<div>
<span style="background-color: transparent; color: black; font-family: Arial; font-size: 14.666666666666666px; font-style: normal; font-variant: normal; font-weight: 400; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;">Next time we will see conditional jumps, or branches.</span></div>
limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-86999539846063801542015-12-27T05:37:00.003-08:002015-12-27T07:02:47.735-08:00Extra: Behind the scenes of a C64 demo<div class="separator" style="clear: both; text-align: left;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen="" class="YOUTUBE-iframe-video" data-thumbnail-src="https://i.ytimg.com/vi/So-m4NUzKLw/0.jpg" frameborder="0" height="266" src="https://www.youtube.com/embed/So-m4NUzKLw?feature=player_embedded" width="320"></iframe></div>
<br />
<br />
An interesting lesson on what lies behind a C64 demo.limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-84358227905850013622015-12-17T22:27:00.002-08:002015-12-19T06:42:09.066-08:00Day 9, Towards Multichannel Sid Programming (Part 2)<div>
Yesterday I was going to find how to write this program:</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> GOSUB SET-UP-SID</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># we set up the continue variables here</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># we want to have them visible in the main loop</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> CO% = 1 #</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># we can also initialize further variables here</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">LOOP: </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># this is how we can emulate a while-true cycle in basic</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> IF CO% = 0 GOTO END-LOOP </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># now we will read the notes and upload them to the correct channel</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># now we will wait 1/4 of a second</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># and after it we jump back</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> GOTO LOOP</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">END-LOOP: </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> GOSUB RESET-SID</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> END</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">SET-UP-SID:</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># rem here we will set up the channels with the correct instruments</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> </span><b style="font-family: 'courier new', courier, monospace;"># We already did this</b></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> RETURN</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">RESET-SID:</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># rem here we will clear the SID</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> <b># We already did this</b></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> RETURN</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>And now I am going to continue it.<br />
<br />
Please note that this formalism has nothing to do with how someone else would approach compuer programming. In the good old Basic Days planning the software was done using <a href="https://en.wikipedia.org/wiki/Flowchart" target="_blank">Flow charts</a>. Nowadays Flow charts aren't neither taught nor used, and someone expects you to just fill random methods provided by your framework or choice in random points of the application.<br />
<h4>
How do we wait for one second?</h4>
</div>
<div>
I'm choosing to tackle this problem next because I need to have a sort of slowdown in place before reading the notes and putting them into the SID registers. The Commodore 64 basic gives two commands to read the time: <span style="font-family: "courier new" , "courier" , monospace;">TIME</span> and <span style="font-family: "courier new" , "courier" , monospace;">TIME$</span>. Due to architectural limitations they will give the time from the last system boot (including when you soft-reset the computer with <span style="font-family: "courier new" , "courier" , monospace;">SYS 64738</span>). In addition to it the <span style="font-family: "courier new" , "courier" , monospace;">TIME</span> is stopped when the computer is serializing data. As a last limitation I can think is that <span style="font-family: "courier new" , "courier" , monospace;">TIME</span> is given pace from the current video signal coming out from the Commodore (an NTSC commodore will have a different timing from a PAL commodore, but I have to check).</div>
<div>
<br /></div>
<div>
The difference between the two instructions is that <span style="font-family: "courier new" , "courier" , monospace;">TIME$</span> will print the time as seconds and it should be text while <span style="font-family: "courier new" , "courier" , monospace;">TIME</span> will print the time as 60th of seconds and will be a number.</div>
<div>
<br /></div>
<div>
We can type this program in and see the two commands in action.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">10 FOR I = 1 TO 24</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">20 PRINT TIME ; TIME$</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">30 REM WE WANT A SLOWDOWN BEFORE</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">31 REM PRINTING THE NEXT VALUE OF TIME</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">35 FOR J = 1 TO 100 : NEXT J</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">40 NEXT I</span></div>
<div>
<br /></div>
<div>
Armed with this insight we can speculate that we can store the current time in a variable, test if 60 <a href="https://www.c64-wiki.com/index.php/Jiffy_Clock" target="_blank">jiffies</a> have passed and print the new time.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">10 PRINT "{CLR/HOME}" ; TIME$ , TIME</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">20 TT = TIME + 60</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">30 IF TT =< TIME GOTO 10</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">40 REM IF YOU PRESS ANY KEY THE PROGRAM WILL END</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">41 GET A$ : IF A$ <> "" THEN END</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">50 GOTO 30</span></div>
<div>
<br /></div>
<div>
This is not perfect but for now it will do.</div>
<div>
<br /></div>
<div>
You can see that we have to change the central loop</div>
<div>
<br />
<span style="font-family: "courier new" , "courier" , monospace;"># since this is a value that does not change we calculate it </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># here, just</span><span style="font-family: "courier new" , "courier" , monospace;"> once</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> DT = INT(60 / 4)</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">LOOP:</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> TT = TIME + DT</span></div>
<div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># this is how we can emulate a while-true cycle in basic</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> IF CO% = 0 GOTO END-LOOP </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># now we will read the notes and upload them to the correct </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># channel</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># now we will wait 1/4 of a second</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># and after it we jump back</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">CHECK-TIME:</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><span style="font-family: "courier new" , "courier" , monospace;"> IF TT =< TIME </span><span style="font-family: "courier new" , "courier" , monospace;">GOTO LOOP</span></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> GOTO CHECK-TIME</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
This does not complete all the reasoning about time because now we will have to test if the time has come for reading our notes in the SID.<br />
<br />
<h4>
Reading and playing the note data.</h4>
The following part is tricky, because we still need to do the following things: finalize the data structure, understand about which channel we are reading the following note, and understand<br />
<br />
Reading the documentation for the SID we see that for playing a single note we need to insert two values for each channel, one for the LOW frequency and the other for the HIGH frequency. The two frequencies will be combined into a single note.<br />
<br />
We also decide that the delay, for now, will be "quarters of second", so when the program jumps to loop we will need to check if the delay has stopped. Remember also that we want to test if the channel is still active.<br />
<br />
So we need to change this representation:<br />
<br />
<span style="background-color: white; color: #333333; font-family: "courier new" , "courier" , monospace; font-size: 14.85px; line-height: 20.79px;">[note-1-pitch],[note-1-delay]</span><br />
<span style="background-color: white; color: #333333; font-family: "courier new" , "courier" , monospace; font-size: 14.85px; line-height: 20.79px;"><br /></span>
to this one:<br />
<br />
<span style="background-color: white; color: #333333; font-family: "courier new" , "courier" , monospace; font-size: 14.85px; line-height: 20.79px;">[note-1-low],</span><span style="background-color: white; color: #333333; font-family: "courier new" , "courier" , monospace; font-size: 14.85px; line-height: 20.79px;">[note-1-high]</span><span style="background-color: white; color: #333333; font-family: "courier new" , "courier" , monospace; font-size: 14.85px; line-height: 20.79px;">,[note-1-delay]</span><br />
<br />
And when we read the data we will just do<br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
<span style="font-family: "courier new" , "courier" , monospace;">READ LO</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">READ HI</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">READ DL</span><br />
<br />
But before reading it we have to decide if we need to read a note, and after reading that note we need to decide when we have to read it next.<br />
<br />
Each channel will have a timer. Each will be initialized, before entering the loop, with the current time.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">T1 = TIME</span><br />
<br />
If T1 is lower or equals to the current TIME then we will make the program read its values<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF T1 > TIME SKIP<br /> READ LO # read the low frequency<br /> READ HI # read the high frequency<br /> READ DL # read the delay.<br /> POKE L1,LO # we put in the Sid 1 low register the value read by low<br /> POKE H1,HL # same but with the high value<br /> T1 = TT + DT * (DL - 1) # this is when we will read the next note.<br />SKIP:<br /> # we skipped here and here we will test channel 2</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> [...] </span><br />
<br />
What does it happen if we want to shut off the channel? Or if the channel was shut off before?<br />
We use another variable: C1, that we will initialize to 1 at the beginning of the program. So our micro-block becomes:<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF C1 = 0 SKIP<br /> IF T1 > TIME SKIP<br /> READ LO # read the low frequency<br /> READ HI # read the high frequency<br /> READ DL # read the delay.<br /> IF DL = -1 THEN C1 = 0 </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF DL = -1 THEN </span><span style="font-family: "courier new" , "courier" , monospace;">SKIP</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> POKE L1,LO # we put in the Sid 1 low register the value read by low<br /> POKE H1,HL # same but with the high value<br /> T1 = TT + DT * (DL - 1) # this is when we will read the next note.<br />SKIP:<br /> [...] #we skipped here and here we will test for C2 and C3</span><br />
<br />
Now we could copy the block and do the same things again<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF C1 = 0 SKIP_1<br /> IF T1 > TIME SKIP_1<br /> READ LO<br /> READ HI<br /> READ DL<br /> IF DL = -1 THEN C1 = 0 </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF DL = -1 THEN </span><span style="font-family: "courier new" , "courier" , monospace;">SKIP_1</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> POKE L1,LO<br /> POKE H1,HL<br /> T1 = TT + DT * (DL - 1)<br />SKIP_1:<br /> IF C2 = 0 SKIP_2<br /> IF T2 > TIME SKIP_2<br /> READ LO<br /> READ HI<br /> READ DL<br /> IF DL = -1 THEN C2 = 0 </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF DL = -1 THEN </span><span style="font-family: "courier new" , "courier" , monospace;">SKIP_2</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> POKE L2,LO<br /> POKE H2,HL<br /> T2 = TT + DT * (DL - 1)<br />SKIP_2:<br /> IF C3 = 0 SKIP_3<br /> IF T3 > TIME SKIP_3<br /> READ LO<br /> READ HI<br /> READ DL<br /> IF DL = -1 THEN C3 = 0 </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF DL = -1 THEN </span><span style="font-family: "courier new" , "courier" , monospace;">SKIP_3</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> POKE L3,LO<br /> POKE H3,HL<br /> T3 = TT + DT * (DL - 1)<br />SKIP_3:</span><br />
<br />
However as you see this wall of text is unreadable, and as such it's prone to inserting errors. It's better to have a subroutine to handle the common parts of this block of code.<br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;"> # channel 1<br /> CS = C1 # status of the channel<br /> TS = T1 # time of the channel</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> LT = L1 # low frequency register of the channel</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> HT = H1 # high frequency register of the channel<br /> GOSUB COMMON_LOADER<br /> C1 = CS<br /> T1 = TS</span><span style="font-family: "courier new" , "courier" , monospace;"><br /> # channel 2</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> CS = C2<br /> TS = T2</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> LT = L2</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> HT = H1<br /> GOSUB COMMON_LOADER<br /> C2 = CS</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> T2 = TS</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> # channel 3</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> CS = C3<br /> TS = T3</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> LT = L3 </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> HT = H3<br /> GOSUB COMMON_LOADER<br /> C3 = CS<br /> T3 = TS</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> [..]</span><br />
<br />
<span style="font-family: "courier new" , "courier" , monospace;">COMMON_LOADER:</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF CS = 0 SKIP</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF TS > TIME SKIP</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> READ LO </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> READ HI </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> READ DL </span><span style="font-family: "courier new" , "courier" , monospace;">#note that we set the "off" channel in CS</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF DL = -1 THEN CS = 0 </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> IF DL = -1 THEN SKIP </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># the values of LT and HT will be L1 and H1 </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># in the first channel, L2, H2 and L3, H3 </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># in the other two</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> POKE LT,LO </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># we put in the Sid 1 low register the value read by low</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> POKE HT,HL </span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># same but with the high value</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> TS = TT </span><span style="font-family: "courier new" , "courier" , monospace;">+ DT * (DL - 1) # this is when we will read the next note.</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">SKIP:</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> RETURN</span><br />
<br />
Tomorrow I will type in the program.</div>
</div>
limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-68563155911757148342015-12-17T13:31:00.002-08:002015-12-17T13:36:00.400-08:00Day 8, Towards Multichannel Sid Programming (Part 1)<i>Note: This is a multi-part post because it's taking me a lot of time. Also don't bother to write in the program right now, I still have to complete and test it, even if I consider the Commodore 64 User Manual to be correct and truthful (and I still have to see if my general algorithm works).</i><br />
<i><br /></i>
I'm trying to write a program, in Basic that allows me to play some music using the Sid. The music has to be stored somewhere as a songsheet, which means notes with tempo and their pitch.<br />
<br />
To do that I must consider three things:<br />
<h2>
Fact 1.</h2>
<div>
The SID has three channels, which can operate indipendently from each other.They map their registers on similar layouts on different memory addresses, where we can POKE the values in.</div>
<div>
<br /></div>
<h2>
Fact 2.</h2>
<div>
Each note I want to play can have a different timing from the others.</div>
<div>
<br /></div>
<h2>
Fact 3.</h2>
<div>
Save building a multitasking os for the C64 (lol, nope, or at least, not yet) I have only one cycle available to read data.</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
The question becomes: how do I store the data and how I load it into the SID registers by using only one program loop?</div>
<div>
<br />
I think I will just do something like this. I read the data about the three notes. The data being laid out like this.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">[note-1-pitch],[note-1-delay],[note-2-pitch],[note-2-delay],[note-3-pitch],[note-3-delay]</span></div>
<div>
<br /></div>
<div>
I will have some counters, independent from the SID, that will tell my loop if the time has come to read another note from the DATA directives. What I'm thinking is about a mechanism that works like this "If I'm ready to retrieve note-1 (or 2 or 3) I will read it, play it and update the corresponding counter". I will be able to mix different notes in the same bus.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">[note-1-pitch],[note-1-delay],[note-1-pitch],[note-1-delay],[note-2-pitch],[note-2-delay],</span><span style="font-family: "courier new" , "courier" , monospace;">[note-1-pitch],[note-1-delay],</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">[note-3-pitch],[note-3-delay]</span></div>
<div>
<br /></div>
<div>
When I put a [-1][-1] as data I will stop a channel, when all the channels are stopped then I will reset the SID and exit the application.</div>
<div>
<br /></div>
<div>
My workflow is something like this. Note that I use labels instead of numbering my statements, and I use the # instead of REM for labeling my comments.</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> GOSUB SET-UP-SID</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># we set up the continue variables here</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># we want to have them visible in the main loop</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> CO% = 1 #</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># we can also initialize further variables here</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">LOOP: </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># this is how we can emulate a while-true cycle in basic</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> IF CO% = 0 GOTO END-LOOP </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># now we will read the notes and upload them to the correct channel</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># now we will wait 1/4 of a second</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"># and after it we jump back</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> GOTO LOOP</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">END-LOOP: </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> GOSUB RESET-SID</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> END</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">SET-UP-SID:</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># rem here we will set up the channels with the correct instruments</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> RETURN</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">RESET-SID:</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># rem here we will clear the SID</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> [...]</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"> RETURN</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span>
As you notice there are some empty boxes, but we are going to fill them up.<br />
<br />
<h4>
Setting up the SID</h4>
</div>
<div>
First we define some helper variables to keep memory locations we need to address</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">SV=54296 # sid volume register</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">W1=54276 # adsr/waveform for voice 1</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">W2=54283 </span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">W3=54290</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">A1=54277 # attack/decay for voice 1</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">A2=54284</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">A3=54291</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">S1=54278 # sustain/release for voice 1</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">S2=54285</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">S3=54292</span></div>
<div>
<br /></div>
<div>
Next we will give up the right values we want to give them</div>
<div>
<br /></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE SV,15 # maximum volume</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># We turn Sid Channel 1 into Flute</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE W1,17 # triangle waveform</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE A1,96</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE S1,0</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># We turn Sid Channel 2 into Harpsichord</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE W2,33 # sawtooth waveform</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE A2,9</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE S2,0</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"># We turn Sid Channel 3 into Organ</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE W3,17 # triangle waveform</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE A3,0</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE S3,240</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<h4>
Resetting the SID</h4>
<div>
In the end we want to set the volume back to zero.</div>
<div>
<b><br /></b></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE SV,0</span></div>
<div>
<br /></div>
<div>
It might also be a good thing to zero all the values we put in the various SID registers. Since SID registers are contiguous we can just use a for loop initialized to the minimum register to the upper register</div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;"><br /></span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">FOR I = W1 TO S3</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">POKE I,0</span></div>
<div>
<span style="font-family: "courier new" , "courier" , monospace;">NEXT</span></div>
<div>
<br /></div>
<div>
<br /></div>
limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-36337872808207735132015-12-16T14:24:00.003-08:002015-12-16T14:24:39.132-08:00Day 7 - Mix and MatchToday's exercise reads (taken from Assembly Language Programming)<br />
<br />
<blockquote class="tr_bq">
<i>Write a program that: Loads a diamond into the accumulator, an asterisk into X and an "E" into Y. Then, without using any further Immediate Mode commands, moves the "E" into A, the diamond into X and the asterisk into Y. Print the diamond in the screen bottom left, the asterisk in the bottom right, and two "E"'s, one in each of the top two corner of the screen.</i></blockquote>
<i><br /></i>
Let's do it together.<br />
<br />
For loading a diamond in the accumulator, the X and E I will look at the petscii values on the commodore Character Set. E is 5, X is 24, and the diamond is 90.<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace;">LDA #$5A ; a diamond - dec 90 -> hex 5A</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">LDX #$24 ; asterisk - dec 42 -> hex 24</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">LDY #$05 ; letter 'E' - dec 5 -> hex 5</span></blockquote>
The next step asks us to swap those characters. We can't use immediate mode commands, that is we can't cheat by just loading them again. So we need a way to transfer those data. We can use some direct transfer instructions, (you can transfer some data from a register to another) but we also need to store one value in a swap area we will define later.<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace;">STX SWAP_AREA ; we will save the value from X into memory<br />TAX ; this will move the diamond from the</span>
<span style="font-family: "courier new" , "courier" , monospace;"> ; Accumulator to the X register<br />TYA ; This will move the 'E' from the Y register</span>
<span style="font-family: "courier new" , "courier" , monospace;"> ; to the Accumulator</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">LDY SWAP_AREA ; in the end we will read the value we saved</span>
<span style="font-family: "courier new" , "courier" , monospace;"> ; before and store into 'Y'</span><span style="font-family: "courier new" , "courier" , monospace;"><br /></span></blockquote>
Now we can proceed to store the data on the four screen locations AND change the foreground character color.<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace;">STA $0400 ; E on top left</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">STA $0427 ; E on top right</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">STX $07C0 ; the diamond (now in X) goes to bottom left</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">STY $07E7 ; the asterisk (now in Y) goes to bottom right</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">LDX #$01 ; we setup the foreground color</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">STX $D800 ; we tell the VIC-2 to use foreground color </span><br />
<span style="font-family: "courier new" , "courier" , monospace;">STX $D827 ; on the four corners</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">STX $DBC0</span><br />
<span style="font-family: "courier new" , "courier" , monospace;">STX $DBE7</span>
</blockquote>
Now we can exit and define the SWAP area<br />
<br />
<blockquote class="tr_bq">
<span style="font-family: "courier new" , "courier" , monospace;"> RTS<br />SWAP_AREA ; this is a label and tells the assembler to</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> ; use the following area as a memory location</span><br />
<span style="font-family: "courier new" , "courier" , monospace;"> BYTE $00</span></blockquote>
The following is the full listing, including the basic launcher.<br />
<blockquote class="tr_bq">
<span class="fctbStyle0" style="font-family: 'Courier New', monospace; font-size: 9pt; line-height: 13px;">; Exercise </span><span class="fctbStyle0Style5" style="font-family: 'Courier New', monospace; font-size: 9pt; line-height: 13px;">01</span><span class="fctbStyle0" style="font-family: 'Courier New', monospace; font-size: 9pt; line-height: 13px;">.</span><span class="fctbStyle0Style5" style="font-family: 'Courier New', monospace; font-size: 9pt; line-height: 13px;">05</span></blockquote>
<pre><span style="font-family: Courier New, monospace; font-size: 9pt; line-height: 13px;"><span class="fctbNone">
*=$</span><span class="fctbStyle5">0820</span><span class="fctbNone">
</span><span class="fctbStyle3">LDA</span><span class="fctbNone"> #$</span><span class="fctbStyle5">5A</span><span class="fctbNone"> </span><span class="fctbStyle0">; </span><span class="fctbStyle0Style5">a</span><span class="fctbStyle0"> diamond - </span><span class="fctbStyle0Style3Style5">dec</span><span class="fctbStyle0"> </span><span class="fctbStyle0Style5">90</span><span class="fctbStyle0"> -> hex </span><span class="fctbStyle0Style5">5A</span><span class="fctbNone">
</span><span class="fctbStyle3">LDX</span><span class="fctbNone"> #$</span><span class="fctbStyle5">2A</span><span class="fctbNone"> </span><span class="fctbStyle0">; asterisk - </span><span class="fctbStyle0Style3Style5">dec</span><span class="fctbStyle0"> </span><span class="fctbStyle0Style5">42</span><span class="fctbStyle0"> -> hex </span><span class="fctbStyle0Style5">2A</span><span class="fctbNone">
</span><span class="fctbStyle3">LDY</span><span class="fctbNone"> #$</span><span class="fctbStyle5">05</span><span class="fctbNone"> </span><span class="fctbStyle0">; letter </span><span class="fctbStyle0Style4">'</span><span class="fctbStyle0Style4Style5">E</span><span class="fctbStyle0Style4">'</span><span class="fctbStyle0"> - </span><span class="fctbStyle0Style3Style5">dec</span><span class="fctbStyle0"> </span><span class="fctbStyle0Style5">5</span><span class="fctbStyle0"> -> hex </span><span class="fctbStyle0Style5">5</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> SWAP_AREA </span><span class="fctbStyle0">; we will save the value from X into memory</span><span class="fctbNone">
</span><span class="fctbStyle3">TAX</span><span class="fctbNone"> </span><span class="fctbStyle0">; this will move the diamond from the</span><span class="fctbNone">
</span><span class="fctbStyle0">; Accumulator to the X register</span><span class="fctbNone">
</span><span class="fctbStyle3">TYA</span><span class="fctbNone"> </span><span class="fctbStyle0">; This will move the </span><span class="fctbStyle0Style4">'</span><span class="fctbStyle0Style4Style5">E</span><span class="fctbStyle0Style4">'</span><span class="fctbStyle0"> from the Y register </span><span class="fctbNone">
</span><span class="fctbStyle0">; to the Accumulator</span><span class="fctbNone">
</span><span class="fctbStyle3">LDY</span><span class="fctbNone"> SWAP_AREA </span><span class="fctbStyle0">; in the end we will read the value we saved</span><span class="fctbNone">
</span><span class="fctbStyle0">; before </span><span class="fctbStyle0Style3">and</span><span class="fctbStyle0"> store into </span><span class="fctbStyle0Style4">'Y'</span><span class="fctbNone">
</span><span class="fctbStyle3">STA</span><span class="fctbNone"> $</span><span class="fctbStyle5">0400</span><span class="fctbNone"> </span><span class="fctbStyle0">; </span><span class="fctbStyle0Style5">E</span><span class="fctbStyle0"> on top left</span><span class="fctbNone">
</span><span class="fctbStyle3">STA</span><span class="fctbNone"> $</span><span class="fctbStyle5">0427</span><span class="fctbNone"> </span><span class="fctbStyle0">; </span><span class="fctbStyle0Style5">E</span><span class="fctbStyle0"> on top right</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">07C0</span><span class="fctbNone"> </span><span class="fctbStyle0">; the diamond (now in X) goes to bottom left</span><span class="fctbNone">
</span><span class="fctbStyle3">STY</span><span class="fctbNone"> $</span><span class="fctbStyle5">07E7</span><span class="fctbNone"> </span><span class="fctbStyle0">; the asterisk (now in Y) goes to bottom right</span><span class="fctbNone">
</span><span class="fctbStyle3">LDX</span><span class="fctbNone"> #$</span><span class="fctbStyle5">01</span><span class="fctbNone"> </span><span class="fctbStyle0">; we setup the foreground color</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">D800</span><span class="fctbNone"> </span><span class="fctbStyle0">; we tell the VIC-</span><span class="fctbStyle0Style5">2</span><span class="fctbStyle0"> to use foreground color </span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">D827</span><span class="fctbNone"> </span><span class="fctbStyle0">; on the four corners</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">DBC0</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">DBE7</span><span class="fctbNone">
</span><span class="fctbStyle3">RTS</span><span class="fctbNone">
SWAP_AREA </span><span class="fctbStyle0">; this is </span><span class="fctbStyle0Style5">a</span><span class="fctbStyle0"> label </span><span class="fctbStyle0Style3">and</span><span class="fctbStyle0"> tells the assembler to</span><span class="fctbNone">
</span><span class="fctbStyle0">; use the following area as </span><span class="fctbStyle0Style5">a</span><span class="fctbStyle0"> memory location </span><span class="fctbNone">
</span><span class="fctbStyle1">BYTE $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle0">
; The following is how the machine stores the SYS </span><span class="fctbStyle0Style5">2080</span><span class="fctbStyle0"> command on line </span><span class="fctbStyle0Style5">10</span><span class="fctbStyle0"> of the
; Basic interpreter</span><span class="fctbNone">
*=$</span><span class="fctbStyle5">0801</span><span class="fctbNone">
</span><span class="fctbStyle1">BYTE $</span><span class="fctbStyle1Style5">0E</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">08</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">0A</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">9E</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">20</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">32</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">30</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">38</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">30</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span></span></pre>
limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-63660642397811329842015-12-15T13:19:00.000-08:002015-12-15T13:19:45.379-08:00Day 6. The Source Awakens.<div class="tr_bq">
I downloaded "<a href="http://www.ajordison.co.uk/" target="_blank">CBM prg Studio</a>" by Arthur Jordison. I'm not tough enough to bear with the Commodore 64 editor mode, it's lovely but too quirky. Also CBM prg studio being an external IDE allows me to have all the source at a glance, shows several useful tools that surely will be handy and has the features that are needed by an ASM ide: labels, macros and automatic build.</div>
<br />
Programming with the IDE is a breeze and you can also use it to program in basic. The tutorial shows you how to run an assembler program by using a basic code loader (the IDE generates it using one of its tools), but you can also ask the IDE to provide you with a "SYS" style execution code.<br />
<blockquote>
<pre><span style="font-family: "courier new" , monospace; font-size: 9pt; line-height: 13px;"><span class="fctbStyle0">; Exercise </span><span class="fctbStyle0Style5">1</span><span class="fctbStyle0">.</span><span class="fctbStyle0Style5">1</span><span class="fctbNone">
*=$</span><span class="fctbStyle5">0820</span><span class="fctbNone">
</span><span class="fctbStyle3">LDA</span><span class="fctbNone"> #$</span><span class="fctbStyle5">01</span><span class="fctbNone">
</span><span class="fctbStyle3">STA</span><span class="fctbNone"> $</span><span class="fctbStyle5">0400</span><span class="fctbNone">
</span><span class="fctbStyle3">STA</span><span class="fctbNone"> $</span><span class="fctbStyle5">D800</span><span class="fctbNone">
</span><span class="fctbStyle3">RTS</span><span class="fctbStyle0">
; </span><span class="fctbStyle0Style5">10</span><span class="fctbStyle0"> SYS </span><span class="fctbStyle0Style5">2080</span><span class="fctbNone">
*=$</span><span class="fctbStyle5">0801</span><span class="fctbNone">
</span><span class="fctbStyle1">BYTE $</span><span class="fctbStyle1Style5">0E</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">08</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">0A</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">9E</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">20</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">32</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">30</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">38</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">30</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span></span></pre>
</blockquote>
This source code create a tiny self contained C64 program that prints a white A on the top left of the screen. It's the first exercise you find in Hayden's "Commodore 64 Assembly Language Programming". Note that I decided to locate the program in memory location $0820, just a couple of bytes after the space reserved for the basic SYS statement. Before I tried to use *=C000 as a start location for for the executable, but apparently it's a bad idea since the generated program will be so large that the emulator will waste time loading it.<br />
<br />
The following instead is still a basic exercise, and it will print a white X on each of the four screen corners.<br />
<blockquote>
<pre><span style="font-family: "courier new" , monospace; font-size: 9pt; line-height: 13px;"><span class="fctbStyle0">; Exercise </span><span class="fctbStyle0Style5">1</span><span class="fctbStyle0">.</span><span class="fctbStyle0Style5">3</span><span class="fctbNone">
*=$</span><span class="fctbStyle5">0820</span><span class="fctbNone">
</span><span class="fctbStyle3">LDA</span><span class="fctbNone"> #$</span><span class="fctbStyle5">18</span><span class="fctbNone">
</span><span class="fctbStyle3">STA</span><span class="fctbNone"> $</span><span class="fctbStyle5">0400</span><span class="fctbNone">
</span><span class="fctbStyle3">STA</span><span class="fctbNone"> $</span><span class="fctbStyle5">0427</span><span class="fctbNone">
</span><span class="fctbStyle3">STA</span><span class="fctbNone"> $</span><span class="fctbStyle5">07C0</span><span class="fctbNone">
</span><span class="fctbStyle3">STA</span><span class="fctbNone"> $</span><span class="fctbStyle5">07E7</span><span class="fctbNone">
</span><span class="fctbStyle3">LDX</span><span class="fctbNone"> #$</span><span class="fctbStyle5">01</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">D800</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">D827</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">DBC0</span><span class="fctbNone">
</span><span class="fctbStyle3">STX</span><span class="fctbNone"> $</span><span class="fctbStyle5">DBE7</span><span class="fctbNone">
</span><span class="fctbStyle3">RTS</span><span class="fctbStyle0">
; </span><span class="fctbStyle0Style5">10</span><span class="fctbStyle0"> SYS </span><span class="fctbStyle0Style5">2080</span><span class="fctbNone">
*=$</span><span class="fctbStyle5">0801</span><span class="fctbNone">
</span><span class="fctbStyle1">BYTE $</span><span class="fctbStyle1Style5">0E</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">08</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">0A</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">9E</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">20</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">32</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">30</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">38</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">30</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span><span class="fctbStyle1">, $</span><span class="fctbStyle1Style5">00</span></span></pre>
</blockquote>
limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-80739909573111350812015-12-14T12:54:00.000-08:002015-12-14T12:54:14.212-08:00Day 5. Exporting a basic program from a D64.I am following a thread on the somethingawful forums titled <span style="font-family: inherit;">"<a class="bclast" href="http://forums.somethingawful.com/showthread.php?threadid=3755200" style="background-color: white; border-bottom-color: rgb(215, 215, 218); border-bottom-style: solid; border-width: 0px; font-size: 13px; font-weight: bold; text-decoration: none;">Let's Play Learning BASIC (And Porting!)</a>" (There could be a paywall in front of the thread, sometimes the mods put it up to encourage registration). It's a quite interesting thread because the author shows a program in basic for the BBC and gives an assignment related to it. </span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">Doing the assignment I found that the Basic language is... clunky. Ok, it was 1983 and it was easier to tell the computer what's the order of the basic commands by using labels than by having a freeform source file with labels (am I wrong or Amiga Basic had named labels?).</span><br />
<span style="font-family: inherit;"><br /></span>
<span style="font-family: inherit;">To export the basic program I saved into a d64 I used <a href="http://style64.org/release/dirmaster-v3.0.0-style" target="_blank">Dirmaster by Style</a>, a very cool windows application that allows you to have a listing of the virtual floppy and to check its files. I only had to convert to uppercase the listing, and to convert the Clr/Screen characters by hand.</span><br />
<br />
I think I could clean up the source of the modified game, for example by cleaning up the decision block between 100 and 120 and adding a random seed based on time, but for now this will suffice.<br />
<blockquote class="tr_bq">
<span style="background-color: #fafafa; font-family: monospace; font-size: 14px; line-height: 20px; white-space: pre;">10 PRINT "{CLR/SCREEN}";
20 PRINT "STARSHIP TAKE-OFF"
21 PRINT "PRESS ANY KEY TO CONTINUE"
22 GET A$ :IF A$ ="" THEN 22
29 PRINT "{CLR/SCREEN}"
30 G = INT(20*RND(1)) + 1
40 W = INT(40*RND(1)) + 1
41 NF = 1
42 XF = 1
50 R = G * W
60 PRINT "GRAVITY = "; G
70 PRINT "TYPE IN THE THRUST"
80 FOR C = 1 TO 10
81 IF NF < 2 AND XF < 2 THEN 90
82 GOSUB 1000
83 PRINT R$
90 INPUT F
91 PRINT "{CLR/SCREEN}"
100 IF F > R THEN PRINT "TOO HIGH";
101 IF F > R AND F < XF THEN XF = F
102 IF F > R AND XF = 1 THEN XF = F
110 IF F < R THEN PRINT "TOO LOW";
111 IF F < R AND F > NF THEN NF = F
112 IF F < R AND NF = 1 THEN NF = F
120 IF F = R THEN GOTO 190
130 IF C <> 10 THEN PRINT ", TRY AGAIN"
140 NEXT C
150 PRINT ""
160 PRINT "YOU FAILED!"
170 PRINT "THE ALIENS GOT YOU!"
180 END
190 PRINT "GOOD TAKE OFF! YOU WIN!"
200 END
1000 IF NF < 2 AND XF > 1 THEN 1002
1001 GOTO 1010
1002 R$ ="THRUST MUST BE UNDER " + STR$(XF)
1010 IF NF > 1 AND XF < 2 THEN 1012
1011 GOTO 1020
1012 R$="THRUST MUST BE OVER " + STR$(NF)
1020 IF NF < 2 OR XF <2 THEN 1040
1030 R$ = "THRUST MUST BE BETWEEN " + STR$(NF) + " AND " + STR$(XF)
1040 RETURN</span></blockquote>
limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-21501512432468926822015-12-13T22:16:00.000-08:002015-12-14T04:38:17.320-08:00Day 4. How to use a wacom tablet with an emulated C64 graphical program in VICE.Now, on a less serious note, I managed to complete a couple of steps that could allow me to use a wacom tablet to edit drawings directly inside the VICE emulator, or better, the windows version (winvice).<br />
<br />
There are a few challenges to this one: I found that you can't use most graphical programs because most of mouse-based peripherials (even the koala painter tablet) under VICE behave like a mouse, and as such it does not behave properly: if you take the pen up and put it down on the tablet again it will start drawing again in the same spot.<br />
<br />
The only problem is that there are currently only two graphical programs that I know to support any kind of light pen and are available as any kind of download on the internet. One is "Picasso Revolution", an old, clunky, 1983 program which will crash in VICE as soon as you ask it to open a file for editing. If you guys are reading about it and tried to re-release it, don't worry, it was my fault and I did not have patience to try to make it work on WinVice, (maybe I should have tried with x64sc). The second one is GEOS.<br />
<br />
To make GEOS work with a Light Pen run you need to have the following things:<br />
<br />
<ol>
<li>WinVice. I used a nightly build (I downloaded WinVICE-2.4.23-x86-r30277).</li>
<li>You need to configure VICE with Disk Drive 9 (if you want to avoid getting mad switching between the OS and the drivers first, geoPaint later). For now just configure a 1551 mouse in the first joystick port.</li>
<li>You need the following software: a bootable disk for GEOS, a drivers disk with the inkwell drivers and geoPaint</li>
<li>Insert Geos in drive 8, The drivers disk in drive 9, boot up GEOS and copy the Inkwell driver from the driver disk to the geos boot disk.</li>
<li>Now, in VICE, stop capturing the mouse and configure an inkwell pen in the first joystick port.</li>
<li>In GEOS press Commodore+I (Left CTRL + I), with the arrow keys choose Inkwell.</li>
<li>Calibrate the inkwell by pressing on the white bar (don't worry about the graphical glitches) and press OK.</li>
<li>Swap the drivers disk in drive 9 with GeoPaint and run it.</li>
<li>Now you are ready to bang your head with GeoPaint for the following 9000 hours.</li>
</ol>
<br />
<div style="text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyqA1t73SyqTTTUSO4OAaeNFdeK2JJOZpnQomvVgSN1wG229HMtNTbvmyRyauleMDP2muHiuAJhXicIZ4piZgTpj6i97Izypa9E6JhhOgfPowng6KTkbjPePOA0C0gwDMvfnUPUwq0UdU/s1600/GeosPaint.PNG" imageanchor="1"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyqA1t73SyqTTTUSO4OAaeNFdeK2JJOZpnQomvVgSN1wG229HMtNTbvmyRyauleMDP2muHiuAJhXicIZ4piZgTpj6i97Izypa9E6JhhOgfPowng6KTkbjPePOA0C0gwDMvfnUPUwq0UdU/s320/GeosPaint.PNG" width="320" /></a></div>
<span id="goog_224100571"></span><span id="goog_224100572"></span><br />
<br />
Some caveats:<br />
<br />
<ol>
<li>If you put winvice at full screen and you erroneously alt+tab away from it, you may not be able to exit from full screen.You'd better have a second monitor ready so that you can use the mouse to click on the winvice icon.</li>
<li>Sometimes menu recognition is clunky, in that case you can use the arrow keys (and a second mouse) and warp to click on the correct option, or to exit from the menu if you chose the wrong one. I don't know why the inkwell driver stops working as soon.</li>
<li>It's better to turn on the disk drive sound emulation. Or just cheat and warp away.</li>
<li>The SC version of x64 seems to be better overall.</li>
<li>You need to press on the tablet to start drawing and press again to stop drawing. If you don't press a second time you will lose control of the pointer and start making big marks.</li>
</ol>
<div>
<br /></div>
limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com2tag:blogger.com,1999:blog-5947317850295044692.post-20200099530687712015-12-12T23:23:00.000-08:002015-12-12T23:23:17.928-08:00Day 3. Decimal and hexadecimal.I am held captive by a brutal beast that adores gnawming my hands so I am currently unable to write many things. So I will update this post when I get released by my captor.<br />
<br />
The book Commodore 64 Language programming has a strange habit to show the various memory addresses as decimal numbers instead of hexadecimal, so I needed a way to convert from decimal and hexadecimal.<br />
<br />
<a href="http://stackoverflow.com/a/19239691" target="_blank">This answer on stack overflow</a> provides an easy method for doing that.limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-84032374972715179292015-12-11T21:26:00.003-08:002015-12-13T00:03:40.415-08:00Day 2. High Def MonitorDownloaded and currently running through Hesmon to play around with the C64 memory and assembly language. Hesmon is not an assembler, is more of a monitor: it has some tracing and memory dump functionality that may help you understand what and how to use the C64 memory, and is surely not as fully featured as other cartridges like The Final Cartridge III.<br />
<br />
I chosed it because I am somehow familiar with it, having owned the original hesmon cartridge and remembering a little how to operate it.<br />
<br />
There's something magic about the hesmon manual. It's colloquial and it rushes through the various functions asking you to pay attention, to be prepared on the subject matter and to be interested to dig out more from the system by yourself.<br />
<br />
I also love the naivetè of some notes, like the following passage<br />
<br />
<blockquote class="tr_bq">
Exception: if you attempt to use RS232 files all bets are off. Also, correct operation of RS232 files is not guaranteed with HESMON installed.</blockquote>
<br />
That's something you don't see anymore, companies peddling software are better at lying and denying there is any kind of problem with their software, expecially if they are videogame companies. Or banks. Maybe hesware at the time wasn't thinking that the RS232 would not have been so impoetant, or there was not enough time to iron out the kinks to launch the software on the market on 1983.<br />
<br />
Anyway, here is a useful list of mnemonics.<br />
<br />
The <b>;</b> (semicolon) command sets the registers.<br />
<br />
You can use the <b>: </b>(colon) command to set the memory contents at a certain address directly.<br />
<br />
To write a short program you must use the <b>A</b> command. A takes a memory location, so you have to write A1200 to start writing at the $1200 memory adddress.<br />
You can operate the A command like this.<br />
<b><br /></b>
<br />
<blockquote class="tr_bq">
<b>A1200 LDX #01</b></blockquote>
<blockquote class="tr_bq">
A1202 <b>STX 0384</b></blockquote>
<blockquote class="tr_bq">
A1205 <b>LDA #02</b> </blockquote>
<blockquote class="tr_bq">
A1207 <b>ADC 0384</b> </blockquote>
<blockquote class="tr_bq">
A120A <b>RTS</b> </blockquote>
<blockquote class="tr_bq">
A120B </blockquote>
As the manual states, to stop inserting the program you need to insert an empty line at the end of your program. Hesmon won't recognize your line and won't alter memory location A120B. Note that after inserting the first line the program will alter your currently input line, if recognized, with the final memory layou, with both the op and the values you are passing to them. The program will provide you the memory locations successive to A1200 by calculating the space taken by your current line and opcode. Convenient.<br />
<br />
To run this little program you use the command G (go) followed by the memory address: G1200. It will not print out anything on screen yet, however you will see that hesmon will report that the content of the accumulator is 03.<br />
<br />
To save the program you need to write S followed by the starting memory area, and the first unused memory area. Our program occupies between the $1200 and $120A, the first unused area therefore will be $120B. So we need to use<br />
<br />
<b>S "SUM" 08 1200 120B</b><br />
<br />
The next time we will need to load our program we will use.<br />
<br />
<b>L "SUM" 08</b><br />
<b><br /></b>
<i>Addendum:</i> the example listing was taken from Commodore 64 Assembly Language Programming by Derek Bush and Peter Holmes, published by Hayden.<br />
<b><br /></b>limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com1tag:blogger.com,1999:blog-5947317850295044692.post-10553560851334648602015-12-10T22:14:00.000-08:002015-12-10T22:14:11.564-08:00Day 1. Keys and TribulationsSo, I took some time to re-accustom myself to winvice and emulate a Commodore 64 by downloading Geos, GeoWrite and trying to write some text into it. It was a success.<br />
<br />
Some adjustements are needed to be able to control the system.<br />
<br />
This is how vice works on a stock installation with an italian keyboard.<br />
<br />
<b>Left ALT+W</b> starts and stops warp mode.<br />
<b>Left ALT+Enter</b> makes the emulator enter or exit fullscreen mode.<br />
<b>Left ALT+Q</b> makes the emulator capture mouse input, useful if you want to run Geos or mouse enabled software, very less so for any other reason other than getting crazy.<br />
<br />
Note that you can't use the Right Alt key for those combinations.<br />
<br />
Mapping for some commodore-specific keys.<br />
<br />
<b>Tab</b> becomes the <b>Control Key</b> on the Commodore Keyboard (that agrees with the placement of the control key of the commodore keyboard)<br />
<br />
The <b>Left Control Key </b>and the <b>Right Alt Key</b> on the windows keyboard become the <b>Commodore Key</b> on the Commodore Keyboard.<br />
<br />
<b>Return</b> and <b>Shift</b> have no change.<br />
<br />
<b>Caps Lock</b> key becomes <b>Run Stop</b>, while <b>Page Up</b> is <b>Restore</b>.<br />
<br />
You can use the <b>four arrow keys</b> to emulate the <b>cursor keys</b>, <b>down </b>and <b>right</b> however will behave like the original keys and if you press the <b>Shift</b> together they will invert their direction.<br />
<br />
<b>Delete</b> works as <b>Inst/Del</b>, it will also insert spaces if you press <b>shift+inst/del</b>.<br />
<b><br /></b>
<b>Home</b> works as <b>Clr/Home</b>.<br />
<b>Insert</b> works af the <b>£</b> key.<br />
<br />
Ohter commodore Keys (the arrow symbol, equals and parentheses) are in the spot reserved to them on the C64 keyboard, so that I have to make a mental map of where is what.<br />
<br />
The only key I haven't found an emulation of is the <b>Shift Lock</b> key, but that's not a problem for now.limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0tag:blogger.com,1999:blog-5947317850295044692.post-35827928346073766742015-12-10T03:36:00.001-08:002015-12-10T03:36:15.380-08:0010 PRINT "Hello World"I have a plan: obsess over programming for the C64 and maybe C128 or the C16 as well for a certain period of time, release something, and then stop and move over.<br />
<br />
You may have seen me from different incomplete projects: a jar library with a small swing videogame, a few (now-deleted) blogs, a document about programming the MSX (I will probably obsess again over the MSX after this trip, because it's a world that fascinates me). However in those times I did neither have a plan, a target, nor the wish to obsess over it.<br />
<br />
Now I have a few projects, old and new, I will uncover as soon as I am able to approach them.limaCAThttp://www.blogger.com/profile/09790785500820726074noreply@blogger.com0