MAX-IDE Simulator User's G

[09-13 17:04:09]   来源:http://www.88dzw.com  控制技术   阅读:8333

文章摘要:For this application, press F7 or select Project→Make.Step 8: If you entered the text exactly as in Table 1, you should get an error when you compile at the line LCALL Hex2Asc2To point to the source of error, double click on the error line in the message window. Retype the line t LCALL Hex2Asc and

MAX-IDE Simulator User's G,标签:计算机控制技术,工厂电气控制技术,http://www.88dzw.com

For this application, press F7 or select Project→Make.

Step 8: If you entered the text exactly as in Table 1, you should get an error when you compile at the line
LCALL   Hex2Asc2
To point to the source of error, double click on the error line in the message window. Retype the line t LCALL Hex2Asc and recompile.

Table 1. hex_to_asc.asm: Converts Hex Data to Its Equivalent ASCII
;example to explain the usage of MAX-IDE
        
      SEGMENT   DATA      ; DATA segment starts here
                                                     ; Default location = 00

; Initialize Data memory
ch:     DB      0                           ;holds ASCII value of upper HEX nibble
ch1:    DB      0                           ;holds ASCII value of lower HEX nibble
ch2:    DB      0                           ;holds HEX byte
ch3:    DB      0       

    SEGMENT CODE                  ; CODE segment starts here
    ORG 0                                      ; SET Absolute address of code = 0
MAXQ30 EQU 3
MAXQ20 EQU 2
MAXQ10 EQU 1
;Choose MAXQ to be MAXQ10, MAXQ20 or MAXQ 30 depending 
;on the architecture you want to use.
MAXQ EQU MAXQ30
; This example is with MAXQ30
IF(MAXQ=MAXQ30)
 #define data_pointer DP[0].b 
; for maxq30 , the data pointer is specified to be in byte mode or word mode by using the 
; notation DP[0].b or DP[0].w                                                   
ENDIF
IF(MAXQ=MAXQ20)
 #define data_pointer DP[0]
 MOVE DPC,#18h
; for maxq 20, the data pointer is specified to be in byte mode or word mode through the 
; DPC register 
ENDIF
IF(MAXQ=MAXQ10)
 #define data_pointer DP[0]
 MOVE DPC,#18h
; for maxq 10, the data pointer is specified to be in byte mode or word mode through the 
; DPC register 
ENDIF
    JUMP main

    ORG 20h                                  ; SET Absolute address of code = 32 HEX
                                        
Hex2Asc:

     MOVE       A[1], A[0]            ; store the HEX value for future use
     MOVE       DP[0], #ch2  
     MOVE       @data_pointer, A[0]       ; store the HEX value @ #ch2 location

     MOVE       A[0], A[1]             ; Process upper nibble
     MOVE       AP,#0
     SRA4
    ADD #030h                    ; value = value + '0'
        
    MOVE        A[2],A[0]
    SUB         #03ah
    MOVE        A[0],A[2]
    SJUMP       C, ??Hex2Asc_0
                                                    ; if value > '9', value=value + ('A' - '9') + 1
    ADD         #07h
    AND         #0ffh

??Hex2Asc_0:
    MOVE        DP[0],#ch           ; store ASCII value of upper HEX nibble
    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

上一页  [1] [2] [3] [4] [5]  下一页


Tag:控制技术计算机控制技术,工厂电气控制技术控制技术

《MAX-IDE Simulator User's G》相关文章