McGill University School of Computer Science



68K Family: 68000, 68020, 68030, 68040

• Two-address machine.

• Starting from 68020, 32 bit address bus and 32 bit data bus.

• Registers:

pc Program counter.

d0 - d7 Data registers.

a0 - a7 Address registers.

fp Frame pointer (a6).

sp Stack pointer (a7).

sr or ps Status register.

• Data and address registers are 32 bit long.

• Data registers can be accessed as byte, word (16 bit) or long (32 bit).

• Address registers can be accessed as word or long.

• Memory is byte addressable.

• Instructions always multiples of words.

Assembling stages.

[pic]

Execution cycle.

[pic]

• Read an instruction from memory at the address stored in instruction counter (IC).

• Decode and execute the instruction.

• Increment instruction counter.

• Repeat.

C program.

#include

int a;

main()

{

a=2+3;

printf(“%d\n”,c);

}

68K Assembly program.

.data

.even

a: .long 0

str: .asciz “%d\n”

.text

.even

.globl _main

_main: movl #2,d0

movl #3,d1

addl d0,d1

movl d1,sp@-

pea str

jbsr _printf

addl #8,sp

rts

Mnemonics: Machine codes (hex):

_main: movl #2,d0 70 02

movl #3,d1 72 03

addl d0,d1 d2 80

movl d1,sp@- 2f 01

pea str 48 79 00 00 40 0c

jbsr _printf 61 ff 04 ff ee 1c

addl #8,sp 50 8f

rts 4e 75

Instruction format.

[label:] [opcode] [operand [,operand]]

e.g.:

_main: movl #2,d0

Some opcodes:

mov Move.

add Add.

sub Subtract.

Some operands:

d0 Data register 0.

a4 Address register 4.

#12 Integer 12.

0x0000ffff Absolute address.

Assembler directives.

.data Indicates the beginning of read/write data segment;

.text Indicates the beginning of read only code segment;

.even Align the following at the even boundary;

.align n Align the following to the boundary of n;

.skip n Advance counter by n bytes;

.globl n Declare a global symbol n.

.byte Reserve a byte;

.word Reserve a word (2 bytes);

.long Reserve a long word (4 bytes);

.ascii Reserve an ASCII string;

.asciz Reserve an \0 terminated ASCII string.

.data

.even

a: .byte 0xf1

.byte 15

b: .word 0xaaff

c: .long 100

.long 0x0000ff00

str: .ascii “Hello world\n\0”

strz: .asciz “Result: %d”

array1: .skip 50

.align 4

array2: .skip 100

.globl array2

Memory.

[pic]

movb 0x00001012,d0

d0 = 0x00 00 00 11

movw 0x00001012,d0

d0 = 0x00 00 11 1f

movl 0x00001012,d0

d0 = 0x11 1f aa ff

Type of long memory access on different architectures.

• 68K MSB first;

• Intel LSB first;

• VAX LSB first;

• IBM 360/370 MSB first.

[pic]

Size of the arguments.

[pic]

andl - long word (32 bits).

andw - word (16 bits).

andb - byte.

movl #0xffffffff,d0

movl #0x000000ff,d1

orb d0,d1

d1?

movl #0x0000ffff,d0

movl #0x000000ff,d1

orw d0,d1

d1?

movl #0x000000ff,d0

movl #0x000000ff,d1

addb d0,d1

d1?

movl #0x000000ff,d0

movl #0x000000ff,d1

addw d0,d1

d1?

An amazing, true story.

memset.o: file format coff-go32 (Intel Assembly !!!, not 68K)

Disassembly of section .text:

00000000 pushl %ebp

00000001 movl %esp,%ebp

00000003 pushl %edi

00000004 movl 0x8(%ebp),%edi

00000007 movl 0xc(%ebp),%eax

0000000a movl 0x10(%ebp),%ecx

0000000d jcxz 00000011

0000000f repz stosb %al,%es:(%edi)

00000011 popl %edi

00000012 movl 0x8(%ebp),%eax

00000015 leave

00000016 ret

68K Instructions.

movS d0,d1 Where S is l,w or b, move contents of

d0 into d1.

nop No operation, do nothing.

exg d0,d1 Exchange contents of d0 and d1.

swap d0 Swap words of d0.

68K Arithmetical instructions.

addS d0,d1 Add d0 to d1 (d1+=d0).

subS d0,d1 Subtract d0 from d1 (d1-=d0).

neg d0 Negate d0 (d0=-d0).

68000 only 16 bit multiplication/division.

68020 and up, also 32 bit multiplication/division.

mulsw d1,d2 Perform signed multiplication of lower

16 bits of d1 and lower 16 bit of d2,

place 32 bit result into d2.

(d2=d2*d1).

muluw d1,d2 Perform unsigned multiplication of

lower 16 bits of d1 and lower 16 bit of

d2, place 32 bit result into d2.

(d2=d2*d1).

mulsl d0,d3:d2 Perform signed multiplication of d0

and d2 and place the 64 bit output into

d3 and d2 (higher bits in d3, lower bits

in d2).

mulul d0,d3:d2 Perform unsigned multiplication of d0

and d2 and place the 64 bit output into d3 and d2 (higher bits in d3, lower bits in d2).

divsw d0,d1 Perform signed division of d1 by d0

and place the result into lower 16 bits

of d1 and the remainder into higher 16

bits of d1. (hi(d1)=d1/d0

,lo(d1)=d1%d0).

divuw d0,d1 Perform unsigned division of d1 by d0

and place the result into lower 16 bits of d1 and the remainder into higher 16 bits of d1. (hi(d1)=d1/d0 ,lo(d1)=d1%d0).

divsl d1,d3:d2 Perform signed division of d3:d2 by

d1. Place the result into d2 and the

remainder into d3.

divul d1,d3:d2 Perform unsigned division of d3:d2 by

d1. Place the result into d2 and the

remainder into d3.

movl #4,d0

movl #5,d1

muluw d0,d1

d1?

movl #0xffff,d0

movl #2,d1

muluw d0,d1

d1?

movl #0xffff,d0

movl #2,d1

mulul d0,d2:d1

d2?

d1?

movl #4,d0

movl #21,d1

divuw d0,d1

d1?

movl #4,d0

movl #21,d1

divul d0,d2:d1

d2?

d1?

68K Bitwise instructions.

andS d0,d1 Computer bitwise and of d0 and d1

place the result into d1. (d1&=d0).

orS d0,d1 Computer bitwise or of d0 and d1

place the result into d1. (d1&=d0).

not d0 Compute bitwise not of d0.

68K Shifting instructions.

aslS #n,d1 Arithmetically shift left d1 by n

(0 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download