Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; multi-segment executable file template.
- ;------------------------;
- data segment
- ex db '!$'
- ; login msgs ;
- PASSWORD db 3,1,5,9
- WORKERID db 11 dup('$')
- counter db 0
- loginmsg1 db "Please enter the password: $"
- loginfailmsg db "INCORRECT PASSWORD! TERMINATING!$"
- loginsuccessmsg db "LOGIN SUCCESSFUL!$"
- workeridmsg1 db "Enter worker ID: $"
- welcomeworker db "Welcome worker #$"
- ;------------------------;
- ; menu msgs ;
- chooseoption db "Choose an option from the following menu: $"
- makeOrder1 db "0 - Make an order.$"
- showTotal1 db "1 - Show total earned & pizzas sold.$"
- exitmsg db "9 - Exit. (Close down the store.)$"
- exitmsg1 db "Closing down store systems... GOODBYE!$"
- incorrect db "Incorrect Input, please choose again!$"
- ;------------------------;
- ; makeOrder ;
- confirmation db "Press 1 to confirm making an order: $"
- orderName db 11 dup('$')
- enterName db "Enter the buyers name: $"
- orderName1 db "Order has been successfully made by $"
- orderName2 db " for $"
- orderName3 db " pizzas.$"
- quantityMsg db "How many pizzas would you like?: $"
- two db 2
- currentOrder dw 0
- temp db 0
- ten db 10
- invalidQuantity1 db "Invalid quantity! Please rechoose!$"
- ;------------------------;
- ; showTotal ;
- showTotalmsg db "You have earned $"
- showTotalmsg0 db " shekels for selling $"
- showTotalmsg1 db " pizzas.$"
- noPizzas db "No pizzas sold...$"
- pizzasSold dw 0
- totalEarned dw 0
- totalEarned1 dw 0,0,0,0
- cheat db 0
- newline db 0dh,0ah,'$'
- ends
- ;------------------------;
- stack segment
- dw 128 dup(0)
- ends
- ;------------------------;
- code segment
- mov ax, data
- mov ds, ax
- lea dx,loginmsg1
- call printst
- mov ch,0
- mov cl,4
- lea bx,PASSWORD
- call login
- mov ax, 4ch
- int 21h
- ; * END OF MAIN * ;
- ;------------------------;
- printst:
- mov ah,09h
- int 21h
- ret
- enter:
- lea dx,newline
- call printst
- ret
- makeNum:
- call getch
- sub al,'0'
- ret
- getch:
- mov ah, 01h
- int 21h
- ret
- printch:
- mov ah,02h
- int 21h
- ret
- ;-------------------------;
- ;START OF ACTUAL FUNCTIONS;
- login:
- call makeNum
- cmp al,[bx]
- jnz loginFail
- inc bx
- loop login
- loginSuccess:
- call enter
- lea dx,loginsuccessmsg
- call printst
- lea bx,WORKERID
- call enter
- lea dx,workeridmsg1
- call printst
- mov cl,10
- jmp getWorkerID
- loginFail:
- call enter
- lea dx, loginfailmsg
- call printst
- ret
- getWorkerID:
- call getch
- cmp al,newline
- je printWorkerID1
- mov [bx],al
- inc bx
- inc counter
- loop getWorkerID
- printWorkerID1:
- call enter
- lea dx,welcomeworker
- lea bx,WORKERID
- call printst
- mov ch,0
- mov cl,counter
- printWorkerID2:
- cmp [bx],'$'
- je continue
- mov dl,[bx]
- call printch
- inc bx
- loop printWorkerID2
- continue:
- lea dx,ex
- call printst
- call enter
- menu:
- call enter
- call enter
- ; Prints Menu msgs ;
- lea dx,makeOrder1
- call printst
- call enter
- lea dx,showTotal1
- call printst
- call enter
- lea dx,exitmsg
- call printst
- call enter
- ; Get option ;
- lea dx,chooseoption
- call printst
- call makeNum
- ; Check option;
- cmp al,0
- je makeOrder
- cmp al,1
- je showTotal
- cmp al,9
- je exit
- call enter
- lea dx,incorrect
- call printst
- jmp menu
- ; In case choosing to exit ;
- exit:
- call enter
- lea dx,exitmsg1
- call printst
- ret
- ;------------------------------------------------;
- makeOrder:
- ; Asking for confirmation of order making ;
- call enter
- lea dx,confirmation
- call printst
- call makeNum
- cmp al, 1
- jne menu
- mov counter,0
- jmp requestQuantity
- ; Asking for quantity ;
- invalidQuantity0:
- call enter
- lea dx,invalidQuantity1
- call printst
- call enter
- jmp requestQuantity
- requestQuantity:
- call enter ; Print quantity msg
- lea dx,quantityMsg
- call printst
- getQuantity0:
- call getch ; Get first num
- sub al,'0'
- mov ah,0
- cmp al,0
- jle invalidQuantity0
- cmp al,9
- jg invalidQuantity0
- mov currentOrder,ax
- GetQuantity1:
- call getch ; Try to get another num, if not enter con
- cmp al,newline
- je endPrice
- sub al,'0'
- cmp al,0
- jl invalidQuantity0
- cmp al,9
- jg invalidQuantity0
- ; Getting another number, multiplying by 10
- mov temp,al
- mov ax,currentOrder
- mul ten
- mov currentOrder,ax
- mov al,temp
- add currentOrder,ax
- endPrice:
- mov ax,currentOrder
- add pizzasSold,ax
- mul two
- add totalEarned,ax
- getName0:
- call enter
- lea dx,enterName
- call printst
- mov al,0
- lea bx,orderName
- mov cx,10
- getName1:
- call getch
- cmp al,newline
- je conOrder
- getName2:
- mov [bx],al
- inc bx
- loop getName1
- conOrder:
- call enter
- lea dx,orderName1
- call printst
- printName:
- mov cx,10
- lea bx,orderName
- printName0:
- cmp [bx],'$'
- je endOrder
- mov dl,[bx]
- call printch
- inc bx
- loop printName0
- endOrder:
- lea dx,ex
- call printst
- call enter
- jmp menu
- ;------------------------------------------------;
- showTotal:
- call enter
- cmp pizzasSold,0
- je noPizzasSold
- lea dx,showTotalmsg
- call printst
- mov bx,totalEarned
- ; Taking care of BH (YYXX TAKING CARE OF YY)
- ; Taking care of BL (YYXX TAKING CARE OF XX)
- mov al,bl
- mov ah,0
- AAM
- add al,'0'
- mov cl,al
- cmp ah,10
- jge resplit
- afterSplit:
- add ah,'0'
- mov dl,ah
- call printch
- mov dl,cl
- call printch
- mov ah,0
- mov al,0
- jmp moreMsgs
- resplit:
- mov al,ah
- mov ah,0
- AAM
- add al,'0'
- mov bl,al
- add ah,'0'
- mov dl,ah
- call printch
- mov dl,bl
- call printch
- mov dl,cl
- call printch
- moreMsgs:
- lea dx,showtotalmsg0
- call printst
- printPizzaAmount:
- mov bx,pizzasSold
- mov al,bl
- mov ah,0
- AAM
- add al,'0'
- mov cl,al
- cmp ah,10
- jge resplit1
- afterSplit1:
- add ah,'0'
- mov dl,ah
- call printch
- mov dl,cl
- call printch
- mov ah,0
- mov al,0
- jmp menuJump
- resplit1:
- mov al,ah
- mov ah,0
- AAM
- add al,'0'
- mov bl,al
- add ah,'0'
- mov dl,ah
- call printch
- mov dl,bl
- call printch
- mov dl,cl
- call printch
- menuJump:
- lea dx,showtotalmsg1
- call printst
- jmp menu
- ret
- noPizzasSold:
- call enter
- lea dx,noPizzas
- call printst
- jmp menu
- ret
- ends
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement