📄 math.lis
字号:
.module math.c
.area text(rom, con, rel)
0000 .dbfile ./math.c
0000 .dbfunc e Addition _Addition fV
0000 _Addition::
0000 .dbline -1
0000 .dbline 21
0000 ; #include <..\math.h> //Place the include file here. '..\. used to locate the math.h
0000 ;
0000 ; //We need to tell the compiler that we are going to use some variables outside
0000 ; //this file. We use the 'extern' keyword. The format for using extern is:
0000 ; // extern <type> RamLocation
0000 ; // extern - Keyword to tell the compiler the location is outside this module
0000 ; // <type> - Type is the C declaration (char,int) of the ram location - default is int
0000 ; // Ex. Var blk 1 equates to char
0000 ; // Var blk 2 equates to int
0000 ; // Var blk 4 equates to long
0000 ; // RamLocation - This is the name of the ram location with the _ we declared in main.asm
0000 ;
0000 ; extern int OperandOne; //Notice we dont have the _ we just need it on the export
0000 ; extern int OperandTwo;
0000 ; extern long OperandThree;
0000 ; extern long Result;
0000 ;
0000 ; //Here we declare our C Function. We do not use the _ even though we call it using
0000 ; //the _
0000 ; void Addition()
0000 ; {
0000 .dbline 25
0000 ; //In this function we will add the two numbers in OperandOne and OperandTwo
0000 ; //We will place the location in Result
0000 ;
0000 ; Result = OperandTwo + OperandOne;
0000 5101 mov A,[_OperandTwo+1]
0002 0201 add A,[_OperandOne+1]
0004 5300 mov [__r1],A
0006 5100 mov A,[_OperandTwo]
0008 0A00 adc A,[_OperandOne]
000A 5F0300 mov [_Result+3],[__r1]
000D 5302 mov [_Result+2],A
000F 470280 tst [_Result+2],-128
0012 A009 jz X0
0014 5501FF mov [_Result+1],-1
0017 5500FF mov [_Result],-1
001A 8007 jmp X1
001C X0:
001C 550100 mov [_Result+1],0
001F 550000 mov [_Result],0
0022 X1:
0022 .dbline -2
0022 .dbline 27
0022 ;
0022 ; }
0022 L1:
0022 .dbline 0 ; func end
0022 7F ret
0023 .dbend
0023 .dbfunc e Multiplication _Multiplication fV
0023 _Multiplication::
0023 .dbline -1
0023 .dbline 30
0023 ;
0023 ; void Multiplication()
0023 ; {
0023 .dbline 34
0023 ;
0023 ; //Lets perform a larger calculation that might be a little tougher in
0023 ; //assembly
0023 ; Result = OperandThree * OperandOne;
0023 5F0001 mov [__r3],[_OperandOne+1]
0026 5F0000 mov [__r2],[_OperandOne]
0029 470080 tst [__r2],-128
002C A009 jz X2
002E 5500FF mov [__r1],-1
0031 5500FF mov [__r0],-1
0034 8007 jmp X3
0036 X2:
0036 550000 mov [__r1],0
0039 550000 mov [__r0],0
003C X3:
003C 5100 mov A,[__r0]
003E 08 push A
003F 5100 mov A,[__r1]
0041 08 push A
0042 5100 mov A,[__r2]
0044 08 push A
0045 5100 mov A,[__r3]
0047 08 push A
0048 5100 mov A,[_OperandThree]
004A 08 push A
004B 5101 mov A,[_OperandThree+1]
004D 08 push A
004E 5102 mov A,[_OperandThree+2]
0050 08 push A
0051 5103 mov A,[_OperandThree+3]
0053 08 push A
0054 7C0000 xcall __mul_32X32_32
0057 38FC add SP,-4
0059 18 pop A
005A 5303 mov [_Result+3],A
005C 18 pop A
005D 5302 mov [_Result+2],A
005F 18 pop A
0060 5301 mov [_Result+1],A
0062 18 pop A
0063 5300 mov [_Result],A
0065 .dbline -2
0065 .dbline 36
0065 ;
0065 ; }
0065 L2:
0065 .dbline 0 ; func end
0065 7F ret
0066 .dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -