.section data 0x1000 { number: .u8 10 main: ; Test addition mov %status, 1 add %r0, 1 cmpeq %r0, 1 jz end ; Test addition from a register mov %status, 2 add %r0, %r0 cmpeq %r0, 2 jz end ; Test addition from a u8 location mov %status, 3 add %r0, (number)u8 cmpeq %r0, 12 jz end ; Test addition overflow mov %status, 4 add %r0, 0xFFFFFFFFFFFFFFFF cmpeq %r0, 11 jz end ; Test subtraction mov %status, 5 mov %r0, (number)u8 sub %r0, 1 cmpeq %r0, 9 jz end ; Test subtraction from a register mov %status, 6 mov %r1, 2 sub %r0, %r1 cmpeq %r0, 7 jz end ; Test subtraction overflow mov %status, 7 sub %r0, 8 cmpeq %r0, 0xFFFFFFFFFFFFFFFF jz end ; Test multiplication mov %status, 8 mov %r0, (number)u8 mul %r0, 1 cmpeq %r0, 10 jz end ; Test multiplication from a register mov %status, 9 mov %r1, 2 mul %r0, %r1 cmpeq %r0, 20 jz end ; Test negative multiplication mov %status, 10 mul %r0, 0xFFFFFFFFFFFFFFFF ; -1 cmpeq %r0, 0xFFFFFFFFFFFFFFEC ; -20 jz end ; Test division mov %status, 11 mov %r0, (number)u8 div %r0, 2 cmpeq %r0, 5 jz end ; Test integer division mov %status, 12 mov %r1, 2 div %r0, %r1 cmpeq %r0, 2 jz end ; Test negative division with idiv mov %status, 13 idiv %r0, 0xFFFFFFFFFFFFFFFF ; -1 cmpeq %r0, 0xFFFFFFFFFFFFFFFE ; -2 jz end ; Test modulo mov %status, 14 mov %r0, (number)u8 mod %r0, 4 cmpeq %r0, 2 jz end ; Test mod from a register mov %status, 15 mod %r0, %r0 cmpeq %r0, 0 jz end ; TODO : Test mod and div by zero mov %status, 0 end: halt .export main } .meta { ip: main }