News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

new member introduction and advice

Started by q12, September 04, 2021, 12:42:56 PM

Previous topic - Next topic

q12

Good day, mister mineiro
QuoteIf you look that file "p12f508.inc" you will see a lot of EQUates like GPIO,OSCCAL as example.
EQU might mean EQUAL as well. It has a bit more sense in my head. FINE EQUAL 0x01
I think I understand this EQU thing now:
I imagine, that it may be a true CONSTANT. I've never used constants in my programming life, and what examples I've seen so far, they were mindless and meaningless.
But now, reading all this... I read your explanations, then I look in both Intel books, then I check 12f508.inc and indeed is full of EQU in it (I dont remember checking this file inside before)
I believe, that assignment name that we give: STATUS,GPIO,OSCCAL and your FINE example, they refer to -imutable- or -unchangeble- values  H'0001' to H'0007' that are fixed registers inside the processor or this PIC ram-memory-register.
Now, and only now, a constant has meaning for me ! That is something. Correct me if im wrong, of course.
After looking in p12f508.inc, what I trully dont understand is why W,INDF,C,PS0   EQU H'0000'. The same goes for those who EQU H'0001' up to EQU H'0007'
I understand perfectly they mean for ex: [NAME of] W EQUAL [BIT] H'0000' but the same goes for the other values.
What (code) is splitting them into registers to fit each specific register? Starting each from 0 to 7. I bet if you change the order of these lines, your compiler will shit itself with errors.
I would love to see the code that split and assign all these bits to their respective registers.
Or at least an interpretation (from your part) of that code, if the real code is buried inside compiler.

QuoteI think that "__config" line in source code is creating a binary number (byte) by seting/reseting some specific bits in 8 bits field.
I totally think that as well, and I did come across other codes (in my life) that were declaring __config as a set of bits something like b'01011010' for example.

QuoteSo, "__config" line used AND (&) operator. You need probably check the meaning (equ) of _MCLRE_ON, _CP_OFF , _WDT_OFF , _IntRC_OSC
So this is homework for me, right? Haha, Yes, I like it.
By looking inside 12F508 datasheet (or manual), I find the Configuration Register that has 11bits in length but only the first 5 bits are active.
The rest, from bit 5 to bit 11, are NOT-implemented (gray out).
Image: https://i.imgur.com/0u5aI8E.jpg
This is the part that I trully love about PIC's (and they made it so hard to see it with meaningless explanations of some weird stuff that is meant to derail you)
Every BIT counts! Haha. Meaning, you can actually count bits and they mean something both in real chip and in your code.
If we look on the table for Configuration Register inside datasheet, we can see the bit values for EVERY possible combination of configuration bits.
So, in our code, and I know this part very well, if let's say for example we have:
                       __config _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
then it means:__config          1                    1                   0                   10
and you can write it as: __config B'11010' and it means the same damn thing as  __config _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
But using only bit codes becomes very encripted, very quickly. It is very good to know this part because is helping your logic.
I know it helps me a lot to see things as they are.

Now, back to your example, I believe, what you mean with your q12config.inc is
FINE EQU B'11010'   ;correct?
To only define this particular register bits, that is let's say [the most used] configuration in the large majority of my PICs.
I am right? I hope I am, because I learn something completly new with you today !
As always, thank you!

mineiro

hello sir q12;
Yes, EQU is a constant.
When your source code grows sometimes will be hard understand if a number seen it's a reference to a memory address that can be a register or just a number. So, to a code be more easy to read we can create distinctions.
Imagine that you see number 6 in your source code. The only sure that you can have is: it's not GPIO register. If number 6 it's a symbol to be echoed in LCD or just part of some arithmetic that you're doing you need comment in your source code.

By q12config.inc I was refering that we can create our own config/equ file. Suppose that you have 2 LCDs, one have 2 pins, other have 3 pins. This means that both need different configurations. Now, suppose that the only difference from a pic point of view is that we need set pin 1,2 as output, while to use other LCD we need set pin 1,2,3 as output.
To make our life easy, we can create 2 config files, label that lcd2.inc and lcd3.inc. We can use same label equate in both. Like:
lcd2.inc
LCDON equ 00000011b
lcd3.inc
LCDON equ 00000111b

We don't need change our code anymore, only include files being used. Same name (LCDON) to different configurations.

