PSEUDO code example

The following are examples of some PSEUDO procedures. In the following examples output machine instruction MACHOP's are preceded by an ^. The output from a MACHOP is relocatable binary code. The SLIC linker supports general fixup expressions thunks. Thunks can reference external and local offsets performing all operations allowed in a MACHOP expression. In general these are add, subtract, multiply, divide, shift, sizing, and, and or.

;
;   Output a procedure call instruction to the object file
;

PSEUDO call proc {

; if a 'far proc' use a far call
; if a 'proc' use a near call
; if a memory referance use memory size to deduce far or near
;                       call needed
; Some of this could be done in the call and farcall MACHOP's

   if TypeAttr:(proc) == farproc
     if segment:(proc) == CurrentSegment {
        ^pushreg cs			; Simulate far call
        ^call    proc}
     else
        ^farcall proc;
   else if TypeAttr:(proc) == proc
        ^call    proc;
   else if SizeAttr(proc) == 2
        ^call    proc;
   else
        ^farcall proc}
;
; Generate code to push arguments onto the stack.
; Keep simple only handles values no pointers here
;
PSEUDO push type,arg {
temp;
;
; If arg in a register and of right type push the rigister
;
   if StorageType:(arg) == register
      if RegType[RegIndex:(arg)] == type
        ^pushreg RegIndex:(arg);
      else if TypeAttr:(arg) << type
        ^pushreg XtendToReg(type, arg);
;
;  Push memory arg here converting to required type. 
;
   else if (type <= 4) && TypeAttr:(arg) in IntegerTypes
; Push sign extension or zero fill
        ^pushfill TypeAttr:(arg), type;
; Push data
        ^push     arg;
   else {
; Convert arg to requested type and the push it.
; Note MakeCompatable is a generator function
;
     temp = MakeCompatable(arg,type);
     if StorageType:(temp) == register
        ^pushreg  RegIndex:(arg);
     else
        ^push     temp;}


Back to SLIC main page


.