| | |
prompt the user to change background and foreground
![]() |
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.
and btw im using a TASM compiler and TLINK linker and running this in the Windows command prompt.
Assembly Syntax (Toggle Plain Text)
TITLE Homework 7 attempt # 2 ;............................................................ STACKSG SEGMENT PARA STACK 'Stack' DB 32 dup(0) ;32 words, might want to set larger STACKSG ENDS ;................................................................. DATASG SEGMENT PARA 'Data' ;data segment paralst LABEL BYTE maxlen db 10 actlen db ? dbdata db 10 DUP('$') prompt1 DB 'Enter a foreground color:$', '$' prompt2 DB 'Enter a background color:$', '$' DATASG ENDS ;............................................................. CODESG SEGMENT PARA 'Code' MAIN PROC FAR ;main procedure ASSUME SS:STACKSG, DS:DATASG, CS:CODESG MOV AX,DATASG ;Set address of data MOV DS,AX ;Segment in DS ; CODE GOES HERE!!!! ; CHANGE OUTER BACKGROUND COLOR mov ah, 06H mov al, 0 mov bh, 10H mov cx, 0000H mov dx, 184FH int 10H ; CHANGE INNER BACKGROUND COLOR mov ah, 06H mov al, 0 mov bh, 70H mov cx, 060FH mov dx, 1240H int 10H ; SET CURSOR POSITOIN mov ah, 02H mov bh, 00 mov dh, 09 mov dl, 30 int 10h ; DISPLAY PROMPT TO USER mov ah, 09H lea bx, prompt1 int 21H ; GET KEYBOARD INPUT mov ah, 0ah lea dx, paralst int 21h ;check if no characters entered lea dx, actlen cmp actlen, 0 je again ; CHECK FOR A CHAR CODE lea dx, dbdata ; CHECK FOR Red cmp dx, 72h ;lower case r je code_R ;check for Green cmp dx, 67h ;lower case g je code_G jmp again ; dont change color ;to clear screen and set background to red code_R: mov ah, 06h mov al, 0 mov bh, 40h mov cx, 060Fh mov dx, 1240h int 10h ;to clear screen and set background to green code_G: mov ah, 06h mov al, 0 mov bh, 20h mov cx, 060Fh mov dx, 1240h int 10h again: jmp again MOV AX,4C00H ;End processing INT 21H MAIN ENDP ;End procedure CODESG ENDS ;End segment END MAIN ;End program
Henry Phillips
Web Programmer
Adirondack Area Network, LLC
Web Programmer
Adirondack Area Network, LLC
![]() |
Similar Threads
- Remove Hidden Windows Components (Windows tips 'n' tweaks)
Other Threads in the Assembly Forum
- Previous Thread: comparing return values of subroutines
- Next Thread: Square Root
| Thread Tools | Search this Thread |





