diff --git a/README.md b/README.md index 3343e30..56663bb 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,15 @@ as -o model.o model.S ld -o model model.o ``` + +#### R0 Status Codes (Linux) + +``` + 1 : standard out (monitor) +``` + +#### R7 Linux Service Commands + +``` + 4 : write string +``` diff --git a/math/modulus/mod.S b/math/modulus/mod.S new file mode 100644 index 0000000..91dce6a --- /dev/null +++ b/math/modulus/mod.S @@ -0,0 +1,13 @@ +/***************************************************************************** +* +* Name: +* +* Description: +* +* Author: Curtis L. Lewis +* Date: +* +******************************************************************************/ +/* +-------|-------|----------------|---------------------------------------------- +*/ diff --git a/utils/v_dec/README.md b/utils/v_dec/README.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/utils/v_dec/README.md diff --git a/utils/v_dec/v_dec_orig.S b/utils/v_dec/v_dec_orig.S new file mode 100644 index 0000000..11aadcd --- /dev/null +++ b/utils/v_dec/v_dec_orig.S @@ -0,0 +1,56 @@ +/***************************************************************************** +* +* Name: v_dec_orig +* +* Description: display numbers in decimal +* +* From Chapter 7 of "Assembly Language Using the Raspberry Pi" by Robert Dunne +* Pages: 151 - 168 +* +* Author: +* Date: +* +*------|-------|----------------|---------------------------------------------- +* +******************************************************************************/ + + .global _start + +_start: mov r0, #125 // An arbitrary sample decimal value for test + bl v_dec // Call subroutine to view dec value in R0 in + // ASCI + mov r0, #0 // Exit status code + mov r7, #1 // service command to terminate program + svc 0 // Issue Linux command to terminate program + +/* + Subroutine v_dec will display a 32-bit register in decimal digits + + r0 : contains number to be displayed + if negative (bit 31 = 1), then a minus sign will be output + lr : contains return address + + ALL REGISTER CONTENTS WILL BE PRESERVED +*/ + +v_dec: push {r0 - r7} // Save contents of registers r0 through r7 + mov r3, r0 // r3 will hold a copy of input word to be + // displayed + mov r2, #1 // number of characters to display at a time + mov r0, #1 // code for standard output + mov r7, #4 // Linux service command to write string + +// If bit 31 is set, then register contains a negative number and "-" should +// be output. + + cmp r3, #0 // determin if minus sign is needed + bge absval // if positive number, then display it + ldr r1, =msign // address of minus sign in memory + svc 0 // service call to write string out to stdout + + rsb r3, r3, #0 // get absolute value (negative of negative) + // for display + +/* +-------|-------|----------------|---------------------------------------------- +*/