70 likes | 226 Views
Practical exercises 5JJ20/2M200: Introduction to the assembler. Dr.ir. Ad Verschueren. Texteditor: wordpad /. Program: XYZ.ASM. Assembler: asm504. Simulator: dScope. Debugger: tScope. Listing: XYZ.LST. Executable: XYZ.HEX. Programmer: Flash tools. Programs and files. With error messages.
E N D
Practical exercises 5JJ20/2M200:Introduction to the assembler Dr.ir. Ad Verschueren
Texteditor:wordpad/... Program:XYZ.ASM Assembler:asm504 Simulator:dScope Debugger:tScope Listing:XYZ.LST Executable:XYZ.HEX Programmer:Flash tools Programs and files With error messages
The assembler • Translate readable instructions to machine code • One processor instruction on one text line • Keep track of addresses with ‘location counter’ • Updated with number of bytes in each instruction • ‘Labels’ assign names to address at start of text line • ‘Pseudo-instructions’ for assembler itself • Reserve memory space, place constants in memory • Assign readable names to constant values • Listing control, conditional assembly, ……...
Tab Translating normal instructions • Use standard instruction names and formats • Label names for JUMP/CALL and direct addresses • Do not forget ‘#’ for constant values • May use calculations for addresses or constants MOV A,#23 + 2 ;load A with constantLoop: DEC A ;A <= A - 1 JNZ Loop ;IF A not 0, GOTO Loop Label Parameter(s) Instruction name Comments after ;
Addressing with the location counter • Keeps track of instruction/data placement • Assembler keeps only one location counter! • Updated by instruction/constant/storage space size • Forced to specific value with ‘ORG’ (ORiGin) • Shown in listing Data memory XXXX0030003100000003 ORG 0030h ;set location to 48Data: DS 1 ;Define Storage, 1 byte ORG 0000h ;set location to 0Strt: MOV Data,#23 ;’Data’ <= 23 SJMP Strt ;keep doing this Program memory
Assembler pseudo-instructions • See assembler documentation! • TITLE, TABS, WIDTH etc. to get nice listing • EQU (EQUals) to name a constant value • DB/DW Define Byte/Word constants (program memory) • END to signal ‘end of text’, is NOT ‘end of program’ TABS 6 ;’Wordpad’ standardLucky EQU 111b ;define named constant MOV A,#Lucky ;register A <= 7 DB ‘Luck’,0 ;define FIVE bytes END ;assembler stops here
The first session’s assignments • Perform ‘getting started’ part of manual • Installation and test of all programs needed here • Setting up connection to practicumprocessor board • Using a given example program • Do NOT use ‘Flash tools’ • Example ‘program’ in assignments document • Demonstrates common assembler ‘constructs’ • Read, discuss and (try to) understand...