initial commit

This commit is contained in:
2019-02-19 22:02:06 +01:00
commit 59e78f996f
14 changed files with 405 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
@ <intstruction> <destination> , <operand>, <operand>
.global _start
_start:
MOV R0, #20
B other
MOV R0, #11
other:
MOV R7, #1
SWI 0

View File

@@ -0,0 +1,32 @@
@ <intstruction> <destination> , <operand>, <operand>
.global _start
/*
CMP R1. R2
if R1 < R2 then N is enabled
if R1 > R2 then N is disabled
if R1 == R2 then Z is enabled
*/
_start:
MOV R1, #20
MOV R2, #10
CMP R1, R2
BEQ values_equal
BGT values_greater
values_less:
MOV R0, #2
B end
values_equal:
MOV R0, #1
B end
values_greater:
MOV R0, #3
end:
MOV R7, #1 @ exit to terminal
SWI 0 @ system reads R7 after interrupt

View File

@@ -0,0 +1,16 @@
.global _start
_start:
MOV R7, #4 @ system call to say we want to output
MOV R0, #1 @ use the window as output device
MOV R2, #12 @ length of our output message
LDR R1, =message
SWI 0
end:
MOV R7, #1
SWI 0
.data
message:
.ascii "Hello World\n"

View File

@@ -0,0 +1,23 @@
.global _start
_start:
MOV R7, #3 @ system call to say we want to read input
MOV R0, #0 @ read from input device keyboard
MOV R2, #10 @ read 10 chars
LDR R1, =message
SWI 0
_write:
MOV R7, #4 @ output
MOV R0, #1 @ to screen
MOV R2, #5 @ 5 chars
LDR R1, =message
SWI 0
end:
MOV R7, #1
SWI 0
.data
message:
.ascii " "

View File

@@ -0,0 +1,14 @@
@ <intstruction> <destination> , <operand>, <operand>
.global _start
_start:
MOV R1, #0x04
MOV R2, #0x03
MOV R3, #0x08
ADD R0, R1, R1
SUB R0, R1, #0x02
MUL R0, R1, R2
MLA R0, R1, R2, R3
MOV R7, #1
SWI 0

View File

@@ -0,0 +1,11 @@
@ instruction <destination>, <operand>, <operand>
.global _start
_start:
MOV R1, #5 @ 0101
MOV R2, #9 @ 1001
AND R0, R1, R2
end:
MOV R7, #1
SWI 0

34
armv6/tutorial/makefile Normal file
View File

@@ -0,0 +1,34 @@
AS = as
LINKER = ld
%.o: %.s
$(AS) $^ -o $@
tutorial: tutorial.o
$(LINKER) $^ -o $@
tutorial2: tutorial2.o tutorial2p2.o
$(LINKER) $^ -o $@
helloworld: helloworld.o
$(LINKER) $^ -o $@
inputexample: inputexample.o
$(LINKER) $^ -o $@
instructions: instructions.o
$(LINKER) $^ -o $@
branching: branching.o
$(LINKER) $^ -o $@
conditionaljump: conditionaljump.o
$(LINKER) $^ -o $@
.PHONY: clean
clean:
rm *.o
rm tutorial
rm tutorial2
rm helloworld
rm inputexample

15
armv6/tutorial/tutorial.s Normal file
View File

@@ -0,0 +1,15 @@
@single line comment
/*
Multi line comment
*/
.text
.global _start @entry point
_start: @label
MOV R0, #65
MOV R7, #1
SWI 0

View File

@@ -0,0 +1,4 @@
.global _start
_start:
MOV R0, #65
BAL _part2

View File

@@ -0,0 +1,4 @@
.global _part2
_part2:
MOV R7, #1
SWI 0

View File

@@ -0,0 +1,22 @@
/*
bit = 1 bit
nibble = 4 bits
byte = 8 bits
word = 32 bits
*/
/*
16 registers of length word
13 general purpose
1 stack pointer
1 link register
1 program counter
*/
/*
CPSR = Current Program Status Registers
N = negative result flag
Z = zero result flag
C = carry over flag
V = overflow flag
*/