-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathNEGATIVE.arm
More file actions
43 lines (35 loc) · 1.31 KB
/
Copy pathNEGATIVE.arm
File metadata and controls
43 lines (35 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Includes
#include "./STACK.arm"
// ///////////////////////////////////////////////////////////
// // This code calls the function called "RegCToNegative". //
// // Similar to "RegCToNegative();" in c++ //
// // Uncomment this and place it where you want it called //
// ///////////////////////////////////////////////////////////
// asm"
// pcr
// "
// add @A,18 -> $_STACK_VAL
// sub $_STACK_POINTER,1 -> $_STACK_POINTER
// change *$_STACK_POINTER = $_STACK_VAL
// goto #RegCToNegative
/////////////////////////////////////////////////////////////////////////////////////////
// This is a function which converts a number to/from a negative using twos compliment //
/////////////////////////////////////////////////////////////////////////////////////////
#RegCToNegative
asm"
swpc
not
ldib 1
add
swpc
"
///////////////////////////////////////////////////////////////////
// This is a "return;" statement. It will end function execution //
// and continue after the above function call //
///////////////////////////////////////////////////////////////////
change $_STACK_VAL = *$_STACK_POINTER
add $_STACK_POINTER,1 -> $_STACK_POINTER
change @A = $_STACK_VAL
asm"
jreg
"