flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Non-x86 architectures > Learning ARM Assembler

Author
Thread Post new topic Reply to topic
m3ntal



Joined: 08 Dec 2013
Posts: 296
Learning ARM Assembler
How 2 Learn?

Search for "ARM assembler beginner tutorial".

* ARM's V6/V7/V8 technical manuals (PDF). Complete instructions reference.
* DaveSpace - Easy introduction to ARM Assembler (<=v4) for beginners
* Tonc: ARM+GBA - Good ARM GBA tutorials
* Simple-Machines: ARM Instruction Set PDF - Clear, concise reference to basic instructions
* Alex Chadwick's OS Tutorials for Raspberry PI - Introduction to OS programming for beginners. Most hobbyist OS distributors (example: Dex/team) use his graphics code and USB 1.0 driver that was written in C. (PS: Dex doesn't write "his" own code. He just takes/accepts credit/praise for everyone else's work).

Tip: Save all PDFs+HTMLs for offline/tablet/phone viewing then backup to drives/cards (example: "X:\PROGRAMMING\TUTORIALS\ARM\").

Programs for ARM Development

* FASMARM Assembler - Help, source, minimal examples for ARM Windows Mobile and Linux. See ReadMe.txt

* Magic-ARM Assembler - An assembler created with FASM's preprocessor.

* Magic-ARM Compiler - Source, examples, graphics and minimal text/font library (DRAW.INC, FONT.INC), instruction encodings and information documented in the source code (from ARM's exhaustive technical manuals), ARM macro language, .if/.while/.repeat, pointer arithmetic: . (u32) *r0++=*r1++

* D-ARM7 Disassembler - Fast & easy to use: Drag & drop, select file and command line. No setup. Customizations. Same format as FASMARM. Source, tests, examples, .BAT scripts.

How 2 Practice?

Practice by writing your own library: Memory (memset, memcpy, etc), text/string (strlen, strcpy, strcat, strcmp, strchr, etc), number conversions, graphics routines (pixel, line, bitmap, 3D objects), font, console, UI.

OS specific code - file I/O and device input - should be written in a general portable fashion with the OS details disguised in macros. Try to use common names that most programmers will recognize: fopen, fcreate, fputs, OpenFile, WriteText, CloseFile and so on.

How to Run Code/Examples?

QEMU

Supports all kinds of CPUs, devices, embedded systems, including "versatile express" platform, Angel-ARM semi hosting (standard interrupt services: SWI/SVC #), ARM PrimeCell PL110 Color LCD Controller, Gumstix Connex, Verdex and much more.

GameBoy Advance: VisualBoy Advance

Visual customizable ARM emulator. Fastest way that I know of to test ARM code, text, graphics, UI, animation and input. From source to execution in 2-3 seconds: In FASM, press F9 to assemble/etc, switch to VBA then press F1/F9 to reload previous file (assuming you've opened it once before).

* Advantages: Easy for beginners. Emulators for Android, Linux, Consoles. Input: 10 buttons total: 4 directions, 4 buttons, select, start. Mouse can be simulated. File I/O is memory-mapped "save state". Settings: *.GBA files can be associated to open with VBA: Options>Emulator>Associate. In Tools>Options, FileRecent01 can be set to F9 to reload previous file. F1 is the default. Redistributable, only 3 files, <2MB.

* Disadvantages: Low resolution: 240x160/160x128. No keyboard, but it is possible to emulate by assigning button combinations to keys: 10 buttons = 1024 configurations. Then make a program that runs in the background and sends 10BIT key messages to the emulator.

Overall, good choice for learning ARM assembler.

Windows Mobile/CE: Microsoft Device Emulator

* Advantages: Predefines memory, file I/O, graphics, input, controls, UI, networking, etc.

* Disadvantages: Mobile/CE is now deprecated. Still on some Chinese Android/CE laptops. Emulator is slow startup/reset (7-10+ seconds here), API is unicode with no A/SCII equivalents and the functions to convert them are not user-friendly.

Setup: Set "Shared Folder" as the one containing \FASM\ with examples and it will appear in "File Explorer as "Storage Card". While inside of this folder, save the emulator state to return here to after startup/reset/crash.

Please post any ARM information that has helped you.
Post 10 Dec 2013, 09:54
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1209
Location: Greece
Re: Learning ARM Assembler

m3ntal wrote:
GameBoy Advance: VisualBoy Advance

Visual customizable ARM emulator. Fastest way that I know of to test ARM code, text, graphics, UI, animation and input. From source to execution in 2-3 seconds: In FASM, press F9 to assemble/etc, switch to VBA then press F1/F9 to reload previous file (assuming you've opened it once before).


GBA Metal Code by krom (Peter Lemon).
Compile with FASMARM, run in VisualBoy Advance.
Many examples to try.
https://github.com/PeterLemon/GBA

GBA Graphics Library.
https://board.flatassembler.net/topic.php?t=11721

GBA tutorial
http://patater.com/gbaguy/gbaasm.htm


Code:

; Showing a picture (FASMARM)
; http://patater.com/gbaguy/gba/ch4.htm
; http://www.gbadev.org/tools.php?showinfo=167

format binary
org 0

main:
    mov r0, #0x4000000
    mov r1, #0x400
    add r1r1, #3
    strh r1, [r0]

    mov r0, #0x6000000
    adr r1pic
    mov r2, #0x960

align 4
loop1:
    ldmia r1!, { r3,r4,r5,r6,r7,r8,r9,r10 }
    stmia r0!, { r3,r4,r5,r6,r7,r8,r9,r10 }
    subs r2r2, #1
    bne loop1

align 4
infin:
    b infin

align 4
pic:
    file "pic.bin"




Image


Last edited by Picnic on 10 Dec 2016, 15:55; edited 1 time in total
Post 10 Dec 2016, 15:21
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15233
Location: 1I/ʻOumuamua
I would suggest that you use the processor directive to customise the assembly output for the specific CPU. Otherwise you can get instruction encodings that are invalid on your CPU.
Post 10 Dec 2016, 15:54
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1209
Location: Greece
A wise forum member has already suggest...
Post 10 Dec 2016, 16:08
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15233
Location: 1I/ʻOumuamua

Picnic wrote:
A wise forum member has already suggest...

Indeed. And very few people feel the need to use it. Sad
Post 10 Dec 2016, 16:14
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6628
Location: Kraków, Poland
Has any of you tried to use a rewritable flash cartridge to run such snippets on the actual hardware? I have a GBA lying around and I'm curious how much trouble would that require.
Post 11 Dec 2016, 13:50
View user's profile Send private message Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1209
Location: Greece
I have not tried, the emulator is my first experience with the GBA.
Now i saw that used GBA's are still around and not expensive.
Post 12 Dec 2016, 20:46
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.