Now think how you do this without EQU. Well, in our code I need set some pic register as output. But I have 2 lcd's with different configurations; so, I will create 2 source codes, one to each lcd. At some point you will ask: Is this 00000111b a configuration to set output bits, it's a symbol that will be echoed in lcd screen, or is just part of some arithmetic/logic that I'm doing?
Quote
So, in our code, and I know this part very well, if let's say for example we have:
                       __config _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
then it means:__config          1                    1                   0                   10
and you can write it as: __config B'11010' and it means the same damn thing as  __config _MCLRE_ON & _CP_OFF & _WDT_OFF & _IntRC_OSC
Fully agree. The only note is when you turn pic on/reset some pins can be high (1) by default instead of low (0).

Masm32 and mpasm are macro assemblers. They use similar facilities. You can create macros to repetitive codes, you can create bit fields with RECORD directive, ... .
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

q12

Can you think on a very short project that I can learn something new, here in masm32?
I have an inspiration blockage. I have no idea what to do next. Ideas come to me, but a bit too slow, especially when I'm not chasing anything specific.
Tell me for example, what projects did you build in your life, using assembler? The cool ones ! Heh.
Anybody is welcome to tell his stories, I will read them all. Promise.

mineiro

No cool projects.

You don't need much to start.
You need know how to open/create/save files, allocate memory, show/receive data to/from user, and exit to O.S.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

daydreamer

I enjoy these strange attractors,great demo based on strange attractors :thumbsup:
http://masm32.com/board/index.php?topic=9402.0
cool 100% asm game :thumbsup:
http://masm32.com/board/index.php?topic=6200.0
I have mostly unfinished projects
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

q12

 Thank you mister daydreamer, those 2 examples are cool indeed. But a bit over my head at this point.
So, mister mineiro, I would like to learn how to manage data from memory. Im not sure how that works in PIC .... but I know I am working with something from it's memory, im not sure what exactly. I imagine, by setting a variable in code, that will store it in memory of the PIC? to be collected later by other part of the code and made some calculations with it? It's the only logic I got about managing memory.  I am kind of new to this 'memory' thing when comes to asm. The only thing I know for sure, is that both PC and PIC memory are volatile, when not powered, its entire stored information get lost, and they will reapear after the entire program restarts and re-initializes the same variables again. Is there anything else more obvious that i fail to remember about memory? Let's think on a simple lesson about this subject.


daydreamer

Quote from: q12 on September 22, 2021, 09:20:10 PM
Thank you mister daydreamer, those 2 examples are cool indeed. But a bit over my head at this point.
typical asm goals,make asm game and asm demo
whats your short term and longterm goal with PIC?control things,some inventions,robot?
there are masm macros that will help you save/load variables to disk
dont know if crossdevelopment tools let you PIC save/load memory on PC disk

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

q12

