Code:
stack_segment segment stack ; declare stack segment section
DB 128 dup(?) ; 128 bytes in size
stack_segment ends ; end stack segment section
;****************************************************************************
data_segment segment
PASSWORD db "HN3460" ; input is convert to UPPERCASE
PASSWORD_LEN equ $ - PASSWORD ; generic length of PASSWORD
PROMPT_SCR db "ÛßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßÛ"
db "Û ALBERTSONS #4402 Û"
db "Û Û"
db "Û ENTER PASSWORD: ±±±±±± Û"
db "Û Û"
db "Û Authorized Personnel Only !!! Û"
db "Û Û"
db "ÛÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÛ"
PROMPT_SCR_LEN equ $ - PROMPT_SCR
NAME1 db "Albertsons" ; print repeatly in blue text / black bkgrd
NAME1_LEN equ $ - NAME1 ; generic length of NAME1
ERR_MSG_001 db 13,10,"CODE 001 / FATAL PROGRAM ERROR HAS OCCURRED..."
db 13,10,"Program has been terminated, "
db "report error to Meridian Software Co.",13,10
ERR_MSG_001_LEN equ $ - ERR_MSG_001
data_segment ends
;****************************************************************************
code_segment segment
assume CS:code_segment,SS:stack_segment,DS:data_segment,ES:Nothing
START: ; begin program run here
; load data segment *****************************************************
mov AX,data_segment ; move data segment address into AX register
mov DS,AX ; move AX register value to DS register
; clear screen *****************************************************
mov AX,03h ; set video mode to 80x25, 16 colors
int 10h ; clear screen & set mode using BIOS interrupt
; set cursor position *****************************************************
mov DH,00h ; set cursor to line 00
mov DL,00h ; set cursor to col 00
mov AH,02h ; set up interrupt to move cursor
int 10h ; perform above function using BIOS interrupt
; set text color *****************************************************
mov BH,00000000b ; set video page to zero
mov BL,00000001b ; set to blue text / black background
push BX ; save to stack for use later
or SP,SP ; check stack pointer using OR statement
jz FULL_STACK ; if stack is full jump out of loop
; main program loop *****************************************************
MAIN_LOOP:
; write NAME1 to scr *****************************************************
mov SI,offset NAME1 ; move string varible address to SI pointer
mov CX,NAME1_LEN ; move length of string to CX register
LOOP_1: ; start printing loop
pop BX ; retreive color value from the stack
push CX ; save CX register valve to the stack
or SP,SP ; check stack pointer using OR statement
jz FULL_STACK ; if stack is full jump out of loop
mov AH,09h ; write character to screen
mov AL,[SI] ; write first character
mov CX,1 ; set for 1 character to print
int 10h ; perform BIOS call
inc SI ; move pointer to next character
call MOV_CURSOR ; checks for end of page and moves cursor
pop CX ; retreive loop count from the stack
push BX ; save the text color to the stack
or SP,SP ; check stack pointer using OR statement
jz FULL_STACK ; if stack is full jump out of loop
loop LOOP_1
; adv cursor by two *****************************************************
mov AH,03h ; set up for BIOS call, returns DL/DH = col/row
mov BH,00h ; set video page to zero
int 10h ; get cursor position thru BIOS call
add DL,2 ; increment col position by 2
cmp DL,80 ; check for writing off page
jl OK ; if not goto OK:
mov DL,0 ; else set col to zero
add DH,1 ; and add 1 to line ct
OK:
cmp DH,24 ; check line ct
jg END_LOOP ; if screen is filled jump out of loop to END_RUN
mov AH,02h ; set up to move cursor
mov BH,00h ; set video page to zero
int 10h ; perform cursor move thru BIOS call
mov CX,02h ; make loop never ending (until conditional jump)
loop MAIN_LOOP
END_LOOP: ; clean up program and stop run
; move cursor to starting position of prompt window *************************
mov DL,20 ; set cursor to col 20
mov DH,7 ; set cursor to row 7
mov BH,0 ; set video to page zero
mov AH,02h ; set function to move cursor
int 10h ; perform BIOS interrupt
; print prompt window to screen *********************************************
mov SI,offset PROMPT_SCR ; load address of PROMPT_SCR into SI
mov CX,PROMPT_SCR_LEN ; load size of string into CX
PROMPT_LOOP:
mov AL,DS:[SI] ; mov character into AL register
push CX ; save loop ct
or SP,SP ; check stack pointer using OR statement
jz FULL_STACK ; if stack is full jump out of loop
mov CX,1 ; set char ct to 1
mov BL,00010111b ; blue background, white text
mov AH,09H ; set up for BIOS call
int 10H ; perform BIOS interrupt
cmp DL,59 ; compare col position to 59
jl NEXT ; jump if less then 59
mov DL,19 ; otherwise reset col to 19
inc DH ; increment row by one (LF)
NEXT:
inc DL ; add 1 to col position
mov AH,02H ; set up to move cursor
int 10H ; perform BIOS interrupt
inc SI ; add 1 to pointer
pop CX ; get loop ct from stack
loop PROMPT_LOOP ; dec ct & check for zero
jmp OVER ; jump to OVER label
FULL_STACK: ; label placeed within reach of ALL calls
call STACK_ERR ; jump to error rtn
jmp TERMINATE ; end program run due to error in stack
START_AGAIN: ; start here if incorrect password entered
call DO_AGAIN ; reset prompt characters to ±
OVER:
; move cursor to PASSWORD input location ************************************
mov DL,42 ; set cursor to col 42
mov DH,10 ; set cursor to row 10
mov BH,0 ; set video to page zero
mov AH,02h ; set function to move cursor
int 10h ; perform BIOS interrupt
; get PASSWORD from keyboard input ******************************************
mov CX,PASSWORD_LEN ; load CX register for ? loops / inputs
INPUT_LOOP:
push CX
or SP,SP ; check stack pointer using OR statement
jz FULL_STACK ; if stack is full jump out of loop
mov AH,08h ; set up for keyboard input using DOS
int 21h ; perform DOS interrupt
cmp AL,01100001b ; test input for lowercase letter 'a' or >
jl NUMERIC ; if less then 01100001 ('a') jump convert
and AL,11011111b ; convert to UPPER case using truth tables
NUMERIC:
pop CX ; pop value into CX to push AX value
push AX ; push AX value onto the stack
or SP,SP ; check stack pointer using OR statement
jz FULL_STACK ; if stack is full jump out of loop
push CX ; save loop count on stack
or SP,SP ; check stack pointer using OR statement
jz FULL_STACK ; if stack is full jump out of loop
mov AH,09h ; set up write character function
mov BH,0 ; set video page to zero
mov AL,"*" ; character to print to screen
mov CX,1 ; print character once
int 10h ; perform BIOS interrupt
mov AH,03h ; set up to read current cursor postion
int 10 ; perform BIOS interrupt
inc DL ; increment col by one
mov AH,02h ; set up to move cursor
int 10h ; perform BIOS interrupt
pop CX ; get loop count off of the stack
loop INPUT_LOOP
;test password *****************************************************
lea BX,PASSWORD ; load effective address of PASSWORD
mov CX,PASSWORD_LEN ; load size of PASSWORD into CX register
add BX,PASSWORD_LEN - 1 ; set BX to read last char first
TEST_LOOP:
pop AX ; retreive last keyboard input from stack (LIFO)
push CX ; save loop ct to the stack
or SP,SP ; check stack pointer using OR statement
jz FULL_STACK ; if stack is full jump out of loop
mov AH,[BX] ; move PASSWORD char to AH for testing purposes
cmp AL,AH ; compare the two characters
je GOOD ; jump over BAD RTN if characters are the same
BAD_RTN: ; just a label for now...
mov AH,02h ; set up for BEEP
mov DL,07h ; move BEEP char to register
int 21h ; perform BEEP using DOS interrupt
pop CX ; get loop ct from the stack
push AX ; put AX on the stack to make the POP_LOOP correct
POP_LOOP:
pop AX ; pop the rest of the password of the stack
loop POP_LOOP
jmp START_AGAIN ; loop back to START_AGAIN label if password is bad
GOOD:
dec BX ; move pointer to next character to be tested
pop CX ; get loop ct from the stack
loop TEST_LOOP
jmp END_PASSWORD_RTN
;****************************************************************************
; SUBROUTINES *
;****************************************************************************
MOV_CURSOR PROC
mov AH,03h ; set up for BIOS call, returns DL/DH = col/row
mov BH,00h ; set video page to zero
int 10h ; get cursor position thru BIOS call
add DL,1 ; advance cursor one space
cmp DL,80 ; compare for page overflow
jl NO_LINE_ADV ; if OK goto NO_LINE_ADV
mov DL,0 ; else set col to zero, add 1 to line ct
add DH,1 ; add 1 to line ct
NO_LINE_ADV:
mov AH,02h ; set up to move cursor
mov BH,00h ; set video page to zero
int 10h ; perform cursor move thru BIOS call
ret
MOV_CURSOR ENDP
;****************************************************************************
STACK_ERR PROC
mov AX,03h ; set video mode to 80x25, 16 colors
int 10h ; clear screen & set mode using BIOS interrupt
mov DX,00h ; set cursor to line 00/00
mov AH,02h ; set up interrupt to move cursor
int 10h ; perform above function using BIOS interrupt
lea BX,ERR_MSG_001 ; load effective address of ERR_MSG_001
mov CX,ERR_MSG_001_LEN ; move ct to CX register to control looping
mov AH,02h ; set up for DOS print to screen function
LOOP2:
mov DL,[BX] ; move char to DL register
int 21h ; perform DOS interrupt
inc BX ; move pointer by 1
loop LOOP2
ret
STACK_ERR ENDP
;****************************************************************************
DO_AGAIN PROC ; print character "±" to password input area !!!!
mov DL,42 ; set cursor to col 42
mov DH,10 ; set cursor to row 10
mov BH,0 ; set video to page zero
mov AH,02h ; set function to move cursor
int 10h ; perform BIOS interrupt
mov SI,offset PROMPT_SCR; load address of PROMPT_SCR into SI
add SI,142 ; move pointer to first ± character
mov CX,PASSWORD_LEN ; load size of PASSWORD INTO CX register
DO_AGAIN_LOOP:
mov AL,DS:[SI] ; mov character into AL register
push CX ; save loop ct
mov CX,1 ; set char ct to 1
mov BL,00010111b ; blue background, white text
mov AH,09H ; set up for BIOS call
int 10H ; perform BIOS interrupt
inc DL ; add 1 to col position
mov AH,02H ; set up to move cursor
int 10H ; perform BIOS interrupt
inc SI ; add 1 to pointer
pop CX ; get loop ct from stack
loop DO_AGAIN_LOOP ; dec ct & check for zero
ret ; return to calling address
DO_AGAIN ENDP
;****************************************************************************
;* TERMINATE *
;****************************************************************************
END_PASSWORD_RTN:
; reset video mode and clear screen *****************************************
mov AX,03h ; 80 x 25, 16 color text mode
int 10h
TERMINATE:
mov AH,4Ch ; setup DOS to terminate program correctly.
int 21h ; perform terminate procedure.
code_segment ends ; end code segment
end START ; end program run
;****************************************************************************
;*END OF SOURCE CODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*
;****************************************************************************
--------------------------------------------------------------------------------
Dit moet je gewoon ff in een ASM compiler gooien...aanpassen naar eigen inzicht...probeer ook eens te schrijven naar int13