Update examples to new assembly syntax

This commit is contained in:
Joscha 2019-11-21 19:17:04 +00:00
parent ae0c31d83a
commit 7446bcab45
6 changed files with 50 additions and 57 deletions

View file

@ -1,18 +1,15 @@
; The same as fib.mimasm, but with an increased number of fibonacci numbers to
; calculate. This file takes 11877318 steps to execute.
.reg IAR main
.reg SP -1
.reg FP -1
IAR = main
SP = 0xfffff
FP = 0xfffff
zero: .lit 0 ; Constant value for use with EQL
one: .lit 1 ; Constant value for use with EQL
zero: LIT 0 ; Constant value for use with EQL
one: LIT 1 ; Constant value for use with EQL
tmp1: LIT 0
tmp1: .lit 0
; Variables for main
max-number: LIT 24
current-number: LIT 0
max-number: .lit 24
current-number: .lit 0
ptr: LDC number-array
main:
@ -181,5 +178,5 @@ fib:
RET
; Fibonacci numbers will be written here
300:
number-array: LIT 0
.org 300
number-array:

View file

@ -1,6 +1,4 @@
IAR = main
ACC = 0
RA = 0
.reg IAR main
; This CALL/RET example does not use any sort of stack, and thus can
; only go 1 call deep. Nevertheless, it demonstrates how the CALL and

View file

@ -1,19 +1,17 @@
IAR = main
ACC = 0
RA = 0
SP = 0xfffff
.reg IAR main
.reg SP -1 ; the last addressable address
; In this example, the stack pointer points to the next free address
; below the stack. The stack grows downwards from large to small
; addresses. The stack has no stack frames to simplify the program.
counter: LIT 0
counter: .lit 0
100:
.org 100
main:
; set counter bit 0
LDV counter
ADC 0x01
ADC 0b00001
STV counter
; Since we're top-level, we don't need to (re-)store our RA when calling
@ -21,16 +19,16 @@ main:
; set counter bit 1
LDV counter
ADC 0x02
ADC 0b00010
STV counter
HALT
200:
.org 200
sub-1:
; Set counter bit 2
LDV counter
ADC 0x04
ADC 0b00100
STV counter
;; Store the current RA on the stack
@ -56,16 +54,16 @@ sub-1:
; Set counter bit 3
LDV counter
ADC 0x08
ADC 0b01000
STV counter
RET
300:
.org 300
sub-2:
; Set counter bit 4
LDV counter
ADC 0x10
ADC 0b10000
STV counter
RET

View file

@ -1,15 +1,15 @@
IAR = main
SP = 0xfffff
FP = 0xfffff
.reg IAR main
.reg SP -1
.reg FP -1
zero: LIT 0 ; Constant value for use with EQL
one: LIT 1 ; Constant value for use with EQL
zero: .lit 0 ; Constant value for use with EQL
one: .lit 1 ; Constant value for use with EQL
tmp1: LIT 0
tmp1: .lit 0
; Variables for main
max-number: LIT 10
current-number: LIT 0
max-number: .lit 10
current-number: .lit 0
ptr: LDC number-array
main:
@ -178,5 +178,5 @@ fib:
RET
; Fibonacci numbers will be written here
300:
number-array: LIT 0
.org 300
number-array:

View file

@ -1,14 +1,14 @@
IAR = technique-1
.reg IAR technique-1
; This file demonstrates a few techniques for jumping to an address
; stored in the ACC.
; A few variables
jump-instruction: JMP 0
tmp: LIT 0
tmp: .lit 0
; Jumping by setting the RA and then returning
100:
.org 100
technique-1:
LDC technique-2
STRA
@ -16,13 +16,13 @@ technique-1:
; Jumping by writing a JMP instruction to a memory location and then
; jumping to that (aka. almost self-modifying code)
200:
.org 200
technique-2:
LDC end
OR jump-instruction
STV tmp
JMP tmp
300:
.org 300
end:
HALT

View file

@ -12,27 +12,27 @@
; Functions take a fixed number of arguments. For this example, all
; values have a size of one word (24 bit).
IAR = main
SP = 0xfffff
FP = 0xfffff
.reg IAR main
.reg SP -1
.reg FP -1
; Temporary variables at a fixed memory location
;
; These are useful for commands like ADD, which need a fixed memory
; address. They are always under the complete control of the currently
; running function.
tmp1: LIT 0
tmp2: LIT 0
tmp3: LIT 0
tmp4: LIT 0
tmp5: LIT 0
tmp1: .lit 0
tmp2: .lit 0
tmp3: .lit 0
tmp4: .lit 0
tmp5: .lit 0
100:
.org 100
main:
CALL caller
HALT
200:
.org 200
caller:
;; 1. Initialisation
@ -121,7 +121,7 @@ caller:
RET
300:
.org 300
callee:
; This callee doesn't really need its own stack since all
; calculations did fit into the temporary variables. I still created