Closed seblovett closed 10 years ago
will fix today
Thanks.
fixed and uploaded
Assembler now runs, but is funtctionally incorrect. It looks like the ISR is being placed at location 12 in memory, not 16. In the interrupt program, the program flow runs straight into this, and then the RETI fails and breaks the CPU.
To replicate, run sim.py -p interrupt -g
. It will stop automatically when it breaks.
fixed
Still not working. Not 100% sure what's going on, but we're ending up in the ISR when we shouldn't, causing the RETI instruction to execute and things go wrong. It seems to match up to the jump over the ISR, the Jump looks like it's going to the wrong place, or that the instruction at the jump is not correct. A BE occurs backwards, and I think that's how we end up in the ISR.
fixed that now aswell it was jumping to last line of ISR not over of it
I understand your point about the stack pointer now. I see you have pushed R0 so you can use it for the jump. However, you don't restore this. Some of the instructions are not being executed - i.e. the ENAI never gets executed. Still getting the same issue with RETI being executed too.
There is a line added after ISR "POP R0" to restore
Okay, didn't see that.
you mean ENAI on 7th line of ISR?
No the ENAI at location 13
DISI ; Reset is off anyway
LUI R7, #7
LLI R7, #208
LUI R0, #2 ; R0 is read ptr 0x0200
LLI R0, #0
ADDI R1,R0,#2 ; 0x0202
STW R1,[R0,#0] ; Read ptr set to 0x0202
STW R1,[R0,#1] ; Write ptr set to 0x0202
LUI R0,#160 ; Address of Serial control reg
LLI R0,#1
LUI R1,#0
LLI R1,#1 ; Data to enable ints
STW R1,[R0,#0] ; Store 0x001 @ 0xA001
ENAI
BR .main
.isr DISI .....
I dont see why it wouldnt. run assembler by itself in Assembler folder for interrupt.asm and see output The "After Preprocessing" list makes sense to me Lines 12-58 are from ISR placement, with 16-57 being the actual ISR
Normal program flow will go 10 -> 11 -> 59 -> 60 ->...
All instructions should be completed here up to and including 14. (in the asm) Should go 13->14->59 ... Why would instructions 12-14 be missed out?
im not talking about the .asm line numbers the output from assembler gives post processing assembly readout
Even still, I don't understand why it would jump from 11 to wherever.
Refering to After Preprossessing, not asm file 0-11 normal program 12-15 setup and perform jump over isr 16-57 ISR 58 restore register 59+ normal program
Okay, fair dos. It's currently going 14->15->43->44
(of actual hex)
ok fixed again, forgot when I wrote it that JMP was not a relative branch
Seems to be working now. Thanks
@mw92 The reason for #99 is the the isr region JMP just sets the SP to 0x7FF but this shouldn’t be hard coded in the assembler, the programmer should define this value
@mw92 I see in the assembler you look for a stack pointer setup using "LUI R7,#x \n LLI R7,#y" but I used SP in broken program which explains why that fails.
However when the SP is not set it just uses 0x07FF which could be an invalid memory address in practice. I can't think of a way to do a jump without destroying data, maybe we'll just have to keep the first 16 lines of code blank?
To jump over isr the stack pointer must be defined to an initial value, from what I understand 0x07FF is the first address in available memory so it is set to that if not defined in user's code. What do you mean by broken program? Keeping first 16 lines blank is wasteful, one alternative I can think of is setting SP to 0x0001, which will be valid so long as some memory is connected and allows enough space for one register to be saved.
But if there is no ISR, then no moving around of anything should occur surely?
SP to 1 will overwrite some of the program (unless you put some blank space in there during assembly). Maybe just doing the jump is the best way forward in the first. It's wasteful, but this gives us something to discuss in our report. And my apologies Martin, I recall us having this discussion before and me telling you not to be wasteful, however I didn't fully comprehend the issue at the time. We'll have a chat about this at 3 today.
Ive just adjusted it so the SP is set to the location in memory just after the program, if this is an invalid space the program would have no data space. Therefore would break anyway. Ive also set program to add one line ISR when there isnt one which is simply a 'RETI'.
It's broken things again.
whats it done?
Trying to work out what exactly isn't working.
In interrupt - we're going 0 -> 1 ... 15 -> 17-> ... Hits RETI and goes back to 0000.
Also "Ive just adjusted it so the SP is set to the location in memory just after the program, if this is an invalid space the program would have no data space. Therefore would break anyway. " There is nothing to say that the memory cannot be later increased. Our CPU is general purpose. It has to cope with larger and smaller memories. What if it is a Von Neumann architecture where program and data are separate?
There is no checking, was just making my point for using the address just after the program. Harvard has separate data and instruction memory, but our system can only be von neumann since there is only one connection to memory.
I was merely stating that we cannot guarantee that the location directly after the program is available. Or writable.
now changed it AGAIN so that it does not use the stack. Instead location 15 is used as a dud instruction for a temporary context save of R0. However it will throw an error if the first 11 lines manage to use every GPR.
thanks, Interrupt and Multiply are okay. Factorial and Random programs are not working still. Looking at why.
Factorial works when you don't try calculate the factorial of 2000.... My herp derp on that one!
lol well done Henry....
:) Random still isn't working though! Seeming we're getting some X's finding their way into the registers. @ashleyjr can you have a look at this. I'm wanting to do a go through of the programmers guide before the meeting.
@seblovett I'll be in labs in 10 mins
:+1: I'll save you a seat.
I dont see the problem, when I run random with sim.py it just gives a stream of random numbers
Extra thing: LSL R0,R0,#16 is allowed by the assembler
Nothing is assembling. It's a traceback, not an error code.
Get this for multiply, factorial and random:
Different for Interrupt: