assembly (8086)

Discussion in 'Homework Help' started by fortune2k, Mar 25, 2009.

  1. fortune2k

    Thread Starter Member

    Mar 18, 2009
    19
    0
    Hi im working on a bit of homework and rather stuck

    this is what im trying to do

    Code ( (Unknown Language)):
    1.  
    2.    0) initialise a temporary numerical value to 00H, base value to 10H and count value to 00H
    3.   1) Read in a character
    4.   2) Apply series of checks  against ‘0’-‘9’ and ‘A’-‘F’ and convert the digit to a numerical value as described above
    5.   3) multiply our temporary numerical value by the base (10H) – remember that mul multiplies the src with what is in AL or AX so we need to make sure that the temporary numerical value is moved into AX before we multiply and since AL contains our digit numerical value we will need to push AX to save it for use later - use version b) of mul i.e. src is 16 bit, result in high word in DX (we will discard this) and low word in AX (which we will use). We can safely multiply by the base the first time round as the temporary numerical value will start out as initilised to 0.
    6.   5) pop AX so we can get the new numerical digit value and add it to the temporary numerical value
    7.   6) increment count of digits converted and go back to 1)
    8.    
    9.   Note – you will also need to echo the digit characters input, but you should ignore i.e. not echo, the non-hex digit termination character.
    10.  
    and well this is what i have

    main.asm
    Code ( (Unknown Language)):
    1.  
    2. BITS 16                 ;Set code generation to 16 bit mode
    3. ORG 0x0100;
    4. SECTION .text;
    5.  
    6. MAIN:
    7.     ;call upon the subroutines
    8.     call Getch
    9.     call Putln
    10.     call Putch
    11.     call Putln
    12.     call Exit
    13.    
    14.  %include "Stdio.asm"
    15.  
    stdio.asm
    Code ( (Unknown Language)):
    1.  
    2.    
    3. ;*************************************************************
    4. ;Subroutine Name:  Putch
    5. ;Function:         Outputs a character at the cursor position
    6. ;                  in the console window by calling DOS INT21H
    7. ;Entry Conditions: Character to be output in DL
    8. ;Exit Conditions:  None
    9. ;Exceptions:       None
    10. ;*************************************************************
    11. Putch:
    12. MOV AH, 02h ; display subprogram
    13. INT 21H
    14. RET ; return
    15.  
    16.  
    17.  
    18. ;*************************************************************
    19. ;Subroutine Name:  Getch
    20. ;Function:         Obtains character input from the keyboard
    21. ;Entry Conditions: Character to be moved into DL
    22. ;Exit Conditions:  None
    23. ;Exceptions:       None
    24. ;*************************************************************
    25. Getch:
    26. MOV ah, 1h ; keyboard input subprogram
    27. int 21h ; read character into al
    28. mov DL, AL
    29. RET ; return
    30.  
    31.  
    32.  
    33.  
    34. ;*************************************************************
    35. ;Subroutine Name:  Putln
    36. ;Function:         Outputs a new line at the cursor position
    37. ;                  in the console window by calling DOS INT21H
    38. ;Entry Conditions: Character to be output in AH
    39. ;Exit Conditions:  None
    40. ;Exceptions:       None
    41. ;*************************************************************
    42. Putln: ;new line
    43. mov dl, 0DH ;Carriage return
    44. int 21h
    45. mov dl, 0AH  ;Line feed
    46. int 21H
    47. RET ; return
    48.  
    49.  
    50. ;*************************************************************
    51. ;Subroutine Name:  Exit
    52. ;Function:         When called upon it will exit the program
    53. ;Entry Conditions: None
    54. ;Exit Conditions:  None
    55. ;Exceptions:       None
    56. ;*************************************************************
    57. Exit:
    58.     mov AX, 04C00H
    59.     int 21H
    60.  
    im stuck on part 1 / 2 atm (for some reason my program atm allows you to input up to 3 character and they will be echo'd onto the screen no idea why only 3 )

    anyway what im trying to work on is a if statement i want somthing like
    if(AH>=30h | AH <=39)
    ;the value of the character is 0-9

    else(AH>=41h | AH <=51)
    ;the value is A-Z

    how can i do this in nasm assembler?

    then once i have made sure the value is 0-9 or A-Z then i can do step 3 which i dont really have any idea on how im going to do that either

    thanks in advance
     
Loading...