24
SL1C COKPOT1TIOI GBOOP Stanford, California CGT" No. 174 flay 1976 MASTER COpy DO NOT REMOVE ;,: ! . MICROCO!PUTER lSSEftBLIBS for the INTEL 8080 and KOTOROLI 6800 Leonard Shustek co.putation Research Group Stanford Linear Accelerator Center P.O. Bo.x 4349 Stanford, California 94305

flay MASTER COpy DO NOT REMOVE - … · MASTER COpy DO NOT REMOVE ;,: ! • . MICROCO!PUTER lSSEftBLIBS for the INTEL 8080 and KOTOROLI 6800 Leonard Shustek co.putation ... ("Progra.aing

Embed Size (px)

Citation preview

SL1C COKPOT1TIOI GBOOP Stanford, California

CGT" No. 174 flay 1976

MASTER COpy DO NOT REMOVE

;,: ! • .

MICROCO!PUTER lSSEftBLIBS

for the

INTEL 8080 and KOTOROLI 6800

Leonard Shustek co.putation Research Group

Stanford Linear Accelerator Center P.O. Bo.x 4349

Stanford, California 94305

ftICROCOMPUT!B ASSE"BLERS

for the

INTEL 8080 and MOTOROLA 6800

The "icroco.puter Lab of the Computation Research Group vas established in 1972 to examine the potential uses for the nevly emerging LSI microprocessor technology. We received the first processor an INTEL 8008 only a few .onths after its announcement when no software vas available from the aanufactnrer. We decided that the quickest way to implement an assembler vas to make use of the powerful .acro lanquaqe available on the IBPl360/91 at SLAC, and siaply write macros for every opcode. When combined with a post-processor to reformat the output, we had a reasonable assembler in less than a week.

The 8008 has been superseded by the aore sophisticated 8080, and our assembler was .odified for the new instruction set. When there vas a need for an assembler for the MOTOROLA 6800 microprocessor. another set of .acros was written and the same post.processor vas used. -

The macro implementation technique allowed us to take a critical look at the ane.onies and operand foraats suggested by the microprocessor aanufacturers and change thea wherever Improweaents could be made. An atteapt was made to include the manufacturer's opcodes andforaats as additions so that proqralls written to those specifications could be asse.bled with few changes. At all times. however, we vere constrained by what could conveniently be parsed and evaluated by the .aero language of the IBM asse.bler.

This document contains independent descriptions of asse.blers for the INTEL 8080 and the !OTOROLA Documentation is also available from the author for the 8008 lssembler.

ACKNOWLEDGEMENTS

the 6800. INTEL

The fticroprocessor Lab. and hence these asse.hlers. owes its existence to the foresight of Harry Saal. John Zolnowsky bas been a .ajor participant and is responsible for parts of the asseablers and luch of the postprocessor.

- 1 -

I""" .

•••• SL1C COMPUTATIOH RES!ARCH GBOUP ••••

••••••••••••••••••••••••••••••••••••••••••••• • • • INTEL 8080 MICROCOMPUTER ASSEMBLER • • • •••••••••••••••••••••••••••••••••••••••••••••

This docuaent aicrocoaputer the 360/370.

describes which is

an asseabler for the INTEL 80aO based on the IBft H-level asseabler for

The language iapie.ented is a minor variation of that described in Intel documentation ("Progra.aing Manual for the 8080 fticrocoaputer Syste.") and available through the MACaO Assaabler. Most of the differences are ainor syntactical changes imposed by the macro language of the IBM asseabler; see 'able II for details.

- 2 -

1. Co •• ent State.ent

Any input card with an asterisk (*) in column 1 is a co •• ent and aay contain any inforaation in coluans 1-11.

2. Source state.ents

'Source state.ents consist of up to four fields: label, opcode, operand, and co •• ent. The first three fields should contain no blanks, and the fields are separated fro. each other by one or aore blanks. Only the opcode field is required; the others are optional.

A) Label

The label field, if present, must begin with a letter in coluan 1 and ear continue for up to 15 aore letters or diqits. If the label field is to be oaitted, coluan 1 must be a blank.

B) Opcode

The opcode is separated froll the label (or coluan 1) by at least one blank. The opcode is required, and may be a .achlne instruction mnemonic or an Asse.bler pseudo-operation.

C) Operands

The operand field is optiortal, and .ay consist of a number of iteas separated by com.a~. There should be no i.bedded blanks. except within quoted strings.

D) Comments

The co •• ent field is optional and may extend out to column 71. If no operand field is required and you wish to include a co •• ent, you must put a single co.ma in the operand field so that the co •• ent vill not b~ mistaken for the operand.

Although free-fora input is allowed, program readability is alaost alvays improved by starting the opcode, operand, and com.ent fields in fixed columns. such as 10 16 36.

- 3 -

The following additions vere .ade to the language as defined by Intel:

1. LOD has been added as a synoa,a for "OY. !oy A,B encourages one to say "mo.e A to Sd, which is the wrong interpretation. LOD A,B encourages "load 1 fro. B", and is therefore less likely to lead to errors.

2. The JMP. CALL, and BET instructions have been generalized to allow an optional first arquaent to specify a conditioD. This allols the short and possibly confusing opcodes like eft to be avoided.

3. Double register pairs can be clearly indicated; one may write Be instead of B when the pair is needad.

".Instructions have been generalized, or general versions introduced, to aini.iz9 the nuaber of special-case opcodesrequired. For e'xaaple, the single opcode INC can be used ta incre.ent both sinqle registers and register pairs. Thus one aay write INC B instead of INB B

and IIC Be instead of INX B

5. I •• ediate-operand ane.onies which are derived fro. the register version by the addition of "I" have been added. Thus further reduces the nn.ber of unique opcodes ,tba t lIust be learned.

6. standard sf.bols for ASCII special characters have been added (e. q. leR for carriage return). See table III.

Althouqh all the opcodes described in Intel docu.ent~tion haye been iaple.ented, the additional features just described allow the selection of a shorter hut still co. plate subset. Tabla I lists the format of a consistent and easier-to-re.ember set of ane.anics which aakes available the entire instruction repertoire of the 8080.

- 4 -

TABLE I - 8080 INSTRUCTIONS

Notation: Upper case letters must be written as shown.

.QJ!£sW!

LOD LOD

LODI tODI LODI

PUSH POP

LD ST LD ST

XCR lea

opr ADD opt! oprI

ROT

IRC DEC

JP!P JRP CALL RET R5T

IN OUT

NOP RLT

STC CMC CMA D1A

II DI

Lover case letters indicate variable fields to be substituted: see the lEY at the end.

(x, y, z) aeans [ J:] aeans

OperanaA!

rrr,rrr SP,Rt

r,data r,addr, «,» rpl,addr

rp2 rp2

l,qaddr A,gaddr RL,addr HL,addr

RL.DE HL, (SP)

r RL,rpl data' addr. «. )') rop( ,n ]

(r , r p 1 ) { , n ] (r, r pi) [ , n ]

[ee, ]addr (RL) (ee, ]addr (cc] II

dey dey

en]

x or y or z x is optional

12!~riRti.2l!

Reqister-to-register loads

Load register fro. iaaediate data

Push onto stack pOinted to by SP Pop fro. stack pointed to by SP

Load 1 fro. me.ory store A into memory Load Rt from .emory store Ht, into me.ory

Exchange HL with DE Exchange Ht with the top-of-stack

' .... register-to-A arithaetic 16-bit addition to HL I •• ediate data to A arith.etic

Accu.lator rotate/shift

Incre.ent register or register pair Deere.ent register or register pair

Jump Juap indirect Call subroutine Return fro. subroutine Restart (CALL 8*., OS.~71

Input to A from I/O device output from A to I/O device

Null operation D ti.es Halt (actually Wait-for-Interrupt)

Set carry bit on Complement carry bit Co.ple.ent 1 Deci.al adjust A

Enable Interrupts Disable Interrupts

- 5 -

rrr one or .ore registers {A,B,C,D,E,H,L,!} LOD B.C .eans "load B fro. e" LOD Bc,Ht is equivalent to LOD a,H then LOD C,L " represents the .emory location pointed to by HL.

r one register (l,B.C,D,E,H.L,ft)

rpl a register pair (BC.DE,HL,SP)

rp2 one or .ore register pairs (BC,DE,RL,AF,PSIJ separated by com. as. (1F =PSW = 1 reg and flaqs) PUSH BC,DE is equiyalent to POSH Be then PUSH DE POP BC,DE is equivalent to POP Be then POP DE

data is an 8-bit constant or expression

addr is a 16-bit constant or expression

«,» is the character < if the high-order 8 bits of the address are to be used, or the character> if the lov-order 8 bit.s of the address are to be used. ftnemonic: view thea as left- or right-pointing arrows.

qaddr a "generalized" address (addr,(BC),(DE),(HL))

opr an arith.etic operation (ADD,lDC,SUB,SBB,ANA,XR1,ORA,CMP)

rop a rot.ate operation (R,L) for 8-bit rotates {RC,LC} for 9-bit rotates

cc a condition code [C,NC,Z,NZ,P,PJ,BS,S,PE,PO,tJ} (S=M=siqn bit on, NS:P=siqn bit off. u=uncondit.ionall~

n a positive inteqer exression or constant indicating how many such instructions should be generated. .

dey . is an 8-bi t I/O device number or expression.

- 6 -

(lab] TITLE • ••• TEXT ••••

var '1ar

op

SPACE n

EJECT

PRINT (OFF ,ON)

EQtJ expr SET expr

OPSYN op

ORG expr

ALIGN n,a{,PILL=exp]

PAGE n[,FILL=exp]

[lab] DB op,op •••

[lab] DW op,op •••

{lab] DS (n]

- 7 -

Title the listing The optional label viiI be used to qualify the nalle of the object file.

Space n lines

Eject to a new page

Stop or restart listing

Define assembly-tiae variable

(re-) def ine opcode

Change location counter

Align the location counter to n bytes past an .-byte boundary.

Adjust the location counter so the following n bytes viiI fit on one page.

The FILL operand for 1L1GB and PAGE specifies the value to be inserted in skipped bytes. If PILL is omitted, skipped bytes are set to HtT instructio"ns (P It L= X' 76 ') •

Define byte constants Each operand can be a constant, expression, or quoted chara~ter string.

Define word constant(s) Each operand can be a constant or an address expression.

Define storage (skip locations without assigning their values). Reserves n bytes of .e.ory (or 1 if n is omitted).

(

••• EXAftPLE PROGBAft •••

What follows is the printer output fro. the asse.bler.

~-~~---~--~---~---------~~--~----~-~~----------~------~--~~~-~---~-------~-------~-----~----------~~-------~--~--~~---~

P1GE 2

Loe OBJECT CODE lDDB1 IDDR2 STftT SOURCE ST1TEIlEWT ASPl H' 05 18.42 05/31/76

1063 • 1. 1064 • rlULTIPLY TWO SIXTER. BIT LOGICAL BURBEIS 2. 1065 • IIPOT: BC=ftOLTIPLICARD,DE=ftULITIPLIER 1. 1066 • OUTPUT: BCzPBODUCT,C1RBY->OYERPLOi 4. 1067 • 5.

000000 E5D5FS 1068 ftULTIPLY PUSH 8L,DE,l" 6. 000003 210000 1070 LODI HL,O INITIALIZE PRODUCT 7. 000006 3E1E 1072 LODI 1,2* (16-1) 8. 000008 15 107. D!C D 9. 000009 14 1076 I tiC D 10. 000001 C21000 1078 JflP IZ.ftOLTILOP 11. OOOOOD 53 1080- LOD D,E SPl1LL IlULTIPLIER, 12. OOOOOE lEOE 1082 LODl 1,2. (8-1) SPEED UP 11. 000010 29 108. rlULTILOP lDD 8L,HL DOUBLE OUTPOT 14. 000011 DC2BOO 1086 C1LL C, PlOL! IOVR IOTE OYERPLOW 15. 000014 ED 1088 XCH RL,DE 16. 000015 29 1090 lDD BL,HL TESt' REXT BIT OP ftULTIPLIER 11. 000016 EB 1092 XCH BL,DE 18. 000017 D21EOO 1094 J!lP RC,ftOLTITI! 19. 000011 09 1096 ADD BL,BC ADD !lULTIPLC1ID 20. 00001B DC2BOO 1098 ClLL C,lIULTIOYR 21. 00001! D602 1100 "OL~ITRft SUSI 2 DECRE"EIT LOOP CODIT 22. 000020 '21000 1102 JIlP IS,!IULTILOP 23. 000023 OP 110. P!UL~IRET ROT R DOlE, SET CARRY POI RETORI CODE 24. 00002' '''''D 11()6 LOD BC,HL POT PRODUCT IM IETUR. REGISTERS 25. 000026 E1 ',08 POP HL 26. 000027 7C 1110 LOD 1,B RESTOBE A REGISTER 27. 000028 D1E1 1112 POP DE,HL 28. 000021 C9 1114 BET U 29.

00002B !'601 1117 !IUtTIO'! OR1I 1 OYER FLOW, TURM ON LOW ORDBa BIT 31. 00002D C9 1119 RET U 32.

1121 BID 33.002

-----~~------------~--~-------~---~~--~~~------~--~~~--~--~-~--~~-~-------~--------------~-------~~----------------~---

The object file for this progra. is:

:1COOOOOOB5D5P52100003E1E1514C21000533EOB29DC2BOOEB29EBD21E0009DC11 : 12001C002BOOD602P210000P44"DE17CD1B1C9'fi01C995 :O()OOOOOOOO

( (

co

ALP~ABE'lIC LIST OP 8080 OPCODIS

8P ADC A BF C"P 1 B7 lOR A 57 LOD D,1 31. LODI A,III 9P SBS I 88 IDC B B8 C!P B BO 101 B 50 LOD D,8 06 LODI B,IIX 98 SBS 8 89 lDC C 89 c!tP C B1 101 C S1 LOD D,C 01 LODI BC,IIX 99 SBB C 8A ADC 0 BA C"P D B2 lOR 0 52 LOD D,D 01 LODI C,XIX 9A SBB D 8B iDC E BB CP.P I 83 YOR E 53 LOD D,E 16 LODI D,III 98 SBS B 8e ADC H BC C"P H B4 YOI 8 S" LOD D,H 11 LODI DE, III 9C saB H 8D ADC L BD C"P L BS 101 L 55 LOD D,L 1£ LODI E,XII 90 sas L 8E IDC " BE C"P ! B6 YOR 8 S6 LOD 0,8 26 LODI 8,XII 98 saB " • * • 5P LOD I,A 21 LODI 8L,III • CE ADCI XXI FE C!PI XIX F6 IORI XII 58 LOD I,B 28 LODI L,XXX DE saBI IIX • * • 59 LOD I,C 36 LODI t!,XXI * 87 ADD A 27 DAI E9 J"P (8L) 51 LOD E,D 31 LODI SP,III 02 ST I, (BC) 80 ADD B * Dl JIIP C,IIX 5B LOD E,E • 12 ST I, (DE, 81 ADD C 3D DEC 1 D2 JltP HC,IIX SC LOD I,H 00 MOP 32 ST A,III 82 ADD D 05 DEC B '2 J"P KS,IXI 5D LOD I,L * 22 ST Ht,lll 83 ADD E OB DEC BC C2 J"P HZ,III 5E LOD E," D3 OUT IXI • 84 ADD R on DEC C !1 JflP PE,XXX 61 LaD ft,l * 37 STC 09 ADD HL,BC 15 DEC D £2 JflP PO,IXI 60 LOD a,B Pl POP AP • 19 ADD RL,DE 1B DEC DE FA JflP 5,111 61 LOD a,e C1 POP BC 97 SUB A 29 ADD RL,8L 1D DEC E C3 J"P U,III 62 LOD H.D 01 POP DE 90 SOB B 39 ADD HL,SP 25 DEC H Cl oJ!!P Z,III 63 LaD a,! E1 POP BL 91 SUB C 85 ADD L 2B DEC Ht • 64 LaD H,H • 92 SUB D 86 ADD " 2D DEC L 01 1.0 A, (BC) 65 LaD .H,t P5 PUSH AP 93 SUB E * 3S J)~c fil 11 tD 1, (DB, 66 LOD H,ft C5 PUSH BC 9" SUB H C6 iDD! XXI 3B DEC SP 3A tD 1,111 6P LaD L.l DS PUSH DE 95 SUB L • • 2A LD HL,II! 68 LOD L,B E5 POSH 8t 96 SUB PI 17 AI'D A F3 DI • 69 LOD L,C • • 0\ AO AMD a PB II 7P LOD 1,1 6A LOD L,O D8 RET C D6 SOB! IIX 11 AID C 76 BLT 78 tOO 1,B 613 LOD L.! DO lET lfC • 12 AMD D • 19 LaD I,C 6(: LOD L,R PO RET 115 E3 ICH BL, (5P) 13 110 E 3C IIC A 1A LOD A,D 6D LOD L.L CO RET NZ EB XCB RL,DE III AlfO H 0" IIC B 7B tOO A,B 61 LOD L,II E8 RET PE * 1S AMD L 03 lie BC 1C tOD A,H 77 LOD ft,l EO RET PO AP XOR A 16 IIiD " OC IIC C 1D LOO l,L 70 LOD fI.B 1'8 RET 5 A8 lOR 8 • '4 IIC D 71 tOO A,8 71 tOO ft,C C9 IP.T U A9 XOl C £6 AMD! XII 13 IHC DE q7 tOO B,I 72 LOD II,D C8 RET Z 11 lOB D • 1C IRC I 110 tOO B,B 73 LOD ft,E • IS loa E DC CAL C.IXI 2" IRe H 41 LaD B,C 74 LOD ft,H 07 lOT L lC lOR H D4 CAL IfC,XII 23 IliC Ht 112 100 B,D 75 LOD 8,L 17 ROT LC AD loa L P4 CAL 115,111 2C IliC L ql LOD B,E r9 LOD SP,BL OF lOT B AE lOR ft C4 CIL IZ,IXI 3' IliC ! q4 LOD B,H * 1P BOT BC * BC CAL PE,IXX 33 IHC SP 45 LOD a,L * BE 10RI IIX B. CAL PO."!XI • .. 6 toO a,s C7 1ST 0 PC CAL S,IIX DB liP IIX liP toO C.l CP 1ST 1 CD CAL U.IXX • "8 LOD C,B D7 RST 2 CC ClL Z.XII 49 tOO C,C DP 1ST 3 • 'I LOD C,O !1 IS~ " 2P eftA '8 LOD e,E EP 1ST S lP esc 4C LOD e.a F7 1ST 6 • liD LOD C.L FP RS'l 1

liE LOD C,"

( ( (

IUftERICAL LIS! OP 8080 OPCODES

00 MOP 20 40 LOD B,B 60 LOD B,B 80 lDD B AO AID B CO BET HZ BO BBT P.o 01 LODl: BC,XXX 21 LODI BL,IIX 41 LOD a,c 61 LOD H,C 81 ADD C l' 110 C Cl POP BC E1 POP HL 02 ST A, (BC) 22 ST HL,IXX 42 LOD B,D E2 LOD B.D 82 100 0 12 lID 0 C2 J!lP HZ ,XIX E2 J"P PO,III 03 INC BC 23 IIiC HL 43 LOD B,E 63 LOD H,E 83 100 E A3 lID E C3 J"P U, XXI £3 XCft 8L, (SP) 04 IIC B 24 IIIC H 44 LOD B,H 64 LOD B,8 84 lDD 8 A_ lID H C" CAL HZ ,XII B4 C1L PO,IIX 05 DEC B 25 DEC H 45 LaD B,L 6S LOD B.L 85 ADD L 15 AID L C5 PUSH BC E5 PUSH HL 06 LODI B,IXI 26 LODI R,IXX 46 LOD B, .. 66 LOD H. ft 86 100 II 16 lID PI C6 1001 IX-X E6 AlfDI XIX 01 RO,. L 27 DAl 41 LaD B,I 67 LOD 8.1 87 lDD 1 11 AID A C7 SST 0 E7 SST 4

08 28 48 LOD C,B 68 LOD L,B 88 lDC B A8 lOB B CS BE! Z B8 BET PE 09 lDD HL,BC 29 IDO Ht,8L 49 LOD C,C 69 LOD L.C S9 ADC C 19 lOR 'C C9 RET U E9 JftP (UL, 01 tD A, (BC) 21 LD 8L,XII 41 LOD C,D 61 LOD L.O SA IDC D Al lOR D Cl JPlP Z, XXX EI JftP PE,IXI OB DEC BC 28 DEC 8L 4B LOD C,E 6B LOD L,E 8B IDC E lB lOR E ca EB Ica RL,DE OC IIC C 2C INC L "C LaD C,8 6C LOD L,8 8C IDC R AC lOR H CC CAL Z, XXX EC C1L PE,III OD DEC e 2D DEC L 4D LOD C,L 6D LOD L,L 80 IDC L AD XOR L CD CIL U. XIX ED OE LODI e,IIX 2£ LODI L,X11 4E LOD C,I! 6E LOD L,P! 8E ADC fI IE XOR " CE lOCI XXX BE 1011 XXX OF BOT R 21' CPlA 41 LOD C,l 6P LOD L,l 8r IDC 1 AF lOR 1 CF 1ST 1 EP SST 5

0 r-l

10 30 50 LOD D,B 70 LOD 11,8 90 SUB B BO lOR B DO RET IC FO BET KS 11 LODI DE,IXI 31 LODI SP,III 51 LOD D,C 11 LOD ft,C 91 soa C B1 lOB C 01 POP DE " POP AP 12 ST A, (DB) 32 ST A,III 52 LOD D.D 72 LOD ft,D 92 SOB 0 B2 lOR 0 02 JftP JC,IIX P2 JRP MS,IXI 13 IIfC DE 33 IIC SP 53 LOD D,E 13 LOD ft,! 93 SOB B 83 lOB E 03 OOT XXI P3 D:I 14 :IRC 0 3_ IIC It 54 LOD D,H 74 LOD !,8 94 SUB 8 B4 lOR H D4 CAL IC, XXI 1'4 CAL NS,IIX 15 DEC D 35 DEC ,. 55 LOD D,L 75 LOD ft,L 95 SOB L B5 lOR L os PUSH DE P5 PUSH IF 16 LOD! D,XXI 36 LODI ft,III 56 LOD 0," 16 HtT 96 SOB II 86 lOR " D6 SUBI IXI 1'6 1011 XIX 17 BOT LC 37 STC 57 10D 0,1 71 LOD PI,A 97 SOB 1 87 lOR A D7 1ST 2 1'7 RST 6

18 38 58 LOD E,B 78 LOD A,B 98 saB B 88 CPlP B De RET C P8 BET S 19 IDD 8L,DE 39 lDD Ht,SP 59 LOD B,C 79 LOD 1,C 99 SBa C Bc) CftP C 09 F9 LOD SP,Rt 11 LD A, (DB' Jl LD A,IIX 51 LOD E,D 71 LOD I,D 91 s8B 0 8A CftP D DA Jftl? C.IXI PI JIIP s,ix! 1B DEC DE 38 DEC SP 5B LOD E,E 1B LOD A,E 98 S8a E BB CltP E DB IMP XXX FB EI 1C IRC B 3C IIC 1 5C too B,B 7C LOD 1,B 9C SB8 B BC CliP H DC CAL C,llt PC CAL S ,lXX', 1D DEC E 3D DEC 1 50 LOD E,L 70 LOD A,L 90 SBB L BD CliP L DD PO 1E LODI E,III 3£ LODI I,XII 51 LOD !,B 71 LOD l,ft 92 SB8 II BE CliP " DE SSBI III 1'1 CftPI III 1P B01' RC 31' CIIC 5P LOD E,I 1¥ LOD A,l 9r SB8 I 81' CPlP I DF RS,. 3 FP SST 7

<. (

i""""" 1. 2.

3. -4.

5.

6.

7. 8.

9.

10. 11.

TABLE II - DIFFERENCES PRO" MACaO

Nuabers in hexadecimal are written X'A2' rather than 12K Nnabers in binary are written B'11001100' rather than 11001100B There are no octal constants. Labels should not be followed by a colon (:) but aay be up to 16 characters long. They .ust begin in col~an 1. Opcodes .ay be used as labels. There should be no blanks in the operand field. Co •• ent fields neea not begin with a se.ieolon (;), and all-eo •• ent cards should begin with an asterisk (*). The functions "OD, NOT, AND, OB, XOR, SHI, and SHL are not available. In instruction in parenthesis is not a legal expression. !acros are defined in a slightly different for.at, but are mnch aore powerful. See an IBft Asse.bler Language .anual. Conditional asseably using IP and ENDl' is done slightly differently. see an IB! lsse.bler Language .anual. Register syabols .ay not be redefinea. SET sy.bols aay not ba redefined: use the IBft asseabler SETA, SETB, or SETC sy.bois'instead.

TABLE III - SPECIAL ASCII SyftBOLS

Q=1 8-15 .l§.=ll 1.!!:ll ---aBut iBS iDLE iCIH iSOR anT iJDC1 lEft is'!'X iLF tlDC2 aSOB IETX iilVT tlDC3 IESC aEOT aFF ~DC4 aps IENO ~CR ilNAK itGS lACK aso iSYN iRS IBEL aSl iETB iUS

111 IDEL

- 11 -

Thefollovinq shows the correspondence between the additional ,"""" instructions of the In tel progra •• ing .annal and those shown

above. Note however, that TABt! I is co.plete in the sense that all valid machine instuctions can be generated using only those instructions.

~ov LOD PlYI LODI lIB INC INX INC OCR DEC Del DEC ADI ADDl ICI IDCI SUI SUBl S8! SBC! All AIDI xaI IRAI OBI OB1I CPI CMPI JC JP!P C, JNC JMP NC, JZ J"P Z, JP J!P P, JPI JMP ft, JP! JPJP PE, JPO JP!P PO, CC CALL C, CNC CALL flC, CZ CALL ~,

CNZ CALL HZ, CP CALL P, CM CALL M, cfE CALL PE, CPO CALL PO, FC RET C RNC RET He RZ RET Z RNZ RET HZ RP RET P ItM RET .. RPE RET PE RPO RET PO LXI 1.0D1 STA ST A, LDA tD A,

- 12 -

XCBG left HL,DE XTHL XCH BL, (SP) SPHL LOD SP,Ht PCRL J"P (Bt) DID ADD HL S'l'IX ST A, tDAXLD 1, SHLD ST 8t, LHLD tD 8L, RLC ROT L RIC ROT R Rlt ~OT LC RAR POT RC

~here 1s a WILBUR exec file available which viII generate all the necesary JCt to use the 80ao assembler. To use it, you should

1) Get the source proqraa in the active file.

2) EXEC FRO" 'ACALL USER MCS GaCUp CG ON CAT This execfile will insert the JCL necessary to run the Isse.bIer at the appropriate points in the actiTe file. It asks so.e questions to which fOU .ay reply "1" to get inforaa tiOD.

The Asse.bler produces a single print output file, which .ay be PETCHed at a WILBUR terminal, or printed. The object file will be sayed on disk SeYEVS under your account, and vill be called "OBJ". If an "ODJ" already exists fro. a previous asse.bIy, it viII be replaced.

Lenny Shustek 8/19/14 1/12/76

- 13 -

·*.* SL1C COMPUTATION RESIARCH GROUP ****

••••••••••••••••••••••••••••••••••••••••••• • • • !OTOIOLI 6800 !ICBOCOPtPO'l'EB ASSEPlBLBR • * • •••••••••••••••••••••••••••••••••••••••••••

This document describes an assembler for the ftotorola "6800 aicrocoaputer which is based on the IBR H-level asse_bIer for the 360/370.

The language iaple.ented is a ainor variation of that described in the ftotorola docu.entation (""6800 Microprocessor Progra •• inq Bannal",. Most of the differences are ainor syntactical changes 1aposea by the .aero lanquaqe of the IBM Asseabler.

In addition to supportinq all the opcode and operand co.binations described by !otorola, certain extensions and additions vere .ade to allow tbe selection of a saaller but still coaplete set of aneaonics.

- 14 -

1. Co •• ent state.ent

Any input card with an asterisk (*) in colnan 1 is a co •• ent and .ay contain any inforaation in columns 1-71.

2. Source state.ents

Source state.ents consist of up to four field: label, opcode, operand, and co •• ent. Each field should contain no blanks, and the fields are separated froll each other by one or aore blanks. Only the opcode field is required; the ethers are optional.

A) Label

The label field, if present, .ust begin with a letter in coln.n 1 and .ay continue for up to 15 aore letters or digits. If the label field is t·o be 0111 tted, c<W.u.n 1 .ust be a blank.

B) Opcode

The opcode is separated froll the label (or coloan 1) by at least one blank. The opcode is required, and .ay be a .achine instruction mne.onic or an Assembler pseudo-operation.

C) Operands

The operand field is optional, and may consist of a nuaber of iteas separated by com.as. There should be no i.bedded blanks, except within quoted strings.

D) Coallents

The co •• ent field is optional and aay extend out to column 71. If no operand field is required and you visll to include a coa.ent, you aus·t put a single co •• a in the operand field so that the co •• ent viII not be mistaken for the operand.

Although free-fora input is allowed, proqraa readability is alaost always improved by starting the opcode, operand, and co •• ent fields in fixed coluans, such as 10 16 36.

- 15 -

Operands aay be constructed (subject to the rules for the particular opcode) in any of the followinq foras:

1. Register indicators

A for accuaulator 1 B for accuaulator B S for the stack pointer p for the "processor" or "PSi"

contains the condition bits X for the index register

2. Constants

32 Deciaal constants X'21' Hexadeci.al constants B'101' Binary constants

3. Sf.bois

register, which

Any symbol which as appeared in the label field of an instruction or pseudo-operation.

4. Location counter reference

An asterisk (.) indicates the current yalue o:f the location counter.

5. Expressions

Any aritbaetic expression built fro. constants. Sf.bols. and • using the standard operators + - * I ( ).

6. Character strings

One or .ore characters enclosed in single quotes like 'A' will be converted to their ASCII value.

- 16 -

7.

8.

ASCII control character sf.bols

The following sf.bols are predefined to haye values corresponaing to the standard ASCII control characters:

aBut iBS IDLE aCAR ~50H aHT IDCl tiE" ~STX iLl' aDe2 aSOB iE'll aVT IDe] lEse .EOT iFF iDell iPS IEIQ iCR ilA(( iGS aACK tbSO ISYH iRS aBEL aSI lETS lOS iDEL

11I.ed1ate addressing operand

1 pound-siqn preceedinq a constant or expression indicates i •• ediate addressing .ode.

ADD A,13 ADD A,'X'PP'

I.aediate operands which are ~ingle ~haracters should be written as character strings, as for exaaple

9. Indexed addressing operand

Indexed addressing is indicated by "(I)", which aar be preceeded with a constant or expression representing the offset.

A"DD A, (X) ADD 1,4(X)

- 17 -

Notation:

Ill)

lrithaetic and

logic

Increaent and

Decreaent

Shifts and Rotates

,,.-,

IuYersions

Set and Clear

Loads

Stores

Branches

Juaps

",-....

X/y or (x,f) aeans "x or 1ft [x] aeans"x is optional" aearef aeans a aeaory reference, either

• a consta.nt, symbol, or expression • an indexed .emory reference

aeans an i.aediate addressing operand

~RI QUlA!ltl~l

ADD/IDe/SOB/SBC (A, B) , (a.aref, i •• ad) AND/BIT/EOR/ORA {A,B},(ae.raf,ia.ed}

CMP (l,B,XJ,(a.aref,i ••• d) TST (A, B ,Ile.ref)

IRC/DEC (A,B,S, X, aearef)

l8L/ISB/LSL/LSB {A, B, aearef} BOLIBOR (A,B, me.ref)

COli/NEG (1,8,aearef)

CLRISET (C,I, V) eLR me.ref

LOD (A,B,S,X},raearef,i •• ed} LOD A, B or B,A LOD S,X or X,S Lon A,P or P,A

STO (A, B, 5, Xl ,ae.ref

BRA mea ref BRA {HI,LS,NE,EO,PL,HI,GE},ae.ref BRA (LT,GT,LE,CC,CS,YC,Ys},aearef BSR lelref

JMP ae.ref JSR me.ref

- 18 -

B1scellaneous PSH/PUL (A,8)

DAI

HOP {expr]

BTl

RTS

SiI

III

lotes:

• The interpretation for LOD is the .ne.onic one; e.q. "LOD 1,S" aeans "LOAD I PROft B" •

• LSL is equiyalent to 1St

- 19 -

1. ORG

2. EOU

3. PCB

4. PDB

5. FCC

6. RltB

Assign prograa count~r The operand is the address (constant or expression) at which subsequent state.ents are to be aaseabled. I label is optional.

Define a sy.bol The operand .ay be any constant or expression; the label is defined and set to the value of the operand.

Fora constant byte There a.y be one or aore operaDds, separated by coaaas. Each operand defines a single byte whose value is the value of the operand. The operands aay be constants, expressions. or single quote4 characters. Skipped operands are ssu.ed to be zero.

Fora double constant byte There aay be one or .ore co •• as. Each operand define t.vo b

ds, separated by teB whose value is

operands •• y be ed operands are

the value of the operand. constants or expressions. assuaed to be zero.

Fora constant characters The operand aay be a single defines a constant as long operands in the fora n,string of bytes to reserve.

qUO~ed strinq, which as the strinq, or tvo wh re n is the number

Reserye me.ory bytes The single operand is a constant o~ expression which indicates how .any bytes to reserye.

7. EJECT Skip to the top of the next page

8. SPACE Skip a line in the listing, or skip as .any lines as indicated in the operand.

9. TITLE Title each page of the asseably li_ting. The single operand should be a quoted string.

- 20 -

This q1 ves the corr upon dance between the add! tiona 1. instructions of the ftotorola proqra •• inq .anual and those shown aboY.. Note however, that the above opcode list is co.plete in the sense that all yalid a.chine instuctions can be generated lIithit.

IBI ADD A,B SBA SUB A,B CBA CftP A,8 CPX CftP X LOS LOD S LDX LOD X LOA LOD {A,B} TAB LOO 8,1 TBA LOD A,B TSX LOD X,S TIS LOD S,X TAP LOD P,A TPA LOD A,P IRS INC S III IIC X DES DBC S DEI DEC X STS STO S STI STO X STi STO (l,B) CLC CLR C CtI CLR I CLl etB V SEC SET C SEl SET I SEV Sft V Bxx BRA xx

- 21 -

.-

,......,

••• !llllPLE PBOGllll ••• What follows is the printer output fro. the asse.bIer.

-- ... -~ .... -.. -~-- ..... -.. -.... -.--------.. ---... -.. -... -.-----.----------.. -....... -------_ ... ----_ ...... -*.. !tOTO ROLl 6800 MICBOCO!lPO!!5 ASS III Bt II •••

LOC OBJECT COD! ADD!1 ADD!2 S'1' PIT SOORC! ST1T!!EM'1'~

1124 • 1125 • THIS IS THE EXA!PLE PIOG 1126 • ~BH 10'1'010LI 86800 PIOGR 1127 • THE FE_EST POSSIBLE CHAB 1128 * 1129 • REEBTBAMT ftULTIPLICATIOI 1130 • MULTIPLIES '1'10 8 BIT OISIGIED 1131 • 1 16 BIT URSIGHED PRODOCT 1132 • 1 • B == 1,B 1133 •

000000 36 1134 "PY8 PSH 1 !lOLT 000001 8608 1136 LDA 1.'8 000003 36 1138 PSH 1 0000011 30 1140 TSI • (I) 000005 qp 1142 eLR 1 000006 56 114" ROI B 000007 2402 11_6 PI] Bec "4 DO • 000009 lB01 1148 lDD A, 1 (X) ADD 000008 "6 1150 !!4 ROR A OOOOOC S6 1152 ROR B OOOOOD 6100 1154 DEC o (X) DECa OOOOOP 26F6 1156 BH! "3 000011 31 1158 INS • BEST 000012 31 1160 IllS 000013 39 1162 RTS • 508R

000014 00100 1165 ORG X'100' 000100 8E0121 1167 TEST LDS 'STICK liS 000103 '8601 1169 LDA 1.110 000105 C614 1171 LDA B,'20 000107 SDOOOO 1173 JSI "PI8 CALL 000101 7E0101 1175 JftP • 00010D 1178 RftB 20 TEftP 000121 1180 STACK 1MB 1 STAll

1182 END

---------~---------------------------------------------------------------The object file for this progra. is:

S111000036860836304P562Q02AB014656610026P631J13987 S1130'008E01218601C61~BD00001E010A8B

- 22 -

There 1s a WYLBUB execfile which will generate the JCL necessary to run the 6800 lsse.bler. To use it:

1) Get the source prograa 1n the active file.

2) EXEC PRO! .lSR6800 USER "CS GROUP CG ON CAT This execfile vill insert the Jct necessary to run the lsse.bler at the appropriate points in the active file. It asks 50ae questions to which you aay reply "1" to qet infora.tion.

The lsse.bIer produces a single print output file. which •• y beP!'rCHed at a WILBOR ter.inal, or printed. tfhe object file vill be saved on disk SerEV5 under your account. and v111 be called "OBJ". If an "OBJ" already exists fro •• previous ass~.bl" it vl11 be replaced.

L. SHOSTEK 3 JAR 15

12 JAN 75

- 23 -