hi. just made this code for my project.

input: time-in, time-out and minimum wage. input will be stored in an array

WAGE CALCULATIONS:
1. deduct 30 for every hour late. (8 am is the call time)
2. add 50 per hour overtime (5pm is the end of work, beyond that is overtime)

NOW MY PROBLEM, the output is not a number. it will output certain characters that i dont understand.

can someone with expertise in assembly language help me please? i highly appreciate any help from you. thank you:)

by the way, HERE'S MY CODE:


;PROJECT SUMMARY:  user inputs time-in and time-out (by hour).  the usual time-in is 8AM and the time-out is 5PM.
;Base Salary is Php270.00
;A deduction of Php30.00 from the base salary will be done for every hour late
;An additional Php50.00 is given for every hour overtime (until 10PM only)
;Output the daily salary and the monthly salary (daily salary * 30)

TITLE wcalcu.asm MICHELLE's WAGE CALCULATOR
.MODEL SMALL
.STACK 100H
.DATA
NOTE db 'DO take note a 24-hour format is followed.  $'
EXAMPLE db 'Ex: 08 corresponds to 8AM while 13 is 1pm.$'
MSG_IN db 'Enter time-in: $'
MSG_OUT db 'Enter time-out: $'
MSG_MIN db 'Enter minimum wage in your company.$'
DAILY_SAL db 'Your daily salary is $'
MONTHLY_SAL db 'Your monthly salary is $'
ERROR1 db 'Invalid Input (time-in!) $'
ERROR db 'Invalid Input (time-out!) $'
daily_wage db ?
monthly_wage db ?
time_in db ?
time_out db ?

.CODE
main proc
;initialize ds
mov ax, @data
mov ds, ax ;initialize data segment

;**************************************************************************;
;---------------------------  OPENING MSGS  -------------------------------;
;**************************************************************************;

;display NOTE
lea dx, NOTE ;load effect data
mov ah, 9 ;displays data input
int 21h

;go to new line
MOV AH, 2 ;display char function
MOV DL, 0DH ;carriage return
INT 21H ;execute

MOV DL, 0AH ;line feed
INT 21H ;execute
;execute

;display example
lea dx, EXAMPLE ;load effect data
mov ah, 9 ;displays data input
int 21h

;go to new line
MOV AH, 2 ;display char function
MOV DL, 0DH ;carriage return
INT 21H ;execute

MOV DL, 0AH ;line feed
INT 21H ;execute

;display msg1 (asking for time-in)
lea dx, msg_in ;load effect data
mov ah, 9 ;displays data input
int 21h

;**************************************************************************;
;------------------------- INPUT and STORING  -----------------------------;
;**************************************************************************;

;input and storing time-in
MOV ah, 1 ; read character function
XOR BX, BX ; clear BX
MOV CX, 0 ; CX = 0

INPUT:
INT 21H ; execute
MOV time_in, AL ; move contents of AL to BL
INC CX ; increment CX by 1
INC BX ; increase BX
CMP CX, 2 ; is CX = 2?
JE NEXT ; if yes, go to NEXT
JMP INPUT ; if not, loop until all digits are placed in array

NEXT:

;go to new line
MOV AH, 2 ;display char function
MOV DL, 0DH ;carriage return
INT 21H ;execute

MOV DL, 0AH ;line feed
INT 21H ;execute

;display second message (for time out)
lea dx, msg_out ;load effect data
mov ah, 9 ;displays data input
int 21h

;input and storing time-out
MOV ah, 1 ; read character function
XOR BX, BX ; clear BX
MOV CX, 0 ; CX = 0

OUTPUT:
INT 21H ; execute
MOV time_out, AL ; move contents of AL to BL
INC CX ; increment CX
INC BX ; increase BX
CMP CX, 2 ; is CX = 2?
JE NEXT2 ; if yes, go to NEXT2
JMP OUTPUT ; if not, loop until all digits are placed in array

NEXT2:
;go to new line
MOV AH, 2 ;display char function
MOV DL, 0DH ;carriage return
INT 21H ;execute

MOV DL, 0AH ;line feed
INT 21H ;execute

;display third message (for minimum wage)
lea dx, msg_min ;load effect data
mov ah, 9 ;displays data input
int 21h

;input and storing min wage
MOV ah, 1 ; read character function
XOR BX, BX ; clear BX
MOV CX, 0 ; CX = 0

WAGE:
INT 21H ; execute
MOV daily_wage, AL ; move contents of AL to BL
INC CX ; increment CX
INC BX ; increase BX
CMP CX, 3 ; is CX = 3?
JE NEXT3 ; if yes, go to NEXT3
JMP WAGE ; if not, loop until all digits are placed in array

