Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 33

Thread: FPC4GBA vs GPC4GBA :P

  1. #21

    FPC4GBA vs GPC4GBA :P

    The save into r8 should be a proper save, unless the compiler expects you to save r8 which you destroy. Hmmm.... I'm going need take a look at the code myself, you can send me the code if you wish so... If no time tomorrow though.

    In the meantime, please compare a version with the "mod" defined as function in the program and when it is in the RTL. Can you see differences?

  2. #22

    FPC4GBA vs GPC4GBA :P

    Quote Originally Posted by dmantione
    The save into r8 should be a proper save, unless the compiler expects you to save r8 which you destroy. Hmmm.... I'm going need take a look at the code myself, you can send me the code if you wish so... If no time tomorrow though.

    In the meantime, please compare a version with the "mod" defined as function in the program and when it is in the RTL. Can you see differences?
    Looking at the compiler generated .s files I can find some small differences, mainly dues to different implementation, I think.
    This comes from function version:
    Code:
    # [41] c := modulus((i * j), 31);
    	mov	r1,#31
    	# Register r0 allocated
    	mov	r0,r4
    	# Register r2 allocated
    	mov	r2,r5
    	# Register r0,r2 released
    	# Register r0 allocated
    	mul	r0,r2,r0
    	# Register r2,r3,r12,r13,r14,r15 allocated
    	bl	P$FILLSCREEN_FPC_MODULUS$LONGINT$LONGINT$$LONGINT
    	# Register r1,r2,r3,r12,r13,r14,r15,r0 released
    	mov	r6,r0
    	# Register r0 allocated
    # [43] VideoBuffer[j + 240 * i] := c;
    and this other one comes from rtl version:
    Code:
    # [39] c := (i * j) mod 31;
    	mov	r0,r4
    	# Register r2 allocated
    	mov	r2,r5
    	# Register r0,r2 released
    	# Register r1 allocated
    	mul	r1,r2,r0
    	# Register r0 allocated
    	mov	r0,#31
    	# Register r2,r3,r12,r13,r14,r15 allocated
    	bl	fpc_mod_longint
    	# Register r1,r2,r3,r12,r13,r14,r15,r0 released
    	mov	r6,r0
    	# Register r0 allocated
    # [43] VideoBuffer[j + 240 * i] := c;
    This is the 'modulus' function:
    Code:
    .globl	P$FILLSCREEN_FPC_MODULUS$LONGINT$LONGINT$$LONGINT
    P$FILLSCREEN_FPC_MODULUS$LONGINT$LONGINT$$LONGINT:
    # Temps allocated between r11-44 and r11-44
    	# Register r13,r11,r12 allocated
    	mov	r12,r13
    	stmfd	r13!,{r11,r12,r14,r15}
    	sub	r11,r12,#4
    	# Register r12 released
    	sub	r13,r13,#44
    # Var number located in register
    # Var denom located in register
    # Temp -44,4 allocated
    # Var $result located at r11-44
    	# Register r0,r1,r2,r3,r12,r13,r14,r15 allocated
    # [27] swi #0x060000
    	swi	#393216
    # [28] mov r0, r1
    	mov	r0,r1
    	# Register r0,r1,r2,r3,r12,r13,r14,r15 released
    # Temp -44,4 released
    	ldmea	r11,{r11,r13,r15}
    	# Register r0 released
    .Le0:
    	.size	P$FILLSCREEN_FPC_MODULUS$LONGINT$LONGINT$$LONGINT, .Le0 - 
    P$FILLSCREEN_FPC_MODULUS$LONGINT$LONGINT$$LONGINT
    It does some "strange" things with r11, r12 and r13 that i can't understand (maybe something related to stack, given that r13 is the stack pointer?).

    I can zip all rtl sources and this small example and send it to your mailbox, if you want.
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  3. #23

    FPC4GBA vs GPC4GBA :P

    I think I see the problem! :twisted:

    Function:
    Code:
       mul   r0,r2,r0  # In other words: the function stores i*j in r0
       bl   P$FILLSCREEN_FPC_MODULUS$LONGINT$LONGINT$$LONGINT
    RTL:
    Code:
      mov r0,#31  # In other words, the rtl stores #31 in r0
      bl   fpc_mod_longint
    In other words, the parameters are reversed!!

    Try this:

    [pascal]
    function fpc_mod_longint(n,z: longint):longint; compilerproc; assembler; [public, alias: 'FPC_MOD_LONGINT'];
    asm
    ; Reverse the parameters!
    mov r2,r0
    mov r0,r1
    mov r1,r2
    ; Do software interrupt.
    swi #0x060000
    mov r0, r1
    end['r0','r1','r2','r3'];
    [/pascal]

  4. #24

    FPC4GBA vs GPC4GBA :P

    YAY!!! It works!!! :mrgreen: :mrgreen: :mrgreen:
    You, THE genius! :clap:

    In other words, I don't understand ASM :lol:

    Thanks alot, Daniel. I should offer a beer to you ^_^
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  5. #25

    FPC4GBA vs GPC4GBA :P

    So any screen shots or something to show working?
    <br /><br />There are a lot of people who are dead while they are still alive. I want to be alive until the day I die.<br />-= Paulo Coelho =-

  6. #26

    FPC4GBA vs GPC4GBA :P

    Quote Originally Posted by savage
    So any screen shots or something to show working?
    Oh, well... nothing so fun to show. I only have this screenshot:



    The code is tacken from an example on Mr. Harbour's book. The interesting thing is that now fpc executable runs faster than the gcc one

    BTW, I have found a nice trick for swapping two registers without involving a third one:
    Code:
      eor r0, r0, r1
      eor r1, r1, r0
      eor r0, r0, r1
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  7. #27

    FPC4GBA vs GPC4GBA :P

    Work goes on... I have discovered why the 2 registers for mod are swapped: in thumb mode it should be used SWI 6 (r0->number, r1->denom); in arm mode SWI 7 (r1->number, r0->denom). So, no need to swap registers... I only have mistaken SWI ops:

    BTW, now I have some problems with asm 'dialect' in fpc. Seems like it is not so much standard compliant. For example, it does not understand asm comments (@, but pascal ones (//); labels should always start with .L; in some cases, asm code that works in gas is not understood by fpc:

    Code:
    mov 	r0, #0x4000006
    generates an "invalid constant" error;

    Code:
    mov    r0, r0, lsl #0x10
    generates an obscure "internal error 200501051"; elsewhere 'lsl' is an invalid opcode. My asm skills are near to 0, so probably I'm doing something wrong in the code. :?:
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  8. #28

    FPC4GBA vs GPC4GBA :P

    This is really a question for Florian. The second one is definately a bug, so feel free to submit one. The first one I don't know, perhaps try to use Pascal syntax, $ instead of ox? Anyway, please ask Florian what to do here.

  9. #29

    FPC4GBA vs GPC4GBA :P

    Quote Originally Posted by Legolas
    Code:
    mov 	r0, #0x4000006
    generates an "invalid constant" error;
    Oh, I respond by myself: ARM does not allow to load any value in a register, but only (8 bit value) << (x*2) values, according with this faq.
    About the other question, I have submitted a bug report, so I'm waiting for a fix.

    In the meanwhile I'm trying to make some nicer-to-look demos, hoping that this can attract more people joining fpc4gba project...
    Get your fpc4gba copy now!
    Get your fpc4nds copy now!

  10. #30

    FPC4GBA vs GPC4GBA :P

    Just a suggestion, you're posting news on your own site. There is nothing wrong with that, but the FPC4GBA url is a little more published. It is there where you need to show the world your progress.

Page 3 of 4 FirstFirst 1234 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •