| ??? 06/30/03 14:37 Read: times |
#49706 - RE: Why not use QBASIC? Responding to: ???'s previous message |
I´ve realized that all the problems that appeared when running my program were due to my compiler.
My compiler doesnt recognize the directive: .org 00h but it does work fine if I write: org 00h I really don´t know what the full stop is used for, but when after trying all I noticed that when eliminited it all worked just fine. I now have 2 problems: 1) I don´t know how to simulate with my 8052 emulator the recieving of data 2) I´m confused, should I get started wuith QBasic, or C? I don´t know oop (object oriented programming) here goes the final version of the code: ORG 000H ;locate routine at 00H AJMP START ;jump to START ORG 003H ;external interrupt 0 RETI ORG 00BH ;timer 0 interrupt RETI ORG 013H ;external interrupt 1 RETI ORG 01BH ;timer 1 interrupt RETI ORG 023H ;serial port interrupt CLR EA ;unable interruptions ACALL HAND_SHAKE SETB EA ;enable interruptions again RETI ORG 035H ;locate beginning of rest of program INICIO_TABLA EQU 040H FIN_TABLA EQU 0FFH SEND: MOV SBUF,A ;Transmit Byte JNB TI,$ ;Wait for transmission to be completed. CLR TI ;Clear Transmit Flag RET RECIEVE: JNB RI,$ MOV A, SBUF CLR RI RET START_SENDING: ;Main program (on power up, program jumps to this point) MOV R0,#INICIO_TABLA LOOPS: MOV A,@R0 ;Move Value in R0 to A (to be sent) ACALL SEND ;Send Value to PC INC R0 ;Increase the 8 bit value of by 1 MOV A,R0 CJNE A,FIN_TABLA,LOOPS ;Go to LOOP(jump back to point labeled LOOP) RET ;End program START_RECIEVING: MOV R0,#INICIO_TABLA LOOPR: ACALL RECIEVE MOV R0,A INC R0 ;Increase the 8 bit value of by 1 CJNE A,FIN_TABLA,LOOPR ;Go to LOOP(jump back to point labeled LOOP) RET ;End program HAND_SHAKE: PUSH 00H ;push R0 PUSH ACC PUSH PSW MOV IP, #010H MOV PCON, #080H ;to double baud rate MOV TH1, #0FDH ;Set up for 9600 baud rate MOV SCON, #01010000B ;Mode = 8 bit UART MOV TMOD, #00100001B ;Sets Timer1 to 8 bit auto reload MOV TCON, #01000000B ;Turns Timer1 on MOV A,SBUF COMPARE: CJNE A,#053H,START_RECIEVING ;if sbuf != s then recieve ACALL START_SENDING ;else send POP PSW POP ACC POP 00H ;pop R0 RET START: MOV IE,#098H JMP $ END |



