Quantcast

Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: Where to find good motorola 68k assembly tutorials?

  1. #1
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    166
    Rep Power
    3

    Default Where to find good motorola 68k assembly tutorials?

    I read everywhere 68k Assembly is one of the best and easiest to learn. I have been searching on google a lot and found some usefull documents. Like the 600+ pages programmers manual, a short version with only the opcodes for the 68000. My biggest problem with these is that they don't have bookmarks in the PDF. For me the programmers manual is way to much information to start with, and not specific to the 68000. I have been looking for some good assembly tutorials that explain how the instructions work, and how they could be used. Included with some timing information.

    Some of you might have read my thread "Getting the genesis online" where i showed some results i have made. If i can have a better knowledge of the 68k i can progress much faster in my project.

    A while back i was working on a Atari 800 emulator, which uses the 6502 processor. I got most information from this site, and especially the reference page. I have been searching for a website with similar info for the 68k processor, but have not found any yet. I am hoping some of you might know where i should look to find the information i need.


    Thanks in advance,
    Archer
    Last edited by Archer; 02-11-2011 at 11:19 AM.
    Learning the genesis one bit at a time

  2. #2
    WCPO Agent Sik's Avatar
    Join Date
    Jan 2011
    Posts
    907
    Rep Power
    9

    Default

    Huh... I've started with the tutorials at Hacking-Cult but you can't do anything with that alone -- it's a good way to get a grasp of how things work, but you'll need the programmer reference manual after that (68kpm.pdf or similar, most of the instructions are in section 4).

    Also you may want to look tutorials elsewhere, the 68000 was so common it's easy to find stuff for it.

    Also on being easier: it's just that the operands can be combined in lots of ways for most instructions. Many processors can only perform calculations with the registers, so code gets messy. Sticking to registers whenever possible is a good idea anyways (faster than working with memory directly).

  3. #3
    ding-doaw Raging in the Streets tomaitheous's Avatar
    Join Date
    Sep 2007
    Location
    Sonoran Desert
    Age
    36
    Posts
    3,057
    Rep Power
    31

    Default

    So you have experience with 6502 assembly? 68k should be easy to pick up on, then.

    There's a quick reference PDF if all you are looking for is instruction chart. It's simpler and more compact than the official manual instruction cycle time chart.

    Are you looking to create a 68k emulator or do you just want to learn 68k for coding? Why not post some questions about specific instructions. Or if you don't know the instruction, but know the logic, ask for the equiv. Etc.

    What instructions are you having problems understanding?

  4. #4
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    166
    Rep Power
    3

    Default

    Quote Originally Posted by Sik View Post
    Huh... I've started with the tutorials at Hacking-Cult but you can't do anything with that alone -- it's a good way to get a grasp of how things work, but you'll need the programmer reference manual after that (68kpm.pdf or similar, most of the instructions are in section 4).

    Also you may want to look tutorials elsewhere, the 68000 was so common it's easy to find stuff for it.

    Also on being easier: it's just that the operands can be combined in lots of ways for most instructions. Many processors can only perform calculations with the registers, so code gets messy. Sticking to registers whenever possible is a good idea anyways (faster than working with memory directly).
    I download the complete programmer reference manual (646 pages long). I even started reading it, but all the info on the other members of the family (68020, 68030, 68040) confused me too much. I have been looking at the Hacking-Cult site, and thats the kind of thing i am looking for. Although i think it's not complete. Thanks for the reference. It has some nice VDP info too, and i think i understand it a bit better now. Like i said i have been looking elsewhere, but could not find something that goes beyond a brief description of the CPU registers and data bus. I noticed a speed increase of 35% when using registers instead of immediate numbers.


    Quote Originally Posted by tomaitheous View Post
    So you have experience with 6502 assembly? 68k should be easy to pick up on, then.

    There's a quick reference PDF if all you are looking for is instruction chart. It's simpler and more compact than the official manual instruction cycle time chart.

    Are you looking to create a 68k emulator or do you just want to learn 68k for coding? Why not post some questions about specific instructions. Or if you don't know the instruction, but know the logic, ask for the equiv. Etc.

    What instructions are you having problems understanding?
    I started assembly programming on the PIC microcontroller. That helped me understand 6502 assembly. I think my 6502 and PIC Micro experience has been invaluable when learning the 68k, but the 68k is a bit more complicated. The concept of specifying .b .w .l was confusing when i started, but now i got it. I have the quick reference guide named "68KOP.pdf", using it a lot but missing bookmarks to jump to an instruction quickly. I also found a PDF named "68000-Timing-Table.pdf", not sure where anymore.

    At this time i am not planing on writing a 68k emulator, although it would be a good experience to learn how it works. So for now, i just want to learn more about writing code for the 68k. Right now i have a problem with a loop:

    Code:
      ...
    _spi_loop:
      btst #4,(%a0)
      beq _spi_loop_read_zero
      bset %d4,%d6
      bra _spi_loop_read_done
    _spi_loop_read_zero:
      bclr %d4,%d6
    _spi_loop_read_done:
      dbra %d4,_spi_loop
      ...
    I think it's the bclr before dbra (i had dbeq first) that is giving me problems. When i leave it out the loop works. i have been experimenting with ori and andi but then i think btst is giving problems.

    What i try here is clock in data from bit #4 and store it in %d6
    Learning the genesis one bit at a time

  5. #5
    WCPO Agent Sik's Avatar
    Join Date
    Jan 2011
    Posts
    907
    Rep Power
    9

    Default

    I must be missing something as I can't think of what's wrong in it... Unless the issue is reading from (a0) for starters.

    Also I'd just set d6 to 0 before the loop then just look up for bits with a 1.

  6. #6
    Mastering your Systems Hero of Algol TmEE's Avatar
    Join Date
    Oct 2007
    Location
    Estonia, Rapla City
    Age
    23
    Posts
    9,060
    Rep Power
    67

    Default

    I used some Amiga docs I found form ProgrammersHeaven
    Death To MP3, :3
    Mida sa loed ? Nagunii aru ei saa "Gnirts test is a shit" New and growing website of total jawusumness !

  7. #7
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    166
    Rep Power
    3

    Default

    Quote Originally Posted by Sik View Post
    I must be missing something as I can't think of what's wrong in it... Unless the issue is reading from (a0) for starters.

    Also I'd just set d6 to 0 before the loop then just look up for bits with a 1.
    The loop was not complete as i posted it, i have some writing code there too. Here is the complete routine

    Code:
      move.b #0x00, EXT_S_CTRL
      move.b #0b00111111, EXT_CTRL
      move.l #0x00A10007, %a0
      ...
    spi_transfer:
      move.w #0x0007, %d4
      move.b (%a0),%d5
      move.b #0,(_spi_data_in)
    
    _spi_loop:
      andi #0b11111101,%d5
      move.b %d5,(%a0)
      lsl.b #1,%d3
      bcs _spi_loop_write_set
      andi #0b11111011,%d5
      bra _spi_loop_write_done
    _spi_loop_write_set:
      ori #0x04,%d5
    _spi_loop_write_done:
      move.b %d5,(%a0)
      ori #0x02,%d5
      move.b %d5,(%a0)
      
      nop
    
      btst #4,(%a0)
      beq _spi_loop_read_zero
      bset %d4,%d6
      bra _spi_loop_read_done
    _spi_loop_read_zero:
      bclr %d4,%d6
    _spi_loop_read_done:
      dbra %d4,_spi_loop
    
      move.b %d6,(_spi_data_in)
      
      andi #0b11111001,%d5
      move.b %d5,(%a0)
      rts
    Learning the genesis one bit at a time

  8. #8
    ding-doaw Raging in the Streets tomaitheous's Avatar
    Join Date
    Sep 2007
    Location
    Sonoran Desert
    Age
    36
    Posts
    3,057
    Rep Power
    31

    Default

    Code:
      btst #4,(%a0)
      beq _spi_loop_read_zero
      bset %d4,%d6
      bra _spi_loop_read_done
    _spi_loop_read_zero:
      bclr %d4,%d6
    _spi_loop_read_done:
      dbra %d4,_spi_loop
    Hmm, maybe I'm missing something but I don't see how bclr can effect the dbra instruction logic directly. DBRA specifically does its own compare/flag logic again the operand register after the decrement. And I don't see where D4 is modified by anything else. Do you have interrupts disabled or your interrupt code restoring the registers?

    The only other thing I noticed is that D6 isn't initialized in the code you listed. Though that doesn't effect the DBRA logic.

    Also, what assembler are you using that requires % for registers!? I see you're a C type programmer (the 0x hex notation)? And what device are you communicating with?

    Edit: Maybe you can change the (An) address mode to self incrementing mode. Setup a fake stream of data to emulate that device communication stream, then run the code through a debugger to see what exactly is going on.

  9. #9
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    166
    Rep Power
    3

    Default

    Quote Originally Posted by tomaitheous View Post
    Code:
    ...
    Hmm, maybe I'm missing something but I don't see how bclr can effect the dbra instruction logic directly. DBRA specifically does its own compare/flag logic again the operand register after the decrement. And I don't see where D4 is modified by anything else. Do you have interrupts disabled or your interrupt code restoring the registers?
    The startup code is not my own. I am using devster's RS232 bootloader, with some modifications by me. This is the very first instruction in the source:

    Code:
    * Disable interrupts
      move.w	#0x2700,%sr
    The interupt vectors are very... ehum...special. I have no idea why those numbers are like this.

    Code:
      .org	0x0000
      .long	0x00FFFE00,0x00000200,0x00020008,0x0002000C,0x00020010,0x00020014,0x00020018,0x0002001C
      .long	0x00020020,0x00020024,0x00020028,0x0002002C,0x00020030,0x00020034,0x00020038,0x0002003C
      .long	0x00020040,0x00020044,0x00020048,0x0002004C,0x00020050,0x00020054,0x00020058,0x0002005C
      .long	0x00020060,0x00020064,0x00020068,0x0002006C,0x00020070,0x00020074,0x00020078,0x0002007C
      .long	0x00020080,0x00020084,0x00020088,0x0002008C,0x00020090,0x00020094,0x00020098,0x0002009C
      .long	0x000200A0,0x000200A4,0x000200A8,0x000200AC,0x000200B0,0x000200B4,0x000200B8,0x000200BC
      .long	0x000200C0,0x000200C4,0x000200C8,0x000200CC,0x000200D0,0x000200D4,0x000200D8,0x000200DC
      .long	0x000200E0,0x000200E4,0x000200E8,0x000200EC,0x000200F0,0x000200F4,0x000200F8,0x000200FC
      .ascii	"SEGA GENESIS    "
    Quote Originally Posted by tomaitheous View Post
    ... The only other thing I noticed is that D6 isn't initialized in the code you listed. Though that doesn't effect the DBRA logic.
    I did try it with move.b #0,%d6, but that quit the loop too. As far as i understood the doc's, it should not interfere and work the way i wrote it. All i know fore sure is it does not.

    Quote Originally Posted by tomaitheous View Post
    ... Also, what assembler are you using that requires % for registers!? I see you're a C type programmer (the 0x hex notation)? And what device are you communicating with?
    I am using the GNU AS assembler version 2.15 compiled from source, running on Ubuntu Linux. I want to use C build can not get GCC compiled yet. The % for registers is to indicate it's a register, and not a C variable with the same name. At least thats what i read somewhere. The device i am communicating with is the Microchip MCP23S17 16bit I/O expander. I am using it to control leds right now, total of 16. Needing only 4 wires to control it. (excluding the read pin)

    Quote Originally Posted by tomaitheous View Post
    Edit: Maybe you can change the (An) address mode to self incrementing mode. Setup a fake stream of data to emulate that device communication stream, then run the code through a debugger to see what exactly is going on.
    I think a simulated stream might be difficult, but i can give it a try. A debuger or simulator would be very helpful in seeing what the code does. I did not look for one, but i guess there are not that many for Ubuntu.

    I think i should explain my development "platform", because it might be important. As i said above, i am using Devster's bootloader. I translated it to GNU AS syntax, and modified a few small things. Fixed an annoying bug too. So this bootloader is on my everdrive booting the mega drive. Then with a serial2USB cable and the XMODEM protocol i send the compiled code to the bootloader. This code get's loaded into RAM at 0xFF0000, when XMODEM is complete a jmp (0xFF0000) is executed and the uploaded code is running.

    sorry for the long post
    Learning the genesis one bit at a time

  10. #10
    Wildside Expert m68k's Avatar
    Join Date
    Jan 2010
    Location
    USA
    Posts
    236
    Rep Power
    4

    Default

    Get a 68k Macintosh and install MacsBug (You can still get it as a download from Apple)
    Its a CPU level debugger that allows you to see what the mac is doing in assembler, and allows you to directly instruct the 680xx.

  11. #11
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    166
    Rep Power
    3

    Default

    Quote Originally Posted by m68k View Post
    Get a 68k Macintosh and install MacsBug (You can still get it as a download from Apple)
    Its a CPU level debugger that allows you to see what the mac is doing in assembler, and allows you to directly instruct the 680xx.
    I actually have a Macintosh classic that i think still works. I had it on my desk for about 8 years i think. Just for decoration But i removed it because i needed the space. A better option would be to use the BasiliskII emulator, since i have a 100% silent PC. The mac is quite noisy if i remember correctly.

    I looked up Macsbug, but it needs a powerPC processor to run. That would not work on my old mac.
    Learning the genesis one bit at a time

  12. #12
    Wildside Expert Archer's Avatar
    Join Date
    Jan 2011
    Location
    Netherlands, The Hague
    Posts
    166
    Rep Power
    3

    Default

    I was looking at an online bookstore and found this book An Introduction To 68000 Assembly Language (site is dutch, sorry)

    It only costs 5 euro (about $6,28 US) so i am thinking of buying it, but does anyone know this book already? It's 112 pages, very old though from 1986.
    Learning the genesis one bit at a time

  13. #13
    ding-doaw Raging in the Streets tomaitheous's Avatar
    Join Date
    Sep 2007
    Location
    Sonoran Desert
    Age
    36
    Posts
    3,057
    Rep Power
    31

    Default

    Quote Originally Posted by m68k View Post
    Get a 68k Macintosh and install MacsBug (You can still get it as a download from Apple)
    Its a CPU level debugger that allows you to see what the mac is doing in assembler, and allows you to directly instruct the 680xx.
    That's a bit extreme when there's already 68k emulator/debuggers out there.

    Mednafen was Genesis support. The debugger isn't fully loaded yet, but it has the basic read/write break points (entire address range), allows you to see and scroll the current disassembly window (or directly type in a start point address to view from. Separate from the PC reg value), see all the processor register states (and change them), single instruction stepping, save stating within the debugger, etc. It doesn't per variable watch, but it does have a separate data view window (scrollable or directly type in the address). I'm not sure if VRAM break points are working yet or not. Or if break on opcode # is working yet. It's based on the debugger interface for a few other emulated cores in mednafen (PCE, Wonder Swan, PCFX, NES, etc).

  14. #14
    Nameless One
    Join Date
    Nov 2010
    Posts
    85
    Rep Power
    3

    Default

    Quote Originally Posted by tomaitheous View Post
    That's a bit extreme when there's already 68k emulator/debuggers out there.

    Mednafen was Genesis support. The debugger isn't fully loaded yet, but it has the basic read/write break points (entire address range), allows you to see and scroll the current disassembly window (or directly type in a start point address to view from. Separate from the PC reg value), see all the processor register states (and change them), single instruction stepping, save stating within the debugger, etc. It doesn't per variable watch, but it does have a separate data view window (scrollable or directly type in the address). I'm not sure if VRAM break points are working yet or not. Or if break on opcode # is working yet. It's based on the debugger interface for a few other emulated cores in mednafen (PCE, Wonder Swan, PCFX, NES, etc).
    Good emulator btw. not very well known. usb control pad support lacks a bit though, configuring a sega usb pad never works properly (6 button atleast)

    check out the atari jaguar programming stuff they had a few 68k programming tutorials as that processor is used to set the system and other processors up.
    i seem to recall them having a nice 68k tutorial.

  15. #15
    Wildside Expert
    Join Date
    Dec 2006
    Posts
    178
    Rep Power
    8

    Default

    Quote Originally Posted by tomaitheous View Post
    That's a bit extreme when there's already 68k emulator/debuggers out there.

    Mednafen was Genesis support. The debugger isn't fully loaded yet, but it has the basic read/write break points (entire address range), allows you to see and scroll the current disassembly window (or directly type in a start point address to view from. Separate from the PC reg value), see all the processor register states (and change them), single instruction stepping, save stating within the debugger, etc. It doesn't per variable watch, but it does have a separate data view window (scrollable or directly type in the address). I'm not sure if VRAM break points are working yet or not. Or if break on opcode # is working yet. It's based on the debugger interface for a few other emulated cores in mednafen (PCE, Wonder Swan, PCFX, NES, etc).
    I like how you chose to keep me in the dark about this development.
    Twilight Translations: Japanese Games - Englisherize!
    (Engrish not included.)
    Now with 25% more Blog than the next leading brand!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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