NEXT3:
;go to new line
MOV AH, 2 ;display char function
MOV DL, 0DH ;carriage return
INT 21H ;execute

MOV DL, 0AH ;line feed
INT 21H ;execute




;**************************************************************************;
;---------------- CHECKING FOR VALIDITY OF INPUT (TIME-IN)-----------------;
;**************************************************************************;

;checking for validity by comparing each digit in the array:

INPUT1_VALIDITY:
XOR BX, BX ; clear BX

MOV AL, time_in ; move contents of time_in to AL
CMP AL, 31H ; is the first digit of the input less than or equal to 1?
JG HANDLE_ERROR ; if not, ERROR!
JL CHECK_UNDERTIME ; if less than, check undertime.
JE CHECK_NEXTD ; if first digit = 1, check 2nd digit

CHECK_NEXTD:
INC BX ; increment BX
MOV AL, time_in ; move the contents of time_in to AL
CMP AL, 37H ; is the second digit greater than 7?
JG HANDLE_ERROR ; if yes, handle error
JMP CHECK_UNDERTIME ; if no error in input1, check undertime due to tardiness

;handling errors
HANDLE_ERROR:
lea dx, ERROR1 ;load effect data
mov ah, 9 ;displays data input
int 21h
JMP EXIT ; jump to exit!



;**************************************************************************;
;----------------- CHECKING IF UNDERTIME DUE TO TARDINESS -----------------;
;**************************************************************************;

; check if employee is late
CHECK_UNDERTIME:
XOR AX, AX ; clear AX
XOR BX, BX ; clear BX

MOV AL,time_in ; move to AL
CMP AL, 1 ; is the first digit = 1?
JE GET_NEXTD ; if yes, compute the number of hours late
INC BX ; if no, incerement BX
MOV AL, time_in ; move contents to AL
CMP AL, 7 ; if the first digit is not 1, is the next digit greater than 7?
JG COMPUTE_LATE ; if yes, compute the number of hours late
JMP INPUT2_VALIDITY ; if not, check if employee had an overtime

; if time in is 1*
GET_NEXTD:
INC BX ; increment BX
MOV AL, time_in ; AL = time_in
CMP AL, 8 ; is the second digit greater than 8?
JG BORROW ; if yes, go to function borrow (subtraction through borrowing)
JLE COMPUTE_LATE ; if not, subtract the simple way

; subtracting the simple way (no borrwing)
COMPUTE_LATE:
MOV AL, time_in ; AX = time_in[1]
SUB AL, 8 ; AX = AX - 8
JMP UNDERTIME ; subtract salary per hour late

; subtracting through borrowing
BORROW:
MOV AL, 10 ; AX = 10
MOV DL, time_in ; DL = time_in
ADD AL, DL ; AX = AX + DL
SUB AL, 8 ; AX = AX - 8
JMP UNDERTIME ; subtract salary per time late

; deducting per hour LATE
UNDERTIME:
MOV BX, 2 ; BX = 2

MOV AL, daily_wage ; move to AL
SUB AL, 3 ; subtract the digit 3 from the 2nd digit of the wage
MOV daily_wage, AL ; copy to BX
CMP AL, 3 ; is the digit less than 3?
DEC BX ; BX = 0
JL BORROW2 ; if yes, borrow from the 1st digit

BORROW2:
MOV AL, daily_wage ; move to AL
DEC AL ; subtract 1 from AL
MOV daily_wage, AL ; copy to array

JMP INPUT2_VALIDITY ; check validity of input 2


;**************************************************************************;
;---------------- CHECKING FOR VALIDITY OF INPUT (TIME-OUT)----------------;
;**************************************************************************;

;checking for validity by comparing each digit in the array:
INPUT2_VALIDITY:
XOR BX, BX ; clear BX

MOV AL, time_out ; move the contents of time_out to AL
CMP AL, 32H ; is the first digit of the input equal to 2?
JE CHECK_IF1 ; if equal to 2, check if the next digit is <= 3
JG HANDLE_ERROR2 ; if greater than, handle error
JMP PRINT
;JL CHECK_OVERTIME ; if it starts with 1, check if employee has OT

CHECK_IF1:
INC BX ; increase BX by 1
MOV AL, time_out ; move the contents to AL
CMP AL, 33H ; check if 2nd digit is less than or equal to 4
JG HANDLE_ERROR2 ; cut off time is 23:00
JMP PRINT
;JMP COMPUTE_OT ; compute no. of hours overtime

