Changeset 59 for branches/ByteArray/Sample.asm
- Timestamp:
- Nov 25, 2023, 11:47:52 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ByteArray/Sample.asm
r57 r59 1 NOP 1 JP Start 2 NOP 3 NOP 4 NOP 2 5 3 LD A, 64 4 LD B, 8 5 OUT (B), A 6 LD B, 0 7 LD C, 10 8 OUT (B), A 6 RET 7 LD R0, (R1) 8 LD (R0), R1 9 LD R0, R1 10 LD R0, 1 11 LD (R0 + 1), R1 12 ;LD (R0), (R1) 13 LD D1, R0, 1 14 LD D1, R0, R1 15 16 JP Start 17 NOP 18 NOP 19 NOP 20 21 VAR DeviceConsole 1 22 VAR ConsoleReadChar 0 23 VAR ConsoleWriteChar 0 24 25 VAR DeviceKeyboard 2 26 27 VAR DeviceScreen 3 28 VAR ScreenGetWidth 0 29 VAR ScreenGetHeight 1 30 VAR ScreenSetAddr 0 31 VAR ScreenWrite 1 32 33 Start: 34 LD R0, 64 35 LD R1, 8 36 OUT (R1), R0 37 LD R1, 0 38 LD R2, 10 39 OUT (R1), R0 9 40 Loop: 10 INC A11 DEC C12 JNZ C, Loop13 HALT41 INC R0 42 DEC R2 43 JNZ R2, Loop 44 HALT 14 45 15 46 WriteStr: 47 ; R0 - string address 48 ; R1 - string length 16 49 PUSH R2 17 50 PUSH R3 18 51 PUSH R4 19 SET R3, ConsoleWriteChar 20 SET R4, DeviceConsole 52 LD R3, ConsoleWriteChar 21 53 WriteStrLoop: 22 54 LD R2, (R0) 23 OUT (R 4: R3), R255 OUT (R3), R2 24 56 INC R0 25 57 DEC R1 … … 35 67 PUSH R2 36 68 PUSH R3 37 SET R0, ScreenSetAddr 38 SET R1, 0 39 SET R3, DeviceScreen 40 OUT (R3: R0), R1 41 SET R0, ScreenGetWidth 42 IN R1, (R3: R0) 43 SET R0, ScreenGetHeight 44 IN R2, (R3: R0) 69 LD R0, ScreenSetAddr 70 LD R1, 0 71 OUT (R0), R1 72 LD R0, ScreenGetWidth 73 IN R1, (R0) 74 LD R0, ScreenGetHeight 75 IN R2, (R0) 45 76 MUL R2, R1 46 SETR0, ScreenWrite47 SETR1, 12077 LD R0, ScreenWrite 78 LD R1, 120 48 79 ClearScreenLoop: 49 OUT (R 3: R0), R180 OUT (R0), R1 50 81 DEC R2 51 82 JNZ R2, ClearScreenLoop … … 58 89 Hello: 59 90 DB 'Hello friend' 91 92 KeyInterrupt: 93 ; Echo key 94 PUSH R3 95 PUSH R2 96 PUSH R4 97 LD R3, ConsoleReadChar 98 IN R2, (R3) 99 LD R3, ConsoleWriteChar 100 OUT (R3), R2 101 POP R4 102 POP R2 103 POP R3 104 RET 105 106 Test: 107 LD R0, (R1 + 1) 108 LD (R1 + 12), R2
Note:
See TracChangeset
for help on using the changeset viewer.