Tag: writing

  • Chapter 16: A Jealous Pastor

    “You embarrassed me out there today in front of everyone. You owe me an apology,” said Pastor Mark.

    “Dad, I’m sorry that I slapped you, but I am also sorry that you can’t accept that there are mistakes in the Bible and that Chad is a better preacher than you,” said Stacy.

    “Chad isn’t even a licensed preacher, pastor, or evangelist! Besides, we must maintain the inerrancy of scripture or people won’t know what to believe!” said Mark.

    “Then you have made an idol out of the Bible. God existed before paper and ink and is still the king of the universe, not you. I am not sure exactly what to believe about the Bible either, but I know Chad cares about doing the right thing and wants the children to know about Jesus,” said Stacy.

    “Since when did you take Chad’s side over your father?” said Mark.

    “There are sides now?! We should be on the same side. Besides, God is my father because we are all God’s children. If you had been listening to what Chad was saying, you would understand that. I do regret yelling at you and slapping you, but only because it was a bad example in front of the children. I don’t know where Chad is going with this new Sunday School mission he started, but I want to be there and support him without getting in the way,” said Stacy.

    “I see what’s going on here! You like Chad!” said Mark.

    “Of course I like Chad. Everyone in Podunk likes Chad because he is a good man who helps people in need, and he loves children and animals,” said Stacy.

    “No, they like Chad because he wins at soccer and he is rich. They will probably believe anything he says because he is the town superstar. Even so, I am glad you finally found a rich guy you can marry,” said Mark.

    “Not that it is any of your business what relationship I have with Chad or anyone else, but you have the wrong idea. I love Chad for who he is, not because of his money, car, fame, or good looks, or his soccer-playing golden retriever dog,” said Stacy.

    “So you DO love Chad!” said Mark.

    Stacy paused for a minute, looking deep in thought, and then finally got up from her chair at the dinner table. She grabbed her purse and walked out the front door of her dad’s house.

    “Hey, where are you going!” yelled Pastor Mark.

    “I am gonna talk to my new boyfriend, Chad!” said Stacy.

    “No, you aren’t. We are not done talking about this!” said Mark.

    “Actually, Pastor Mark, we are. You just don’t like that you are not in charge anymore, and you’re no longer my dad either,” said Stacy.

  • Is This the Real Art?

    People often criticize AI generated pictures or music for taking money away from real artists who should be paid for what they made with their time, blood, sweat, and tears. These concerns are valid, but it raises larger questions. Can humans tell the difference between pictures, music, or videos made by Artificial Intelligence compared to what a human can make?

    From what I have seen, I would argue that it is usually impossible to see the difference between something made from an AI vs a human. AI is getting so good that I can’t tell what is real. What even is real art? All artists take inspiration from other sources and generate remixes based on what they know. The reason AI threatens artists is because it knows everything and has been fed the writings, music, and visual art made by people who were never paid.

    But it goes deeper than that, people are not given the sources used to generate art. The AI bots will never give credit to the people whose art was used to train the AI in the first place. And sometimes, the original creator of the art gets automatically banned for copyright infringement by a robot even though a robot stole it from them.

    So the issue is not only that it potentially prevents people from buying the original work due to not knowing where it came from, but that the original work is deleted from the internet because the artist is banned and accused of stealing what was actually stolen from them.

    Once again, the issue is that the truth is hidden from the public and the AI can take credit for knowing how to make art that seems original because we don’t know which human made it originally. Even if the humans were paid billions of dollars by the AI companies, they would still not receive credit for their creations. But since they are not receiving money either. two crimes are being committed against real humans by machines controlled by the owners who are profiting from someone else’s work.

    Sources:

    AI companies accused of hoarding and destroying millions of books:

    The facts about AI companies destroying books:

  • What Microsoft Copilot says about Assembly Arithmetic Algorithms

    I tried something new. I asked Microsoft Copilot what it could tell me about my own series of books on Assembly. I have to say I am impressed with the nice summary it came up with. I really think it highlights how unique this series is because it is written from the perspective of my autism and math obsession.

    Assembly Arithmetic Algorithms is a series of assembly‑language programming books written by Chastity White Rose, covering DOS, Windows (32‑ and 64‑bit), and Linux editions. They teach low‑level programming by focusing on arithmetic, binary/hex math, system calls, and how computers actually perform operations like addition, subtraction, multiplication, and division.

    📘 What the books are

    Chastity White Rose has published multiple editions of Assembly Arithmetic Algorithms, each targeting a different operating system:

    1. 16‑bit DOS Edition

    • Teaches how to write .com programs for MS‑DOS.
    • Focuses heavily on binary/hex arithmetic and low‑level operations.
    • Includes explanations of interrupts, pointers, memory addresses, and arithmetic routines.
    • Emphasizes learning how computers “think” numerically.
    • MS-DOS | Definition, Features, Importance, & Facts | Britannica
    • MS-DOS - Wikipedia
    • Difference Between Assembly And Binary at Donna Bull blog
    • Program Development and Execution | Assembly language, Assembly ...

    2. 32‑ and 64‑bit Windows Edition

    • Covers Windows API calls (GetStdHandle, WriteFile, ExitProcess).
    • Introduces registers, stack behavior, and bit operations.
    • Provides “Hello World” examples for both 32‑bit and 64‑bit Windows.
    • Designed for beginners and intermediate programmers wanting deeper control.
    • 理解 Windows API 调用过程 - 厚积薄发 - 开发者Cpp博客
    • Architecture Overview - Win32 apps | Microsoft Learn
    • X64 registers
    • PPT - Introduction to Machine-Level Programming: Basics of x86 ...

    3. 32‑bit Linux Edition (co‑authored with Chandler Klebs)

    • Focuses on POSIX system calls: read, write, open, close, lseek, exit.
    • Includes C programs to help explain assembly routines.
    • Teaches how to write fast, minimal Linux console applications.
    • Manage Your Linux System Resources With These 7 Terminal Commands
    • Timer In Linux Terminal at Rita Skelley blog
    • x86 Assembly Guide-CSDN博客
    • Assembly Language Tutorial No. 1 : Introduction To Registers - YouTube

    🧠 What the books emphasize

    Across all editions, the core themes are:

    • Binary arithmetic (addition, subtraction, multiplication, division)
    • Understanding CPU registers and flags
    • Memory addressing and pointer arithmetic
    • System calls and OS‑level interaction
    • Writing extremely small, efficient programs
    • Learning how computers actually perform math internally

    Chastity frames arithmetic as the foundation of all computation — the CPU’s “native language.”

    📚 Why these books stand out

    • They are modern books about old‑school assembly, which is rare.
    • They teach assembly through arithmetic, not through abstract theory.
    • They are written by a transgender Christian author who blends technical instruction with personal philosophy and creativity.
    • They aim to preserve low‑level programming knowledge that is becoming harder to find.

  • Assembly Arithmetic Algorithms RISC-V

    Assembly Arithmetic Algorithms

    RISC-V Edition

    Preface

    This book is the RISC-V edition of Assembly Arithmetic Algorithms. This is the third book in the series but it is a completely acceptable way to learn programming, even for beginners.

    The first book was for 16-bit DOS programming using Assembly. The second book was for 32-bit Linux programming using the same assembly language for Intel machines.

    But the book you are reading now, is fundamentally different in nature. It uses simulators that run in any operating system to teach a new type of Assembly language for the RISC-V (Reduced Instruction Set Computing-Generation 5) processor.

    RISC-V is important because it is a royalty free open standard. This means that as it catches on, more companies will be able to make cheaper computers because they will not have to pay royalties to the Intel or ARM companies. I guess you could say that it is Open Source Hardware, which in my opinion is the final piece we need to match the Open Source Software people like me already have been enjoying with GNU and Linux.

    Introduction

    First, let me introduce this book by telling you what I will teach you. By the end of this book, you will have enough information to write small programs that will run on your machine but also allow you to bypass complicated languages like C++, Java, or even the Bash Linux shell. Arguably, the beautiful thing about Assembly is its simplicity.

    RISC-V is great because it is a Reduced Instruction Set Computing device. It has fewer instructions to learn and remember, especially when compared to Intel. It also has more registers available for use. Each of them have special purposes and conventions for how they are used. However, as the programmer, you are allowed to break these conventions because right now, your focus should be on learning it for fun!

    Required Knowledge

    To get the most out of this book, some background on the Binary and Hexadecimal numeral systems is going to be helpful, but this is not strictly required because I will be providing functions you can use in your code that will convert between decimal (base ten), binary (base two), and hexadecimal (base sixteen).

    However, I would say that experience in at least one programming language is necessary for an understanding of terminology like “arrays”, “pointers”, “addresses”, “integers”, etc. I recommend the C Programming Language as a start. C++ is also a good starting language, but it tends to abstract details away that directly apply to Assembly Language, which is the lowest level a human can go for understanding a computer.

    But I think it is perfectly okay for this Assembly language to be your introductory language for the world of computer programming. The language is simple, beautiful, and in my opinion, was designed better than Intel x86. The makers of the RISC-V architecture saw what other processors were doing and in some ways tried to avoid making the same mistakes as previous generations did.

    RISC-V is a new processor type and philosophy that was created in 2010 at University of California, Berkeley. The V in its name is actually the Roman number 5. That means there were apparently those named I,II,III,VI in the past.

    Many people have high hopes about this new computer architecture that is also old enough to trust. Because it is 16 years old at this time and has been standardized, there are many simulators available. This book will present two of these simulators and perhaps a passing mention of others as I learn about them myself and can provide more links.

    But because RISC-V is still relatively young compared to Intel 8086 (year 1978) and ARM (year 1983), I expect that the timing of this book will be of use to people who have heard about RISC-V and wonder what it is about.

    Low Level

    Low level is a term that confuses people. People think something high-level is better than low-level. In simple terms, humans consider themselves superior to machines and therefore think themselves higher or more important because of their abstract thought.

    A computer thinks only in terms of numbers. A computer may not understand “high-level” abstractions such as love, religion, philosophy, etc, but that is not its job. A computer must add, subtract, multiply, and divide. These are the four arithmetic functions that many humans struggle with.

    Therefore, I ask you, between a human and a computer, who is really low level or high level? In the age of Artificial Intelligence taking over human jobs and beating humans at Chess, we would all do well to take this question seriously.

    I wrote this book because I think like a machine, and I hope to help others think this way because it is the best way to learn programming and control your computer by writing Assembly Language programs, or to go back to your favorite programming language with a greater understanding of why things work as they do.

    Why RISC-V

    After writing 3 programming books, I decided I wanted to learn a language that offered the things I love about C and Assembly but was also new and exciting at the time.

    I first learned RISC-V from Robert Winker’s book.

    https://leanpub.com/riscvassemblyprogramming

    It was also available on Leanpub and I thought his teaching style is a standard that I hope to live up to. Obviously he is more experienced and his book is probably better than mine. Even so, I wanted to do my own part to promote education about RISC-V because I want to see a world where programming is easier and computers are cheaper. As much as I love Intel machines because I grew up with them, RISC-V provided me a new learning experience that I hope others discover and enjoy as much as I have!

    Chapter 1: The First Program

    For this chapter, I will explain give the source code of an example program that works in both RARS and riscemu simulators. Take a good look at it and the comments I included. I will be explaining this in detail. I also recommend you type or copy and paste this code into a text editor and save the file as “main.s” in a place on your computer that you prefer.

    Hello World

    .data
    
    string0: .asciz "Hello World!\n"
    
    .text
    
    li a0, 1       # STDOUT file number
    la a1, string0 # address of string 
    li a2, 13      # length of string
    li a7, 64      # write call number
    ecall          # environment call
    
    li a0, 0       # status
    li a7, 93      # exit
    ecall          # environment call
    

    There are two sections named “.data” and “.text”. All variables used in the program should be defined in the .data section. The .text section is where your code starts executing. This organization scheme is required for most simulators and assemblers.

    This program prints “Hello World” followed by a newline. It uses only 3 kinds of instruction and is fairly easy to follow.

    • li = load integer (or immediate value)
    • la = load address (a special kind of integer)
    • ecall = enviroment call (or syscalls)

    The reason that sometimes li is used to load a register and other times la is used is because technically, there is a limit on the size of integers that can be part of an instruction. Instructions like “la” are technically macros for multiple instructions that load upper and lower bits of a register.

    But besides that, having la for memory addresses and li for regular numbers makes the code more readable in my opinion.

    ecall is the how you would call the system calls of your operating system. It is the same idea as “int 0x80” was in my Linux Intel Assembly book. However, in RISC-V, there are different registers and different system call numbers than you would expect on Intel CPUs.

    But more importantly, this program was written for simulators and not a real operating system. The call numbers, which are loaded into the a7 register, are specific to the RARS and riscemu simulators. In the next chapter, I will explain the differences between these two simulators and how to run the program.

    Chapter 2: Simulator Choices

    There are two simulators I personally use and test my code against. Both of them are Free Software and available to download from their Github repositories. I will offer some information about them so you can choose which to use when following along with this book.

    RARS

    RARS is a port of the MARS simulator for MIPS processors. It is written in Java and is downloadable as a

    https://github.com/rarsm/rars

    This book favors RARS because it is easy to use and is reliable enough to use from any operating system. It also supports a lot of system calls and is the simulator I learned to use first. Because it runs using Java, you must have the Java Runtime installed. However, since Java can be installed and run on any operating system, you can be sure that it will work no matter whether your host operating system is Windows, Linux, or Mac.

    On my system, I usually have the file named “rars.jar” in my home directory. This allows me to run my source file like this:

    java -jar ~/rars.jar main.s
    

    Because ~ is a shortcut for the home directory, this allows me to run it from whichever directory I happen to be in that contains my source file, which in this case is named “main.s”.

    riscemu

    Riscemu is a simulator written in Python. It does not have as many system calls built in but it is a good option for people who have Python installed but cannot, or don’t want to install Java.

    https://github.com/AntonLydike/riscemu

    Running a source file with riscemu is even easier that with RARS.

    riscemu main.s
    

    In my experience, riscemu also launches faster than RARS does, mostly just because RARS requires Java to load the whole virtual machine before it starts. Because riscemu is written in Python, and Python is written in C, it is only natural that it might be faster.

    However, riscemu is really picky about having a space after commas in your instructions. It will fail with cryptic error messages if you don’t have proper spacing between your arguments to an instruction. This is probably a bug but it allows for consistency in formatting if you just remember to add a space after each comma. If you don’t like to do this, just forget riscemu and stick with RARS.

    Why use a simulator?

    You might be wondering why I am recommending using these simulators rather than a real assembler for a real machine with an operating system. There are 3 reasons.

    • I don’t have a computer with a RISC-V processor.
    • Simulators can be used by more people because they don’t require buying new hardware.
    • No “risk” in trying out this new RISC based machine.

    In short, I use these simulators or emulators for the same reason I used DOSBox in the DOS version of Assembly Arithmetic Algorithms.

    An emulator allows people to learn the language a Central Processing Unit uses before they have invested time or money into learning it. This means no investment or sacrifice from you.

    In fact, you might decide to forget learning RISC-V Assembly and learn Java or Python instead. Even so, I wrote this book so that I can share what a beautiful language the RISC-V Assembly language is and why I enjoy coding in it.

    Chapter 3: System Calls

    There are many more system calls for RARS than I will be teaching in this book. riscemu has less than RARS but the table below shows the calls that these two simulators both have in common. The 3 calls are enough for most programs.

    System Calls for RARS and riscemu

    Name a7 a0 a1 a2
    exit 93 status
    read 63 fd buf count
    write 64 fd buf count

    For more advanced programs that open and close files, you will need to use different call numbers and also different mode numbers. Unlike Linux and the POSIX system calls, the simulators are meant for teaching the language but you can’t count on them being compatible with each other in the same way. It is pure luck that the system calls for the 3 calls above matched. It is precisely this reason that I chose RARS and riscemu as the simulators for this book.

    Registers on RISC-V

    There are a LOT more registers than there were on Intel machines. This makes using RISC-V very easy because you don’t have to use memory locations as often.

    Name meaning/usage
    zero always = zero
    ra return address
    a0->a7 arguments
    s0->s11 saved values
    t0->t6 temporary

    The zero register is just a register that always equals zero. It may seem weird but remember than RISC-V does not allow comparing a register directly with a number. Normally you need to load a number into another register. But because comparing with zero is a common operation, this zero register is available to be compared or copied any time!

    The ra register is important for function calls. It is the register that keeps where you will return to when the function is done. Because of this, you will run into trouble if you try to do something else with it.

    The other registers can technically be used any way you want except that those starting with ‘a’ are used for arguments to environment calls. For this reason, they are used more than others.

    The registers that begin with ‘s’ or ‘t’ are technically the same but it is a convention or tradition that t0 to t6 are used for temporary cases where you need to add, subtract, multiply, or divide numbers. After you are done with them, you use them for something else and forget what you did with them last time.

    The s0 to s11 registers are the most abundant and you are expected to keep things that endure most or all of the program in them. For example, you might keep a file descriptor in one of them so that you could copy it to the correct ‘a’ register when you need to.

    Because of the fact that you cannot compare or otherwise perform math on memory addresses directly, you have to always load everything into registers. However, because RISC-V has more registers, you can also write programs that run faster because you access memory less often.

    However, you will be loading and saving memory for variables stored in the data section. Usually these will be strings you are printing.

    In the next chapter I will be introducing a function that can print any string by automatically calculating its length. I will also be using the calling convention of the recommended register usage.

    To be continued

  • new program: chastearg

    I wrote a small program for both Linux and DOS assembly. It is very easy to explain what it does with some pictures. The first picture is what it looks like when I use the Linux version on my Debian system. The second is the DOS version running under the DOSBOX emulator.

    As you can see, the words surrounded by quotes are displayed on the same line because they count as one argument. Linux handles this by default but DOS needed some help. I had to rewrite my entire argument filter for the DOS version.

    The reason I wrote this project and worked to make it consistent for both DOS and Linux is because I wanted to do an upgrade to the DOS version of chastext. As you can see from the picture below, I have succeeded!

    When I first posted about my chastext project, some people said it was useless because we can already use sed for Linux or other tools for find and replace. However, my assembly versions are simpler and faster than sed when you don’t need regular expressions. They also don’t depend on anything other than interrupt calls of the operating system.

    But more importantly, their argument is stupid. Writing similar programs to existing programs is a great programming exercise and is especially important for tiny projects where I don’t want to implement all the features of a program or its dependencies. I can also bring the program to platforms that the original program does not support, such as DOS.

    This attitude some people have is one that I don’t like. Should I not sing just because Taylor Swift can sing better than me? Should I not play the piano just because other people can do it better than me? Or should I not play Chess just because I can’t do it as well as Magnus Carlsen or a chess engine?

    I started programming for the joy of learning and writing me own things. I often reinvent the wheel such as how I wrote my own strlen and strcmp functions for my chastext project. I don’t have access to the C standard library with the way I am doing it. I can’t imagine criticizing someone else’s programming project just because it has features to a similar tool that may exist. Otherwise, I would be saying Linus Torvalds should not have created Linux just because Unix and Minix existed which had similar file systems.