8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

Save Integer to Address

Submitted by Steve Fewell

Routine: iout
Name: Save Integer to Address
Starting Address: &B347
Entry criteria: &37 and &38 (lo, hi) contain the address of the first byte of the memory location to store either the 32-bit Integer from the IWA (4 consecutive bytes required), or the 8-bit Integer from the IWA (1 byte required). &39 must contain zero if an 8-bit result is required, otherwise a 32-bit result is assumed.
Exit: The 1 or 4 byte memory location specified by &37 and &38 contain a copy of the contents of the IWA.

Description:
Saves a copy of the IWA to the memory location specified by &37 and &38. The least significant byte of the IWA (&2A) is copied first. If &39 contains zero, the routine then exists as the 8-bit integer in &2A has been copied to the requested location.

Otherwise, the rest of the Integer in the IWA is copied into the 3 subsequent bytes of the address pointed to by &37 and &38.

Disassembly for the Save Integer to Address routine

B347 * 165 042 A5 2A LDA &2A
B349 7 146 055 92 37 STA (&37)
B34B 9 165 057 A5 39 LDA &39
B34D   240 016 F0 10 BEQ 16 --> &B35F
B34F + 165 043 A5 2B LDA &2B
B351   160 001 A0 01 LDY#&01
B353 7 145 055 91 37 STA (&37),Y
B355 , 165 044 A5 2C LDA &2C
B357   200 C8 INY
B358 7 145 055 91 37 STA (&37),Y
B35A - 165 045 A5 2D LDA &2D
B35C   200 C8 INY
B35D 7 145 055 91 37 STA (&37),Y
B35F ` 096 60 RTS

 


 Back to 8BS
Or