flat assembler
Message board for the users of flat assembler.
![]() Goto page Previous 1, 2 |
Author |
|
edfed 21 Mar 2011, 03:00
there is the last advancement of picmacro.
now, it can easy define osccall, configuration and eeprom in the source code. Code: ; use this conneciton driagram to test this code. ; ; vdd 5v vss gnd ; | | ; ------1|"""V"""|8----- ; ----------2| |7---------------+----PGC ; | -----3| |6----PGD | ; | | 4|VPP____|5------- R10k ; | | | | ; R3k R3K vdd | [white led] ; | | | v | ; [red and green led] ---[trimmer 10k]--+ ; | | ; GND GND ; ; include 'include/pic14.inc' ;;;;;;;;;;;;;;;;;;;;;;;;; [type your code here] ;;;;;;;;;;;;;;;;;;;;;;;;; osccal 66h conf (CPDoff + CPoff + PWRToff + INTGP4) eeprom db ' h e l l o w o r l d' db ' p r o g r a m m e t e s t n ° 0 .' for eeprom, just take care that it needs 2 bytes for one byte, and the high byte is used to fill the eeprom zone. need to do a macro for simple eeprom definition. ugly Code: : db ' ',H',' ','E',' ','L',' ','L,',' ','O' db ' w o r l d' tested the ADinterrupt, but it seems to run too fast and randomly, and then, makes random delays [edit] update with some more code. program memory size is 3FFh words. macro to tell used and free instructions macros for: mov reg,reg loop reg,adress [edit 2014/01/19] and now, i have a arduino based thing, to drive RGB leds (pixels). the goal now is to replace all the fucking c++ shit, and maybe also strip out anything related to arduino. the end of this cpp arduino thing will comes when i'll use a sort of teensy, or anything else with a lot of ram, and make it really powerfull using only fasm to compile the code, and another tool (maybe a simple ShellExecute ) to send the code to the mcu based module. and one more step to the ease of fasm coding. this code is there to show what is really needed from the fun coder point of view, and then, try to implement this directlly in a lighter and more direct fashion possible for my humble brain. as you can see, the c++ like code here is really a pure shit, and it's due to the design behind the scene about the unfinished neopixel lib, and the syntax of the C++ particurally. Code: #include <Adafruit_NeoPixel.h> #define dword uint32_t #define pxl Adafruit_NeoPixel #define Black 0x00000000 #define Dark 0x00040404 #define Green 0x00008000 #define Silver 0x00C0C0C0 #define Lime 0x0000FF00 #define Gray 0x00808080 #define Olive 0x00808000 #define Gold 0x00C0C000 #define White 0x00FFFFFF #define Yellow 0x00FFFF00 #define Orange 0x00FF4000 #define Maroon 0x00800000 #define Navy 0x00000080 #define Red 0x00FF0000 #define Blue 0x000000FF #define Purple 0x00800080 #define Teal 0x00008080 #define Fuchsia 0x00FF00FF #define Aqua 0x0000FFFF #define Random -1 #define Tcolor -2 #define PIN 6 #define LEDS 60 #define XL 10 #define YL 6 dword w = 1000/24,//second/fps t = 0,//frame counter foreground = Green, background = Dark, limiter = 0x7F7F7F; pxl strip = pxl(LEDS, PIN, NEO_GRB + NEO_KHZ800); const byte mapping[] = { 0, 1, 2, 3, 4, 5, 11,10, 9, 8, 7, 6, 12,13,14,15,16,17, 23,22,21,20,19,18, 24,25,26,27,28,29, 35,34,33,32,31,30, 36,37,38,39,40,41, 47,46,45,44,43,42, 48,49,50,51,52,53, 59,58,57,56,55,54 }; #define R Red class Char { private: public: }; class Vector { private: double _dx; double _dy; public: Vector(double __dx,double __dy) { dx(__dx); dy(__dy); }; ~Vector(){}; double dx() { return _dx; }; double dy() { return _dy; }; void dx(double dx) { _dx = dx; }; void dy(double dy) { _dy = dy; }; }; class Ball { private: int _x; int _y; dword _c; public: Ball(int __x,int __y,dword __color) { x(__x); y(__y); color(__color); }; ~Ball(){}; int x() { return _x; }; int y() { return _y; }; dword color() { return _c; }; void x(int x) { _x = x; }; void y(int y) { _y = y; }; void color(dword color) { _c = color; }; void put() { putPixel(_x,_y,_c); }; }; class Box { private: int _x; int _y; int _xl; int _yl; dword _c; public: Box(int __x,int __y,int __xl,int __yl,dword __color) { x(__x); y(__y); xl(__xl); yl(__yl); color(__color); }; ~Box() {}; int x() { return _x; }; int y() { return _y; }; int xl() { return _xl; }; int yl() { return _yl; }; dword color() { return _c; }; void x(int x) { _x = x; }; void y(int y) { _y = y; }; void xl(int xl) { _xl = xl; }; void yl(int yl) { _yl = yl; }; void color(dword color) { _c = color; }; void put() { for (int y=0;y<_yl;y++) { for (int x=0;x<_xl;x++) { putPixel(_x+x,_y+y,_c); } } }; }; class Pong { private: Ball*_ball; Box*_frame; Vector*_vector; int xmin; int xmax; int ymin; int ymax; double x; double y; double dx; double dy; public: Pong( Box*f, Ball*b,Vector*v) { _ball = b; _frame = f; _vector = v; x = b->x(); y = b->y(); dx = v->dx(); dy = v->dy(); xmin = f->x(); xmax = xmin+f->xl(); ymin = f->y(); ymax = ymin+f->yl(); }; ~Pong() { }; Ball*ball() { return _ball; }; Box*frame() { return _frame; }; void frame(Box*f) { _frame = f; }; void bounce() { y += dy; if (y>=ymax || y<ymin) { dy=-dy; y+=dy*2; } x+=dx; if (x>=xmax || x<xmin) { dx=-dx; x+=dx*2; } _ball->x(x); _ball->y(y); _ball->put(); }; }; dword image[] = { 7,6, 0,R,R,0,R,R,0, R,0,0,R,0,0,R, R,0,0,0,0,0,R, 0,R,0,0,0,R,0, 0,0,R,0,R,0,0, 0,0,0,R,0,0,0 }; String input, output, logg; byte rx; Box outframe(0,0,10,6,Tcolor); Box inframe(1,1,8,4,Dark); Pong redpong(&outframe,new Ball(2,2,Red),new Vector(0.3,0.8)); Pong greenpong(&outframe,new Ball(2,2,Green),new Vector(-0.5,0.37)); Pong bluepong(&outframe,new Ball(2,2,Blue),new Vector(0.722,1.195)); Pong purplepong(&outframe,new Ball(2,2,Purple),new Vector(-0.722,1.195)); Pong yellowpong(&inframe,new Ball(2,2,Random),new Vector(0.995,0.61)); void setup() { pinMode(7, OUTPUT); Serial.begin(9600); strip.begin(); strip.show(); } void loop() { matrix(); } void matrix() { shell(); outframe.color(colorWheel(t)); outframe.put(); inframe.put(); redpong.bounce(); greenpong.bounce(); bluepong.bounce(); purplepong.bounce(); yellowpong.bounce(); sync(); } void printState() { Serial.print("delay = ");Serial.println(w,HEX); } void putChar(byte x,byte y,dword c, byte a) { } void putBmp(byte x, byte y, dword*b) { int i = 0; for (int _y=0;_y<b[1];_y++) { for (int _x=0;_x<b[0];_x++) { dword c = b[2+i++]; if (c!=0) { putPixel(_x+x,_y+y,c); } } } } void putPixel(byte x,byte y,dword c) { if (x>=0 && x<XL && y>=0 && y<YL) { if (c == Tcolor) { c == colorWheel(t); } else if (c == Random) { c = random(); } dot(x*YL+y,c); } } dword colorWheel(byte WheelPos) { if(WheelPos < 85) { return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); } else if(WheelPos < 170) { WheelPos -= 85; return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); } else { WheelPos -= 170; return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); } } String command(String name,String msg,dword*d,dword v) { if (input == name) { if (d != 0) { *d = v; } output = msg; Serial.println(output); input = ""; } return msg; } void shell() { if (Serial.available() > 0) { rx = Serial.read(); logg += rx; input += (char)rx; command("hello","world",0,0); command("fadeup","fade up ok",&background,0x202020); command("fadedown","fade down ok",&background,0x040404); command("Black" ,"Black = 0x00000000",&background,Black); command("Green" ,"Green = 0x00008000",&background,Green); command("Silver" ,"Silver = 0x00C0C0C0",&background,Silver); command("Lime" ,"Lime = 0x0000FF00",&background,Lime); command("Gray" ,"Gray = 0x00808080",&background,Gray); command("Olive" ,"Olive = 0x00808000",&background,Olive); command("Gold" ,"Gold = 0x00C0C000",&background,Gold); command("White" ,"White = 0x00FFFFFF",&background,White); command("Yellow" ,"Yellow = 0x00FFFF00",&background,Yellow); command("Orange" ,"Orange = 0x00FF4000",&background,Orange); command("Maroon" ,"Maroon = 0x00800000",&background,Maroon); command("Navy" ,"Navy = 0x00000080",&background,Navy); command("Red" ,"Red = 0x00FF0000",&background,Red); command("Blue" ,"Blue = 0x000000FF",&background,Blue); command("Purple" ,"Purple = 0x00800080",&background,Purple); command("Teal" ,"Teal = 0x00008080",&background,Teal); command("Fuchsia" ,"Fuchsia = 0x00FF00FF",&background,Fuchsia); command("Aqua" ,"Aqua = 0x0000FFFF",&background,Aqua); if (rx == 's') { printState(); } Serial.println(output); } else { input = ""; } } void bmp(dword* b) { dword j = t%b[0]; for (dword i = 0; i < LEDS; i++) { dot(i,b[i*b[0]+j+2]); } } void effect(dword* c) { dword y; for (dword i = 0; i < c[0]; i++) { y = t + ((LEDS*i)/c[0])%LEDS; dot(y,((c[i+1]+dot(y)+dot(y-1)>>1+dot(y+1)>>1)>>1)&limiter); } } void dots(dword* c) { for (dword i = 0; i < c[0]; i++) { dot(t + ((LEDS*i)/c[0])%LEDS,c[i+1]); } } void noise() { for (dword i = 0; i < LEDS; i++) { dot(i,random()&limiter); } } dword dot(int y) { y = y%LEDS; return strip.getPixelColor(y); } void dot(int y, dword c) { y = (int)mapping[y%LEDS]; // y = y%LEDS; strip.setPixelColor(y,c); } void sync() { delay(w); strip.show(); cls(background); t++; } void cls(dword c) { if (c < 0) { return; } for (dword i = 0; i<LEDS; i++) { dot(i,c); } } this code fo course, evolves to a design similar to fool design. here, the avr, via c++, will manage items alike in fool, but it is not totally fool cause the classes are not in asm. an if not in asm, it is not really fool, but it is a begining, the next step, create a virtual screen, and a capture of that screen to a framebuffer. this framebuffer will be a set of pixels extracted from the virtual screen, and for this, in order to have a really cool virtual screen, i need a teensy3.1, who says teensy3.1 says.... FasmArm, then, a new step to do fasm in the context of an embeded platform ![]()
Last edited by edfed on 01 Oct 2015, 13:31; edited 4 times in total |
|||||||||||||||||||||||||||||||
![]() |
|
shutdownall 21 Nov 2011, 20:55
Hi there,
I am looking for a Z80 assembler with a comfortable editor and macro functions but found nothing else than different command line tools. As I use fasm for a longer time I thought about changing fasm to a Z80 instruction set. Did this maybe anyone ago or does anybody have some hints how to realize it ? In searching I found this thread only with Z80. Is there maybe any special documentation how to implement a different instruction set and different register names / size ? |
|||
![]() |
|
shutdownall 21 Nov 2011, 21:06
|
|||
![]() |
|
Goto page Previous 1, 2 < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.