assembly

General discussion on mikroPascal.
Post Reply
Author
Message
trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

assembly

#1 Post by trigstig » 16 Nov 2011 19:21

can someone help, im needing to do some inline assembly, not really getting anywhere, i just need to count to 480 in assemby been messing with a lot of code but start to get lost in the amount of decfz's and goto $ etc.
all im looking to do is the equiv of "repeat until x = 480",but its not easy, can some one give me just a pointer please? :? thanks in advance

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: assembly

#2 Post by janni » 16 Nov 2011 22:42

Which processor family?

trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

Re: assembly

#3 Post by trigstig » 16 Nov 2011 22:57

im just using a 16f84 at this point, the project is a vga sync chip, so i think
this chip is all i will need, ive used some hex from the net for a vga project, but, it doesnt
work with all monitors i have as the timing is out a bit looking on the scope, so im starting from scratch.
just need to count the lines then break out of the routine give a v sync and back to the counting again.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: assembly

#4 Post by janni » 17 Nov 2011 01:33

If all you need is 'repeat until x = 480' then why don't you just write it in mP and look at the assembly the compiler produced?

BTW, 'repeat until x = 480' comes to a comparison rather than to any counting requiring decfz's and goto $. Or do you 'count' the lines by a time delay? (In such case simply write delay_us(required_time_in_microseconds) and see what the compiler produced with the processor clock you've chosen.)

trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

Re: assembly

#5 Post by trigstig » 17 Nov 2011 15:00

hi mate,
i tried to copy the asm produced,there were 14 lines and when i debugged the code it didnt appear to do anything but loop around, i set x to 10 just to see it exit the loop when x =10.
is there something else i could try?

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: assembly

#6 Post by janni » 17 Nov 2011 15:12

Post the code you tried so we'll be able to know what do you exactly need.

trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

Re: assembly

#7 Post by trigstig » 17 Nov 2011 16:37

the pascal is






program x1;
var
x:integer;


begin
x :=0;
repeat
until x = 10;
end.

the copied asm after taking addresses out is
when debugging it just goes round and round without changing val of X

program x1;
var
x:integer;
begin
x :=0;
asm
BCF STATUS, RP1
BCF STATUS, RP0
CLRF _x
CLRF _x+1
;x1.ppas,9 :: repeat
x1_L_1:
;x1.ppas,10 :: until x = 10;
x1_L_2:
MOVLW 0
XORWF _x+1, 0
BTFSS STATUS, Z
GOTO L_main_0
MOVLW 10
XORWF _x, 0
L_main_0:
BTFSS STATUS, Z
GOTO x1_L_4
x1_L_5:
GOTO x1_L_3
x1_L_4:
GOTO x1_L_1
x1_L_3:
end;
end.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: assembly

#8 Post by janni » 17 Nov 2011 17:38

trigstig wrote:when debugging it just goes round and round without changing val of X
Well, what did you expect? x stays 0, you do not modify it inside the loop. Add inc(x) to the Pascal code, and the loop will end after x reaches set limit.

To tell the truth, I still don't really know what you want to achieve and why do you need assembly.

trigstig
Posts: 33
Joined: 05 Sep 2006 09:07

Re: assembly

#9 Post by trigstig » 17 Nov 2011 17:45

yeah sorry didnt see that, is it possible write a vga sync signal in pascal?
everyone seems to use assembly
ive always had this impression that assembly is faster than a high level language.

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

Re: assembly

#10 Post by janni » 17 Nov 2011 18:02

trigstig wrote:yeah sorry didnt see that, is it possible write a vga sync signal in pascal?
everyone seems to use assembly
That's because assembly has fully predictable timing.
ive always had this impression that assembly is faster than a high level language.
Assembly may be faster, depending on who writes it :wink: .
As I told you before, you may write needed code in Pascal, then take the resulting assembly and optimize it. At the least you'll learn how to write assembly inserts under mP.

And search the forums, somebody might have already done what you need.

Post Reply

Return to “mikroPascal General”