Shop OBEX P1 Docs P2 Docs Learn Events
WHATS happening here? — Parallax Forums

WHATS happening here?

dufflingduffling Posts: 73
edited 2005-04-07 15:58 in General Discussion
why does the LED turn off in debug mode .. yet not when i program the sx?
what am I doing wrong?



;
DEVICE DIRECTIVES
··DEVICE··SX28,OSC4MHZ,TURBO,STACKX,OPTIONX
········ IRC_CAL··IRC_SLOW
··FREQ ·50_000_000



··RESET··Initialize
;
VARIABLES

COUNT1 EQU $09
COUNT2 EQU $10

WATCH COUNT1,8,UDEC
;
INITIALIZATION ROUTINE
Initialize

··;Configure port settings

mov !rb,#%01111111··· ;SET RB.7 AS OUTPUT FOR LED
;
MAIN PROGRAM
MAIN
CLR COUNT1
CLR COUNT2


MOV RB,#%00000000

LOOP·················· ; SHORT DELAY
DJNZ COUNT1,LOOP
DJNZ COUNT2,LOOP


··· ; TURN OFF LED
MOV RB,#%10000000···


END




·

Comments

  • RsadeikaRsadeika Posts: 3,837
    edited 2005-04-06 12:20
    I had the same thing occuring to my little test program just the other day. Here are the assumptions that I made: In assembly, END is not a command; without specific code such as an endless loop, SLEEP, or a jmp $, the processor just keeps running the program over and over. So, the coomand you have at the end of your program to turn off the LED occurs so quickly, it looks like your LED never turns off. As a begginer this is what I think is occuring.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2005-04-06 16:22
    I can only confirm what Rsadeika mentioned: END simply signals the Assembler that no more program code to be handled by the assembler follows. IOW, you could place whatever kind of text in lines following the END, and the Assembler will ignore them. This sometimes is handy when you want to add some documentation to a source code file.

    When the SX executes the code, generated from your sample program, it will run into "nowhere land" after doing the MOV RB, #%10000000. This unprogrammed area of the program memory usually contains $FFF in each location.

    Just add

    jmp $

    following the

    MOV RB, #%10000000

    to bring the SX into an endless loop.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • dufflingduffling Posts: 73
    edited 2005-04-06 17:53
    Ok . i follow that .. the jmp$ fixed the problem .. thanks for the help guys..
  • KenMKenM Posts: 657
    edited 2005-04-07 15:58
    And just for your info, the command
    jmp $
    

    is a jump to the current program address, and that instruction is cryptic to some.
    The equivalent less cryptic command is:
    finish 
    jmp finish
    

    And just at Guenther mentioned the program is in an endless loop to nowhere.

    K
Sign In or Register to comment.