ãã¼ãã»ã¯ã¿ããã°ã©ãã³ã°ã§ã¯é常BIOS Functionã³ã¼ã«ã使ãã¯ããããã§ãBIOS Functionã³ã¼ã«ã§æ¼ããããã¼ãåå¾ããã«ã¯ahã¬ã¸ã¹ã¿ã0ã«ãã¦int 0x16ãå¼ã³åºãã°OKãããããã°alã¬ã¸ã¹ã¿ã«æ¼ããããã¼ã®ASCIIã³ã¼ããå ¥ãã®ã§ãããã使ãã以ä¸ãµã³ãã«ãã¢ã»ã³ãã©ã¯nasmã使ã£ã¦ãã
cpu 8086 bits 16 org 0x7C00 %macro draw 3 mov ax, %1 mov cx, %2 mov dx, %3 int 0x10 %endmacro %define CPOS_DEFAULT_X 320 %define CPOS_DEFAULT_Y 400 %define CMOVE_X 4 %define DRAW_BLACK 0x0C00 %define DRAW_GREEN 0x0C02 xor ax, ax mov ds, ax ; si is x ; di is y mov si, CPOS_DEFAULT_X mov di, CPOS_DEFAULT_Y ; init display mov al, 0x12 int 0x10 draw DRAW_GREEN, si, di input_key: ; get key mov ah, 0x00 int 0x16 ; if key is a then left move cmp al, 'a' je left_move ; if key is b then left move cmp al, 'd' je right_move ; wait next key jmp input_key left_move: ; erase current character dot draw DRAW_BLACK, si, di ; next position sub si, word CMOVE_X ; draw character dot draw DRAW_GREEN, si, di ; wait next key jmp input_key right_move: ; erase current character dot draw DRAW_BLACK, si, di ; next position add si, word CMOVE_X ; draw character dot draw DRAW_GREEN, si, di ; wait next key jmp input_key times 510 - ($ - $$) db 0x00 dw 0xAA55