145 lines
1.8 KiB
Text
145 lines
1.8 KiB
Text
; =============================================
|
|
; compiled with Copper 1.0
|
|
; 2015-10-11 17:43:16
|
|
; =============================================
|
|
|
|
; native method: print(…)
|
|
; native method: shutdown(…)
|
|
; native method: outb(…)
|
|
; native method: inb(…) → UINT8
|
|
; native method: toInt8(…) → INT8
|
|
; native method: toInt16(…) → INT16
|
|
; native method: toInt32(…) → INT32
|
|
; native method: toUInt8(…) → UINT8
|
|
; native method: toUInt16(…) → UINT16
|
|
; native method: toUInt32(…) → UINT32
|
|
.type CpuState {
|
|
eax : UINT32;
|
|
ebx : UINT32;
|
|
ecx : UINT32;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; 0, sendCommand
|
|
sendCommand:
|
|
pushnil ; return value
|
|
_private_0:
|
|
pushi 4 100
|
|
callnr inb 1
|
|
pushi 3 2
|
|
op2 12
|
|
pushi 3 0
|
|
op2 6
|
|
jmp_if_not _private_1
|
|
jmp _private_0
|
|
_private_1:
|
|
|
|
load -1
|
|
pushi 2 96
|
|
callnr toUInt16 1
|
|
calln outb 2
|
|
|
|
ret
|
|
; end of sendCommand
|
|
|
|
; 0, initKeyboard
|
|
initKeyboard:
|
|
pushnil ; return value
|
|
_private_2:
|
|
pushi 4 100
|
|
callnr inb 1
|
|
pushi 3 1
|
|
op2 12
|
|
pushi 3 0
|
|
op2 6
|
|
jmp_if_not _private_3
|
|
pushi 4 96
|
|
calln inb 1
|
|
|
|
jmp _private_2
|
|
_private_3:
|
|
|
|
ret
|
|
; end of initKeyboard
|
|
|
|
; 1, main
|
|
.export main
|
|
main:
|
|
pushnil ; return value
|
|
pushnil ; i:INT32
|
|
pusht "Initialize keyboard...\n"
|
|
calln print 1
|
|
|
|
call initKeyboard 0
|
|
|
|
pusht "\n"
|
|
pushi 2 16
|
|
callnr toInt8 1
|
|
calln print 2
|
|
|
|
pusht "Hello World!\n"
|
|
calln print 1
|
|
|
|
pushi 2 1
|
|
store 1
|
|
|
|
_private_4:
|
|
load 1
|
|
pushi 2 5
|
|
op2 8
|
|
jmp_if_not _private_5
|
|
pusht "\n"
|
|
load 1
|
|
calln print 2
|
|
|
|
load 1
|
|
pushi 2 1
|
|
op2 0
|
|
store 1
|
|
|
|
jmp _private_4
|
|
_private_5:
|
|
|
|
ret
|
|
; end of main
|
|
|
|
|
|
; 1, irq
|
|
.export irq
|
|
irq:
|
|
pushnil ; return value
|
|
pushnil ; scancode:UINT8
|
|
load -1
|
|
pushi 2 33
|
|
op2 5
|
|
jmp_if_not _private_6
|
|
pushi 4 96
|
|
callnr inb 1
|
|
store 1
|
|
|
|
pusht "\n"
|
|
load 1
|
|
pusht "keypress: "
|
|
calln print 3
|
|
|
|
load 1
|
|
pushi 3 1
|
|
op2 5
|
|
jmp_if_not _private_7
|
|
calln shutdown 0
|
|
|
|
_private_7:
|
|
|
|
_private_6:
|
|
|
|
ret
|
|
; end of irq
|
|
|