to mister daydreamer
Quotewhats your short term and longterm goal with PIC?control things,some inventions,robot?
Wow, I didn't quantify at all what I will do and how much with PICs (although I have a pretty bunch of them). I am very upset (on myself) because I started learning PIC's some long time (~20years) ago , then very rarely throw a very fast look saying "aah, its hard" over the years, and Now... deciding to draw the line I suppose. It's a very long time personal ambition !!! I did catch the thing back then, I was speaking PIC language quite fluent for a very short period, but after that,  I just stop using it, dealing with 'shit' in my life. And now, when Im looking back, I say to myself, "I used to know this stuff Quite OK" and now I can not link A to B anymore. You loose it, if don't use it. Also, in this period I am putting together a very short and to the point tutorial for myself in the first place, but also made public, called "Easy PIC" using my artpages that I mentioned already in my other answers. The idea behind "Easy PIC" is that PIC's should be easy to learn ! If Proper Explained and Illustrated ! Here is recently made artpage2 : https://www.deviantart.com/q12a/art/q20210920-EasyPIC-2-Problems-892416332  Im not sure how I will deal with this project, if I will even finish it, because I'm at 2 artpages down at this point and is very slow. I'll see. But like I said before, the PIC it's my drive to learn and experiment new stuff. Especially some assembler that I am quite alienated.
I am very open to everything at this point.
Your "crossdevelopment tools" is a very new concept for me ! It will be very cool if I can bypass pickit2 with simple serial port connection of some sort, although this days everything is USB... I remember back in the days, I was programming PICs using pascal language (and C, c++ for a bit) through a serial port RS232 I think it was, with 9 pins on it... hmmm or another port maybe? the port used for printer, which had like 50 pins on it? but I remember it was a serial port and not an USB. And I did used a "quick and dirty" breadboard circuit to program the PIC, long before I buy pickit2 programmer and it's demo/testing board. I loved programming through serial port directly from a high level language!!! I think it is VERY possible directly from asembly !!!  I know from experience it is possible to program the thing, without their "obligatory stuff". And I was programming like that a bigger and more complicated PIC , was a 16F84, that I still have it today.
Quotetypical asm goals,make asm game
Hmmm. So your point is to learn asm by trying to make a game, right? Like the one with the plane between the mountains, arcade style that you linked me. Actually I played those games on some hand held devices that I dont know their name anymore. Exactly like this model here: https://i.etsystatic.com/14707614/r/il/160fd1/1982339783/il_570xN.1982339783_789z.jpg  I loved them at their time.
Yeah, it will be cool to shift in making a game, but I have some very limited experience in making games. I tried some stuff in my c# win app, but nothing worked. Also I tried in Unity, and I got in a point I didnt know how to do some stuff so I quit that too. I learned over the years what is hard and what is really hard. Haha.
I suppose, some very very very basic game just for learning asm, will definetly not hurt. I am thinking right now at bouncing ball game, that should be very basic to make, right? example here: https://www.101computing.net/wp/wp-content/uploads/break-out-game.png Let's play !
Quote...control things,some inventions,robot?
I already have 100pcs DIP8 and another 100pcs SMD PIC12F508. They were VERY cheap that's why I took so many. First, I want to have no problems with programming them. Second, I will do a couple of automation projects. I have a very cool project built from 1 year ago still in tests and still as prototype, still with bugs that I learned to accept them, haha. It is working like 90% of the time. And I did included 1x12F508 PIC in the entire project, but it is mostly an analog project. I am very proud of it. Heh. So yes, other automation future projects to use the PICs. Also robots, I have some very cool robot plans, simple enough and very practical, but... ugh... I know I can make them but not with what I have. In time. Definitely, PIC asm programming will help speed up their birth into reality.

mineiro

I read that you use Proteus. Do you have electronic knowledge? Both, analog and digital? Well, diodes, transistors, capacitors, inductors, impedance, signal gain, band pass filters, active/reactive potency, ... ?
Link some sensors in pic.
I have seen a book from 80 very cool, Digital Computer Electronics by Malvino. This book tells how to create a 8 bit processor. You can simulate/emulate that in Proteus.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

q12

 To mister mineiro
  Hmmm, haha, it's a lot to discuss about this chapter, I will refrain as much as I can, haha. First of all, I am not an electronist or electrician. I don't have full knowledge in electronics. But I do have knowledge to some degree. I build this thing : https://www.deviantart.com/q12a/art/q20210621-Led-Wings-Circuit-SensitivityControl-883289626 This is actually that cool electronic project prototype I mentioned about. If it seems complicated on the first look, it is really not , when you split it in modules, which I did pretty evidently. This circuit is still in use today. You can see I use 1 PIC in this project for the remote control, and I had some help only for this particular module with the IR remote, since it was over my ears. But the idea to have it remotely activated, was my desire from the start. And it come out exactly how I felt it should. That's another reason I am very proud of it. Heh, yes. All those wires to the leds are manually soldered, also all led positions, It is all build on cardboard and a metal shield behind the cardboard, the entire design is thought and planned carefully and with patience. After I build it, I had some very special problems, near the wall, the sensor was catching very strong interference, so I had help to resolve that part. And the help extended to the remote control as well. But dont confuse the help I got with the entire project. The guy who helped me, was following my direction and I managed to make it work directly on the wall. At some point I was desperate, thinking I will not be able to make it work on the wall. That was the biggest problem after finishing it on the working table. It took months of building it, and then other months of testing it and calibrating it. Because I took breaks, it's how I work best. Again, it is still a prototype and it still have some major issues that I did not resolve yet, but in general lines, hell yeah, it is working beautifully and most important thing, it is working as I felt and planned and wished and desired from the very start. It is like an arrow thought into the hearth of the future. It is how I see it. Haha. I love it, and the other guy (s) really love the initial project as well. Some crazy dude (which i respect) build a copy of this thing but only on breadboard, using only opamps, reproducing my LM3914 basically. It was a crazy project and still is. Please, don't start me on it, because I will never stop, haha. Here is how it looks in reality: https://www.deviantart.com/q12a/art/IR-REMOTE-CONTROL-for-my-LED-WINGS-PROJEKT-877191366
