Thread: Assembly help

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Assembly help


    I have done half, but don't know other half.
    By looking at the comment, fill in the question marked filled.

    org 100h
    jmp START

    _numberOperators EQU 7h
    operatorString db ' +-*/^()' ;list of valid operators for IS_OPERATOR preceeded with a space

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;This infinite loop reads a one character symbol from the keyboard and echoes it to the screen.
    ;Then calls IS_OPERATOR to find if it is true(1) or false(0) that the symbol is an operator.
    ;The '1' or '0' rv is sent to the screen and the screen advances to a new line.
    ;Kill this infinite loop by clicking the window's x button

    START:
    mov ah, 07h ;Read symbol
    int 21h ;from keyboard.
    mov ah, 02h ;Echo
    mov dl, al ;symbol
    int 21h ;to screen

    push dx ;Push argument. The previous "mov dl, al" moved symbol into dl.
    call IS_OPERATOR ;Call IS_OPERATOR to find if input symbol is an operator.
    pop dx ;This loads dl with rv (1 0r 0) to be echoed to screen.
    mov ah, 02h ;Send rv
    int 21h ;to screen

    ;Advance screen to new print line
    mov ah, 02h
    mov dl,0Dh
    int 21h
    mov dl,0Ah
    int 21h

    jmp START ;Jump to START of infinite loop
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;IS_OPERATOR returns true(1) or false(0) that the input parameter is an operator
    IS_OPERATOR Proc

    ;Push 3 registers subrtn will use.
    push ax ;Stores the input char in al
    push bx ;Used as subscript i in C++ version
    push bp ;Stores sp

    ;???????? ;mov sp to bp

    ;??? ;mov argument (input char) to ax
    ;??? ;mov _numberOperators to bx
    ;??? ;mov input char to beginning of operatorString; in C++ operatorString[0]=symbol;

    jmp WHILE_CONDITION
    WHILE_TOP: ;loop to see if input is an operator
    ;??? ;in C++ i = i-1;
    WHILE_CONDITION:
    ;cmp ??? ;check to see if the input is equal to one of the operators:
    ;j? ??? ;in C++ if (symbol != operators[i])goto WHILE_TOP;

    ;If bx=0, symbol wasn't found in the original initialization of the array and return 0 (equivalent to false).
    ;Else symbol was part of the original initialization of the array and set bx=1 (equivalent to true).
    ;cmp ???
    ;???
    ;??? ;set up to return 1 (the symbol is an operator).
    END_IF:

    ;this line makes 0 into '0' and 1 into '1' so they will print to the screen in ascii
    add bx,30h ;AFTER proving to me that your pgm works, remove this line

    ;??? ;mov bx (the rv) to the stack

    ;Restore registers subrtn used
    ;???
    ;???
    ;???
    ret
    IS_OPERATOR ENDP
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    THE OUT PUT SHOULD LOOK LIKE THIS:
    +1
    -1
    *1
    /1
    ^1
    <1
    >1
    00
    10
    20
    30
    40
    50
    60
    70
    80
    90
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2007
    Posts
    765
    Rep Power
    929
    sub{*{$::{$_}}{CODE}==$_[0]&& print for(%:: )}->(\&Meh);

IMN logo majestic logo threadwatch logo seochat tools logo