From 3af03f58f84a0e9cf096c68adecda96c1d1a21ce Mon Sep 17 00:00:00 2001 From: zxq5 Date: Thu, 19 Jun 2025 18:07:57 +0100 Subject: [PATCH] Update assembler/usage --- assembler%2Fusage.md | 83 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/assembler%2Fusage.md b/assembler%2Fusage.md index 7fe3075..af296fa 100644 --- a/assembler%2Fusage.md +++ b/assembler%2Fusage.md @@ -775,8 +775,58 @@ include fib "../resources/dsa/fib.dsa" ``` ## Example Programs and libraries. +```dsa +// lib: +// print.dsa + +// usage: +// +// include print """ +// +// usage for print: +// push (register containing address of string) +// push pcx +// jmp print::print +// +// usage for reset: +// push pcx +// jmp print::reset + +dw display: 0x20000 +dw current: 0x20000 + +reset: + pop ret + ldw display, rg1 + stw rg1, current + jmp 4, ret + +print: + pop ret // return address + pop rg0 // string + ldw current, rg1 + +loop: + ldb rg0, acc + stb acc, rg1 + + iadd rg0, 1 + iadd rg1, 1 + + cmp acc, zero + jne loop + + // return +end: + // set current to + stw rg1, current + jmp 4, ret +``` + ```dsa +// lib: +// fib.dsa // this is a simple library to calculate the fibonacci sequence up to n, writing each value to the stack. fib_n: @@ -799,6 +849,39 @@ start: jmp 4, ret ``` +```dsa +include print "print.dsa" +include fib "fib.dsa" + +dw stack: 0x10000 +db string: "An idiot admires complexity, a genius admires simplicity, +a physicist tries to make it simple, for an idiot anything the more complicated it is, +the more he will admire it, if you make something so clusterfucked he can't understand it he's +gonna think you're a god cause you made it so complicated nobody can understand it. +That's how they write journals in Academics, they try to make it so complicated people think you're a genius" + +init: + ldw stack, bpr + mov bpr, spr + +start: + lwi string, rg1 + + // push variables + push rg1 // string address. + push pcx // return address. + + // call + jmp print::print + + + lli 25, rg0 + push rg0 + push pcx + jmp fib::fib_n + + hlt +```