The 68000 has two modes of operation - supervisor and user mode. In supervisor mode additional priviledged instructions are available. Usually system software runs in supervisor mode while user programs run in user mode.
The 68000 provides eight 32 bit general purpose data registers(D0-D7) and 9 address registers. Only seven of these are general purpose(A0-A6) with the others being used for stack pointers. Special instructions are required to move addresses into and out of address registers. The status register, shown below, contains flags(like zero, negative, etc.) as well as the "interrupt immunity level" the machine is currently running at(specified by bits I0-I2).
STATUS REGISTER
Mode Generation Notes Register Direct Addressing Data EA=Dn EA=An EA=Effective Address Register Direct Address Dn=Data Register Register Direct An=Address Register Absolute Data Addressing EA=(Next Word) ()=contents of Absolute short Absolute long EA=(Next two PC=program counter d8=8 Words) bit offset Program Counter Relative EA=(PC)+d16 d16=16-bit offset N=1 Addressing Relative with offset EA=(PC)+d8 for byte, 2 for word, Relative with Index and Offset and 4 for long words. If An is the stack pointer and the operand size is byte, N=2 to keep the stack pointer on an even boundary. Register Indirect Addressing EA=(An) <- replaces Xn= Address Register indirect Postincrement EA=(An),An<-[[Alph or Data register used as Register Indirect Predecrement a]]n+N index register SR=Status Register Indirect Register An<-[[Alpha]]n-N,E register USP=user stack Indirect with offset Indexed A=(An) pointer SSP=supervisor Register Indirect with offset EA=(An)+d16 stack pointer EA=(An)+(Xn)+d8 Immediate Data Addressing DATA=Next Immediate Quick Immediate Word(s) Inherent Data Implied Addressing Implied EA=SR,USP,SSP,PC Register
Instr Description Instr Description ABCD Add decimal with extend MOVE Move source to destination ADD Add MULS Signed multiply AND Logical AND MULU Unsigned multiply ASL Arithmetic shift left NBCD Negate Decimal with Extend ASR Arithmetic shift right NEG Negate Bcc Branch conditionally NOP No operation BCHG Bit test and change NOT Ones complement BCLR Bit test and clear OR Logical OR BRA Branch always PEA Push effective address on stack BSET Bit test and set RESET Reset External devices BSR Branch to subroutine ROL Rotate left without extend BTST Bit test ROR Rotate right without extend CHK Check register against bounds ROXL Rotate left with extend CLR Clear operand ROXR Rotate right with extend CMP Compare RTD Return and deallocate DBcc Decrement and branch RTE Return from exception conditionally DIVS Signed divide RTR Return and restore DIVU Unsigned divide RTS Return from subroutine EOR Exclusive OR SBCD Subtract decimal with extend EXG Exchange registers Scc Set conditional EXT Sign extend STOP Stop JMP Jump SUB Subtract JSR Jump to subroutine SWAP Swap data register halves LEA Load Effective Address TAS Test and set operand LINK Link stack TRAP Trap LSL Logical shift left TRAPV Trap on overflow LSR Logical shift right TST Test UNLK Unlink stack
68000 assembly code bears a strong resemblance to Macro-11 code. The general form of an instruction is
Operation.size Source,Destination
For example:
ADD.W D1,D2 ;ADD LOWER WORD OF D1 TO D2
SUB.B #5,(A1) ;SUBTRACT 5 FROM BYTE AT
;LOCATION IN A1
The size extension can be either B for byte, W for word, or L for long(32 bits). If you were to look at a 68000 program it would likely look like a Macro-11 program except for the size extensions. The 68000 uses the same conventions for the basic addressing modes and has very similar names for operations. The addition of address registers causes most of the differences in operation names. Address registers must be used to refer to memory locations(ie. (D0) is not valid) and special instructions must be used to "load" the address registers. The MOVEA(move address operation) is used most commonly to load address registers. For example, to load the address of a buffer at label BUFF into A1 the instruction MOVEA #BUFF,A1 would be used.
Connect the ribbon cable from port1 to the RS232 port on the terminal and the ribbon cable from port2 to a data switch line. After you turn the terminal on the prompt "TUTOR 1.3>" should appear(press return if it does not). This prompt is for the monitor program included in ROM on the ECB board. It is very similar to ODT on the LSI-11 computers. If at any time your program gets in an infinite loop you can press the red button on the ECB to interrupt the program and return to the TUTOR prompt. If the machine is hung then it can be reset by pressing the black button. This resets the computer and clears memory.
Normally programs would not be assembled on the board because the one line assembler provided by TUTOR is very limiting. Instead one can enter the code into a file on Hercules, the CS department's MIPS computer running UNIX(TM), and use the 68000 cross assembler on that machine. After the program is assembled it can be downloaded to the ECB.
To connect to Hercules issue the TM command at the TUTOR prompt. This will connect you to the data switch. To return to the ECB type control-a at any point. Once you are logged into Hercules enter your program using vi(use a .s extension). To assemble the program enter:
asm -l -c filename.s
Once the program is assembled with no errors return to the ECB by typing control-a. To download and run your program from Hercules to the ECB type:
TUTOR 1.3>LO2=getcode filename.o
.
.
TUTOR 1.3>GO 1000
Below is an example program which illustrates 68000 assembly language. To cleanly exit your program back to TUTOR the two lines following the EXIT: label are required.
;***
;* Given an ASCII hexidecimal digit convert it to an integer.
;* For example if B(ASCII 66) is passed 11 will be returned.
;* The digit is passed and returned in data register D0
;***
GETHEX: CMP.B #$30,D0 ;IF HEX DIGIT<0
BLT.S ERROR ; GOTO ERROR ROUTINE
CMP.B #$39,D0 ;IF HEX NO.>9
BGT.S GTHX2 GOTO ROUTINE TO HANDLE A-F
;
GTHX1: AND.L #$F,D0 ;SAVE ONLY LOWER 4 BITS
EXIT: MOVE.B #228,D7 ;THESE TWO LINES EXIT TO THE
TRAP #14 ;;TUTOR PROGRAM
;
GTHX2: CMP.B #$41,D0 ;IF HEX NO.<A
BLT.S ERROR ; GOTO ERROR ROUTINE
CMP.B #$46,D0 ;IF HEX NO.>F
BGT.S ERROR ; GOTO ERROR ROUTINE
SUB.B #37,D0 ;CONVERT A TO 10 ETC.
BRA GTHX1 ;GOTO EXIT CODE
;
ERROR: MOVE.L #$FF,D0 ;RETURN ERROR CODE OF FF
JMP EXIT
END
A pinout of the 68000 and a table of the symbols used in the read/write timing diagrams are shown below:
READ WORD CYCLE
Write Word Timing
In the above diagrams it should be noted that the 68000 does its reads and writes asynchronously. Before the read or write cycle can finish the I/O device being accessed must assert xto(DTACK) indicating it has completed its portion of the operation. The 68000 repeatedly executes "wait states" until xto(DTACK) is asserted. This allows devices of varying speeds to be easily interfaced to the 68000.