prompt the user to change background and foreground

Reply

Join Date: Jun 2007
Posts: 42
Reputation: sickly_man is an unknown quantity at this point 
Solved Threads: 0
sickly_man's Avatar
sickly_man sickly_man is offline Offline
Light Poster

prompt the user to change background and foreground

 
0
  #1
Apr 22nd, 2008
hello everybody. the project im working on asks me to propmt the user once to change the background color and once to change the foreground (text) color. right now my program prompts the user...but not with the message i have in the data segment...it spits out some unattractive code. could some of you kind assembly programmers take a look at my code? IM NOT ASKING THAT YOU DO MY ASSIGNMENT FOR ME! ive done work, i am just stuck on the keyboard input part....im doing something wrong with displaying my prompt and getting keyboard input. thanks in advance. my code is below.

and btw im using a TASM compiler and TLINK linker and running this in the Windows command prompt.

  1. TITLE Homework 7 attempt # 2
  2. ;............................................................
  3. STACKSG SEGMENT PARA STACK 'Stack'
  4. DB 32 dup(0) ;32 words, might want to set larger
  5. STACKSG ENDS
  6. ;.................................................................
  7. DATASG SEGMENT PARA 'Data' ;data segment
  8. paralst LABEL BYTE
  9. maxlen db 10
  10. actlen db ?
  11. dbdata db 10 DUP('$')
  12. prompt1 DB 'Enter a foreground color:$', '$'
  13. prompt2 DB 'Enter a background color:$', '$'
  14.  
  15. DATASG ENDS
  16. ;.............................................................
  17. CODESG SEGMENT PARA 'Code'
  18. MAIN PROC FAR ;main procedure
  19. ASSUME SS:STACKSG, DS:DATASG, CS:CODESG
  20. MOV AX,DATASG ;Set address of data
  21. MOV DS,AX ;Segment in DS
  22.  
  23.  
  24. ; CODE GOES HERE!!!!
  25.  
  26. ; CHANGE OUTER BACKGROUND COLOR
  27. mov ah, 06H
  28. mov al, 0
  29. mov bh, 10H
  30. mov cx, 0000H
  31. mov dx, 184FH
  32. int 10H
  33.  
  34. ; CHANGE INNER BACKGROUND COLOR
  35. mov ah, 06H
  36. mov al, 0
  37. mov bh, 70H
  38. mov cx, 060FH
  39. mov dx, 1240H
  40. int 10H
  41.  
  42. ; SET CURSOR POSITOIN
  43. mov ah, 02H
  44. mov bh, 00
  45. mov dh, 09
  46. mov dl, 30
  47. int 10h
  48.  
  49. ; DISPLAY PROMPT TO USER
  50. mov ah, 09H
  51. lea bx, prompt1
  52. int 21H
  53.  
  54. ; GET KEYBOARD INPUT
  55. mov ah, 0ah
  56. lea dx, paralst
  57. int 21h
  58.  
  59. ;check if no characters entered
  60. lea dx, actlen
  61. cmp actlen, 0
  62. je again
  63.  
  64. ; CHECK FOR A CHAR CODE
  65. lea dx, dbdata
  66.  
  67. ; CHECK FOR Red
  68. cmp dx, 72h ;lower case r
  69. je code_R
  70.  
  71. ;check for Green
  72. cmp dx, 67h ;lower case g
  73. je code_G
  74.  
  75. jmp again ; dont change color
  76.  
  77. ;to clear screen and set background to red
  78. code_R: mov ah, 06h
  79. mov al, 0
  80. mov bh, 40h
  81. mov cx, 060Fh
  82. mov dx, 1240h
  83. int 10h
  84.  
  85. ;to clear screen and set background to green
  86. code_G: mov ah, 06h
  87. mov al, 0
  88. mov bh, 20h
  89. mov cx, 060Fh
  90. mov dx, 1240h
  91. int 10h
  92.  
  93. again: jmp again
  94.  
  95. MOV AX,4C00H ;End processing
  96. INT 21H
  97. MAIN ENDP ;End procedure
  98. CODESG ENDS ;End segment
  99. END MAIN ;End program
Henry Phillips
Web Programmer
Adirondack Area Network, LLC
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC