Forum

Command Line Assemb...
 
Notifications
Clear all

Command Line Assembler?

41 Posts
2 Users
3 Reactions
7,179 Views
rbourque
Posts: 43
Topic starter
(@rbourque)
Trusted Member
Joined: 2 months ago

So far with my initial testing everything is working except DIM, registers and strings.   Chip files like this assemble to a file containing the same bytes shown on the Vetus Pars view code screen.

[chipfile]
type = single

[chips]

---

[meta]
name = sandbox
pins = 14
type = 4
imageIndex = 2

[code]
LOOP 0xa 0x0 0x0
CALL shiftLED
ENDLOOP 0x0 0x0 0x0

ENDTEST 0x0 0x0 0x0

FUNC shiftLED
LEDON 0x0 0x0 0x0
DELMS 0x12C 0x0 0x0
LEDOFF 0x0 0x0 0x0
DELMS 0x12C 0x0 0x0
ENDFUNC

[strings]
0=
1=
2=
3=
4=
5=
6=
7=

[ENDCHIPS]

Reply
rbourque
Posts: 43
Topic starter
(@rbourque)
Trusted Member
Joined: 2 months ago

DIM is now finished.  I also added /* */ and ; comments support.

It looks like Strings are uploaded to the device, so there isn't anything for the assembler to do with that yet.

Can you explain a little bit about how Registers are handled?   In the Code View on the Vetus Pars it shows #R0, but I'm assuming that's just for viewing.  What bytes are actually created when the assembler generates the machine code?


Reply
2 Replies
Admin
(@nivbot)
Joined: 8 months ago

Member
Posts: 84

@rbourque By the way, did you get 65C02 working?


Reply
rbourque
(@rbourque)
Joined: 2 months ago

Trusted Member
Posts: 43

@nivbot No, the source needed tweaking and the gui editor kept messing up, so it got me thinking “How can I do this in Linux with my dev tools”. Hence the assembler.


Reply
Posts: 84
Admin
(@nivbot)
Member
Joined: 8 months ago

Registers are a little different and you're getting into things Vetus needs to do internally, that will be out when I get the docs done but I can tell you that the registers are obviously an array within the firmware so we need a way to tell which register we want to use. We can use a literal number 0x1 for instance, and that will work just fine anytime we want to tell Vetus which register we are talking about but there are many times where we have the choice between a literal number and a register value. In that instance, we need to differentiate between a literal number and a register index. To do that we use 0x80000000 where 0x80000000 is index 0, 0x80000001 is index 1 and so on up to 32. So when we want a value from the register we give it the 0x8000000n value and if we are talking about the register index itself we just give it a normal value. Vetus Pars takes care of translating it. 


Reply
1 Reply
Admin
(@nivbot)
Joined: 8 months ago

Member
Posts: 84

This is from the firmware source code. This is how I convert the long number into a usable index, and there are other functions for determining what do based on whether it is a register or literal number in the firmware.

#define ARG_REG_FLAG 0x80000000
#define ARG_VALUE_MASK 0x7FFFFFFF
#define ARG_REG(n) (ARG_REG_FLAG | (n)) 

 


Reply
rbourque
Posts: 43
Topic starter
(@rbourque)
Trusted Member
Joined: 2 months ago

The compiler now will report compilation errors, where they are, and parameter information.   
Also don't have to pad 0x0 anymore.   If you leave them out it will add them automatically since it knows the number of parameters each opcode requires.

./vp-asm.py ./chip-samples/sandbox-bad.chip ./output/sandbox-bad.chipout
=== vp-asm v1.00.00 ===
Assembly error: Assembly failed with 5 errors:
Line 12: Unknown instruction: FOO
Line 16: SET8 missing required parameter(s): Index, Address, In/Out (expected 3, got 0)
Line 17: SET8 missing required parameter(s): In/Out (expected 3, got 2)
Line 18: SET8 has too many parameters (expected at most 3, got 4)
Line 21: Unknown function: shiftLED2

 

./vp-asm.py ./chip-samples/sandbox.chip ./output/sandbox.chipout
=== vp-asm v1.00.00 ===
Assembly successful.
Wrote 48 bytes.

Hopefully the machine code generated is equivalent to your GUI.   We will find out once I can upload to the Vetus Pars.


Reply
2 Replies
Admin
(@nivbot)
Joined: 8 months ago

