AQA Assembly Code

mildenhall

New Member
I currently teach AQA A Level ELectronics. One of the units is "Programmable Control Systems" where we are using a 28X1 chip. One of my students has got his program working in BASIC however now needs to convert it into AQA Exam Board Assembly Code.

He has managed lots already however we are both stumped when it comes to re-writing...

Code:
if b6 = b5 then goto main
I have tried...

Code:
movw b5
subw b6
jpz main
and get told by the standard PICAXE programming editor they we have a syntax error on movw.

I have tried movw (b5) aswell and this makes no difference at all.

Does anyone have any ideas where we are going wrong please?
 

administrator

Technical Support
Staff member
www.rev-ed.co.uk/docs/picaxe_ocr.pdf

movw is for a literal (e.g. 5)
movrw is for a register (variable e.g. b1)

but subw only works for literals aswell, there is no support for register-register in AQA instruction set (which is a reduced instruction set, it would be possible in the real world!)
 

hippy

Ex-Staff (retired)
"movw b5"

From the AQA section of http://www.rev-ed.co.uk/docs/picaxe_ocr.pdf the syntax for AQA mov instructions are ...

MOVWR R
MOVRW R
MOVW K

So in this case your student is using a "MOVW K" where K should be a constant and 'b5' is a register rather than constant. "movrw b5" ( move b5 into W ) is what is required.

Also ensure that the AQA extensions are selected for compiling; View -> Options -> Mode -> PICAXE-28X1 -> Advanced
 

mildenhall

New Member
Thanks for all your help guys!!

Right I need to use movrw....

I'm at home now, using linaxepad (I use Ubuntu at home) which doesn't support AQA assembly code :-( so can't try it out until I'm in school tomorrow.

When using SUBW b6, I intend to subtract the contents of b6 from the contents of w. From what I can remember SUBW is expecting a literal rather than a register as administrator said. Any idea how I could get round this please?

In a previous life as a design engineer I wrote firmware myself but not on such reduced instruction sets. This AQA standard code is bugging me!!

Thanks.
 
Last edited:

Technical

Technical Support
Staff member
There is no subrw command in AQA assembler. So you just can't do what you want to - all you can do is subtract a constant from W. The exam board supported commands are, deliberately, pretty restricted.

So realistically the best you can do here is insert some BASIC to do the job and say 'I would use subrw if it existed!'
 

hippy

Ex-Staff (retired)
AQA assembler is a very limited command set with only a few opcodes which work with registers and you have to jump through hoops to get some things to work, thinking quite laterally at times ...

Code:
;   Set initial values of b5 and b6

    movw  15
    movwr b5

    movw  16
    movwr b6

;   Move the values into temporary registers
;   which can be altered without changing 
;   the original values

    movrw b5
    movwr b15

    movrw b6
    movwr b16

;   Check if the two register values are 
;   the same. By decremening in tandem, when
;   one value reaches zero then so will the
;   other if they are the same value

b15decrement:

    dec   b15
    jpz   b15iszero

    dec   b16
    jmp   b15decrement

b15iszero:

    dec   b16
    jpz   equal
    jmp   notequal

;   Report when values are equal

equal:

    SerTxd( #b5, " equals ", #b6, CR, LF )
    End

;   Report when calues are not equal

notequal:

    SerTxd( #b5, " does not equal ", #b6, CR, LF )
    End
 

mildenhall

New Member
Thanks for all your help! It looks like we'll just say there is no such function. We have a lot of ifs so would take a lot of code.

Thanks again.
 
Top