- Joined
- Feb 25, 2004
- Location
- MA, USA
I need some help with an assembly program. Its suppose to decode 4 lines of text 1x44 characters long by subtracting three from the hex representation of the character and then write over it, giving us the final message, but it doesn't do that. It rights the hex characters in sequence starting from 00 and so on.
I've attached the folder as well if anyone wants to try running it
I've attached the folder as well if anyone wants to try running it
Code:
INCLUDE Irvine32.inc
.data
mycode byte "Li#|rx#fdq#uhdg#wklv#phvvdjh#|rx#kdyh#vroyhg" ;text to decode
byte "wkh#sx}}oh#ehfdxvh#rqo|#wkhq#zloo#|rx#vhh#d#"
byte "phvvdjh#wkdw#pdnjv#dq|#vruw#ri#vhqvh1##Li###"
byte "|rx#jrw#wklv#idu#frqjudwxodwlrqv$$$$$$$$$$$$"
mycodelen = ($ - mycode) ;determines the length of the code
myrows = mycodelen / LENGTHOF mycode ;determines the number of rows
mycols = LENGTHOF mycode ;determines the number of columns
currentcol byte ? ;variable to hold the currentcol
currentrow byte ? ;variable to hold the currentrow
countsave dword ? ;variable to hold the counter from ecx
delayvar sword ? ;variable to hold the delay number for procedure delay
val3 = 3 ;variable to subtract 3
.code
main proc
;set up first loop to write encode text in 4X44 block
mov esi, OFFSET mycode
mov ecx, myrows ;put the number of rows in ecx
mov currentrow, 0 ;set the currentrow number to 0
OUTERLOOP1: ;start of outerloop
mov countsave, ecx ;move the value of ecx to countsave
mov ecx, mycols ;set ecx to the number of columns
mov currentcol, 0 ;set the currentcol to 0
INNERLOOP1: ;start of innerloop
mov dh, currentrow ;set the x variable of gotoxy to currentrow
mov dl, currentcol ;set the y variable of gotoxy to currentcol
call Gotoxy ;call gotoxy
mov al, [esi] ;mov the address of esi into al
call writechar ;call writechar
inc BYTE PTR [esi] ;increase the address of ESI by one
inc currentcol ;increase the curretcol
loop INNERLOOP1 ;end the loop
mov ecx, countsave ;move countsave back into ecx to restore later
inc currentrow ;increase current row
loop OUTERLOOP1 ;end the loop
mov delayvar, 1000 ;call the delay function
call Delay
;set up second loop to write decode text in a 4X44 block
mov esi, OFFSET mycode
mov ecx, myrows ;put the number of rows in ecx
mov currentrow, 0 ;set the currentrow number to 0
OUTERLOOP2: ;start of loop
mov countsave, ecx ;move value of ecx back into countsave
mov ecx, mycols ;move value of ecx into mycols
mov currentcol, 0 ;set currentcol to 0
INNERLOOP2: ;start loop
mov dh, currentrow ;set the x variable of gotoxy to currentrow
mov dl, currentcol ;set the y variable of gotoxy to currentcol
call gotoxy ;call gotoxy
mov al, [esi] ;mov the address of esi into al
sub al, val3 ;subtract three for al
call writechar ;call writechar
inc BYTE PTR [esi] ;increase the address of esi
inc currentcol ;increase the value of currentcol
mov delayvar, 200 ;call delay
call Delay
loop INNERLOOP2 ;end of loop
loop OUTERLOOP2 ;end of loop
call Crlf ;write end of line sequence
exit ;end of program
main ENDP
END main
Last edited: