You are on page 1of 2

;

;
;
;
;
;
;
;
;
;
;
;
;
;
;

This is the SKELETON for the YourName3.txt program which


you must finish. The code that calls the Draw1Char
subroutine has been provided but the Draw1Char subroutine
is still a copy of the Draw1Char subroutine that was used
in YourName2.txt. This old Draw1Char subroutine had to
be called with the accumulator holding a value that was
8 times the index of the alphabet letter we wanted sent
to the signboard. This means the programmer had to keep
multiplying his alphabet indices by 8. Your job is to
write a new Draw1Char subroutine that can be called
when the accumulator holds a straight alphabet index.
The first thing this new Draw1Char subroutine will do
is to multiply the value passed in the accumulator by 8.
The rest of the new Draw1Char subroutine can be identical
to the old Draw1Char subroutine.

; To modify this program to march your own name across the signboard
; you will be aided by the following table of indices for all the
; alphabet letters:
; A B C D E F G H I J K L M N O P Q R S T U V W X Y Z blank
; 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
; Note that FontData.txt holds the image data for a blank (space)
; character at the very end of the alphabet.
LJMP Start

; Jump over the DB statements included from


; the "FontData.txt" file since DB statements
; hold data rather than executable instructions.

INCLUDE "FontData.txt"
Start:

MOV DPTR,#StartOfImageData
; We initialize the DPTR ("data pointer"), a 16 bit
; SFR ("special function register"), to point to
; the first column of font data (the first column
; of the letter 'A') in program memory. The DPTR
; register continues to hold this same value
; throughout this program.
MOV A,#9
; The letter 'J' has alphabet index 9 (indices always
; start from 0)
LCALL Draw1Char
MOV

A,#14

; letter 'O' has alphabet index 14

LCALL Draw1Char
MOV

A,#7

; letter 'H' has alphabet index 7

LCALL Draw1Char
MOV

A,#13

; letter 'N' has alphabet index 13

LCALL Draw1Char
Done:

SJMP Done

Draw1Char:
; This is a subroutine which is responsible for outputting exactly 8

;
;
;
;
;

columns (hence 1 character) of font data to the electric sign board.


Before you call this subroutine initialize the ACC with the alphabet
index of the letter you want sent to the signboard. That is, if
you want the letter 'C' output to the signboard then call this
subroutine with ACC = 2.

; We first need to convert the alphabet index (ranging from 0 to 26)


; to a column index (ranging from 0 to 26 * 8 = 208). This column index
; will describe the byte offset to that letter's column data.
<<<<< you need 2 new instructions here >>>>>>
;
;
;
;
;
;
;

Within this subroutine we use R0 as a temporary storage location


for the accumulator's value (we need this because the "MOVC A,@A+DPTR"
instruction keeps perturbing the accumulator). And we use the
R1 register to control the loop (that is, decide how many times
we iterate). Note that R0 is synonymous with data memory location 0
and R1 is synonymous with data memory location 1 (at least while
the 8051 is in its default configuration).
MOV

R0,A

MOV

R1,#0

CharLoop: MOV
MOVC
MOV
INC
INC
CJNE
RET

; preserve this starting column # since the


; upcoming "MOVC A,@A+DPTR" instruction
; replaces the value in the ACC
; we use R1 to control the looping

A,R0
; prepare for upcoming "MOVC A,@A+DPTR" instr
A,@A+DPTR ; the ACC now holds one column of font data
P0,A
; write that column to the sign board
R0
; advance to the next column
R1
; increment the loop counter
R1,#8,CharLoop
; we loop 8 times in order to output 8 columns

You might also like