My syntax for labels is simple. Everything that has an underscore before the label name is independent and must be called.

Everything That does not have a label is part of something independent and can not be called individually.

The problem I am having with my code is the appearance of "ABCD " even though there is no " " char in my code.

I feel like it is an imbalance in my PUSH's and POP's but alas I am blind to it.

Any incite is greatly appreciated.

_START:
        ;Clear Registers
    XOR    AX, AX
    XOR    BX, BX
    XOR    CX, CX
    XOR    DX, DX
   
_MAIN:             
    CALL    _CHECKFORKEY
    JMP    _MAIN

_CHECKFORKEY:
        ;Store Registers
    PUSHA
        ;Set Up For Int
    MOV    AH,1
        ;Check For Key Press
    INT    16h   
        ;If Key Press Jump To SKIP
    JNE      SKIP
        ;Restore Registers
    POPA       
        ;Return Control
    RET
   
    SKIP:
    PUSH    AX             
    MOV    AL, 'A'
    CALL    _PRINTCHAR
    POP    AX
        ;Check For Backspace
    CMP    AL, 08h
        ;If So Move To BACKSPACE
    JE      BACKSPACE
    PUSH    AX             
    MOV    AL, 'B'
    CALL    _PRINTCHAR
    POP    AX
        ;Check For Return
    CMP    AL, 0Dh     
        ;If So Jump To RETURN
    JE      RETURN
    PUSH    AX             
    MOV    AL, 'C'
    CALL    _PRINTCHAR
    POP    AX
        ;Check For Non-Normal Character
    CMP    AL, 7Eh 
        ;If So Jump To FINISHED
    JG      FINISHED
    PUSH    AX             
    MOV    AL, 'D'
    CALL    _PRINTCHAR
    POP    AX             
    CALL    _PRINTCHAR
        ;Check For Non-Normal Character
    CMP    AL, 20h                   
        ;If So Jump To FINISHED
    JL      FINISHED 
    PUSH    AX             
    MOV    AL, 'E'
    CALL    _PRINTCHAR
    POP    AX
        ;Print Single Character
    CALL    _PRINTCHAR
        ;Jump To Finished
    JMP    FINISHED

    BACKSPACE:
        ;Set Up For Int
    MOV    AH, 03h
        ;Get Cursor Location
    INT    10h           
        ;Set Up For Int
    MOV    AH, 02h
        ;Check To See If The Current Column Location is '0'
    CMP    DL, 0
        ;If So, Jump To Back Line To Bandle Backspace Differently
    JE      BACKLINE
        ;Set Cursor Location Back By One Column
    DEC    DL 
        ;Put Cursor Location Back By One Column
    INT    10h
        ;Jump To FINISHED
    JMP    FINISHED

    BACKLINE:
        ;Check To See If Cursor Is On The Top Most Line
    CMP    DH, 0
        ;If So  Jump To NOHIGHER
    JE      NOHIGHER
        ;Jump To FINISHED (FOR NOW)
    JMP    FINISHED

    NOHIGHER: 
        ;Jump To FINISHED
    JMP    FINISHED

    RETURN:
        ;Set Up Register To Receive Cursor Location
    MOV    AH, 03h
        ;Call Int
    INT    10h
        ;Set Up Registers To Set Cursor Position
    MOV    AH, 02h                           
        ;Increment The Row
    INC    DH           
        ;Set The Column To 0
    XOR    DL, DL         
        ;Move The Cursor
    INT    10h

    FINISHED:
        ;Remove Character From Keyboard Buffer And Return To Check
    CALL    _KEYBUFCHAR
        ;Restore Registers
    POPA
        ;Return Control
    RET
     
        ;Removes One Char From Keyboard Buffer
        ;Returns Everything Sent To It Exactly As It Was
_KEYBUFCHAR:
        ;Store Register In AX
    PUSH    AX           
        ;Set Up Registers For Int
    XOR    AH, AH                         
        ;Call Interrupt To Clear Character
    INT    16h
        ;Restore Original Register Value
    POP    AX   
        ;Return Control
    RET

        ;Prints The Char In AL
        ;Returns Everything Sent To It Exactly As It Was     
_PRINTCHAR:           
        ;Store Register In BX
    PUSH    BX
        ;Move ASCII Char In AL To BL
    MOV    BL, AL
        ;Store AH In AX Register
    PUSH    AX
        ;Set Up Registers For Int
    MOV    AH, 0Eh
        ;Set Up Registers For Int
    MOV    AL, BL
        ;Call Interrupt To Write
    INT    10h
        ;Restore Register In AX
    POP    AX
        ;Restore Register In BX
    POP    BX
        ;Return Control
    RET
Posted on 2011-10-30 15:51:54 by watachiaieto
Sorry, I guess it works fine. I recompiled it... Either way i realize now this code is in the wrong section. If you want to use it as an algorithm you may...
Posted on 2011-10-30 16:07:28 by watachiaieto