;handling errors
HANDLE_ERROR2:
lea dx, ERROR ; load effect data
mov ah, 9 ; displays data input
int 21h ; execute
JMP EXIT ; jump to exit!


;**************************************************************************;
;------------------------PROCESSING OVERTIME ------------------------------;
;**************************************************************************;
;check for overtime

;**************************************************************************;
;------------------------ENDING THE PROGRAM  ------------------------------;
;**************************************************************************;
PRINT:
;print output
;display daily salary
LEA DX, DAILY_SAL ; load effective data
MOV AH, 9 ; displays data input
INT 21H ; execute

XOR BX, BX ; clear BX
PRINT2:
lea dx, daily_wage ;load effect data
mov ah, 9 ;displays data input
int 21h ;execute
INC BX ; increment BX
CMP BX, 3 ; is BX = 3?
JE EXIT ; exit if yes
JMP PRINT2 ; print until BX = 3.

;go to new line
MOV AH, 2 ;display char function
MOV DL, 0DH ;carriage return
INT 21H ;execute

MOV DL, 0AH ;line feed
INT 21H ;execute

EXIT:
;return to DOS
EXIT:
mov ah,4ch ;DOS exit function
int 21h ;execute
main endp
end main
Posted on 2009-10-10 23:15:07 by lloydie
Hi :)

You wish to print the ASCII CHARACTERS representing an integer value.

Currently, the code is printing the raw BINARY values.
If you look at a table of ASCII values, you will see that the characters for 0 thru 9 are represented by the ASCII codes of 0x30 thru 0x39 (hex).
You will therefore need to add 30h to each value before trying to print it.

Have a nice day :)
Posted on 2009-10-11 01:17:18 by Homer
oh. i see. thank you so much! i'll try it now! thank you! :)
Posted on 2009-10-11 01:24:11 by lloydie
hey. i stored the digits for the salary in an array. to print the character i used this code:

PRINT:
;print output
;display daily salary
ADD_30H:
ADD daily_wage, 30H ; add 30H to each character
INC BX ; increment BX
CMP BX, 33H ; is BX = 3?
JE display_char ; if equal, display character
JMP ADD_30H ; if not, loop

display_char:
MOV DL, BL ; retrieve character
INT 21H
LEA DX,daily_wage
MOV AH,9
INT 21h
; display character
MOV DL, BL ; retrieve character
INT 21H


;go to new line
MOV AH, 2 ;display char function
MOV DL, 0DH ;carriage return
INT 21H ;execute

MOV DL, 0AH ;line feed
INT 21H ;execute


but when i tried it using cmd prompt, it reported an error.:(
IS THIS RIGHT???
Posted on 2009-10-11 01:46:38 by lloydie
No its not right.
Don't modify the data in the array, its bad coding practise to 'fudge source data'.. instead just add 30h to each character IN THE REGISTER just as you are about to print it!
Make more sense?
Posted on 2009-10-11 02:39:52 by Homer

No its not right.
Don't modify the data in the array, its bad coding practise to 'fudge source data'.. instead just add 30h to each character IN THE REGISTER just as you are about to print it!
Make more sense?



oh! okay. thank you. :)

hmmmm. can i ask you a favor sir? can you please check my code. the one with the "check if undertime due to tardiness"...

please please sir. i would highly appreciate your help! :)
Posted on 2009-10-11 03:04:10 by lloydie
This looks like homework.
I can't do your homework for you, I can only answer specific questions.
That's mentioned in our Rules.
Besides, if I solve all your current problems, how can you learn to solve future problems?
I would not be doing you any favors, I would be just spoon feeding you.
I think you deserve better.
Posted on 2009-10-11 03:47:56 by Homer
well, n that case..

can i just ask you (if its ok) which part/s are wrong and i'll just try to find solutions for it myself?:)
Posted on 2009-10-11 04:26:39 by lloydie
When you run your code through your compiler, it will give you error codes.

Post those and we can help you with that.

Posted on 2009-10-11 07:57:05 by skywalker
hi skywalker..

can i ask... uhmmm. can we use registers (BX) to store the address of the array?

when i have a multi-digit number stored in an array, how can i add/subtract that number to another number?

i think that's what my problem is.

multi-digit input and storage was not taught to us by our instructor. :(
Posted on 2009-10-11 08:06:35 by lloydie
Maybe you should team up xxxlancexxx and figure this out for your class, together :idea:
Posted on 2009-10-11 12:43:55 by SpooK