
Instruction Set
4-204
RET
RET
Examples
This example writes a zero-terminated string to the serial port in polled mode. The full
address (segment:offset) of the string is passed as an input parameter on the stack.
Tips
The assembler automatically generates a different machine-language opcode for RET
depending on the type of procedure (near or far) in which it is used.
Related Instructions
If you want to
See
Call a procedure
CALL
Reserve storage on the stack for the local variables of a procedure
ENTER
Resume an interrupted procedure
IRET
Stop executing the current sequence of instructions and begin another sequence JMP
Remove the local variables of a procedure from the stack
LEAVE
; initialize and program serial port for transmit
...
; write zero-terminated string to serial port in polled mode
; input parameters:
offset of string pushed on stack
segment of string pushed on stack
SendSerialString
PROC
NEAR
MOV
BP,SP
; use BP to access parameters
PUSHA
; save general registers
PUSH
DS
; save DS
MOV
AX,[BP]+2
; get segment of string
MOV
DS,AX
; DS points to string segment
MOV
AX,[BP]+4
; get offset of string
MOV
SI,AX
; SI points to string offset
CLD
; process string from low to high
SENDSS_LOOP:
LODSB
; load byte from string to AL
CMP
AL,0
; is character a null?
JZ
SENDSS_DONE
; if so, then done
mSPRT_TXCHAR_P
; transmit character (macro)
JMP
SENDSS_LOOP
; jump to top of loop
SENDSS_DONE:
POP
DS
; restore saved DS
POPA
; restore general registers
RET
4
; pop string address and return
SendSerialString
ENDP
Summary of Contents for Am186 Series
Page 1: ...Am186 and Am188 Family Instruction Set Manual February 1997...
Page 10: ...Table of Contents x...
Page 18: ...Programming 1 8...
Page 40: ...Instruction Set Listing 3 14...