Antivirus from Jimmy Conner

In a previous review, I talk about jvirus which is a very tiny virus.
Today I will explain antivirus to see if this programs does what it promiss :D.

You can find this file here.



.NOLIST #define equ .equ #define EQU .equ #define END .end #define length 8265h ; My var for the length of the program name #define prog 8266h ; My var for if it found the program or not #include "ti83asm.inc" #include "tokens.inc" .LIST .org 9327h ; ALL TI-83 Programs start here in memory


So far we have usual header for ti83 regular (not ti83plus).
So we have some equates (for assembling step), some var adress, the includes and teh origin (9327 is for ti83 regular!).
So I continue because there's nothing interesting here.

call _clrLCDFull ; Clear Screen call _runIndicOff ; Turns off Runindicator set textinverse, (iy+textflags) ; Toggle text inverse on call _homeup ; Goto 0,0 of screen ld hl,timagic ; Load String Jimmy's AntiVirus call _puts ; Output it to screen res textinverse, (iy+textflags) ; Reset text inverse (off) call _newline ; New Line call _newline ; New Line


So Jimmy starts by cleaning the screen (_clrLCDFull), then he turn off teh indicator (the loading bar on the right top corner).
Then he inverse text by seting the special textinverse bit into the textflags (a byte somewhere in memory) Then he put the cursor at the left top corner (_homeup), it is the same than puting 0 in curcol and currow, he load the timagic string and print it to the screen.
There's a lot of comments so you don't really need my help in fact :D The goal of these part is to print a kind of menu screen.

detect: ld hl, (progptr) ; Start here to look for programs` ld a, 0 ; You have to load it into 'a' before into an address ld (prog), a ; Do this so later we'll know if it found it


Now Jimmy starts a the adress contained by the adress progptr...
What's this? Simply : POINTER TO START OF PROGRAM/LIST SYMBOL ENTRIES
The var called prog wil be used as boolean (virus found ?).
Let's time to search viruses !

startdetect: ld a,(hl) ; Get the type and %00011111 ; need to mask out bits 0-4 cp $06 ; Is it a protected program? jp z, program ; If so jump to the program cp $05 ; Is it a program, but not protected? jp z, program ; If so jump to the program cp $01 ; Is it a list? jp z,list ; If so jump to the list loop cp $0D ; Is it a complex list? jp z,list ; If so jump to the list loop ld a, (prog) ; Reload the 'found it' variable cp 1 ; Did it find it? jr z, pf ; Yes jr nz, pnf ; No ret ; Nothing left so quit


Here you could see how to detect a program, a list or a complex list.
Depending the type of the var, he jumps to program, list.


program: dec hl ; move to ptr (skip var type) dec hl ; move past fisrt ptr dec hl ; move past second ptr to the name length push hl ; Store it for later ld a, (hl) ; Put the length in 'a' ld (length), a ; Store the length for later cp 5 ; Five letters in name? jp nz, nextprog ; If not then it isn't it so goto the next program ; OK we know that it has five letters so now will ; the letters be the same? dec hl ; First letter ld a, (hl) ; Load the first letter cp 56h ; V? jp nz, nextprog ; Nope isn't right letter dec hl ; Second letter ld a,(hl) ; Load the second letter cp 49h ; I? jp nz, nextprog ; Nope isn't right letter dec hl ; Third letter ld a,(hl) ; Load the third letter cp 52h ; R? jp nz, nextprog ; Nope isn't right letter dec hl ; Forth letter ld a,(hl) ; Load the forth letter cp 55h ; U? jp nz, nextprog ; Nope isn't right letter dec hl ; Fifth letter ld a,(hl) ; Load the fifth letter cp 53h ; S? jp nz, nextprog ; Nope isn't right letter ld a, 1 ld (prog), a ; It found it if it got this far so store 1 to 'prog' jp nextprog ; let it finish searching


As there's a lot of comments, I will simply explain the process.
Jimmy compare each byte to see if the program name is VIRUS (a virus is really cool if it takes only this exact name).
If it isn't, go to the next prog.
This is not optimized at all, but I'm not here to criticize so I will simply say that you can do that in less than 10 lines.
Finally, if the name is VIRUS, then put 1 in prog and go to next prog.


nextprog: pop hl ; Go back to the length list: dec hl ; lists enter here to be skipped dec hl ; Skip the last part of the pointer dec hl ; should be at the length ld b, (hl) ; load that so we can loop past it list2: dec hl ; dec hl to goto next letter in name djnz list2 ; loop until the end of the name dec hl ; should be at the next item jp startdetect ; go find next item


As you can see, nextprog is for program, then you have list and complex list in the same code.
nextprog has only a tiny stack access as bonus :).


pf: ; This place is were it outputs that it found it. ld hl, progfound ; Load the text call _puts ; Output it call _newline ; Go to the next line ld hl, inprogram ; Load the text call _puts ; Output it call _newline ; Go to the next line set textinverse, (iy+textflags) ; Toggle text inverse on ld hl, VIRUS ; Load the text call _puts ; Output it res textinverse, (iy+textflags) ; Toggle text inverse on ret pnf: ; This place is were it outputs that it didn't find it. set textinverse, (iy+textflags) ; Toggle text inverse on ld hl, prognotfound ; Load the text call _puts ; Output it res textinverse, (iy+textflags) ; Toggle text inverse on call _newline ; Go to the next line so when it displays 'DONE' ret


These two routines simply puts a text to tell "Virus found" or the contrary.
Like this :



Refer to the first part of this review for more information about these call.


timagic: .db "Jimmys AntiVirus", 0 ; 0 terminated string for display Progfound: .db " Virus detected", 0 ; 0 terminated string for finding the program inprogram: .db " In the Program", 0 ; 0 terminated string for finding the program virus: .db " VIRUS ", 0 ; 0 terminated string for finding the program prognotfound: .db " No Virus found ", 0 ; 0 terminated string for not finding the program .end END


To conclude, here's the string used in this program. Always terminated by 0 (for puts).

This is not the best review isn't it :)

Not the best code or the best program, but as always if you enjoy it that's cool !