hey everybody. i've got what might be a simple question about return values of subroutines in assembly. okay here goes.
say i've got a subroutine that under normal conditions will do a normal return (RET), and under one condition will return zero (RET 0). so now back in main after this function has been called, i need to compare the return value with zero....only i dont know what the syntax is, or rather, how a subroutine's return value can be referenced in main. does anyone know how to do this? can i just do cmp 0??? i havent tried it, but it doesnt seem right. thanks in advance. my code is below. i know it looks liek a lot, its mostly subroutines, and the part i need help with is towards the bottom. THANKS AGAIN
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: ret 0 ; 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: ret 0 ; 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
; CHANGE COLOR OF BACKGROUND
next: 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 ret, 0
jmp end_it ; end program
CALL get_back
cmp ret, 0
jmp 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