8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

BC51 Push String to Stack

Submitted by Steve Fewell

Description:

Check whether there is space for the length of the String in the String Buffer (SWA) plus 1 byte (for length)
on the stack. If no space, then generate "No Room" error.

Y = length of the String Buffer (?&36, Length of SWA). If length is zero then store
binary zero on the Stack (length of String) and return, as the first byte retrieved from
the Stack will be the String length, 0 in this case.
Otherwise, store the String on the Stack (in reverse order).
Lastly, the length of the string is stored on the stack (?&36) [last byte of Stack Value] and routine exits.


Disassembly for the Push String to Stack routine

BC51   024 18 CLC
BC52   165 004 A5 04 LDA &04
BC54 6 229 054 E5 36 SBC &36
BC56   032 030 189 20 1E BD JSR &BD1E Check for Stack clash with Heap
BC59 6 164 054 A4 36 LDY &36
BC5B   240 008 F0 08 BEQ 8 --> &BC65
BC5D   185 255 005 B9 FF 05 LDA &05FF,Y
BC60   145 004 91 04 STA (&04),Y
BC62   136 88 DEY
BC63   208 248 D0 F8 BNE -8 --> &BC5D
BC65 6 165 054 A5 36 LDA &36
BC67   146 004 92 04 STA (&04)
BC69 ` 096 60 RTS

 


 Back to 8BS
Or