; 测试的代码 ;mov a, 0x0f ; 写入0x0f到A寄存器 ;mov d, a ;mov a, [0x05] ;mov b, [a] ;nop ; mov [0x0], 0xff ;mov a, 0xff ;mov [0x0], a ; 转移指令测试 mov d, 0 increase: inc d cmp d, 0x5 jz decrease jmp increase decrease: dec d cmp d, 0x0 jz increase jmp decrease end: hlt ;逻辑运算 测试 ;mov a, 5 ;mov d, 2 ; and a, d ; a:0 ; or a, d ; a: 111 mov a, 5 ; 101 mov d, 4 ; 100 xor a, d ; a: 00000001 not a ; a: 1111_1110 hlt ; 加减 1 测试 mov a, 253 inc a inc a inc a dec a ; a: 0xff, psw: 101 dec a dec a dec a dec a dec a dec a hlt ; 加减法测试 mov b, 5 add b, 3 ; b:8 mov a, b ; a: 8 add a, b ; a: 10 add a, 250 mov a, 0 mov b, 0 add a, b mov a, 5 mov b, 2 sub a, b sub a, 4 mov a, 4 mov b, 2 sub a, b ; a: 2 hlt ; mov 指令测试 mov [0x33], 0x99 mov a, [0x33] mov [0x2f], a mov a, 0x2f mov [0x0], [a] mov a, 0x00 mov [a], 0x05 ; 0x00: 0x5 mov a, 0x01 mov [a], [0x00] ; 0x01: 0x5 mov b, 0x02 mov d, 0x00 mov [b], [d] ; 0x03: 0x5 hlt