Member
Posts: 84

@rbourque Hi, I'm going to give you a rough outline I did of everything. Anyone else can use it too. Feel free to ask for further explanation if needed. I'll have the official stuff up in a few days. 

Edit: I forgot to attach the file. 


Reply
Admin
(@nivbot)
Joined: 8 months ago

Member
Posts: 84

Actually, this shold help too so you don't waste time trying to look for every opcode.

case "0X01": return "SETPIN";
case "0X02": return "SETIN";
case "0X09": return "SETOUT";
case "0X03": return "RDPIN";
case "0X05": return "MULTIO";
case "0X06": return "MULTII";
case "0X07": return "MULTIHI";
case "0X08": return "MULTILO";
case "0X0B": return "ASAFE";
case "0X0D": return "GOSTRT";
case "0X0E": return "ALLDIR";
case "0X0F": return "ALLEVEL";
case "0X22": return "DEFADDR";
case "0X21": return "SETADDR";
case "0X20": return "ADDRBIT";
case "0X23": return "ADDRCLR";
case "0X10": return "LOOP";
case "0X11": return "ENDLOOP";
case "0X13": return "BRKLOOP";
case "0X16": return "DELUS";
case "0X17": return "DELMS";
case "0X18": return "WHILE";
case "0X19": return "ENDWHL";
case "0X1A": return "JMP";
case "0X1B": return "DOUNTIL";
case "0X1C": return "ENDUNTIL";
case "0X1D": return "CLKST";
case "0X1E": return "CLKSTP";
case "0X50": return "IF";
case "0X51": return "ENDIF";
case "0X6C": return "LEDON";
case "0X6D": return "LEDOFF";
case "0X40": return "REGLOD";
case "0X41": return "REGCLR";
case "0X42": return "REGINC";
case "0X43": return "REGDEC";
case "0X44": return "ADD";
case "0X45": return "SUBTR";
case "0X46": return "MULT";
case "0X47": return "DIV";
case "0X49": return "RNG";
case "0X4A": return "AND";
case "0X4B": return "OR";
case "0X4C": return "SHL";
case "0X4D": return "SHR";
case "0X4E": return "NOT";
case "0X4F": return "XOR";
case "0X6A": return "BTNPR";
case "0X6B": return "BTNWT";
case "0X61": return "FILSCR";
case "0X60": return "SHOSTR";
case "0X63": return "TXTCOL";
case "0X64": return "PROG";
case "0X6F": return "UDSCRN";
case "0XF2": return "PASSFAIL";
case "0XF0": return "ENDTEST";
case "0X68": return "BLINKON";
case "0X69": return "BLINKOFF";
case "0X24": return "FANON";
case "0X25": return "ARRADD";
case "0X26": return "ARRGET";
case "0X27": return "GETADDR";
case "0X28": return "PHIZ";
case "0X29": return "TOGPIN";
case "0X2A": return "PIN2ARR";
case "0X2B": return "DEF8";
case "0X2C": return "SET8";
case "0X2D": return "GET8";
case "0XC0": return "DEFFUNC";
case "0XC1": return "FUNC";
case "0XC2": return "ENDFUNC";
case "0XC3": return "CALL";
 

 


Reply
rbourque
Posts: 43
Topic starter
(@rbourque)
Trusted Member
Joined: 2 months ago

Thanks.  That was very helpful.   

I made a very rudimentary loader this evening that sends the chipout data and some hardcoded strings and meta data.    It needs a LOT of polish and testing, and I still need to update it to read from the chip file instead of hardcoded placeholders, but I got it uploading, and uploading with save functional.

At the moment everything is done in Linux.  When I get it all documented and tested on Mac and PC, I'll give you access to my Git server so you can go over it yourself.

I don't code in python daily, so it's been fun working in something different.

./vp-loader.py --port /dev/ttyACM0 --chip ./output/sandbox.chipout --name sandbox --type 1 --pins 14 --image-index 2
Strings: 100%|████████████████████████████████████████| 9/9 [00:00<00:00, 13.93it/s]
Code: 100%|███████████████████████████████████████████| 1/1 [00:00<00:00, 13.91it/s]
Chip upload complete.

Reply
1 Reply
Admin
(@nivbot)
Joined: 8 months ago

Member
Posts: 84

@rbourque cool thanks. I'll gladly host a link here for it too.


Reply
Page 2 / 5
Share: