First off, I know this is homework, and I don't expect anyone to do everything for me. Just a simple explanation is more than enough. The first project I am taking in a number in seconds that the user enters and converting it to hours, minutes, and seconds, but I get a scalar error. I get the expecting scalar type at line 38- if x >= 3600 and line 51 if x < 3600. Additionally, at line 45 - if ah < 60
I get illegal use of register; how would I put the remainder from ah and not get that error?
In the second project, I am not getting any errors or anything, but when I run the program, I get a bunch of random characters.
COMMENT † Part A) Takes in seconds from sdin and computes hours, minutes, and seconds from that † .MODEL SMALL .STACK 100 CR EQU 13 ;symbolic constant LF EQU 10 ;symbolic constant .DATA x db ? hours db ? minutes db ? seconds db ? prompt1 db 'Enter an amount in seconds in which to compute hours, minutes, and seconds from.', CR, LF, '$' hlabel db 'Hours: ', CR, LF, '$' mlabel db 'Minutes: ',CR, LF, '$' slabel db 'Seconds: ', CR, LF, '$' .CODE Main PROC lea dx, prompt1 ;prompt that gives instructions to user mov ah, 9h int 21h mov ah, 01h ;get # from user from sdin int 12h mov x, ah ;put that # into x Main ENDP Worker PROC if x >= 3600 mov al, x mov bl, 60 div bl mov hours, bl ENDIF if ah < 60 mov minutes, ah else mov seconds, ah ENDIF if x < 3600 mov al, x mov bl, 60 div bl mov minutes, bl mov seconds, ah ENDIF Worker ENDP END Main
COMMENT † Part B) Takes a value from sdin, stores in variable x, and follows the function: Y = f(x) = x^3 - 11x^2 + 98x - 24 † .MODEL SMALL .STACK 100 CR EQU 13 ;symbolic constant LF EQU 10 ;symbolic constant .DATA x dw ? num1 dw ? num2 dw ? num3 dw ? constant db 98 str1 dw ? prompt1 db "Y = f(x) = x^3 - 11x^2 + 98x - 24", CR, LF, '$' prompt2 db "Enter the value of x", CR, LF, '$' .CODE Main PROC lea dx, prompt1 ;prompt that shows formula mov ah, 9h int 21h lea dx,prompt2 ;prompt user to enter value of X via sdin mov ah, 9h int 21h mov ah, 01h ;get x from user from sdin int 12h mov x, ax Main ENDP Worker PROC mov ax, x ;calculate x^3 imul x imul x mov num1, ax mov ax, x ;calculate -11x^2 imul x mov ax, -11 imul x mov num2, ax mov ax, x ;calculate 98x mul constant mov num3, ax mov ax, num1 ;computes Y = f(x) = ? mov bx, num2 add ax, bx add bx, num3 sub num3, 24 lea dx, num3 mov ah, 9h ;print to sdout int 21h Worker ENDP END Main
Thank you for your time and effort.