The Proteus program... sincerely I am using it rarely and is the only good microcontroler simulator I know. For everyday electronic simulations, I am using circuitjs. It is fenomenal good electronic simulator, highly recommended !
I downloaded and took a quick look inside the 8bit processor book you mentioned. I find it very interesting book ! Thank you for it. Very cool.

mineiro

I'd rather be this ambulant metamorphosis than to have that old opinion about everything


q12

#117
QuoteI have seen a book from 80 very cool, Digital Computer Electronics by Malvino. This book tells how to create a 8 bit processor. You can simulate/emulate that in Proteus.
So, pretty much to build an 8bit processor in Proteus simulator.
I read the book until SAP2 (p179).
The explanations in the book are Awesome, I really like them !!! but it get very complicated, very quickly. I have a partial knowledge of the things he is saying in the book, but not everything.
I learned Proteus (better), it's interface and it's tools with this occasion.
I managed to make SAP1 (Simple As Possible 1) Computer in Proteus; but I get 4 errors I can not find the problem and the computer does not compute anything.
I managed to successfully simulate a working [Memory basic ROM] and a [Memory Small TTL 74189] in Proteus. (No errors in these2)
I attached all the files here in this message attachment. Please check my saved files and also see if you can repair my 4 mistakes I made in [8bitCalculator] file. When you have time of course. Thanks.
This was way out of my comfort zone and I take my time with it, enjoying my breaks because I had some very tough days with this project. It was hard and intense for me. But I did something!  :toothy:
(Recomanded to download) Full package(book+pictures+save files): https://drive.google.com/file/d/1Is9rTb8Lzl0tTTU_9srhOD0vbfhBiXo8/view?usp=sharing

q12

I build the circuit of SAP1 as best as I could but it come out wrong for some reason. I tried to debug it, and I managed to clean the errors. What I did, I inserted on the red "error" wire for most susceptible IC's, 4 jumpers, for each "error" wire. And I did it for only 2 IC's that I suspected them the most. Now, with those jumpers activated, it's like it was before, teoretically, a simple wire, but now I dont get any errors of any kind. The circuit still behaves as before. 4 leds ON, 4 leds OFF in the 8 Wire/Word Bus.
When simulation is running, the 555 Clock circuit is doing it's thing, pulsating the Clock output. And every IC is receiving fine this signal on it's clock input. I put a couple of logic probes and they show me the activity of this Clock. So it was relatively easy to debug to this point. I believe it is more complicated than this. I believe my circuit is OK. Excepting those weird errors I got before which got solved by inserting jumpers on the wires (which should not solved the problem, but it did). Haha.  I believe it is a couple of Manual switching and a specific order of switching some elements there, also the ram programming as well. So its a bit more complicated problem.
---
The bottom line is: I push it as far as I could. I failed, but I learned some interesting stuff along the way, even if I failed the main goal.
- Now, what should I practice more to be better with assembler in both worlds (windows processors and PIC's) ?
Give me something good, another book perhaps or another tutorial from a website somewhere, as long as it is good.

q12

Update:
At 75% of the book(the last big chapter),  the autor is talking about a couple of processors. So my bright idea was to search for an emulator or simulator for an old processor like he described and listed. The most popular emulator I find and downloaded and installed already is this one: https://emu8086.en.lo4d.com/windows
But then, after researching some more, and also paying attention to the book, I find this one, unfortunatly online version and not stand alone : http://www.6502.org/tools/emu/  in which the very first link will send you to http://www.6502asm.com/
This is my first encounter with these emulators. I have no idea what I should do first. In a way, problem is solved with the SAP (SimpleAsPossible) circuit, because I completely switched towards a much better choice , these 2 functional emulators. You should have tell me about them/prepared me , but is good either way.
Being said that, I still look like an idiot to these emulators. Is good that I have the option of using them, and I SUPPOSE the perspective of learning the true basics of asm. Smaller number of instructions and the most basic ones compared with the new processors asm instructions, is my logic. Im not completely sure. What is your advice guys?
Also, I'm not so sure if I am doing the right choice of splinting between PIC asm and Windows asm, to be super sincere. I think I got in some more deep mud than staying only in PICs world. I really hope I didnt do a stupid choice here. I need your thoughts about this problem as well.
Please, and thank you.
P.S. Alone, I usually do shit, but with you guys, I have a better chance. I believe in you.