I am having a hard time getting my program to execute correctly. it is supposed to take two numbers entered by the user store them in an array, and reverse the array so when added they display correctly. i am to get the numbers using a procedure two seperate times, and reverse the arrays three times (reverse each entered number, and the sum array). furthermore when the user has entered one more than the max number of keys a + or = sign is to be entered for them. eg. i have the computer program set to take 3 numbers for each array so when the user enters a fourth a + or = sign should automatically appear. I cannot get the program to do this, or go any farther. I was hoping someone could let me know where i am going wrong with my code.
here it is:
BOZOS_CODE SEGMENT ;The "logical" segment is named BOZOS_CODE
ASSUME CS:BOZOS_CODE ;The "assume" statement tells the assembler
; that BOZOS_CODE is a code segment (CS)
ORG 100h ;In case we decide to convert the program
; to a COM file (makes 256 "empty" locations)
START: jmp begin ;Since this is a code segment the first non-
; directive item must be an instruction. We
; jump around our data area
num_of_bytes EQU 3
first_num db num_of_bytes dup (0), '$'
second_num db num_of_bytes dup (0), '$'
the_sum db num_of_bytes + 1 dup (0), '$'
message_1 db 'Enter the first multi-digit number (up to 12 digits in length) followed by a'
db '"+" symbol then enter a second multi-digit number (up to 12 digits in '
db 'length) followed by a "=" symbol $'
key_stroke db 'x$'
operand db 'x$'
GET_NUM: mov ah, 00h ;Read keyboard function
int 16h ;Call BIOS (return occurs when key is pressed)
;AL now contains the ASCII code of key pressed
mov key_stroke, al
mov ah, 09h ;Display string function
mov dx, offset key_stroke ;Pass the starting address of string
int 21h ;Call DOS
mov al, key_stroke
cmp al, cl
jne continue
ret ;return
continue: and al, 0fh
mov [BX], al
inc BX
cmp [bx], ch
jbe get_num
mov operand, cl
mov ah, 09h ;Display string function
mov dx, offset operand ;Pass the starting address of string
int 21h ;Call DOS
ret ;return
REV_NUM: mov cl, [bx]
mov ch, [di]
mov [di], cl
mov [bx], ch
dec BX
inc di
cmp di, bx
jae rev_num
ret
begin: mov ax, cs
mov ds, ax
mov cl, 0
mov ah, 06h ;Scroll-up window function
mov al, 0 ; Clear entire window
mov bh, 1ch ; Display "attribute byte" for cleared area
; Blue background/Red characters
; Bit definitions: Blink|Background R,G,B|
; Intensity|Character R,G,B
mov ch, 0 ; Y = 0 (Corner coordinates of window
mov cl, 0 ; X = 0 to clear)
mov dh, 24 ; Y = 24
mov dl, 85 ; X = 79
int 10h ;Call BIOS
mov ah, 02h ;Set cursor position function
mov bh, 0 ; Display page 0
mov dh, 0 ; Y position 25 rows (Y: 0 -> 24)
mov dl, 0 ; X position 80 columns (X: 0 -> 79)
int 10h ;Call BIOS
mov ah, 09h ;Display string function
mov dx, offset message_1 ;Pass the starting offset of the
; string to be displayed
; (the string to be displayed starts
; at the label message (in the data
; area) and ends with a '$')
;Note: DS must point to the beginning
; of the segment containing the
; string to be displayed, e.g.,
; mov ax, cs (usually done at
; mov ds, ax the beginning of
; the program)
;Note: This display procedure updates
; the cursor position as each
; character is displayed
int 21h ;Call DOS
mov bx, offset first_num
mov cl, '+'
mov ch, num_of_bytes
call get_num
mov bx, offset second_num
mov cl, '='
mov ch, num_of_bytes ;do i need to do this again?
call get_num
mov di, offset first_num
call rev_num
mov di, offset second_num
call rev_num
mov BX, 0 ;Index set to zero now
mov ah, 0 ;ah now used for carry, and is set to zero
adder: mov al, first_num[BX]
add al, second_num[BX]
add al, ah
cmp al, 9
jbe no_carry
mov ah, 1
sub al, 10
jmp make_ascii
no_carry: mov ah, 0
make_ascii: or al, 30h
mov the_sum[BX], al
inc BX
cmp BX, num_of_bytes
je fix_carry ; if array is full jump to fix carry character
jmp adder
fix_carry: or ah, 30h
mov the_sum[BX], ah
mov bx, num_of_bytes - 1
mov di, offset the_sum
call rev_num
;to display sum
display: mov ah, 09h ;Display string function
mov dx, offset the_sum ;Pass the starting address of string
int 21h ;Call DOS
;To exit to DOS
exit: mov ah, 4ch ;Exit to DOS function
mov al, 0 ;ERRORLEVEL = 0
int 21h ;Call DOS
BOZOS_CODE ENDS
END START ;You MUST have a carriage return after START
thank you