Spogg wrote:At this point, I really beg our Assembler Gurus, to help us out. The program isn't very long and I'm sure you can make much more sense of it in shorter time! Pretty please?
You rang?!
OK I had a brief look, but I'm not sure if I can be helpful. At a first glance, the code seems to load values from memory and then incrementing/decrementing them based on their values. I'm not quite sure what the code is meant to do, since I don't know what the values represent. The best I can do is transliterate the code into C.
- Code: Select all
#X,Y,U,S are pointers to stacks
#a,b are accumulator registers
byte *X,*Y,*U,*S;
byte a,b;
byte temp,carry;
a=*U; #LDA ,U ; osc semitone
a=a+*S; S++; #ADDA ,S+ ; add raw wave semitone shift
a=a-0x24; #SUBA #$24 ; wave octave is -3 to -1
if(a<0)goto hED54; #BLT hED54 ;
#CMPA #$18 ; wave octave is 0 or 1
if(a-0x18<0)goto hED52; #BLT hED52 ;
#
#;------------------------------------------------
#;--- wave octave is >=2 -------------------------
#;------------------------------------------------
b-=1; #DECB ; adjust address bus resolution (speed up)
goto hED63; #BRA hED63
#
#;------------------------------------------------
#;--- wave octave is 0/1 -------------------------
#;------------------------------------------------
hED52: goto heD61; #hED52: BRA hED61 ; only tune up via semitone
#
#;------------------------------------------------
#;--- wave octave is -3 to -1 ---------------------
#;------------------------------------------------
hED54: b++; #hED54: INCB ; adjust address bus resolution (slow down)
a=a+0x0c; #ADDA #$0C ; +1 octave
if(a>=0) goto hED61; #BGE hED61
b++; #INCB ; adjust address bus resolution (slow down)
a=a+0x0c; #ADDA #$0C ; +1 octave
if(a>=0) goto hED61; #BGE hED61
b++; #INCB ; adjust address bus resolution (slow down)
a=a+0x0c; #ADDA #$0C ; +1 octave
#
#;------------------------------------------------
#;--- wave octave is 0/1/2 -----------------------
#;------------------------------------------------
hED61: a=a+0x0c; #hED61: ADDA #$0C ; +1 octave
#
#;------------------------------------------------
#;--- set DOC frequency and control --------------
#;------------------------------------------------
hED63: *(Y-0x37)=a; #hED63: STA -$37,Y ; set DOC frequency MSB
a=*(U+0x01); #LDA +$01,U ; get osc fine tune
temp=a; a=a+*S; S++; carry=temp<a; #ADDA ,S+ ; add raw wave fine tune
*(Y-0x36)=a; #STA -$36,Y ; set DOC frequency LSB
if(~carry) goto hED72; #BCC hED72
(*(Y-0x37))++; #INC -$37,Y ; increment DOC frequency MSB
hED72: *(Y-0x36)=a; #hED72: STA -$36,Y ; set DOC frequency LSB
presumably address (U+0x01) holds "osc fine tune" variable, which is 1byte int and (Y-0x36) holds 2byte int, which would explain the LSB/MSB addition and incrementing (adding fine tune (1byte int) to DOC frequency (2byte int)).
The MSB of "DOC frequency" seems to hold semitone values, since the result of all that code in the octave/semitone branches writes there. LSB seems to hold fine tune. Namely, it holds "osc fine tune" + "raw fine tune" plus if overflow occurs, MSB gets incremented (aka fine-tuned by more than 1 semitone). Strangely, there is no code for decrementing, so it appears that fine-tuning lower than 1 semitone is impossible.
That also clears out why (S) stack pointer is incremented when read. It also hold 2byte value. First byte being "raw wave semitone shift" (read at the beginning of the code) and second being "raw fine tune" (read near the end of the code).
Register "b" seems to hold "address bus resolution" whatever that means... It is never loaded or stored in this code - only modified by incrementing/decrementing it in some cases. Every time decrement occurs, comment say "(speed up)" and for every increment they say "(slow down)". It appears that the value is used elsewhere to bitshift some sort of address/index to double/half the reading speed.