Basic assembly question
Basic Jim
Posts: 106
Hi,
I am finally trying to tackle the strange world of assembly language. What I find odd is that it doesn't seem to behave the same in the regular run mode vs. the debug mode. For example, if you run the following program in debug mode three of the LED’s will light as they should (I think) But, if you assemble it in regular run mode it never turns any lights on. I can't see why it doesn't. I have also run into several tutorial examples that behave this way as well. I'm sure I’m missing something obvious here. But I don't know what it is.·
Thanks,
Jim W.
; Traffic Lights
;
LIST Q = 37
DEVICE· SX28L, TURBO, STACKX, OSCHS2
IRC_CAL IRC_FAST
FREQ··· 4_000_000
RESET·· 0
· Mov·· !rb, #%00000000··; Setup RB as outputs
· Mov ·!RA, #%1111 ··; Setup ra as input from switches
; Make a variable that is tied to the Configuration switches
;
; Setup Initial conditions
clrb·· rb.0 ·; 1 Red
clrb·· rb.1·; 1 Yellow
clrb·· rb.2·; 1 Green
setb·· rb.3·; 2 red
setb·· rb.4·; 2 Yellow
setb·· rb.5·; 2 Green
sleep
I am finally trying to tackle the strange world of assembly language. What I find odd is that it doesn't seem to behave the same in the regular run mode vs. the debug mode. For example, if you run the following program in debug mode three of the LED’s will light as they should (I think) But, if you assemble it in regular run mode it never turns any lights on. I can't see why it doesn't. I have also run into several tutorial examples that behave this way as well. I'm sure I’m missing something obvious here. But I don't know what it is.·
Thanks,
Jim W.
; Traffic Lights
;
LIST Q = 37
DEVICE· SX28L, TURBO, STACKX, OSCHS2
IRC_CAL IRC_FAST
FREQ··· 4_000_000
RESET·· 0
· Mov·· !rb, #%00000000··; Setup RB as outputs
· Mov ·!RA, #%1111 ··; Setup ra as input from switches
; Make a variable that is tied to the Configuration switches
;
; Setup Initial conditions
clrb·· rb.0 ·; 1 Red
clrb·· rb.1·; 1 Yellow
clrb·· rb.2·; 1 Green
setb·· rb.3·; 2 red
setb·· rb.4·; 2 Yellow
setb·· rb.5·; 2 Green
sleep
Comments
Ray
It seems to work for me from within the IDE.
What do you mean by "if you assemble it in regular run mode it never turns any lights on"
What exactly are you doing, that it doesn't work ?
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
If I push the program button it programs the chip but the lights never come on. but when I single step using debug the lights turn on as they should and they stay on as they should.
Ray,
All I'm trying to do here is to light the LED's by using clrb or setb if the program is exectuted once then I should have three lights on and three lights off. There shouldn't be any need for for delay loops. The light is set or reset and thats all.
You need to hit the RUN button (red circle w/arrow).
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
Thanks again,
Jim W.
Ray
I might have something different going on here. Isn't hitting the program chip button along the top of the screen the same thing as hitting the program selection in the nemu. They both have cntrl/p as a short cut. I tried it the way you said but it still isn't working. If I hit the run button it works but using the program button and powering down, then removing the SX-Key all the lights stay off. I think there is something funny about my code or I'm missing something. I know it seems to work ok with SX/b code.
Thanks,
Jim W.
Ray
; Traffic Lights
;
LIST Q = 37
DEVICE SX28L, TURBO, STACKX, OSCHS2
IRC_CAL IRC_FAST
FREQ 4_000_000
RESET 0
Mov !rb, #%00000000 ; Setup RB as outputs
Mov !RA, #%1111 ; Setup ra as input from switches
; Make a variable that is tied to the Configuration switches
; Blinker sub routine
; regular lights
; Setup Initial conditions
clrb rb.0 ; 1 Red
clrb rb.1 ; 1 Yellow
clrb rb.2 ; 1 Green
setb rb.3 ; 2 red
setb rb.4 ; 2 Yellow
setb rb.5 ; 2 Green
sleep
*** This SX b version downloads and works as expected. ***
' =========================================================================
' File...... Traffic Lights
' Purpose... SX/B Programming Template
' Author....
' E-mail....
' Started...
' Updated...
' =========================================================================
' Program Description
'This program will emulate a traffic light and be able to do what the
'flagmen do at roadwork sites.
'
' Device Settings
DEVICE SX28, OSC4MHZ, TURBO, STACKX, OPTIONX
FREQ 4_000_000
'
' IO Pins
Tim1 VAR RA.0
Tim2 VAR RA.1
'Tim45 VAR RA.2
'Tim60 VAR RA.3
Red1 VAR RB.0 '; 1 Red
Yel1 VAR rb.1 '; 1 Yellow
Grn1 VAR rb.2 '; 1 Green
Red2 VAR rb.3 '; 2 red
Yel2 VAR rb.4 '; 2 Yellow
Grn2 VAR rb.5 '; 2 Green
'
' Constants
'
' Variables
INTERRUPT
ISR_Start:
ISR_Exit:
RETURNINT ' {cycles}
' =========================================================================
PROGRAM Start
Pgm_ID:
DATA "SX/B Template", 0
'
' Subroutines / Jump Table
SW00 Sub
SW01 Sub
SW10 Sub
SW11 Sub
Trans Sub
'
' Program Code
Start:
TRIS_B = %00000000 ' make RB pins output
TRIS_a = %1111 ' make Ra pins input
low red1
high yel1
high grn1
high red2
high yel2
low grn2
Main:
If tim1 = 0 then
gosub SW00
If tim1 = 1 then
gosub SW01
If tim2 = 0 then
gosub SW10
If tim2 = 1 then
gosub SW11
ENDIF
ENDIF
ENDIF
ENDIF
low red1
high yel1
high grn1
high red2
Low yel2
High grn2
gosub Trans 'transistion from grenn to yellow
low red1
high yel1
high grn1
high red2
Low yel2
High grn2
' main code here
GOTO Main
SW00:
pause 1000
return
SW01:
Pause 1000
Return
SW10:
Pause 1000
Return
SW11:
Pause 1000
Return
Trans:
pause 500
return
'
' Page 1 Code
Page_1:
ADDRESS $200
P1_Start:
GOTO P1_Start ' error if Pg0 overruns Pg1
'
' Page 2 Code
Page_2:
ADDRESS $400
P2_Start:
GOTO P2_Start ' error if Pg1 overruns Pg2
'
' Page 3 Code
Page_3:
ADDRESS $600
P3_Start:
GOTO P3_Start ' error if Pg3 overruns Pg4
Best,
Jim W.
· In the SX/B version you are using the internal 4MHz oscillator. Is that what you want the assembly version to do also ? If so you need to change your DEVICE line in your assembly program.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Cheap 4-digit LED display with driver IC·www.hc4led.com
Low power SD Data Logger www.sddatalogger.com
"You're braver than you believe, stronger than you seem, and smarter than you think" Christopher Robin to Pooh
·
Best,
Jim W.