以下程序更换一语句后程序模拟调试为何出现错误结果
;*******************************************************************************;
; NEC Electronics 78K0S/KB1+
;
;*******************************************************************************
; 78K0S/KB1+ Sample program
;*******************************************************************************
; Initialization
;*******************************************************************************
;<<History>>
; 2007.4.-- Release
;*******************************************************************************
;
;<<Overview>>
;
; This sample program initializes the microcontroller by setting functions
; such as clock frequency and the port to the input or output.
; After the initialization, three LED lights are controlled by two switches.
;
; <Principal setting contents in initialization>
;
; - Set the vector table
; - Set the stack pointer
; - Stop the watchdog timer operation
; - Set the CPU clock frequency at 2 MHz
; - Stop the low-speed internal oscillator
; - Set the ports to the input or output mode
; - Set the connection of on-chip pull-up resistors (input port only)
; - Set the output latches of the output ports
;
;
; <Switch input and LED output>
;
;+---------------------------------------+
;|SW1|SW2|LED1 |LED2 |LED3 |
;| (P40) | (P43) | (P20) | (P21) | (P22) |
;|---------------|-----------------------|
;|OFF|OFF|OFF|OFF|OFF|
;|ON |OFF|ON |OFF|OFF|
;|OFF|ON |OFF|ON |OFF|
;|ON |ON |OFF|OFF|ON |
;+---------------------------------------+
;
;
;<<I/O port settings>>
;
;Input:P40, P43
;Output: P00-03, P20-23, P30-33, P41, P42, P44-P47, P120-P123, P130
;# All unused ports are set as the output mode.
;
;*******************************************************************************
;===============================================================================
;
; Vector table
;
;===============================================================================
XVCT CSEG AT 0000H
DW RESET_START ;(00) RESET
DW RESET_START ;(02) --
DW RESET_START ;(04) --
DW RESET_START ;(06) INTLVI
DW RESET_START ;(08) INTP0
DW RESET_START ;(0A) INTP1
DW RESET_START ;(0C) INTTMH1
DW RESET_START ;(0E) INTTM000
DW RESET_START ;(10) INTTM010
DW RESET_START ;(12) INTAD
DW RESET_START ;(14) --
DW RESET_START ;(16) INTP2
DW RESET_START ;(18) INTP3
DW RESET_START ;(1A) INTTM80
DW RESET_START ;(1C) INTSRE6
DW RESET_START ;(1E) INTSR6
DW RESET_START ;(20) INTST6
;===============================================================================
;
; Define the ROM data table
;
;===============================================================================
XTBL1 CSEG AT 0100H 改动处////////./emotion/em025.gif
LEDDATA:
DB 00000011B ;00: SW1=ON, SW2=ON-> LED3=ON
DB 00000101B ;01: SW1=OFF,SW2=ON-> LED2=ON
DB 00000111B ;02: Dummy
DB 00000111B ;03: Dummy
DB 00000111B ;04: Dummy
DB 00000111B ;05: Dummy
DB 00000111B ;06: Dummy
DB 00000111B ;07: Dummy
DB 00000110B ;08: SW1=ON, SW2=OFF -> LED1=ON
DB 00000111B ;09: SW1=OFF,SW2=OFF -> LED1,2,3=OFF
;===============================================================================
;
; Define the memory stack area
;
;===============================================================================
XSTK DSEG AT 0FEE0H
STACKEND:
DS 20H ; Memory stack area = 32byte
STACKTOP: ; Start address of the memory stack area = FF00H
;*******************************************************************************
;
; Initialization after RESET
;
;*******************************************************************************
XMAIN CSEG UNIT
RESET_START:
;-------------------------------------------------------------------------------
; Initialize the stack pointer
;-------------------------------------------------------------------------------
MOVW AX, #STACKTOP
MOVW SP, AX ; Set the stack pointer at FF00H
;-------------------------------------------------------------------------------
; Initialize the watchdog timer
;-------------------------------------------------------------------------------
MOV WDTM, #01110111B ; Stop the watchdog timer operation
;-------------------------------------------------------------------------------
; Initialize the clock generators
;-------------------------------------------------------------------------------
MOV PPCC, #00000010B ; The clock supplied to the peripheral hardware (fxp) = fx/4 (= 2MHz)
MOV PCC, #00000000B ; The clock supplied to the CPU (fcpu) = fxp (= 2MHz)
MOV LSRCM, #00000001B ; Stop the low-speed internal oscillator
;-------------------------------------------------------------------------------
; Initialize the port 0
;-------------------------------------------------------------------------------
MOV PM0, #11110000B ; Set P00-P03 as output mode
MOV P0, #00000000B ; Set output latches of P00-P03 as low
;-------------------------------------------------------------------------------
; Initialize the port 2
;-------------------------------------------------------------------------------
MOV PM2, #11110000B ; Set P20-P23 as output mode
MOV P2, #00000111B ; Set output latches of P20-P22 as high, P23 as low
;-------------------------------------------------------------------------------
; Initialize the port 3
;-------------------------------------------------------------------------------
MOV PM3, #11110000B ; Set P30-P33 as output mode
MOV P3, #00000000B ; Set output latches of P30-P33 as low
;-------------------------------------------------------------------------------
; Initialize the port 4
;-------------------------------------------------------------------------------
MOV PM4, #00001001B ; Set P40 and P43 as input mode, P41, P42 and P44-P47 as output mode
MOV PU4, #00001001B ; Connect on-chip pull-up resistors to P40 and P43
MOV P4, #00000000B ; Set output latches of P41, P42 and P44-P47 as low
;-------------------------------------------------------------------------------
; Initialize the port 12
;-------------------------------------------------------------------------------
MOV PM12, #11110000B ; Set P120-P123 as output mode
MOV P12, #00000000B ; Set output latches of P120-P123 as low
;-------------------------------------------------------------------------------
; Initialize the port 13
;-------------------------------------------------------------------------------
MOV P13, #00000001B ; Set output latch of P130 as high
;-------------------------------------------------------------------------------
; Initialize the general-purpose register
;-------------------------------------------------------------------------------
MOVW HL, #LEDDATA ; Set the table address to the HL register
;*******************************************************************************
;
; Main loop
;
;*******************************************************************************
MAIN_LOOP:
MOV A, P4 ; Read switch-input status
AND A, #00001001B ; Mask the data except the switch-input status
MOV L, A ; Set switch-input status to the lower 8 bits of the table address
MOV A, ; Read LED output data from the table
MOV P2, A ; Output the LED light
BR $MAIN_LOOP ; Go to the MAIN_LOOP
end
改动的语句为XTBL1 CSEGAT 0100H 改为XTBL1CSEG AT 0088H 错误结果是怎么样的呢?
是不能编译还是运行结果不对呢?还是其他问题? 编译是正常,就是结果不对(查表结果不对)
总的说来就是数据段,代码段,表数据如何安排的问题 是执行哪步逻辑出了问题呢? MOV L, A ; Set switch-input status to the lower 8 bits of the table address
MOV A, ; Read LED output data from the table 你是用软件仿真看结果的吧?
目前没有找到不能设置088H的资料,看你程序,的值是根据P4的值得到吧,可能问题出自这里,P4的值因为代码的位置而随机得到。
我再找下相关资料,希望能找到让你满意的资料。 (P4的值因为代码的位置而随机得到 )这句话你理解不对,它是读取键的值 . 你能将整个项目都传上来么?
因为修改地址是允许的我们一起调试一下看问题出自哪里/ 重新上传
点击此处下载 ourdev_410608.rar(文件大小:15K) (原文件名:fyz.rar) 兄弟
你项目里面都没有东西 已重新上传 你程序的问题是逻辑问题
如果你定义XTBL1 CSEG AT 0100H,那么你执行
MOV L, A
MOV A,
后,可以将正确的查表地址传到,
如果你定义XTBL1 CSEG AT 0088H
那么你执行
MOV L, A
MOV A,
显然没有将正确的地址传给,比如你的P4值为9,经过MOV L, A 后
的地址就等于9
所以结果不对。
如果你在MOV L, A 处用加不用MOV的话,就可以解决这个问题了
页:
[1]