8-Bit Software

The BBC and Master Computer Public Domain Library

Back to 8BS Or Back to Disassembly


Page Last Altered:

8D84 Check for Variable name character or digit (in A)

Submitted by Steve Fewell

Entry: A contains an ASCII character code.
Exit: The carry flag is 1 if the character in A is a valid variable name letter ('A'-'Z', '_', '£', 'a'-'z') or a
digit ('0'-'9'). The carry flag is 0 otherwise.

Description:

If the character (in A) is greater than or equal to 123 (&7B) then exit with Carry = 0 [char > 'z'].
If the character is greater than or equal to 95 (&5F) then exit with Carry = 1 [char = '_' or '£' or 'a'-'z'].
If the character is greater than or equal to 91 (&5B) then exit with Carry = 0 [char = '[', '\', ']' or '^'].
If the character is greater than or equal to 65 (&41) then exit with Carry = 1 [char = 'A'-'Z'].
If the character is greater than or equal to 58 (&3A) then exit with Carry = 0 [char = ':', ';', '<', '=', '>', ?' or '@'].
[&8D94] If the character is greater than or equal to 48 (&30) then exit with Carry = 1 [char = '0'-'9'].
Otherwise (if character is less than 48 (&30) then exit with Carry = 0.


Disassembly for the Check for Variable name character or digit (in A) routine

8D84 { 201 123 C9 7B CMP#&7B
8D86   176 250 B0 FA BCS -6 --> &8D82 [CLC : RTS]
8D88 _ 201 095 C9 5F CMP#&5F
8D8A   176 014 B0 0E BCS 14 --> &8D9A
8D8C [ 201 091 C9 5B CMP#&5B
8D8E   176 242 B0 F2 BCS -14 --> &8D82 [CLC : RTS]
8D90 A 201 065 C9 41 CMP#&41
8D92   176 006 B0 06 BCS 6 --> &8D9A
8D94 : 201 058 C9 3A CMP#&3A
8D96   176 234 B0 EA BCS -22 --> &8D82 [CLC : RTS]
8D98 0 201 048 C9 30 CMP#&30
8D9A ` 096 60 RTS

 


 Back to 8BS
Or