hewlett-packard HP 9835A — 011

Getting Started 11 Now that the routine has been developed, it is necessary to get it into the memory of the machine as a program. This is done by preceding each and every assembly language statement with the keyword ISOURCE and entering it as a program line. The process of entering (with the AUTO and the 8 key in the same way you normally enter any BASIC statement. (This process is fully described in the "Program Entry" section of this chapter.) keyword included) is the same as with any other BASIC statement - so you can use EDIT or The final result of entering the routine would look something like - NAM Multipl ication i B8]inning of module E>-::T [r'i""'or'"" .. ,e::,::

'j t, :::;,:::'t ',),:j, 'i ' .. ,i!:::'. Put ',)d,! i,.j!:::' ! !...it j 'i '11:. '! e:::, Integers: H~~ ar8a for integers cr8ated ;:::: C I ::: otJ F:' C E :3i:::i I ::;()!...!F:C[ I ('lPi,..!t i :: Ii···!T I npt.Jt ~2:: Indicates 81try pJint follows I nC!'i C.:::i.t E':::· it'j (it ~:'!;iE:'r" r)::j. ('.:::!. fl"let E'r-':::· ·::i~·-·i:::· Cil...!tPi,..it :: Multiply: LDA =Integers f)::t::::·~::'i::'cj 'i ri t 1'''iE Cit-·C!E:·!· .. · !~'i i)!:::'r"i !:::::) t!·-!e~::.t-::· statemefits and are giv8~ n~~es f:i c t iM.f.~i '! !:::' I"'! t (.~) 1::::Ci 'i i"'1 t ( r-i,::j, rfi E' : I'll !) 1 t 'i I:)'j ~) ) ;: r'()I...Jt '! n~:' l:::,,:::',::) '! n::::, b::.!

'fe-t h 'j (p;i ,:::I.C 'i:, I .. ,~:i 'I ').::1.1 i,..i e () f t 1''1 e i i''', pu t p::i rOO,,:::;, r;'p:::"i:, eT :::' from BASIC and storing them where the routine can use them ,.1":::: rii :::; '::' t ',},3, 1 i) e L .. DH ::: I l"';t~'e(;iei'-':::,+:L L .. DB ::: I nput ~::: 12[1 jSOi...lF:CE:: .I, ,,::OJ::.' I ::::;UU~:CE ,J::::;I"1 (;,:::'t '),:::;, 'i ue LDH Inte':;lei''''::::, 1. 40 I :::;C)i,JF\:::E i 50 I ::::OU F:CE arithmetic accumulator and i6~] I'::::O!...H:;::C[ i ?Ci I :::OUF:CE f 'j n,:::;. 'II::.! i'fiU 'j t 'j i:) ': 'j e:::, t j''',er;', H c hec k fOi,'" O')':::'i''''f 'j 01 .. .1 'j :::' t:"::' r"'t''(:'r'''rned :!. '::+i I ':::OU::;::C[::: :!.f:~j E;O:".iF:CE L.!

':..' , i'··' ec k i i"; (J 1:. :.", ,:::' e::::, i,,'; : t f ':)(" ,"'" ", 'i:. i'''' c ,,","" ~md the rc~tine is aborted L.Ii A = I t-1 t E- :;;~ ~:' ! .... ::::. ! The product is then returned to the LI1I:; =Cil .. ~'t. f:)t~t c! u t. ~)i_,l t !,).::t. r" i ,:~,1::! '1 E- i i,Hi :B ~::1 :::; I C: -~'j ~::. t E:'(] among the arguments END Multipl ication This source code demonstrates the three critical items in assembly subprograms. First, a routine has to be part of a module; modules are delimited with the NAM and END pseudo-instructions (see lines 10 and 270 in the source).

Second, a routine has to have an entry point; this consists of a SUB pseudo-instruction (see line 40), any parameters (see lines 50 through 70), and a name (the label used on the first machine instruction following the SUB, see line 80). Finally, a routine must be able to return to the BASIC program which called it; this is accomplished with the RET 1 instruction (see line 260). The NAM, END, and SUB pseudo-instructions are discussed in Chapter 4. The RET 1 instruc- tion is discussed in Chapter 3.