flat assembler
Message board for the users of flat assembler.

Index > Tutorials and Examples > ARM Example + Emulation for PL110

Author
Thread Post new topic Reply to topic
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 29 Jul 2013, 10:40
For learning ARM assembler: 2 small ARM examples + QEMU emulator for the ARM PrimeCell PL110 Color LCD Controller: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0161e/I904755.html

A fast, easy way to test ARM code+graphics in under 5 seconds without an expensive simulator. No setup required. To test an example, click the corresponding *.BAT. For some reason, QEMU runs the examples most (70%?) of the time, but not always. If QEMU appears with a black screen ("[Stopped]"), close and try again 1-3 times.

Download: Click Here

Image
Image
Have fun! Cool
Post 29 Jul 2013, 10:40
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 29 Jul 2013, 11:09
Previews of recent projects: ARM Visual Reference and Future Macro Language:

Image

Click to Enlarge:

ARM VR: http://sungod777.zxq.net/arm.jpg
Future ML: http://sungod777.zxq.net/fml.jpg


Last edited by uart777 on 10 Aug 2013, 09:25; edited 1 time in total
Post 29 Jul 2013, 11:09
View user's profile Send private message Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 618
cod3b453 29 Jul 2013, 17:08
Thanks for sharing this. As it happens, I was wondering today how you'd put something like this together - I hadn't realised there was a qemu for ARM - but I doubt I'll try porting my "OS" Laughing
Post 29 Jul 2013, 17:08
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 29 Jul 2013, 19:26
cod3b453: And thanks for your contributions. QEMU supports various CPUs: Intel, ARM, MIPS, PPC, etc.

Noticed one mistake: At the end of DRAW.INC, forgot align 4 before name:
Code:
; create image file/s+structure/s...

macro IMAGE [p] {
common
 local w, h
forward
 match name==f, p \{
  align 4
  name\#.file: file \
   'IMAGE\'\#\`f\#'.IMAGE'
   load w word from name\#.file+2
   load h word from name\#.file+6
  align 4
  name:
   .p dw name\#.file+16
   .x dw (SCREEN.W/2)-(w/2)
   .y dw (SCREEN.H/2)-(h/2)
   .w dw w
   .h dw h
 \}
}    


Last edited by uart777 on 06 Aug 2013, 14:57; edited 1 time in total
Post 29 Jul 2013, 19:26
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 01 Aug 2013, 06:23
Future Macro Language:
Code:
. r0=0, r1=3, while r0<r1, r0++, endw
. r0=0, r1=3, repeat r1, r0++, endr
. loop r0=0 to r1, r2++, endl

. (i8) *r0=*r1, (u8) *r0=*r1++
. (i16) *r0++=*r1, (u16) *r0++=*r1++
. (i32) r0=*r1++, (u32) *r0++=r1    


Last edited by uart777 on 08 Aug 2013, 23:45; edited 1 time in total
Post 01 Aug 2013, 06:23
View user's profile Send private message Reply with quote
uart777



Joined: 17 Jan 2012
Posts: 369
uart777 08 Aug 2013, 23:45
New dialog design last night: "Create New Project".

Image

String functions...
Code:
; Future Macro Language...

function strlen(s)
. r0=s, r1=r0
. while (i8) *r0++, endw
. r0-r1, r0--
endf

function strcpy(a, b)
. r0=a, r1=b
. while (i8) *r1
 . (i8) *r0++=*r1++
. endw
. r0--, (i8) *r0=0
endf

function strcat(a, b)
. strlen(a), r0+a, strcpy(r0, b) 
endf    


Written in direct ARM assembler (no macros):
Code:
; strlen(s) - get string length

strlen:
stmfd sp!, { lr }
mov a2, a1
@@:
 ldrb a3, [a1], 1 ; a3=*a1++
 tst a3, a3       ; until 0
bne @b
sub a1, a1, a2    ; return n (a1=a1-a2-1)
sub a1, a1, 1
ldmfd sp!, { pc }

; strcpy(a, b) - string copy

strcpy:
stmfd sp!, { lr }
@@:
 ldrb a3, [a2], 1 ; a3=*a2++
 strb a3, [a1], 1 ; *a1++=a3
 tst a3, a3       ; until 0
bne @b
sub a1, a1, 1     ; return end
mov a3, 0
strb a3, [a1]
ldmfd sp!, { pc }

; strcat(a, b) - string concencate

strcat:
stmfd sp!, { lr }
mov v1, a1
mov v2, a2
bl strlen
add a1, a1, v1
mov a2, v2
bl strcpy
ldmfd sp!, { pc }    

Portable syntaxes generate optimized code for X86 + ARM:
Code:
; . (i8) *r0++=*r1++

movsx ebx, byte [ecx] ; X86...
inc ecx
mov byte [eax], bl
inc eax

ldrsb r10, [r1], 1 ; ARM...
strb r10, [r0], 1    


Preview in CodeVu with highlighted syntax+keywords:

Image
Post 08 Aug 2013, 23:45
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.