Image Map Image Map
Page 1 of 6 12345 ... LastLast
Results 1 to 10 of 54

Thread: Adding NOPs

  1. #1
    Join Date
    Jan 2011
    Location
    Vancouver, BC
    Posts
    4,817
    Blog Entries
    3

    Default Adding NOPs

    Question.

    I am playing around with my OSI 300 and am trying out the 'experiment' they have that can produce audio on a stereo by connecting the output latch on the 300 to the stereo 'aux in' port.

    The program, as they've written it, is as follows:

    audio experiment.png

    I'm not sure exactly what they're telling me to do with adding NOPS there later. Are they saying, for example, ad memory address 03, sub in 10 NOPS and then move the rest down by however many addresses?

  2. #2
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,476

    Default

    I think the number of NOPs is (possibly) a 'variable' depending upon the note you want to produce?

    I think the 10 NOPs may be a 'for example'?

    However, once you insert a number of NOPS, you will move the address to which the JMP instruction jumps to at instruction address 03 (e.g. jmp 6 = 4C 06 00). If you add some NOPs then the jump operand (06 00 in this case) will need to be adjusted accordingly.

    I haven't quite worked out the timing myself yet... It depends how many cycles a NOP takes of course...

    Dave

  3. #3
    Join Date
    Feb 2017
    Location
    Guildford, U.K.
    Posts
    294

    Default

    Quote Originally Posted by daver2 View Post
    I think the number of NOPs is (possibly) a 'variable' depending upon the note you want to produce?

    I think the 10 NOPs may be a 'for example'?

    However, once you insert a number of NOPS, you will move the address to which the JMP instruction jumps to at instruction address 03 (e.g. jmp 6 = 4C 06 00). If you add some NOPs then the jump operand (06 00 in this case) will need to be adjusted accordingly.

    I haven't quite worked out the timing myself yet... It depends how many cycles a NOP takes of course...

    Dave
    Correct, essentially the NOPs are to introduce a delay between I/O writes/reads. The actual delay will depend upon the CPU's clocking frequency times the number of cycles each instruction takes. e.g. (1 sec / 4MHz = 250ns cycle) x (say 4 cycles per NOP) x no. of NOPs = delay.

    Jumps are relative (i.e. "here" +/- a number of bytes. The location of "here" depending upon CPU instruction set). If not using an assembler you must do the calculation yourself. An Assembler will work out how far away a labelled location is and put in the correct offset.

  4. #4
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    33,437
    Blog Entries
    18

    Default

    It's worth noting that the Apple II disk controller uses NOPs to ensure precise timing. It's basically little more than a PROM, shift register and a latch operating as a sequencer. Read up on the technical details; it's pretty interesting. Jim Sather's "Inside" book is a good source.

  5. #5

    Default

    I wonder how the latch is wired up on the 300. Will accessing page zero effect it. If not, there are a number of page zero operations that can be used to fine tune, closer than a NOP. The page zero operations are usually 3 cycle or one and a half NOP worth of timing.
    Dwight

  6. #6
    Join Date
    Mar 2017
    Location
    New Jersey, USA
    Posts
    551

    Default

    Quote Originally Posted by falter View Post
    I'm not sure exactly what they're telling me to do with adding NOPS there later. Are they saying, for example, ad memory address 03, sub in 10 NOPS and then move the rest down by however many addresses?
    Yes. The idea here is that the program without NOPs takes 14 cycles per loop, and that you can measure the actual audio frequency emitted to calculate the exact cycle time for your computer.

    Then, once you know the cycle time you can add the 10 NOPs as instructed (raising the loop time to 54 cycles and changing the output audio frequency accordingly), or a different number of NOPs if there is a different audio frequency you want to generate. Since you will know the cycle time from the NOP-less version already, and you know that each NOP adds 2 cycles (iirc), you will be able to calculate the number of NOPs needed to get a desired audio frequency (or as close to it as you can).

  7. #7
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,476

    Default

    >>> I wonder how the latch is wired up on the 300.

    It is a set/reset flip flop formed by cross-coupling two 2-input NOR gates in an SN7402 package.

    Only by accessing any byte in page 2 or 3 can the SR flip-flop be set or reset. There appear to be two (2) outputs (P2 and P3) in antiphase to each other (i.e. the effective Q and /Q from the FF).

    Accessing page 0 should have no effect on the state of the output.

    Accessing page 3 will cause mayhem (both the Q and /Q outputs [= P2 and P3] will be simultaneously cleared)!

    Dave

  8. #8

    Default

    So it seems that a page 0 access can make about a 2% or better adjustment of the frequency.
    Dwight

  9. #9

    Default

    So they conveniently attached the flip flop to page 1 (where the 6502 stack lives)? Better take that into consideration any time you use a subroutine call to play with the flip flop!

  10. #10
    Join Date
    Jun 2012
    Location
    UK - Worcester
    Posts
    3,476

    Default

    There is a typo. in my post #7. I meant pages 1 and 2 not pages 2 and 3 as I have written.

    Page 3 will still affect the flip/flop though!

    It will be interesting to check how much RAM there is, there may only be 128 or 256 bytes - so that will make subroutines a bit tricky on a 6502... Although I am sure I have seen some subroutine examples in the manual. I will check...

    Dave

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •