|
I previously worked through the book (by one of my favorite tech authors - Jeff Duntemann) x64 Assembly Language Step-by-Step: Programming with Linux[^]
There was a lot of build-up to read just to get to the meat. At least 100 pages or so. It was tough & I read a lot.
This RISC-V Assembly Book Is Amazing!
I recently stumbled upon this new book that I'm reading right now:
RISC-V Assembly Language Programming: Unlock the Power of the RISC-V Instruction Set[^]
This book :
1. gets right to the point - you start writing Assembly almost immediately.
2. Explains things really clearly -- It has helped me put some ideas together that I've never understood and things seem much more clear.
Why Is It Easier?
I believe a lot of it is easier because it is based in the RISC-V Assembly.
Wow! You can really tell that RISC-V was built with all the "lessons learned" from x86/x64 Assembly
Getting the QEMU RISC-V Emulator Was Difficult
One thing that was very difficult was getting the QEMU RISC-V emulator going.
Unfortunately the book's instructions were a bit out of date or wrong.
I found a great blog that got me going in no time[^].
No I can write and run the book's code samples!
The Hardware Is on The Way
I have some hardware (where I can run some of these programs) coming today, too.
ESP32 C3[^]
Only $12 for two of them.
Anyone Else Learning / Writing RISC-V Assembly?
Anyone? Anyone?
|
|
|
|
|
raddevus wrote: One thing that was very difficult was getting the QEMU RISC-V emulator going.
I gave up. QEMU refused to operate in any of my environments. I tried several guides, and nada.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
honey the codewitch wrote: I gave up. QEMU refused to operate in any of my environments. I tried several guides, and nada.
I felt the same way yesterday. I had spent all day yesterday and could not find any help or get it working.
It was a real pain. I even asked Copilot to help me but it wasn't helpful.
I finally got it working because I found that blog site (mentioned in original post).
I got very lucky.
I really had no idea what I was doing.
Even the blog site had so much information that I barely made it through it.
But, here's the deal.
First of all make sure you've installed QEMU properly on your dev machine:
$ sudo apt install qemu-system-riscv64
$ sudo apt install u-boot-qemu opensbi
After that, all I had to do was:
1) run this command to download a debian image:
$ wget "https://gitlab.com/api/v4/projects/giomasce%2Fdqib/jobs/artifacts/master/download?job=convert_riscv64-virt" -O debian-rv64.zip
2) Then follow these commands:
$ mkdir debian-rv64
$ cd debian-rv64
$ unzip ../debian-rv64.zip
$ cd artifacts NOTE: That last step was wrong bec the directory that gets unzipped is not named artifacts but is named something else.
Inside that "artifacts" directory, there is a readme.txt.
I ignored the rest of the blog author's instructions and followed that readme.
There is a command in there for how to start it:
Note: Edited command because I had line breaks incorrect
qemu-system-riscv64 -machine 'virt' -cpu 'rv64' -m 1G -device virtio-blk-device,drive=hd -drive file=image.qcow2,if=none,id=hd -device virtio-net-device,netdev=net -netdev user,id=net,hostfwd=tcp::2222-:22 -bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf -kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf -object rng-random,filename=/dev/urandom,id=rng -device virtio-rng-device,rng=rng -nographic -append "root=LABEL=rootfs console=ttyS0"
3rd Edit - With Line Breaks For Easier Reading (tested & it works)
qemu-system-riscv64 -machine 'virt' \
-cpu 'rv64' \
-m 1G -device virtio-blk-device,drive=hd \
-drive file=image.qcow2,if=none,id=hd \
-device virtio-net-device,netdev=net \
-netdev user,id=net,hostfwd=tcp::2222-:22 \
-bios /usr/lib/riscv64-linux-gnu/opensbi/generic/fw_jump.elf \
-kernel /usr/lib/u-boot/qemu-riscv64_smode/uboot.elf \
-object rng-random,filename=/dev/urandom,id=rng \
-device virtio-rng-device,rng=rng \
-nographic \
-append "root=LABEL=rootfs console=ttyS0"
That's it. Once I ran that command I had my RISC-V environment running.
It's running right now.
I had to install the build-essential package and I was able to compile, build, link via as and ld
Cannot believe I got it going.
I hope these steps might help you some time too.
modified 27 mins ago.
|
|
|
|
|
Not all assembly languages are created the same. The Intel/CISC machine languages have their roots in the old IBM 360 mainframes. These are complex instruction sets that require a lot of hardware to implement. The newer RISC instruction sets trade some of this hardware complexity for a significantly simpler machine language implementation using a lot more instructions to do the same functions. We've found that the RISC machines generally operate faster and can be optimized in ways that CISC cannot, which is why even the CISC instruction set used by Intel to this day has become more of a macro language on an underlying RISC instruction set that Intel has highly optimized.
As for having to read 100 pages before getting to the actual assembler, this is the sign of a poor tutorial on assembly. It has nothing to do with the actual language. I ran into the same issue when learning Windows programming until I found Charles Petzgold's books. Same language, same OS, but his books were far better at teaching Windows programming.
|
|
|
|
|
obermd wrote: As for having to read 100 pages before getting to the actual assembler, this is the sign of a poor tutorial on assembly.
Yeah, it's a balance. I mean, to really learn what's going on underneath the surface, a lot has to be explained.
And, since learning Assembly means you need to understand so many concepts (number bases, what hardware is actually doing, tools (compiler, linker, make, etc.)) there can be a lot to learn just to get to where you're learning the target thing.
Petzold's books were long and in depth, but I really enjoyed his style and I felt like he was inviting me into a secret club to learn things that few others knew.
|
|
|
|
|
for Charles Petzold
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
If... I do PLC, haven'T touched a uC since college.
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
I assume you know about the 'fluent api pattern', e.g. in c#, something like:
new MyFluentApi()
.DoThis(x)
.DoThat(y)
.DoAnother(z);
Now, I was looking for that pattern to do a similar thing in Pascal and recognized, that it is allready something like 'build in' since decades
WITH myFluentThing DO BEGIN
DoThis(x);
DoThat(y);
DoAnother(z);
END;
|
|
|
|
|
Yep
Relearning Pascal, Turbo Pascal 3.0 on a RC2014 Z80 hardware running under CP/M 2.2.
Been since college days the last time I even saw any Pascal code. Wrote a couple of simple apps, still learning.
Learning the editor is twice as hard as the code. We sure take modern editors for granite.
If you can't find time to do it right the first time, how are you going to find time to do it again?
PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
To be honest, I don't know Pascal really. I was a Modula2 Guy for decades (Modula also invented by Niklaus Wirth, the Pascal inventor I think).
And yes, I hate the 'WITH' in Pascal/Modula (especally when nested), but now I recoginze, it can be usefull too
|
|
|
|
|
Modula is available to run on CP/M, been thinking about kicking the tires.
Going on vacation tomorrow for a week but may give it a whirl when I get back.
If you can't find time to do it right the first time, how are you going to find time to do it again?
PartsBin an Electronics Part Organizer - Release Version 1.4.0 (Many new features) JaxCoder.com
Latest Article: EventAggregator
|
|
|
|
|
Enjoy your vacation
|
|
|
|
|
I was stunned by "FluentApi" when I heard the term.
I first saw it in modern times in C# unit testing and all these new devs were like "fluent api is so special...oh, wow, this new fluent api is just so amazing."
I was like, "what is fluent api?"
Then I saw it was something we were doing in C++ (specifically MFC/C++) back in 1995 or something.
Ok, so you return an object from the method and then you can call another method on the object immediately.
These new technologies which are 25 years old are so amazing!!
Bell bottoms are in too and they are also amazing new technology that the world has never seen.
|
|
|
|
|
|
I know some Clapton but hadn't heard that song. Great stuff! Sounds great and it's live.
Thanks for sharing.
|
|
|
|
|
Mike Hankey wrote: Been since college days the last time I even saw any Pascal code. Was Pascal already there when you went to college?
Sorry... I could not avoid it
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Wordle 1,065 4/6*
⬛🟨⬛⬛⬛
⬛🟨🟨⬛🟨
⬛🟩⬛🟨🟩
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,065 4/6
⬛⬛⬛⬛🟨
🟨⬛⬛🟨⬛
🟨🟨🟨🟩⬛
🟩🟩🟩🟩🟩
|
|
|
|
|
Wordle 1,065 6/6*
⬜⬜⬜⬜⬜
🟨⬜⬜🟨🟨
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
Close ... too close ...
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Wordle 1,065 5/6
⬜⬜🟨⬜⬜
⬜⬜⬜🟨⬜
⬜🟩⬜⬜⬜
🟨🟩⬜🟨⬜
🟩🟩🟩🟩🟩
|
|
|
|
|
🟨⬜⬜⬜⬜
⬜🟩⬜⬜⬜
⬜🟩🟩🟩🟩
⬜🟩🟩🟩🟩
🟩🟩🟩🟩🟩
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Wordle 1,065 6/6
⬛⬛⬛⬛⬛
⬛🟩🟩🟨⬛
⬛🟩🟩⬛⬛
⬛🟩🟩🟩🟩
⬛🟩🟩🟩🟩
🟩🟩🟩🟩🟩
This one took me too long!
Ok, I have had my coffee, so you can all come out now!
|
|
|
|
|
Wordle 1,065 3/6
🟩⬛⬛⬛🟨
🟩⬛⬛🟨⬛
🟩🟩🟩🟩🟩
Jeremy Falcon
|
|
|
|
|
You'll strain your voice.
*runs away*
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix
|
|
|
|
|
good one
"A little time, a little trouble, your better day"
Badfinger
|
|
|
|