Making Homebrew with ASM

Discussion in '3DS - Homebrew Development and Emulators' started by [GBATemp]~IceStorm, Aug 6, 2015.

  1. [GBATemp]~IceStorm
    OP

    [GBATemp]~IceStorm Banned

    Banned
    71
    5
    Oct 29, 2013
    United States
    yo mama's house
    Hello.

    I am new to the Homebrew scene. I have a comprehensive understanding of C++ and I am starting to learn devkitpro. My question is, do you have to know both ARM assembly and a compiled language like C++ to do Homebrew or just one? If you don't need to know ARM, then why are people using it for Homebrew? What are the benefits of it? Also can you mix C++ code and ARM code that compiles and also uses an assembler?
     
  2. Rinnegatamante

    Rinnegatamante GBAtemp Psycho!

    Member
    3,127
    3,271
    Nov 24, 2014
    Italy
    Bologna

    Code you see in ASM is for ARM9.
    You can write regular homebrews (ARM11) in C/C++ through devkitpro using ctrulib.
     
  3. [GBATemp]~IceStorm
    OP

    [GBATemp]~IceStorm Banned

    Banned
    71
    5
    Oct 29, 2013
    United States
    yo mama's house
    Oh. What functionality do both ARM9 and ARM11 processors provide? Why is only the ARM9 written with ARM asm code?
     
  4. UraKn0x

    UraKn0x Official senpai

    Member
    360
    268
    Mar 20, 2014
    France
    The ARM9 core is mainly used by the operating system of the 3DS. The code you see in ASM is mainly exploit code or assimilated to exploit, for example a CFW launcher.
    There is no interest in writing homebrew for the ARM9 core apart from using privileged commands, such as booting the firmware. For a "normal" homebrew you'll only ever need ARM11.
    Of course you can write ASM code for the ARM11 core but this is mainly useless unless you're doing very specific operations on which you need to control EXACTLY what's happening on your 3DS, and you can also write C/C++ (Not sure for C++) for the ARM9 core, but given why this core is used, you'll mainly write ASM code for it.
     
  5. Jim_e

    Jim_e Advanced Member

    Newcomer
    79
    41
    Nov 13, 2007
    United States
    The benefits of ASM for ARM11 is generally more speed, for the ARM9 it's privileged access. On the 3ds the ARM11 is just barely fast enough to do most of what you want.

    You don't need to know or use ASM to do homebrew. You don't need to know ASM to use ASM functions in fact, you can probably find some well written ARM ASM functions that could speed up code floating around on the internet. But understanding ASM can give you an understanding on how to optimize your code. Many people make the mistake of thinking that making C++ code look smaller and cleaner produces faster code, but that's not generally the case.

    If you're interested in ASM, Steam has a programming game called TIS-100 based on a massively parallel accumulator processor. It's pretty cool, and can definitely give you a feel of asm.
     
  6. [GBATemp]~IceStorm
    OP

    [GBATemp]~IceStorm Banned

    Banned
    71
    5
    Oct 29, 2013
    United States
    yo mama's house
    Thank you for your quick replies

    @Jim_e
    Thank you for you answer. However, I would feel more comfortable learning assembly from a traditional textbook rather than a game
     
  7. nop90

    nop90 GBAtemp Maniac

    Member
    1,437
    2,138
    Jan 11, 2014
    Italy
    Rome
    If you want develop an homebrew for 3DS, stat doing it in c/c++.

    If you want to learn arn asm, search a tutorial online (there are really good ones) and start studying it, but leave the udea of writing homebrews for the moment.

    Both the thing need a large amount of knowledge so keep focused on learning well only one at a time
     
  8. [GBATemp]~IceStorm
    OP

    [GBATemp]~IceStorm Banned

    Banned
    71
    5
    Oct 29, 2013
    United States
    yo mama's house
    Thanks. After I have learned ARM, how can I apply my programming knowledge to the 3DS? Like what functions/ libraries/ assemblers/ compilers should I use?
     
  9. Jim_e

    Jim_e Advanced Member

    Newcomer
    79
    41
    Nov 13, 2007
    United States
    GCC will build asm files. If you are using Devkitpro, just place the .S files in the src folder and they will build. Normal C header files can reference any functions in the .S.

    Be aware, assembly is not easy, and bad assembly is worse than bad C. Unfortunately I'm not aware of any good assembly books for ARM(many will target specific markets such as smart phones or low power embedded devices). If you are interested in a reasonably concise example, CTRULIB's gpu example implements a simple memcpy routine using asm. It should show you how to make a S file and how to use the ASM function from C.

    Also TIS-100 was a game recommendation, not a resource for learning.