The code below is supposed to take a string of ascii 0s and 1s (representing bits) that follows this format: 1byte start of transmission (can be ignored), 4 byte ip address and up to 8 bytes of text, then an ending byte 03H, then there is an address saved in a WORD
I encounter these errors when trying to link it:
***3.o: In function `sipo':
***3.asm

.text+0x73): undefined reference to `proc_PutStr'
***3.o: In function `aLoop':
***3.asm

.text+0x8a): undefined reference to `proc_GetCh'
***3.o: In function `inner_loop':
***3.asm

.text+0xcb): undefined reference to `proc_GetCh'
***3.o: In function `receiveCheckSum':
***3.asm

.text+0x169): undefined reference to `proc_GetCh'
Code:
%include "io.mac"
.DATA
char_prompt db "Please input a string of 0s and 1s that represents the XXY protocol ",0
IP_prompt db "The IP address is: ",0
message_prompt db "The message is: ",0
char_prompt2 db "Error in Transmission",0
query_msg db "Do you want to quit (Y/N): ",0
.UDATA
input resb 1
address resb 4
message resb 8
checksum resw 1
counter resb 1
savingCheckSum resb 1
locationInCheckSum resb 1
currentByte resb 1
.CODE
.STARTUP
begin:
push input
push address
push checksum
mov [savingCheckSum], byte 0
call sipo
PutStr IP_prompt
;output actual ip address TODO
PutStr message_prompt
PutStr message
push message
push address
call checker
test AX,[savingCheckSum]
je the_end
PutStr char_prompt2
the_end:
.EXIT
sipo: ;paramters:
PutStr char_prompt ; request a char. input
; 1) an array called "address" which contains the 4 bytes of the address .
pop ECX ;save call stack ; 2) An array called "message" which contains the bytes of the message.
pop EAX ;save checksum location ;3) a word variable called "checksum" which contains the checksum.
pop EBX ;save ip address location
pop ESI ;save message address
push ECX ;put back the call address
mov ECX, 8
aLoop:
GetCh [input] ;get the first 8 characters and do nothing with them
loop aLoop
mov [counter], byte 7
mov AL, 0 ;current byte
outer_loop:
mov ECX, 8 ;loop 8 times for 8 bits
mov AH, 80H ;mask byte
inc AL
mov [currentByte], AL ;save currentbyte so that at the end we know how many bytes were read excluding checksum
inner_loop:
inc byte [counter]
test [savingCheckSum], byte 0
je receiveCheckSum
GetCh [input]
cmp [counter], byte 40
jl receiveIP
jmp receiveMessage
receiveIP:
test [input], byte 0
je endof_innerLoop ;if it's 0, let's finish this loop!
mov EDX, EBX
dec EDX
add EDX, [currentByte]
OR [EDX], AH ;use the mask to set the bit to 1
jmp endof_innerLoop
receiveMessage:
mov EDX,ESI
add ESI,[currentByte]
sub EDX,6
cmp [EDX],byte 03H ;check for termination char, put a NULL at the end of message if it is (done below in ready)
je ready
test [input], byte 0
je endof_innerLoop
mov EDX,[currentByte]
add EDX,ESI
sub EDX, 5
OR [EDX], AH ;use the mask to set the bit to 1
jmp endof_innerLoop
ready: ;get ready to save the checksum
mov EDX,ESI
add ESI,[currentByte]
sub EDX,6
mov [EDX], byte '' ;put null character
mov [locationInCheckSum], byte 0
mov [savingCheckSum], byte 1
jmp endof_innerLoop
receiveCheckSum:
test [locationInCheckSum],byte 16 ; THIS IS THE ONLY PLACE TO EXIT THE LOOP, after we read 16 bits from the checksum, we exit the loop
je finish_loop
GetCh [input]
test [input], byte 0
inc byte [locationInCheckSum]
je endof_innerLoop
OR [EAX], AH
endof_innerLoop:
shr AH, 1
cmp ECX,1
je endOf_OuterLoop
dec ECX
jmp inner_loop
endOf_OuterLoop:
jmp outer_loop
finish_loop:
dec byte [currentByte]
dec byte [currentByte]
ret
checker:
pop ECX ;get everything into the registers and return the stack to the way it was before it was setup for this function
pop EDX ;address
pop ESI ;message
mov EBX, 0
push ECX
mov AX, 0
mov ECX, 2 ;check 2 bytes for a WORD
check_address_outer:
push ECX
mov ECX, 8
mov AH, 80H ;mask byte
check_address_inner:
test AH, [EDX+EDI] ;EDI is stack pointer -- CONFIRM THIS
jz endThisLoopAlready
inc AX
endThisLoopAlready:
shr AH, 1
loop check_address_inner
pop ECX
loop check_address_outer
mov ECX, [currentByte]
dec ECX
dec ECX
dec ECX
anotherOuterLoop: ;goes through the message
push ECX
mov AH, 80H ;mask byte
mov ECX, 8 ;8 bits
anotherInnerLoop:
test [ESI+EBX], AH
jz endInner
inc AX
endInner:
shr AH, 1
loop anotherInnerLoop
endOuter:
pop ECX
inc EBX
loop anotherOuterLoop
outOfLoops:
ret
If you see any other problems please let me know!! this code has never been compiled/tested because I haven't gotten past this stage so I'm sure there are other flaws in it.
and PS: it's obvious because I didn't even bother to remove the references that this is an assignment and to be clear I'm not asking for answers I'd just like some help
Thanks in advance!!