so i cant actually return a number like in C or C++? in other words, the RETURN statement in my get_fore and get_back subroutines is incorrect/illegal? so i guess i will have to put these values in registers before i do the return statement, right?
it seems to me then, that nothing is actually returned in terms of data that the subroutine computed. is that an accurate statement?
TITLE Homework 7
;...................................................
STACKSG SEGMENT PARA STACK 'Stack'
DB 32 dup(0) ;32 words, might want to set larger
STACKSG ENDS
;.....................................................
DATASG SEGMENT PARA 'Data' ;data segment
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!!!!
get_fore proc near
; 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
; LOOK FOR KEYBOARD INPUT...STORE IN DL
mov ah, 0aH
int 21h ; will store char in AL
cmp al, '' ; compare AL with the empty string
je empty
mov dl, al ; char stored in DL
ret
empty: mov dl, 0
ret ; return zero if no keyboard input
endp
get_back proc near
; SET CURSOR POSITOIN
mov ah, 02H
mov bh, 00
mov dh, 13
mov dl, 30
int 10h
; DISPLAY PROMPT TO USER
mov ah, 09H
lea dx, prompt2
int 21H
; LOOK FOR KEYBOARD INPUT...STORE IN DH
mov ah, 0aH
int 21h ; will store char in AL
cmp al, '' ; compare AL with the empty string
je empty2
mov dh, al ; char stored in DH
ret
empty2: mov dh, 0
ret ; return zero if no keyboard input
endp
set_color proc near
; CHANGE COLOR OF TEXT (FOREGROUND)
mov ah, 06H
mov al, 00H
cmp dl, 72H ; checking for 'r' -> red
je red_text
cmp dl, 67H ; check for 'g' -> green
je green_text
cmp dl, 62H ; check for 'b' -> blue
je blue_text
cmp dl, 79H ; check for 'y' -> yellow
je yellow_text
cmp dl, 77H ; check for 'w' -> white
je white_text
; SET TEXT COLOR ATTRTIBUTE
red_text: mov bh, 04H ; red text attribute
jmp next
green_text: mov bh, 02H ; green text attribute
jmp next
blue_text: mov bh, 01H ; blue text attribute
jmp next
yellow_text: mov bh, 0EH ; yellow text attribute
jmp next
white_text: mov bh, 07H ; white text attribute
jmp next
; INVOKE INTERRUPT
next: mov cx, 0000H
mov dx, 184FH
int 10H
; CHANGE COLOR OF BACKGROUND
mov ah, 06H
mov al, 00H
cmp dh, 72H ; checking for 'r' -> red
je red_bg
cmp dh, 67H ; check for 'g' -> green
je green_bg
cmp dh, 62H ; check for 'b' -> blue
je blue_bg
cmp dh, 79H ; check for 'y' -> yellow
je yellow_bg
cmp dh, 77H ; check for 'w' -> white
je white_bg
; SET BG COLOR ATTRIBUTE
red_bg: mov bh, 04H ; red bg attribute
jmp finish
green_bg: mov bh, 02H ; green bg attribute
jmp finish
blue_bg: mov bh, 01H ; blue bg attribute
jmp finish
yellow_bg: mov bh, 0EH ; yellow bg attribute
jmp finish
white_bg: mov bh, 07H ; white bg attribute
jmp finish
; INVOKE INTERRUPT
finish: mov cx, 0000H
mov dx, 184FH
int 10H
ret
endp
clear_out proc near
endp
clear_in proc near
endp
start: CALL get_fore
cmp dl, 0
je end_it ; end program
CALL get_back
cmp dh, 0
je end_it ; end program
CALL set_color
jmp start
;........................................................
end_it: jmp end_it
MOV AX,4C00H ;End processing
INT 21H
MAIN ENDP ;End procedure
CODESG ENDS ;End segment
END MAIN ;End program
so just for your own edification, this program is supposed to prompt the user twice, once to change the foreground color with char codes (r, g, b, y, w) and once to change the background with the same codes. its supposed to keep prompting until the user enters an empty string after either of the prompts.
so now am i returning values correcntly? thanks. also if anybody has a burning desire to run my code and check it out feel free!