help with some ASM

Go To Last Post
9 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
What I'm looking to accomplish here is a bit of a hack to the v-usb project. Normally the assembly will return on interrupt. I need to make it return regardless if the interrupt bit is not set. The test here is to see if the driver will return and send NAK instead of doing nothing when the interrupt is disabled.  Note: before disabling interrupts I run the busy command that will return NAK. So if this works, it should return from this code and then return NAK as it was told to. 

normal code
sofError:
    POP_RETI                    ;macro call
    RETI
test code

sofError:
    POP_RETI                    ;macro call
    brne EIMSK >> 2;if not set branch (int0 is pd2 on my chip)
    RETI;was set
    RET;was not

 

Will assembly do a bit wise calculation like that or do I need to use the OP commands and put it in a register.

Last Edited: Fri. Nov 10, 2017 - 01:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

A few things:

 

1) you haven't shown POP_RETI

 

2) As you have RETI then RET presumably you meant some kind of SKIP not BRANCH

 

3) If it is really meant to be BRNE then the operand should be a label not a bit number (or even shifted bit number)

 

4) Is EIMSK in the bottom 32 registers? If so then maybe "SBIC EIMSK, 2" ?

 

5) Other wise you likely need to IN (or even LDS) from the register and then SBRC

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

SBIC was the op code I was trying to recall, been far too long, I need more ASM excuses to code...

 

Ok, yes SBIC EIMSK, 1  would be in the correct place.

bit 7 6 5 4 3 2 1 0
EIMSK INT1 INT0

 

macro POP_RETI     ; 5 cycles
    pop     YL
    out     SREG, YL
    pop     YL
endm

so I'm looking more at

 

 

sofError:
    POP_RETI                    ;macro call
    SBIC EIMSK, 1 ;if not set branch (int0 is pd2 on my chip)
    RETI;was set
    RET;was not
Last Edited: Fri. Nov 10, 2017 - 02:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which AVR? Is EIMSK in range for the SBIC opcode?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry atmega328 in this case. I believe its a global interrupt bit mask.

Last Edited: Fri. Nov 10, 2017 - 02:57 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Is EIMSK in range for the SBIC opcode?
S_K_U_N_X wrote:
I believe its a global interrupt bit mask.

???

 

"Are those shoes made of leather?"

"I believe they are brown."

 

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

Last Edited: Fri. Nov 10, 2017 - 03:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

328P data says EIMSK is 0x3D (IO 0x1D) so it should be in range of SBIC

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

YUp, I didn't not understand that question right.

 

Ok, ill give this code a try and see if this works. Thx.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In the past I have had this code at the end of a subroutine :

sei

ret

If you run both instructions it become a reti.

The instruction after sei will be executed so there won't be bigger stack use if there is a waiting ISR, the only problem could be under debug where you use that.

 

I have never disabled a ISR that way, but sometimes enabled it, (init ISR rutine by calling it).

Last Edited: Sat. Nov 11, 2017 - 10:20 AM