I have managed to get a simple "Hello World" program to work!
Hopefully, now I have more of an idea what the assembler program should look like, I will be able to do some more.
mark
grep __NR_ /usr/include/asm/unistd.h
mov r3, r1ldr r2, =6099.section .data
string:
.asciz "Euclid's Algorithm: Greatest Common Divisor\n"
result:
.asciz "Result: %d\n"
.text
.globl main
main:
ldr r0, =string
bl printf
ldr r2, =6099
ldr r3, =2166
loopa:
loopb:
sub r4, r2, r3
cmp r4, r3
movge r2, r4
bge loopb
cmp r4, $0
movgt r2, r3
movgt r3, r4
bgt loopa
moveq r1, r3
ldr r0, =result
bl printf
mov r7, $1
swi 0
antiloquax wrote:In line 30, it's never going to be less than zero, since r4 is the remainder.
antiloquax wrote:I've also been reading about using immediate values. It just so happens that the example from TAOCP works, but I think I should have used(for example).
- Code: Select all
ldr r2, =511
mov r0, #0xf00d.code32
myRoutine:
...
ldr r0, _myLiteral ; load my literal
...
bx lr
.ltorg
_myLiteral:
dc.l 0xfeedface
mov r0, #0xface
movt r0, #0xfeed
Donald Knuth wrote:Many computer users feel that input and output are not actually part of "real" programming; input and output are considered to be tedious tasks that people must perform only because they need to get information in and out of a machine.
m:
.long 6099
n:
.long 2166 ldr r5, =m
ldr r2, [r5], $4
ldr r5, =n
ldr r3, [r5], $4digit = pow(10, index)
[--buf] = '0' + (value / digit % 10)