Page 1 of 3 123 LastLast
Results 1 to 10 of 26

Thread: Learning ASM

  1. #1

    Default Learning ASM

    So me and AH are learning ASM now, and we've sort of figured some of it out, but there's problems when we tried to actually make a code.

    So to start out, it's a really basic code. Slot cycler (U 1.0)

    it should add 1 to whatever's in slot 1 (or so I thought)

    Code:
    ldr r0,=0x021D88FE
    add r1,r0,#1
    str r1,[r0]
    bx  r14
    and with comments (yay )
    Code:
    ldr r0,=0x021D88FE	; store slot one in r0
    add r1,r0,#1		; r1 = r0 + 1
    str r1,[r0]			; load r1 into r0
    bx  r14				; end the branch
    and so the ARDS comes out as
    Code:
    023FF090 012FFF11
    E0000000 00000014
    E59F0008 E2801001
    E5801000 E12FFF1E
    021D88FE 00000000
    023FF090 E3520003
    I put an R activator on it

    so anyway, it work sort of... except it doesn't add 1 to the item...
    I typed in 0019 in text to item to get a blue rose seed, then I checked (the blue rose seed was there)
    then I tapped R and...
    *poof* my blue rose seed had changed into an item with no name

    I also tried making FFF0 into FFF1... but it just changed it into who knows what

    EDIT: I also tried this one now:

    Code:
    ldr r0,=0x021D88FE
    ldr r1,[r0]
    add r1,#1
    str r1,[r0]
    bx  r14
    getting this:

    Code:
    94000130 FEFF0000
    023FF090 012FFF11
    E0000000 00000018
    E59F000C E5901000
    E2811001 E5801000
    E12FFF1E 021D88FE
    023FF090 E3520003
    D2000000 00000000
    and it gave me the same results... :/


    I'm about to try this one:

    Code:
    ldr r0,=0x021D88FE
    ldr r0,[r0]
    add r1,r0,#0x1
    str r1,[r0]
    bx  r14
    Code:
    94000130 FEFF0000
    023FF090 012FFF11
    E0000000 00000018
    E59F000C E5900000
    E2801001 E5801000
    E12FFF1E 021D88FE
    023FF090 E3520003
    D2000000 00000000
    does that seem more right?

    EDIT 2: that didn't work either, that just made no modifying to it at all
    This is my siggy. I'll make it better when I stop being lazy

  2. #2
    J.P. (Global Moderator) Maniac's Avatar
    Join Date
    Sep 2007
    Location
    Ohio, USA
    Posts
    2,083
    Blog Entries
    5

    Default Re: Learning ASM

    Code:
    ldr r0, Slot
    ldrh r2,[r0]
    add r1,r0,#0x1
    strh r1,[r0]
    bx  lr
    
    Slot:
    .long 0x021D88FE
    Or how you had it...
    Code:
    ldr r0, =0x021D88FE
    ldrh r2,[r0]
    add r1,r0,#0x1
    strh r1,[r0]
    bx  r14
    It does the same thing, the other way is just for organization and how I'm use to seeing things.

    Try that. :P If it doesn't work I'll have to put another register in.

    Say what you mean, mean what you say, and let your actions speak for you.


  3. #3

    Default Re: Learning ASM

    ah! thank you! I didn't think to use half words! (ok, I did for a sec but didn't know the command :P)

    but! it still didn't work :P

    I'm trying this one now:
    Code:
    ldr r0,=0x021D88FE
    ldrh r2,[r0]
    add r1,r2,#0x1
    strh r1,[r0]
    bx  r14
    but it didn't work either
    This is my siggy. I'll make it better when I stop being lazy

  4. #4

    Default Re: Learning ASM

    i take it lrdh is load half word

    But it still doesn't explain why its adding so much :S

    Remember to always click the thanks button of those who help you! It makes them feel wanted:

  5. #5
    Chris (Administrator) Vash's Avatar
    Join Date
    Sep 2007
    Location
    Teh Interwebz
    Posts
    1,992
    Blog Entries
    27

    Default Re: Learning ASM

    Hm, have you watched the value change when you're using the code? Try an activator. When I use ldrh for a half word, it's putting the bytes in reverse order. Make sure the bytes are in the correct order when you're using ldrh.
    Animal Crossing: City Folk
    ACToolkit - NPC_Tool - PattView

  6. #6

    Default Re: Learning ASM

    Code:
    ldr r0,=0x021D88FE
    ldrh r2,[r0]
    add r2,#0x1
    strh r2,[r0]
    bx  r14
    Doesn't add automatically add one to the last byte?

    *joes to test it with furniture*

    Ah ha! I found the problem (I hope) but it's a different problem
    For some reason, it seems to loop even though I have a terminator!

    I put in 3000, and I tested this code a few times. My results were that it added:
    0xCC-0xCF
    0x74-0x77
    0x2C-0x2F

    each time I tapped L and R quicker than the time before...
    so that means the code does work, but it loops for some reason >_>

    The code I am using for it is:
    Code:
    94000130 FCFF0000
    023FF090 012FFF11
    E0000000 00000018
    E59F000C E1D020B0
    E2822001 E1C020B0
    E12FFF1E 021D88FE
    023FF090 E3520003
    D2000000 00000000
    shouldn't that not loops because of the terminator though?
    This is my siggy. I'll make it better when I stop being lazy

  7. #7
    Chris (Administrator) Vash's Avatar
    Join Date
    Sep 2007
    Location
    Teh Interwebz
    Posts
    1,992
    Blog Entries
    27

    Default Re: Learning ASM

    add = register + #immediate.

    I'm definitely not the person to be asking but as I understand it, yours adds #0x1 to the address. ex. 0x02000000 goes to 0x02000001. I could be wrong.

    Here's an example from one of my ASM codes I'm working on:

    Code:
    ldr r0, =0x021ECB88
    add r0,#1
    strb r2, [r0]
    That takes the address, changes it to 0x021ECB89 then stores one byte from r2 to that address.
    Animal Crossing: City Folk
    ACToolkit - NPC_Tool - PattView

  8. #8

    Default Re: Learning ASM

    I don't wanna change the address, I wanna change what's in it, and it actually is doing that :P

    here's what mine does:

    ldr r0,=0x021D88FE <- takes the address
    ldrh r2,[r0] <- takes what's stored in the address
    add r2,#0x1 <- adds one to what's stored in the address
    strh r2,[r0] <- stores it back in the address
    bx r14


    maybe it's a problem with the activator?
    This is my siggy. I'll make it better when I stop being lazy

  9. #9
    Chris (Administrator) Vash's Avatar
    Join Date
    Sep 2007
    Location
    Teh Interwebz
    Posts
    1,992
    Blog Entries
    27

    Default Re: Learning ASM

    Haha, see? I was wrong

    Anywho, I'd wait for Maniac or Toe to check out your problem. Seems like it should work to me...
    Animal Crossing: City Folk
    ACToolkit - NPC_Tool - PattView

  10. #10

    Default Re: Learning ASM

    pretty much, it works right in adding one to whatever's in slot one, but it keeps doing it over and over the longer you're holding down the activator :/

    how do we fix that?

    Quote Originally Posted by Vash
    Hm, have you watched the value change when you're using the code? Try an activator. When I use ldrh for a half word, it's putting the bytes in reverse order. Make sure the bytes are in the correct order when you're using ldrh.
    that's because of how it stores words and halfwords and bytes, it's backward :P
    bx = byte number

    4 bytes:
    0xb1 0xb2 0xb3 0xb4

    2 halfwords:
    0xb2b1 0xb4b3

    1 word:
    0xb4b3b2b1


    (sorry if I showed that wrong, I can't quite remember but that looks right >_> )

    but assuming that's right, pretend you say Hello me
    space will be represented by _ and every two letters will be a byte
    you get it this way in bytes:
    H e l l o _ m e
    this way in halfwords:
    eH ll _o em
    and this way as words:
    lleH em_o
    assuming you wanna go up to dwords, you get:
    em_olleH

    the phrase in reverse
    This is my siggy. I'll make it better when I stop being lazy

Posting Permissions

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