💾 Archived View for spam.works › mirrors › textfiles › apple › assembler.txt captured on 2023-06-14 at 15:44:09.
View Raw
More Information
-=-=-=-=-=-=-
- *****************************************************************************
- *** THE BEST APPLE'S ASSEMBLY TUTORIAL ****
- *****************************************************************************
- *** PART 1: THE ASSEMBLER ****
- *****************************************************************************
- *** WRITTEN BY THE BEST APPLE AND EDITED BY NOWHERE MAN ****
- *****************************************************************************
THIS SERIES IS FOR BEGINNERS. YOU WILL NEED AN ASSEMBLER AND A THOROUGH KNOWLEDGE OF APPLESOFT BASIC.
PREFACE:
ASSEMBLY LANGUAGE IS THE FASTEST AND MOST FLEXIBLE OF ALL PROGRAMMING LANGUAGES ON ANY COMPUTER, BECAUSE YOU ARE ACTUALLY TELLING THE COMPUTER WHAT TO DO DIRECTLY, WITHOUT A LOT OF "MIDDLEMEN" LIKE THE APPLESOFT BASIC INTERPRETER. ALSO FOR THIS REASON, ASSEMBLY IS A VERY HARD LANGUAGE TO LEARN. I HOPE THIS TUTORIAL WILL MAKE THE JOB A BIT EASIER.
- ******************************************************************************
THE ASSEMBLER:
THIS TUTORIAL WILL CENTER MAINLY ON THE S-C MACRO ASSEMBLER, BUT IF YOU HAVE A DIFFERENT BRAND (MERLIN/BIG MAC, ORCA/M, LISA, ETC.) YOU SHOULD BE ABLE TO FOLLOW ALONG. IT HELPS IF YOU HAVE A MANUAL SO YOU CAN SEE IF THERE ARE ANY DIFFERENCES IN YOUR ASSEMBLER AND THE ONE I USE.
MOST ASSEMBLERS HAVE TWO PARTS I WILL DISCUSS EACH AND THE MAKEUP IN THIS ARTICLE.
PART 1: THE EDITOR
THE EDITOR IS USALLY A TEXT EDITOR FOR CREATING YOUR PROGRAMS IT WILL HAVE FEATURES FOR EDIT, DELETE, INSERT AND IF IT'S GOOD MUCH MORE.
PART 2: THE ASSEMBLER
THIS PART ASSEMBLES THE TEXT INTO MACHINE LANGUAGE CODE.
- *******************************************************************************
THE VARIABLES:
JUST AS IN APPLESOFT, ASSEMBLY LANGUAGE HAS VARIABLES. BUT, WHERE IN BASIC YOU HAD THOUSANDS TO PLAY AROUND WITH, HERE YOU ONLY HAVE A FEW AND YOU ARE RESTRICTED IN THEIR USES. WHAT FOLLOWS IS A DESCRIPTION OF EACH VARIABLE AND IT'S FUNCTION.
THE 6502 HAS 5 REGISTERS, WHICH ARE USED SIMILARLY TO VARIABLES IN HIGHER LEVEL PROGRAMMING LANGUAGES.
1. THE ACCUMULATOR ("A-REGISTER")- IS THE MAIN VARIABLE FOR GENERAL FUNCTIONS.
2. THE X REGISTER- USED FOR COUNTING
3. THE Y REGISTER- USED FOR COUNTING
4. THE STACK ("S-REGISTER")- CONTAINS THE STACK POINTERS FOR APPLESOFT AND ASSEMBLY LANGUAGE PROGRAMS
5. THE P REGISTER- KEEPS TRACK OF THE SYSTEM STATUS. IT IS DIVIDED INTO BITS, LIKE THIS:
7 6 5 4 3 2 1 0 >
^ ^ ^ ^ ^ ^ ^ ^ > ALL OF THIS
> IS CONTAINED IN
> THE "P-REGISTER"
N V * B D I Z C >
N. THE NEGITIVE BIT-0 IF THE LAST COMPARE WAS + 1 IF IT WAS -
V. THE OVERFLOW BIT-0 IF THE LAST RESULT DID NOT OVERFLOW
B. BREAK STATUS-1 AFTER A BRK COMMAND
D. DECIMAL MODE-0 AFTER CLD COMMAND 1 AFTER SED
I. INTERRUPT-0 AFTER CLI 1 AFTER SEI
Z. ZERO-0 IF LAST RESULT WAS NON-ZERO 1 IF IT WAS 0
C. CARRY-0 IF THE LAST RESULT DID NOT CARRY OR A CLC AND 0 AFTER A CARRY OR SEC
IF THIS ALL SOUNDS CONFUSING, YOU'RE ABSOLUTELY RIGHT. THIS WILL BE EXPLAINED MORE THOROUGHLY IN A LATER CHAPTER OF TUTORIAL
- *****************************************************************************
THE LINE:
THE LINE IN ASSEMBLY HAS 5 PARTS:
1. THE LINE NUMBER, THIS IS FOR EDITING PURPOSES ONLY AND YOU CAN'T GOTO A LINE BY LINE NUMBER.
2. THE LABEL, THIS IS FOR BRANCHING YOU CAN IN SENSE GOTO A LINE BY IT'S LABEL.
3. INSTRUCTIONS THESE ARE THE COMMANDS AND THERE ARE 56 OF THEM DEVIDED INTO 10 GROUPS:
1. TRANSFER:LDA, STA, LDX, STX, LDY, STY, TXA, TAX, TYA, TAY, TXS, TSX
PLA, PHA, PLP, PHP
2. ARITHMETIC:ADC, SBC, INC, INX, INY, DEC, DEX, DEY
3. LOGICAL:AND, ORA, EOR, BIT
4. SHIFT:ASL, LSR, ROL, ROR
5. COMPARE:CMP, CPX, CPY
6. STATUS:SEC, SED, SEI, CLC, CLV,, CLD, CLI
7. BRANCH:BCC, BVC, BNE, BPL, BCS, BVS, BEQ, BMI
8. JUMP:JMP, JSR
9. RETURN:RTS, RTI
10. OTHER:NOP, BRK
YES, YOU MAY HAVE NOTICED THEY ARE ALL 3 LETTERS. THERE ARE ALSO ASSEMBLER COMMANDS THAT ARE DIFFERENT FOR EACH ASSEMBLER. NEXT WEEK I'LL LIST AND EXPLAIN THESE AND THE ASSEMBLER COMMANDS FOR S-C MACRO ASSEMBLER.
4. THE OPCODE: IS THE NUMBER USALLY FOUND AFTER THE COMMAND THERE ARE 4 TYPES:
1. $00-MEANS WHATS IN THE LOCATION $00
2. #00-MEANS THE DECIMAL NUMBER 0
3. #$00-MEANS THE HEX NUMBER $00
4. $300,Y-MEANS THE VALUE OF THE ADDRESS $300+Y SO $300,Y WHEN Y=2 IS $302'S VALUE
5. THE REM FIELD FOR REMARKS
GET THE IDEA? IT'S EASY!
NEXT TIME: THE COMMANDS
- *****************************************************************************
CREATED AND WRITTEN BY:
THE BBB
B B
BBB
B B
BBB EST APPLE
(OF SADISTIC SOFTWARE AND THE BLACK HOLE BANDITS)
EDITED BY:
// /
/ / /
/ / /
/ // OWHERE MAN
(OF SADISTIC SOFTWARE AND THE BLACK HOLE BANDITS)
- *****************************************************************************
ORIGINALLY WRITTEN IN 80 COLUMNS, UPPER CASE ONLY, ON TUESDAY NOVEMBER 20 1984
THIS MAY BE DISTRIBUTED AND POSTED ON BBS'S *AS LONG AS IT IS NOT CHANGED*
- ******************************************************************************