flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2, 3, 4 |
Author |
|
kalambong 04 Sep 2012, 04:51
http://www.cl.cam.ac.uk/freshers/raspberrypi/tutorials/os/
University of Cambridge is offering a 12-step online course on Ras-Pi The course, Baking Pi - Operating Systems Development, is aimed at students of 16 and over with some prior programming experience, "although younger readers may still find some of it accessible, particularly with assistance" |
|||
![]() |
|
krom 04 Sep 2012, 17:03
Hi All,
I am releasing my Mandelbrot fractal code as it will show you how to turn on the Floating Point unit of the Raspberry Pi. Rename this source code to kernel.asm and compile it with FASMARM to create a 408byte kernel.img file =D Code: ; Raspberry Pi 'Bare Metal' Mandelbrot Fractal Demo: ; 1. Turn on Vector Floating Point Unit ; 2. Setup Frame Buffer ; 3. Plot Fractal using Double-Precision ; ; Developers: ; Dex (Craig Bamford) - Original Frame Buffer Code ; krom (Peter Lemon) - Optimized Frame Buffer & Fractal Code ; ; Thanks to revolution for the FASMARM Assembler: http://arm.flatassembler.net/ ; ; To Run: ; Copy kernel.img to SD-Card (bootcode.bin, loader.bin, start.elf are also required) ; For best results create a config.txt file that contains the line: disable_overscan=1 ; ; For HDMI video output you can add config.txt lines to force a specific HDMI mode: ; hdmi_group=2, hdmi_mode=16 format binary as 'img' ; Setup Frame Buffer SCREEN_X = 640 SCREEN_Y = 480 BITS_PER_PIXEL = 32 ; Setup VFP VFPEnable = $40000000 VFPSingle = $300000 VFPDouble = $C00000 org $8000 ; Enable Vector Floating Point Calculations mrc p15,0,r0,c1,c0,2 ; R0 = Access Control Register orr r0,VFPSingle + VFPDouble ; Enable Single & Double Precision mcr p15,0,r0,c1,c0,2 ; Access Control Register = R0 mov r0,VFPEnable ; Enable VFP fmxr fpexc,r0 ; FPEXC = R0 FB_Init: adr r0,FB_STRUCT orr r0,1 ; MAIL_FB ldr r1,[MB_WRITE] str r0,[r1] ; Mail Box Write MBox_Read: ldr r1,[MB_READ] ldr r0,[r1] and r0,$F ; Load Channel Number cmp r0,1 ; Compare Frame Buffer Channel 1 bne MBox_Read ; Wait For Frame Buffer Channel 1 Data ldr r0,[FB_POINTER] ; R0 = Frame Buffer Pointer cmp r0,0 ; Compare Frame Buffer Pointer to Zero beq FB_Init ; IF Zero Re-Initialize Frame Buffer ldr r1,[LAST_PIXEL] add r0,r1 ; R0 = Frame Buffer Pointer Last Pixel mov r1,SCREEN_X ; Load Double Screen X fmsr s31,r1 fsitod d0,s31 ; D0 = X% fcpyd d2,d0 ; D2 = SX mov r1,SCREEN_Y ; Load Double Screen Y fmsr s31,r1 fsitod d1,s31 ; D1 = Y% fcpyd d3,d1 ; D3 = SY fldd d4,[XMAX] ; D4 = XMax fldd d5,[YMAX] ; D5 = YMax fldd d6,[XMIN] ; D6 = XMin fldd d7,[YMIN] ; D7 = YMin fldd d8,[RMAX] ; D8 = RMax fldd d9,[ONE] ; D9 = 1.0 ldr r12,[COL_MUL] ; R12 = Multiply Colour LoopY: fcpyd d0,d2 ; D0 = X% LoopX: fsubd d10,d4,d6 ; CX = XMin + ((X% * (XMax - XMin)) / SX) fmuld d10,d0 fdivd d10,d2 faddd d10,d6 ; D10 = CX fsubd d11,d5,d7 ; CY = YMin + ((Y% * (YMax - YMin)) / SY) fmuld d11,d1 fdivd d11,d3 faddd d11,d7 ; D11 = CY mov r1,192 ; R1 = IT (Iterations) fsubd d12,d12 ; D12 = ZX fsubd d13,d13 ; D13 = ZY Iterate: fmuld d14,d13,d13 ; XN = ((ZX * ZX) - (ZY * ZY)) + CX fmscd d14,d12,d12 faddd d14,d10 ; D14 = XN fmuld d15,d12,d13 ; YN = (2 * ZX * ZY) + CY faddd d15,d15 faddd d15,d11 ; D15 = YN fcpyd d12,d14 ; Copy XN & YN To ZX & ZY For Next Iteration fcpyd d13,d15 fmuld d14,d12,d12 ; R = (XN * XN) + (YN * YN) fmacd d14,d13,d13 ; D14 = R fcmpd d14,d8 ; IF R > 4 THEN GOTO Plot fmstat bgt Plot subs r1,1 ; IT -= 1 bne Iterate ; IF IT != 0 THEN GOTO Iterate Plot: mul r1,r12 ; R1 = Pixel Colour orr r1,$FF000000 ; Force Alpha To $FF str r1,[r0],-4 ; Store Pixel Colour into the Frame Buffer fsubd d0,d9 ; Decrement X% fcmpzd d0 fmstat bne LoopX ; IF X% != 0 LoopX fsubd d1,d9 ; Decrement Y% fcmpzd d1 fmstat bne LoopY ; IF Y% != 0 LoopY Loop: b Loop XMAX: dd 1.0 YMAX: dd 1.0 XMIN: dd -2.0 YMIN: dd -1.0 RMAX: dd 4.0 ONE: dd 1.0 COL_MUL: dw $231AF9 ; Multiply Colour LAST_PIXEL: dw (SCREEN_X * SCREEN_Y * (BITS_PER_PIXEL / 8)) - (BITS_PER_PIXEL / 8) MB_READ: dw $2000B880 ; PERIPHERAL_BASE + MAIL_BASE + MAIL_READ MB_WRITE: dw $2000B8A1 ; PERIPHERAL_BASE + MAIL_BASE + MAIL_WRITE + MAIL_FB align 16 FB_STRUCT: ; Frame Buffer Structure dw SCREEN_X ; Frame Buffer Pixel Width dw SCREEN_Y ; Frame Buffer Pixel Height dw SCREEN_X ; Frame Buffer Virtual Pixel Width dw SCREEN_Y ; Frame Buffer Virtual Pixel Height dw 0 ; Frame Buffer Pitch (Set By GPU) dw BITS_PER_PIXEL ; Frame Buffer Bits Per Pixel dw 0 ; Frame Buffer Offset In X Direction dw 0 ; Frame Buffer Offset In Y Direction FB_POINTER: dw 0 ; Frame Buffer Pointer (Set By GPU) dw 0 ; Frame Buffer Size (Set By GPU) |
|||
![]() |
|
Dex4u 10 Sep 2012, 14:28
Here is the latest DexOS port to the Pi, you will need a usb keyboard pluged in to test it.
http://www.dex-os.com/MinDos/PiDexOS.zip Its not finished yet, but it gives you a idea of what its like. Just format a SD card to fat32 and add the files from boot folder and the kernel.img and start you pi. Menu keys are enter, left, right arrow key and type help in cli. Note: Not all usb keyboards work about 50% so far. |
|||
![]() |
|
Dex4u 31 Dec 2012, 17:51
The source code (fasmarm) to the RPI port, is now open source:
http://www.dex-os.com/DexOS_R_PI/DexBasicSource.zip |
|||
![]() |
|
krom 04 Mar 2013, 21:21
I have made a Git Hub for all my complete R-Pi projects in bare metal:
https://github.com/PeterLemon/RaspberryPi This includes minimal Hello World CPU & DMA Demos, Tags Channel Demo, VFP Fractal Demos, NES & SNES Input Demos & Sound Demos. Screenshots of Input Demos: https://github.com/PeterLemon/RaspberryPi/blob/master/Input/NES/Controller/NESController.png https://github.com/PeterLemon/RaspberryPi/blob/master/Input/SNES/Controller/SNESController.png I have more to come: N64,PSX,PS2 Controller & SNES Mouse input. VFP software 3D engine. & some other surprises!! This should be a nice start... I hope this helps people out =D |
|||
![]() |
|
Goto page Previous 1, 2, 3, 4 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.