Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Addressing...

IDKIDK Member Posts: 1,784
I'm trying to load a byte from memmory.

;a lot of code

mov dl, [InputChar+ch]

;a lot of more code
InputChar: db "ASDFJKL"

This wont work but now you hopefully
got my problem.
How do I load the bytes?

Another question:
On an american keyboard, wich button
is right to L ?
On mine it's (I got a swedish one)

[b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]

Comments

  • shaolin007shaolin007 Member Posts: 1,018
    [b][red]This message was edited by shaolin007 at 2005-7-18 6:18:35[/red][/b][hr]
    : I'm trying to load a byte from memmory.
    :
    : ;a lot of code
    :
    : mov dl, [InputChar+ch]
    :
    : ;a lot of more code
    : InputChar: db "ASDFJKL"
    :
    : This wont work but now you hopefully
    : got my problem.
    : How do I load the bytes?
    :
    : Another question:
    : On an american keyboard, wich button
    : is right to L ?
    : On mine it's (I got a swedish one)
    :
    : [b]Niklas Ulvinge[/b] [white]aka [b]IDK[/b][/white]
    :

    [green]
    What are you trying to do? Are you adding ch to the contents at InputChar or are you indexing into that array? By the way, it won't work like that. You can't use the register ch in that way and it is not allowed. See links...

    http://www.clipx.net/ng/asm/ng2e254.php

    [red]edit[/red]
    http://www.clipx.net/ng/asm/ng2e56c.php
    [red]edit[/red]

    You could replace ch with bx and it will work but why do that?

    To the right of my 'L' is the key ';:'.
    [/green]




  • IDKIDK Member Posts: 1,784
    [b][red]This message was edited by IDK at 2005-7-18 8:52:10[/red][/b][hr]
    Edit:
    I fixed it. Thanks.

    This is my cool program:
    binkbb21.asm:
    [code]
    ;
    ;The binary keyboard driver version 2.1
    ;
    ;For now it's only a simple program that looks like a driver.
    ;
    ;I'll make it a driver when I know how...
    ;
    ;

    format mz
    org 100h

    MOV dl, 10 ;print char
    MOV ah, 02h
    INT 21h
    MOV dl, 13 ;print char
    MOV ah, 02h
    INT 21h

    start:
    call PrintInfo

    mov al, 06 ;makes the input buffer not to be full
    mov ah, 0Ch
    mov dl, 0FFh
    int 21h

    xor ax, ax
    IN al, 60h ;get input from keyboard

    ;nop ;something, dont have to be there.

    cmp ax, cx ;loop until input change
    mov cx, ax
    je start

    ;
    ;checking all chars
    ;
    ;beginning with makecodes
    ;
    cmp cx, 1EH
    je makea

    cmp cx, 1FH
    je makes

    cmp cx, 20H
    je maked

    cmp cx, 21H
    je makef

    cmp cx, 24H
    je makej

    cmp cx, 25H
    je makek

    cmp cx, 26H
    je makel

    cmp cx, 27H
    je makeo

    cmp cx, 39H
    je makespace

    cmp cx, 1
    je exit
    ;
    ;the brake codes
    ;

    cmp cx, 9EH
    je brakea

    cmp cx, 9FH
    je brakes

    cmp cx, 0A0H
    je braked

    cmp cx, 0A1H
    je brakef

    cmp cx, 0A4H
    je brakej

    cmp cx, 0A5H
    je brakek

    cmp cx, 0A6H
    je brakel

    cmp cx, 0A7H
    je brakeo


    ;
    ;make codes for each input key
    ; make brake
    ; dec hex hex
    ;a = 30 1E 9E
    ;s = 31 1F 9F
    ;d = 32 20 A0
    ;f = 33 21 A1
    ;j = 36 24 A4
    ;k = 37 25 A5
    ;l = 38 26 A6
    ; = 39 27 A7
    ; = 57 39 B9
    ;(space)
    ;
    ;brake codes are make code + 128
    ;


    endOfChecking:

    jmp start

    exit:
    mov ah, 4Ch
    int 21h




    ;
    ;actions of the make and brake codes
    ;
    makea:
    or bx, 10000000b
    jmp endOfChecking
    makes:
    or bx, 01000000b
    jmp endOfChecking
    maked:
    or bx, 00100000b
    jmp endOfChecking
    makef:
    or bx, 00010000b
    jmp endOfChecking
    makej:
    or bx, 00001000b
    jmp endOfChecking
    makek:
    or bx, 00000100b
    jmp endOfChecking
    makel:
    or bx, 00000010b
    jmp endOfChecking
    makeo:
    or bx, 00000001b
    jmp endOfChecking

    brakea:
    and bx, 01111111b
    jmp endOfChecking
    brakes:
    and bx, 10111111b
    jmp endOfChecking
    braked:
    and bx, 11011111b
    jmp endOfChecking
    brakef:
    and bx, 11101111b
    jmp endOfChecking
    brakej:
    and bx, 11110111b
    jmp endOfChecking
    brakek:
    and bx, 11111011b
    jmp endOfChecking
    brakel:
    and bx, 11111101b
    jmp endOfChecking
    brakeo:
    and bx, 11111110b
    jmp endOfChecking

    makespace:
    MOV dl, bl ;print char
    MOV ah, 02h
    INT 21h

    jmp endOfChecking

    char: db ?


    PrintNumInCl:
    ;convert ax to number and print
    push ax
    push dx

    xor ax, ax
    mov al, cl ;2 char
    mov dh, 100 ;1 char skipping this for now
    div dh

    add al, 30h
    MOV dl, al ;print char
    MOV ah, 02h
    INT 21h

    xor ax, ax
    mov al, cl ;2 char
    mov dh, 100
    div dh
    mov al,ah
    xor ah,ah
    mov dh,10
    div dh

    add al, 30h
    MOV dl, al ;print char
    MOV ah, 02h
    INT 21h

    xor ax, ax
    mov al, cl ;last char
    mov dh, 10
    div dh

    add ah, 30h
    MOV dl, ah ;print char
    MOV ah, 02h
    INT 21h

    pop dx
    pop ax

    ret

    PrintInfo:
    push ax
    push dx
    push cx

    mov ah,03h ;Read Cursor Position and Size
    xor bh,bh ;on page
    int 10h ;rets CH Cursor start line
    push dx ; CL Cursor end line
    ; DH Row
    ; DL Column
    ;
    ; check all states
    ;
    xor dx,dx ;set cursor position
    mov ah,02h
    xor bh,bh
    int 10h

    mov cl,10000000b
    mov ch,8
    PrintInfoLoop:
    mov ax,bx
    and al,cl
    dec ch
    shr cl,1

    cmp al,0
    je PrintSpace

    push cx
    mov cl, ch
    xor ch, ch
    mov DI, cx
    MOV dl, [InputChars+DI] ;print char
    MOV ah, 02h
    INT 21h
    pop cx

    PrintInfoLoopReturn:

    cmp ch,0
    jne PrintInfoLoop

    MOV dl, 20h ;print char
    MOV ah, 02h
    INT 21h

    MOV dl, '=' ;print char
    MOV ah, 02h
    INT 21h

    MOV dl, 20h ;print char
    MOV ah, 02h
    INT 21h

    mov cl, bl
    call PrintNumInCl


    pop dx ;set cursor position
    mov ah,02h
    xor bh,bh
    int 10h

    pop cx
    pop dx
    pop ax

    ret

    PrintSpace:
    MOV dl, 20h ;print char
    MOV ah, 02h
    INT 21h
    jmp PrintInfoLoopReturn


    InputChars: db ";LKJFDSA"
    [/code]
Sign In or Register to comment.