With the information gained in last posts investigations, I now know how to turn the smaple code of the insertion sort out of TAOCP into runnable code.
Continue readingCategory Archives: Software
MIXAL on Fedora
The examples in The Art of Computer Programming (TAOCP) are in the MIXAL programming language. In order to see these examples run, I want to install the tools on my Fedora box. They are packaged as RPMS, so this is trivial. Here are the steps to run and debug a sample program in MIXAL.
Continue readingPrinting an Integer Array in (ARM64) Assembly
For the next couple tasks I want to do in assembly, I need to be able to inspect an array of numbers. This is useful for debugging searching and sorting algorithms. Since my last attempt to convert binary to ASCII was so ugly, I figured I would clean that up at the same time.
It turns out I can use the reverse code as well.
Continue readingA Horrible Conversion from Binary to Decimal in (ARM64) Assembly
This is not my finest code. It is the worst case of “just make it work” I’ve produced all week.
But it runs.
What does it do? It takes the first binary number in an array, and converts it to decimal. It assumes that the number is no more than 3 digits long.
It divides that number by 100 to get the 100s digit. Then it multiples that number by 100, assuming that it has gotten truncated. It subtracts that value from the original number to chop off the 100s digit, and divides the result by 10 to get the 10s digit.
Continue readingAutomating Baremetal Node Creation for Ironic
Sometime your shell scripts get out of control. Sometimes you are proud of them. Sometimes….both.
I need to be able to re-add a bunch of nodes to an OpenStack cluster on a regular basis. Yes, I could do this with Ansible, but, well, Ansible is great for doing something via SSH, and this just needs to be done here and now. So shell is fine.
This started as a one liner, and got a bit bigger.
Continue readingCalling a Function in (ARM64) Assembly
In my last post, I reversed a string. I want to build on that to make reusable code; I want to reverse multiple strings. I do this by turning the reverse code into a function and then call it.
Continue readingReversing a String in (ARM64) Assembly
In my last post, I showed that I could modify a single character in a string. I want to build upon that to perform more complext string manipulations. Lets start with something simple.
Continue readingChanging the Output in (ARM64) Assembly
When ever I write new console based code from scratch, I start with “Hello World.” Then I make one small change at a time, test it, and commit. Then I move on. While this slow process might seem tedious, it is based on years of wasting time debugging my own poorly written code in interim changes.
Once I had “Hello, World!” working in assembly, I want to make a single character change to message and see it in the console. Here’s my steps.
Continue readingRunning Assembly Code Through the debugger
There are two basic ways to inspect a running program: print out a bunch of debug statements or run it through a debugger. Since I don’t yet know how to print out my own statements in ARM64 debugging (I’ll get there soon) I want to use the debugger to see my code in action.
Continue readingSimplest (ARM64) Assembly Program that Runs without an error
In order for a program to run successfully, it needs two things: an entry symbol, and a return code that represents that success. The following program provides those two things.
.global _start _start: MOV X0, #0 MOV X8, #93 SVC 0 |
Compile it using the simple Makefile from the previous article.
The symbol _start is a special symbol expected by the linker. If you try to rename like this…….
.global _ADAM _ADAM: MOV X0, #0 MOV X8, #93 SVC 0 |
…you get the following error:
$ make other as -o other.o other.s ld -o other other.o ld: warning: cannot find entry symbol _start; defaulting to 0000000000400078 |
Which will still compile and run.
If you leave off the three assembly instructions at the end, you do not return 0 indicating the program success.
.global _start _start: |
That gives you this error:
]$ ./bad_return -bash: ./bad_return: cannot execute binary file: Exec format errorTo be honest, there are no instruction in the code, and I think that is a different problem. If we skip executing the function to send the return code:
.global _start _start: MOV X0, #0 MOV X8, #93 |
That gives this error when run:
$ ./bad_return Illegal instruction (core dumped) |