THIS IS THE ASSIGNMENT I MUST DO : Write an assembly language routine that enables the user to enter a number. The program (routine) will
THIS IS THE ASSIGNMENT I MUST DO: Write an assembly language routine that enables the user to enter a number. The program (routine) will count up from that number that was entered till it reaches 250. Once it reached 250 it will count down by 2 till it will reach 240 and thereafter the program will end.
Here are some of the commands I must use to work it
pp:; this is another label or location in the program
call display ; call the display routine
inc al ; increment the value of AL by 1
cmp al, 251 ; compare AL = 251
jnz pp ; if the last command is not zero go back to PP
call keyin ; call the kein routine that enables the user to enter data
cmp al, 5 ; Compare if AL (the value that was entered from keyboard) = 4
js qq ; jump sign i.e. if the previous command is resulted in a negative.
pp:; this is another label or location in the program
call display ; call the display routine
dec al ; decrement the vslue of AL by 1
cmp al, 3 ; compare AL = 3
jnz pp ; if the last command is not zero go back to PP
Here is the Whole program in which I must input it, I must do so IN-BETWEEN THE LINES WHERE IT SAYS "ENTER YOUR PROGRAM BELOW AND DO NOT CROSS THIS LINE". NOTE: I Write this code in Notepad saved as 280-8 and as all files. I run it in Windows vDos.
.model small .386 .stack 100h
.data operation db ? base_addr dw 0 first_key db 0 by10 dd 10 stack_counter db 0 delayv dw ? total_key db 0 an_msg db 13, 10, "Enter any key --> ", "$" key_msg db 13, 10, "Enter any number --> ", "$" msg1 db " LOC1=","$" msg2 db " LOC2=","$" msg3 db " LOC3=","$" msg4 db " AL=","$" msg5 db 0DH,0AH, "Disp=","$" a db ? b db ? c db ? d db 232 stt db 0 Loc1 db ? Loc2 db ? Loc3 db ? ; msg dd ? ; .code extrn clrscr:proc
main proc mov ax,@data ; set up data segment mov ds,ax
call clrscr ; clear the screen ;enter your program below_________________________________________________________________
;do not cross this line____________________________________________________________________ mov ax,4C00h ; return to DOS int 21h
display proc and eax, 000000ffh mov ebx, eax
mov ah,9 mov dx,offset msg5 int 21h
mov ah, 0 call display10 call space mov eax, ebx call display1 mov ah, 0 ret display endp display1 proc mov cl, al mov a, al mov b, 8 lp1: shl cl, 1 jnc short print0 mov dl, d mov ah, 6 int 21h dec b jnz lp1 mov al, a
call delay1 mov ah, 0 ret print0: mov dl, 30h mov ah, 6 int 21h dec b jnz lp1 mov al, a
call delay1 ret display1 endp delay1 proc cmp stt, 255 jnz short skip ret skip: mov bx, 9999 yy: mov delayv, 4000 zz: dec delayv jnz zz dec bx jnz yy ret delay1 endp space proc
mov dl, 20h mov ah, 6 int 21h
ret space endp
Status proc mov stt, 255 mov c, al ; save al mov ah,9 mov dx,offset msg1 int 21h mov al, loc1 mov d, 31h call display1
mov ah,9 mov dx,offset msg2 int 21h mov al, loc2 call display1
mov ah,9 mov dx,offset msg3 int 21h mov al, loc3 call display1
mov ah,9 mov dx,offset msg4 int 21h mov al, c call display1 mov d, 232 mov stt, 0 ret status endp display10 proc
mov eax, ebx lp10: mov edx, 0 div by10 push dx inc stack_counter cmp eax, 0 jnz lp10 ;--- lp10B: pop dx call view10 dec stack_counter jnz lp10B ret display10 endp view10 proc add dl, 30h mov ah, 6 int 21h and eax, 000000ffH ret view10 endp keyin proc no_num: mov total_key,0 mov first_key, 0 mov ah,9 mov dx,offset key_msg int 21h rpt:
mov ah, 1 int 21h cmp al, 13 jz short finkey cmp al, 30h js no_num cmp al, 3Ah jns no_num sub al, 30h
call tabulate mov first_key, 1 jmp rpt
finkey: mov al, total_key mov first_key, 0 mov ah, 0 ret keyin endp Tabulate proc and eax, 000000ffh cmp first_key, 0 jz short skip_mul mov bh, al mov al, total_key mul by10 add al, bh skip_mul: mov total_key, al ret tabulate endp
Message proc
msgrpt:
mov edx, msg shr edx, 24 mov ah, 6 int 21h
mov edx, msg shr edx, 16 mov ah, 6 int 21h
mov edx, msg shr edx, 8 mov ah, 6 int 21h
mov edx, msg mov ah, 6 int 21h ret message endp ;____________________ keyin_AN proc mov bx, 200 mov ah,9 mov dx,offset an_msg int 21h rptmsg: mov ah, 1 int 21h cmp al, 13 jz short finkeymsg mov operation , al mov [bx], al inc bx jmp rptmsg
finkeymsg: mov base_addr, bx mov al, operation mov ah, 0 ret keyin_AN endp mssg_an proc mov bx, 200 rptan:
mov dl, [bx]
mov ah, 6 int 21h inc bx cmp bx, base_addr jnz rptan ret mssg_an endp main endp end main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started