用汇编语言写51单片机程序开头为什么一般都这样:ORG 0000H LJMP MAIN ORG 0030H

1)ORG 是汇编的伪指令 告诉编译器我的代码放在什么位置
2)在单片机复位的时候 在你没有做任何改变的时候 程序指针会是指向0000H的地址
3)所以我们把MAIN卸载地址0000H 让单片机复位后直接跳转到 MAIN的程序段去执行
4)ORG 0030H 是你程序的代码开始地址,由于地址0030H以前有中断向量入口和寄存器的地址,所以一般用户程序都是从0030H开始的。

  • 8
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
这是一小部分代码 请参考 org 0000h jmp start ;Start of the program org 0100h start: mov A,#030h ;1 line, 8 bits call wrcmd mov A,#LCD_SETVISIBLE + 4 call wrcmd mov A,#LCD_SETDDADDR+15 ; Start at right hand side of the display call wrcmd mov A,#LCD_SETMODE + 3 ; Automatic Increment - Display shift left. call wrcmd mov 025h,#00h ; Set output mode (floating point). call boundsbuffer ; Initialise the bounds buffer - used for error checking. mov mode,#4 ; Initialise the constant buffer to 100. Primarily used for % ops. mov digitcode,#031h call storedigit mov digitcode,#030h call storedigit mov digitcode,#030h call storedigit mov status,#00h ; variable used to determine the first key press after an operation. mov bufferctr,#00h mov opcounter,#00h mov decimalcnt,#00h call waitkey halt: mov PCON,#1 ;Halt ;*********************************************************** ;**** Floating Point Package **** ;******************************** $INCLUDE (FP52.ASM) ;Routine to peek arg at DPTR argout: mov R0,#FP_NUMBER_SIZE aoloop: movx A,@DPTR anl A,#0F0h rr a rr a rr a rr a add A,#aodata-$-3 movc A,@A+PC call sndchr movx A,@DPTR anl A,#0Fh add A,#aodata-$-3 movc A,@A+PC call sndchr inc DPTR djnz R0, aoloop ret aodata: db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' ;Routine to output character in A, preserving all but A. sndchr: push R0B0 push R1B0 call getmode mov digitcode,A call storedigit pop R1B0 pop R0B0 ret ;Routine to print error message at DPTR. prterr: jmp wrstr ;Routine to handle input parameter error. badprm: mov DPTR,#bpmsg jmp wrstr bpmsg: db 'Bad Parameter',0 ;*********************************************************** ;**** LCD Display Routines **** ;****************************** ;LCD Registers addresses LCD_CMD_WR equ 00h LCD_DATA_WR equ 01h LCD_BUSY_RD equ 02h LCD_DATA_RD equ 03h LCD_PAGE equ 80h ;LCD Commands LCD_CLS equ 1 LCD_HOME equ 2 LCD_SETMODE equ 4 LCD_SETVISIBLE equ 8 LCD_SHIFT equ 16 LCD_SETFUNCTION equ 32 LCD_SETCGADDR equ 64 LCD_SETDDADDR equ 128

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Elec Liu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值