附上如何KEIL C嵌入汇编的过程,软件代码已删除
以下内容仅供参考。
////////////main.c文件内容如下////////////////
#include <c8051f120.h>
#include "test.h"
extern void vSram_Write_nWord(word wXpos, word wYpos, word bSramWriteNum);
extern byte xdata g_wSramBuf[2048];
void vSYSCLK_IntOsc_Init(void)
{
//todo
}
void vRAM_Init(void)
{
//todo
}
void vPORT_Init(void)
{
//todo
}
void cmd(void)
{
//todo
}
void main(void)
{
WDTCN = 0xde;
WDTCN = 0xad;
SP = 0x60;
vSYSCLK_IntOsc_Init();
vRAM_Init();
vPORT_Init();
//vSram_Write_nWord(100,100,100);
while(1){
cmd();
;
}
}
void UART0_ISR(void) interrupt 4 using 1
{
//todo
}
////////////test.h文件内容如下////////////////
#ifndef _TEST_H_
#define _TEST_H_
typedef unsigned char byte;
typedef unsigned int word;
void vSram_Write_nWord(word wXpos, word wYpos, word bSramWriteNum);
void vSram_Read_nWord(word wAddressL, byte bAddressH, word bSramReadNum);
#endif
/////////////////////test.c文件内容如下/////////////////////////
$NOMOD51
#include <c8051f120.h>
NAME TEST
public g_wSramBuf
public _vSram_Write_nWord,vSram_Read_nWord
;vSram_Write_Data_Seg segment data
; rseg vSram_Write_Data_Seg
dseg at 27h
bSfrBuf: ds 1
;------------------------------------------------------------------------------
; XDATA SEGMENT--Reserves space in XDATA RAM--Delete this segment if not used.
;------------------------------------------------------------------------------
vSram_Write_Xdata_Seg segment xdata ; segment for XDATA RAM
rseg vSram_Write_Xdata_Seg ; switch to this xdata segment
g_wSramBuf: ds 2048 ; reserve 2048 Bytes for xdata_array
vSram_Write_nWord_Prog segment code
rseg vSram_Write_nWord_Prog
using 0
;-------------------------------------------------------------------
;vSram_Write_nWord
;parameter: wXpos(R6, R7), wYpos(R4,R5), bWriteNum(R2,R3)
;use global variable: g_wSramBuf[2048]
;Return: No
;-------------------------------------------------------------------
_vSram_Write_nWord:
vSram_Write_nWord:
;todo
ret
_vSram_Read_nWord:
vSram_Read_nWord:
;todo
ret
end
/////////////////driver.asm文件内容如下//////////////////
$NOMOD51
#include <c8051f120.h>
public TFT_640x480_Drv, TFT_320x240_Drv, TFT_480x272_Drv
public TFT_DISP_MODE
;TFT_DRIVER_REG segment data ; segment for DATA RAM.;
; rseg TFT_DRIVER_REG ; switch to this data segment
dseg at 28h
TFT_DISP_MODE: ds 1
cseg AT 002BH
ljmp TFT_DRIVER_ISR
;TFT_DRIVER_PROG segment code
; rseg TFT_DRIVER_PROG
cseg AT 1000H
; org 0x1000
TFT_Driver_ISR:
push acc ;保护现场
push dph
push dpl
push psw
mov psw, #0x18 ;使用第三组寄存器, RS1 = 1, RS0 = 1;
Tft_Isr_Next:
mov A, TFT_DISP_MODE
mov dptr, #Entry_Mode0_Jmp
jmp @a+dptr ;
Entry_Mode0_Jmp:
acall TFT_640x480_Drv ;2 bytes,模式0,640×480模式
sjmp Tft_Driver_Isr_End ;2 bytes
Entry_Mode1_Jmp:
acall TFT_320x240_Drv; ;模式1,320×240模式
sjmp Tft_Driver_Isr_End
Entry_Mode2_Jmp:
acall TFT_480x272_Drv; ;模式2,480×272模式
sjmp Tft_Driver_Isr_End
Tft_Driver_Isr_End:
pop psw
pop dpl
pop dph
pop acc
reti
TFT_640x480_Drv:
;todo
ret
TFT_320x240_Drv:
;todo
ret
TFT_480x272_Drv:
;todo
ret
end
} |