beautypg.com

Maxim Integrated MAX-IDE MAXQ Microcontrollers User Manual

Page 7

background image

MOVE @data_pointer,A[0]
MOVE A[0], A[1] ; process lower HEX nibble
AND #0fh
ADD #030h

MOVE A[2],A[0]
SUB #03ah
MOVE A[0],A[2]
SJUMP C,??Hex2Asc_1
; if value > '9', value = value +
('A' - '9') + 1
ADD #07h
AND #0ffh

??Hex2Asc_1:
MOVE DP[0], #ch1 ; Store ASCII value of lower HEX
nibble
MOVE @data_pointer, A[0]
RET

main:

MOVE A[0], #041h ; hex value to be converted to ASCII
LCALL Hex2Asc ; process the HEX value
SJUMP $ ; RUN forever

END

The above source code is available for

download

(ZIP)

Step 9: Recompile the code by pressing F7 or selecting

Project→Make. If compilation is successful,

output files named hextoasc.hex and hextoasc_d.hex will be generated along with a list file. You are now
ready to run the application.

Step 10: Before executing the application, set some break points to investigate the application's
behavior. Click on the line number at the left edge of the editor window to set a breakpoint. The
breakpoint will be indicated by a

to the side of the number. Set a break point on the line below "main,"

and another at the subroutine, Hex2Asc. Press F5 to start the simulator. This will save the files (if not
already saved) and compile the project. If the compilation is successful, the simulator will load the file
and start running. When the simulator hits a break point, the program execution will pause at the current
line, as indicated by highlighting of the current line and a → mark to the left of the margin.

Figure 5 shows the breakpoint and an instance of the application running.

Page 7 of 11