tutorial lab 1 s2010
TRANSCRIPT
-
8/8/2019 Tutorial Lab 1 S2010
1/23
E&CE 222
Lab Tutorial 1Hand Assembling
Prepared by: Peter Tysowski, T.A.E-mail: [email protected]
May 18, 2010
Spring 2010 term
1
-
8/8/2019 Tutorial Lab 1 S2010
2/23
Lab 1 Tutorial Outline
Objectives of Lab 1 Program Operation and Loading Explanation of I/O Subroutines Modifying the Code Hand Assembling Operation Post Lab Subroutines Deliverables and Marking Scheme
2
-
8/8/2019 Tutorial Lab 1 S2010
3/23
Objectives of Lab 1
Familiarize yourself with hand assembly ofMotorola 68000 instructions (ISA_A)
Familiarize with simple instructionse.g. and, bsr, cmp, jmp, jsr, lea, move, rts, suba, trap
Use different Effective Addressing modesAbsolute, Immediate, Register Direct, Register Indirect
Perform offset calculationse.g. beq, bne, bra
3
-
8/8/2019 Tutorial Lab 1 S2010
4/23
Objectives of Lab 1
Use common assembler directives e.g. equ, org, dc
Handle monitor operationsTrap #15 vectors
Familiarize with input/output operations
4
-
8/8/2019 Tutorial Lab 1 S2010
5/23
Program Operation
Print message asking for inputCall Read String subroutine
Read input characters into bufferAllocate a second bufferReverse the string into the second buffer
Call Output String subroutineExit to the Monitor
5
-
8/8/2019 Tutorial Lab 1 S2010
6/23
I/O Subroutines
Out-CharacterStore parameter D0 on the stackOutput the register D1 (in ASCII)
Restore D0 from the stack
In-CharacterStore parameter D0 on the stack
Capture the input into D1 (in ASCII)Select the first byteDisplay the characterRestore D0 from the stack 6
-
8/8/2019 Tutorial Lab 1 S2010
7/23
Modify the Program
lea BUFFER,A1 ;point to start of bufferbsr.w in_string ;read string andbsr.w out_crlf ;go to next line
* Scan for end of string.
move.l #BUFFER,A0 ;point to start of buffer
bloop1 tst.b (A0)+ ;see if we found the NULL yet.
bne bloop1 ;nope, keep loopingsuba.l #1,A0 ;ignore the NULL
movea.l #BUFFER+1024,A2 ;set up another buffer for result
Insert the necessary instructionshere - approximately 5 lines.
bsr.w out_string ;print the stringbsr.w out_crlf ;and go to new line
* Exitmove.l #$0000,d0TRAP #15
end ;optional, marking end of assembly
Handassemble
7
-
8/8/2019 Tutorial Lab 1 S2010
8/23
Program Operation
Reverse string orderDetermines end of the stringDefines new bufferStores the reversed string in new bufferDisplays the reversed string
Buffer
Buffer + 1024
L
A
B
1
NULL
1
B
A1
A0
A2
8
-
8/8/2019 Tutorial Lab 1 S2010
9/23
Program Loading
Using Motorola S-record FormatProduced by assemblers and compilers
Encapsulates opcodes with addresses and checksums
Using Text File (for Lab 1)Load the program through the terminal using text files
(OPCODES.txt)
9
-
8/8/2019 Tutorial Lab 1 S2010
10/23
OPCODES.TXT
mm 10210000546869732070726f6772616d2077
696c6c207072696e74206f7574206120737472696e6720696e2074686520
etc
10
-
8/8/2019 Tutorial Lab 1 S2010
11/23
Hand Assembling of Move
Move.L #100,D2 0 0 1 0 0 1 0 0 0 0 1 1 1 1 0 0
Size Field 00 Byte Operation 01 Word Operation 10 Long Word Operation 11 Reserved
11
-
8/8/2019 Tutorial Lab 1 S2010
12/23
Hand Assembling (Move)
Translate: Move.L #100,D2
0010 0100 0011 1100 0000 0064 2 4 3 C 0000 0064Enter code:
mm.w10200000
243c064 12
-
8/8/2019 Tutorial Lab 1 S2010
13/23
During Your Lab
Download the codes to the board Manually add on the rest of the program
Enter your hand-assembled program(including the new instructions required to complete it)
Run the program Debugging techniques: breakpoint, trace, disassemble
Test the program Print out the reverse of the input string
Finish assembly and test before demo day13
-
8/8/2019 Tutorial Lab 1 S2010
14/23
Post Lab Subroutines
DEC2BINConverts a decimal ASCII string to a binary numberReads null-terminated string from A1 (doesnt modify A1)Converts ASCII bytes to decimal using Horners equation
Decimal: 3210 = (((3) * 10 + 2) * 10 + 1) * 10 + 0Store result in D1Write as subroutine (save registers to stack, use rts)Hint: use a loop, multiply instruction, and accumulatorHint: use data registers to hold temporary valuesNo error checking on input required 14
-
8/8/2019 Tutorial Lab 1 S2010
15/23
Post Lab Subroutines
BIN2DECConverts binary number to decimal ASCII stringReads word-sized binary number from D1 (doesnt modify it)Writes null-terminated string at location in A2Horners equation requires a divide subroutine
Hex: 3210 = (((3) * A + 2) * A + 1) * A + 0Size is 16-bit positive number (one word)No error checking on input requiredHint: use division and remainder instructions in loop 1Hint: output the decimal string then reverse it in loop 2 15
-
8/8/2019 Tutorial Lab 1 S2010
16/23
Post Lab Subroutines
Decimal ASCII String Binary Number(stored in Big Endian)
6980 0x36
0x39
0x38
0x30
0x1B44
or0 to 65535
16 bit positive number ranges from 0x0000 to 0xFFFF
16
-
8/8/2019 Tutorial Lab 1 S2010
17/23
Deliverables
The Grade FormAccess from ACE and print it for the lab
Code for string-reverse program Full machine code listing (original program + additions) Lines added in assembly code, with comments
Post-lab: DEC2BIN and BIN2DEC subroutines In assembly language, with comments No hand assembly required
17
-
8/8/2019 Tutorial Lab 1 S2010
18/23
Marking Scheme
LAB demo3 marks Lab completion (program must work 100%)2 marks Questions answered during lab demo
Individual mark May be asked about the program and/or asked to hand assemble
Post lab2 marks per subroutine (DEC2BIN & BIN2DEC)
Final Reports due 48 hours after demo, on ACE20% late penalty per day
18
-
8/8/2019 Tutorial Lab 1 S2010
19/23
Marking Scheme
19
-
8/8/2019 Tutorial Lab 1 S2010
20/23
20
-
8/8/2019 Tutorial Lab 1 S2010
21/23
21
-
8/8/2019 Tutorial Lab 1 S2010
22/23
22
-
8/8/2019 Tutorial Lab 1 S2010
23/23
23