Good day! Can someone check my code for mistakes? And, if there are mistakes, help me to fix it. This procedure should swap bits in R0 and be 'effective'.
//'n' is bit, that procedure should swap with 'm' n equ 1 m equ 4 push R0 call swap swap: pop R0 push A mov 20h, R0 mov C, 20h.n mov 21h.0, C mov C, 20h.m mov 20h.n, C mov C, 21h.0 mov 20h.m, C mov R0, 20h pop A RET
Have you checked it yourself?
eg, Have you run it in the Simulator to see that it does what you wanted ?
If you want others to check it, you should provide comments which describe what you expect it to do.
I can't use simulator right now, but I need someone to check it :(
Why not??
Haven't PC right now, but I need this code without mistakes :( In my university (Russia) we programming asm on paper, without PC, so...
Since this code snippet is a procedure and the Carry bit is changed it should be saved at entry and restored at exit, Carry is in PSW. Except if you use the Carry bit as status information to the caller. ...
Thank you very much!
So also simulate it on paper without the PC!
Draw columns (or use squared paper) to record each register & memory location before & after each instruction.
www.avrfreaks.net/.../2539006
www.avrfreaks.net/.../1383161
This is how we did it at school - called a "dry run"
Nowadays, you could save some of the manual effort by using a spreadsheet ...
It seems that some still do:
teachinglondoncomputing.org/.../
My first computer programs were written and run on paper; back in 1977. But then the 4004 was way out of reach of my pocket money.