Prog8 language and compiler topic

All aspects of programming on the Commander X16.
User avatar
ahenry3068
Posts: 1131
Joined: Tue Apr 04, 2023 9:57 pm

Re: Prog8 language and compiler topic

Post by ahenry3068 »

Thank you.. That is useful...
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Prog8 language and compiler topic

Post by yock1960 »

More head scratching!

I wrote a 'ghetto' assembler to use with my current project....a simulator for...oh hell, just see:

https://www.youtube.com/watch?v=y149hLe ... AQONTKxql3

Anyway, the assembler works fine....by itself, but when I add the code to the simulator, in it's own block, I keep getting:

undefined symbol: prog8_interned_strings.string_24

error. This is the string variable:

str[] addrs = ["i0","i1","i2","i3","i4","i5","i6","i7","o0","o1","o2","o3","o4","o5","o6","o7","s0","s1","s2","s3","s4","s5","s6","rr"]

I moved it from the separate code block to main, I've renamed it, I'm down to, 'I must have used up the space allotted for strings' or something.

Help! Using v9.01
User avatar
desertfish
Posts: 1091
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Prog8 language and compiler topic

Post by desertfish »

Whoops, that is a bug in the compiler. Will need to see the piece of code more fully that causes this error.
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Prog8 language and compiler topic

Post by yock1960 »

desertfish wrote: Sun Jul 23, 2023 10:47 am Whoops, that is a bug in the compiler. Will need to see the piece of code more fully that causes this error.
Here ya go. String declarations and code. I've marked the offending line with some asterisks. As I said, this code works fine in a standalone program, but when I tacked it to the 'main' program, it fails. Originally the declarations were in the same block as the assembler, but I moved them up to main...it makes no difference. The arguments of the sub are strings that I'm trying to match in the string arrays.

; mc14500b opcode mnemonics and byte codes
str[] insts = ["nopo","ld","ldc","and","andc","or","orc","xnor","sto","stoc","ien","oen","jmp","rtn","skz","nopf"]
ubyte[] instv = [0,16,32,48,64,80,96,112,128,144,160,176,192,208,224,240]

; mc14500b minimal system simulator input, output, scratchpad and result register mnemonics and byte code
str[] addrs = ["i0","i1","i2","i3","i4","i5","i6","i7","o0","o1","o2","o3","o4","o5","o6","o7","s0","s1","s2","s3","s4","s5","s6","rr"]
ubyte[] addrc = [0,1,2,3,4,5,6,7,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]

sub translate(uword instr, uword data) { ubyte x byte res dbyte = 0 for x in 0 to 15 { res = string.compare(instr,main.insts[x]) if res == 0 { dbyte = dbyte + main.instv[x] } } for x in 0 to 23 { res = string.compare(data,main.addrs[x]) ***** if res == 0 { dbyte = dbyte + main.addrc[x] } } main.ram[main.address] = dbyte main.address += 1 } }
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Prog8 language and compiler topic

Post by yock1960 »

I found the problem. The last string in the addrs string array is "rr", I also have a boolean variable called rr in the 'main' program. Once I renamed one, it compiled. An easy fix...if I'd paid closer attention to the error message I'd have caught it sooner...
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Prog8 language and compiler topic

Post by yock1960 »

yock1960 wrote: Sun Jul 23, 2023 3:09 pm I found the problem. The last string in the addrs string array is "rr", I also have a boolean variable called rr in the 'main' program. Once I renamed one, it compiled. An easy fix...if I'd paid closer attention to the error message I'd have caught it sooner...
Okay, you'll probably know/learn this. It compiled after I changed the array string from 'rr' to something different. I want that string to be 'rr'! Prog8 doesn't want it however! :lol: I guess I'll wait on your fix....I'll make a temporary change so that I can continue testing!
User avatar
desertfish
Posts: 1091
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Re: Prog8 language and compiler topic

Post by desertfish »

Can't reproduce the error. You'll need to post more code , part or all of the main program as well , that I can compile to trigger the error.
I've pasted your snippet in a main program myself, added some variables, and it compiled just fine.
yock1960
Posts: 136
Joined: Tue Nov 16, 2021 8:42 pm

Re: Prog8 language and compiler topic

Post by yock1960 »

desertfish wrote: Sun Jul 23, 2023 8:36 pm Can't reproduce the error. You'll need to post more code , part or all of the main program as well , that I can compile to trigger the error.
I've pasted your snippet in a main program myself, added some variables, and it compiled just fine.
Holy Cow! You programming gurus are amazing! :lol:

I decided to 'improve' my assembler to make this problem irrelevant! An even chance it's my error to begin with....anyway, I am improving it...but it's one step forward, 2 steps back! Every time I get it 'fixed' and then throw another source file at it, that's different in some way....it's broken again! :lol: Of course, it's a different section of the code that is at fault and then there's the things that you thought were working, but it was just dumb luck that they were! The most fun however, was when I spent...??? hours trying to fix my code, when the code was fine....it was an error in the file being assembled! :roll: That was when I decided that another improvement....some error checking, was required. All of this, before any potential 'user' starts doing totally unexpected things... :o
User avatar
desertfish
Posts: 1091
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Important prog8 version 9.2.1 released

Post by desertfish »

:!: Prog8 version 9.2.1 has been released: https://github.com/irmen/prog8/releases/tag/v9.2.1
User avatar
desertfish
Posts: 1091
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Help me test the upcoming 9.3 version

Post by desertfish »

Note: the current development version of prog8 (which will become 9.3) has an important change in the code generator.
The software stack that was used to translate complex (nested) expressions, has been removed.
Although all my own programs and several from other people have been compiled successfully already, this is a rather big change and may still result in problems for the more obscure cases.

If you'd like to help me out and help test/debug this new code generator change, please use the development build in place of the official 9.2.1 release. You can find it on github https://github.com/irmen/prog8/actions? ... h%3Amaster
(choose the most recent CI build and download the build artifact zipfile). Thanks!
Post Reply