270 likes | 379 Views
ME 4447/6405. Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume Lecture #10. ASCII Character Codes. ASCII – A merican S tandard C ode for I nformation I nterchange
E N D
ME 4447/6405 Microprocessor Control of Manufacturing Systems and Introduction to Mechatronics Instructor: Professor Charles Ume Lecture #10
ASCII – American Standard Code for Information Interchange ASCII assigns a hexadecimal ‘code’ to individual characters Examples: Character ASCII ‘A $41 ‘E $45 ‘e $65 (Note: Different codes for lower and upper case) ‘1 $31 BS $08 (Note: BS is Backspace. ) A microcontroller must send these codes to a display terminal in order for the terminal to display these characters. ASCII Character Codes
ASCII Character Codes (continued) • Hex to ASCII Conversion table from Programming Reference Guide Page 58
An array of characters is called a string Example: character array String ASCII Representation ‘H ‘e ‘l ‘l ‘o “Hello” $48 $65 $6C $6C $6F ASCII Character Codes Note: Character ASCII ‘H $48 ‘e $65 ‘l $6C ‘o $6F
Assembly Control ORG, END Symbol Definition EQU Data Definition/Storage Allocation FCC, FCB, FDB, RMB, ZMB, BSZ, FILL Listing Control PAGE, OPT Assembly Directive Types
ORG : Stores translated machine language instructions in sequence starting at given address for any mnemonic instructions that follow END: Stop translating mnemonics instructions until another ORG is encountered (Note: These were already discussed in Lecture 7) ORG and END
EQU EQU lets you refer to a number or an address as a variable name. Example: VALA EQU $10 *LABEL VALA USED TO REFER TO $10 ORG $1000 LDAA #VALA *LOAD HEX NUMBER $10 IN ACCUMULATOR A LDAB VALA *LOAD CONTENT OF MEMORY LOCATION $10 *IN ACC. B SWI END Same As: VALA EQU $10 *LABEL VALA USED TO REFER TO $10 ORG $1000 LDAA #$10 *LOAD HEX NUMBER $10 IN ACCUMULATOR A LDAB $10 *LOAD CONTENT OF MEMORY *LOCATION $10 IN ACC. B SWI END
FCC FCC – Form Constant Character string FCC stores ASCII characters into consecutive bytes of memory. Any printable ASCII characters can be contained in the string. String is specified between two identical delimiters, which can be any printable ASCII character. First non-blank character after the string is used as a delimiter.
FCC Cont’d Result Operand Prebyte Opcode Example: ORG $0400 FCC “12345” Address 31 $0400 32 $0401 33 $0402 34 $0403 35 $0404
FCB FCB – Form Constant Byte FCB has one or more operands. Value of each operand is truncated to eight bits, and is stored in single byte of object program. Operand may be a numeric constant, character constant, a symbol or an expression. Multiple operands are separated by commas, and are stored in successive memory bytes.
FCB Cont’d Example: VALA EQU $10 ORG $0400 FCB $34,’A, $28AC, $0A ,VALA Result Operand Prebyte Opcode Address 34 $0400 41 $0401 AC $0402 0A $0403 $0404 10
FDB FDB – Form Constant Double Byte FDB stores a double (two byte) word. May have one or more operands separated by commas. Operand may be a numeric constant, a character constant, a symbol, or an expression.
FDB Cont’d Example: ORG $0400 FDB $1234,’&,’G Result Operand Prebyte Opcode Address 12 $0400 34 $0401 00 $0402 26 $0403 00 $0404 47 $0405 Note: ASCII value for & is $26 ASCII value for G is $47
RMB RMB – Reserve Memory Byte RMB saves a place in memory for a number. Example: ORG $0400 XVAR RMB 2 *TWO MEMORY *LOCATIONS $0400 *and $0401 ARE *RESERVED FOR XVAR ORG $1000 LDD #$FFAA STD XVAR SWI END Result Prebyte Opcode Operand Address FF $0400 AA $0401
Question a student asked: What happens if you change the previous example to "XVAR RMB 3" instead of "XVAR RMB 2" ? What happens to the 3rd reserved byte when a 2 byte number is stored in XVAR? Answer: Remains unchanged Modified Program: ORG $0400 XVAR RMB 3 ORG $1000 LDD #$FFAA STD XVAR SWI END
ZMB, BSZ ZMB – Zero Memory Byte and BSZ – Block Storage of Zero These directives fill a given number of memory locations with zero. Causes assembler to allocate a block of memory bytes, and each memory byte is assigned a value of zero. Both directives do the same thing. Number of bytes allocated is given in the operand field. Result Example: ORG $0400 ZMB #$02 BSZ #$02 Prebyte Opcode Operand Address 00 $0400 $0401 00 00 $0402 $0403 00
FILL Fill given number of memory locations with any number. (Note: Fill uses one byte. If two bytes are specified, then it will truncate it and use LS Byte.) Example: ORG $0400 FILL #$FF, #$02 Result Prebyte Opcode Operand Address $0400 FF FF $0401
Question a student asked: What happens when the previous example is changed to "FILL #$9ABC, #$02" instead of "FILL #$FF,#$02"? What happens if you fill memory with a 2 byte number? Answer: FILL will just use the LS Byte Modified Example: ORG $0400 FILL #$9ABC,#$02 END (Note: There is no ”go 1000” on the screen since these are just assembly directives and not a program)
PAGE PAGE The PAGE directive causes a page break in the list file. If no source listing is being produced, the PAGE directive will have no effect. The directive is not printed on the source listing.
OPT OPT Allows for various options in assembly of a program, including generating a listing and counting instruction cycles. Options: nol-no output listing (default) l-do an output listing noc-no cycle number count (default) c-turn on cycle count using zero initial value contc-turn cycle count on, begin with last value cre-create a cross reference table (default anyway) RMB s-create a symbol table (default anyway) EQU Example: OPT l – Print source listing from this point