MAIN START RPUSH ; Init Variables LAD GR1,I002 XOR GR2,GR2 LAD GR3,258 CALL C010 ; Do J001 NOP ; Print "Number?" OUT LB001,LL001 ; Input s IN SB001,SL001 XOR GR0,GR0 ST GR0,EOF LD GR0,SL001 JPL J003 JZE J003 ST GR0,EOF XOR GR0,GR0 ST GR0,SL001 J003 NOP ; If (s = "end") Then LAD GR1,SB001 LD GR2,SL001 LAD GR3,='end' LAD GR4,3 CALL C004 SLL GR0,15 SRA GR0,15 XOR GR0,=#FFFF LD GR7,GR0 AND GR7,GR7 JZE J004 ; Exit Do JUMP J002 ; End If J004 NOP ; n = CInt(s) LAD GR1,SB001 LD GR2,SL001 CALL C000 LD GR7,GR0 ST GR7,I002 ; If (n < 1) Then LD GR7,I002 LAD GR6,1 LAD GR0,#FFFF CPA GR7,GR6 JMI J014 XOR GR0,GR0 J014 LD GR7,GR0 AND GR7,GR7 JZE J013 ; Print "Invalid Input" OUT LB002,LL002 ; Continue Do JUMP J001 ; End If J013 NOP ; If ((n Mod 15) = 0) Then LD GR7,I002 LAD GR6,15 LD GR3,GR6 LD GR2,GR7 CALL C009 LD GR0,GR1 LD GR7,GR0 XOR GR6,GR6 SUBA GR7,GR6 JZE J034 LAD GR7,#FFFF J034 XOR GR7,=#FFFF AND GR7,GR7 JZE J016 ; s = "FizzBuzz" LAD GR1,SB001 LAD GR2,SL001 LAD GR3,='FizzBuzz' LAD GR4,8 CALL C007 JUMP J015 ; ElseIf ((n Mod 3) = 0) Then J016 NOP LD GR7,I002 LAD GR6,3 LD GR3,GR6 LD GR2,GR7 CALL C009 LD GR0,GR1 LD GR7,GR0 XOR GR6,GR6 SUBA GR7,GR6 JZE J037 LAD GR7,#FFFF J037 XOR GR7,=#FFFF AND GR7,GR7 JZE J017 ; s = "Fizz" LAD GR1,SB001 LAD GR2,SL001 LAD GR3,='Fizz' LAD GR4,4 CALL C007 JUMP J015 ; ElseIf ((n Mod 5) = 0) Then J017 NOP LD GR7,I002 LAD GR6,5 LD GR3,GR6 LD GR2,GR7 CALL C009 LD GR0,GR1 LD GR7,GR0 XOR GR6,GR6 SUBA GR7,GR6 JZE J038 LAD GR7,#FFFF J038 XOR GR7,=#FFFF AND GR7,GR7 JZE J018 ; s = "Buzz" LAD GR1,SB001 LAD GR2,SL001 LAD GR3,='Buzz' LAD GR4,4 CALL C007 JUMP J015 ; Else J018 NOP ; s = CStr(n) LD GR7,I002 LD GR3,GR7 LAD GR1,TB001 LAD GR2,TL001 CALL C002 LAD GR1,SB001 LAD GR2,SL001 LAD GR3,TB001 LD GR4,TL001 CALL C007 ; End If J015 NOP ; Print s OUT SB001,SL001 ; Loop JUMP J001 J002 NOP EXIT NOP RPOP RET ; Dim n As Integer I002 DS 1 ; Dim s As String SL001 DS 1 SB001 DS 256 EOF DS 1 TL001 DS 1 TB001 DS 256 LL001 DC 7 LB001 DC 'Number?' LL002 DC 13 LB002 DC 'Invalid Input' ; FuncCInt C000 PUSH 0,GR1 PUSH 0,GR2 PUSH 0,GR3 PUSH 0,GR4 PUSH 0,GR5 ADDL GR2,GR1 XOR GR0,GR0 XOR GR4,GR4 CPL GR1,GR2 JZE J010 LD GR3,0,GR1 CPL GR3,='+' JNZ J012 LAD GR1,1,GR1 JUMP J011 J012 CPL GR3,='-' JNZ J011 LAD GR4,-1 LAD GR1,1,GR1 J011 CPL GR1,GR2 JZE J010 LD GR3,0,GR1 SUBL GR3,='0' JMI J010 CPL GR3,=9 JPL J010 LD GR5,GR0 SLL GR0,3 ADDL GR0,GR5 ADDL GR0,GR5 ADDL GR0,GR3 LAD GR1,1,GR1 JUMP J011 J010 XOR GR0,GR4 SUBL GR0,GR4 POP GR5 POP GR4 POP GR3 POP GR2 POP GR1 RET ; FuncCStrArgInt C002 CPL GR3,=#8000 JNZ J039 PUSH 0,GR3 PUSH 0,GR4 LAD GR3,='-32768' LAD GR4,6 CALL C007 POP GR4 POP GR3 RET J039 AND GR3,GR3 JNZ J040 LAD GR3,1 ST GR3,0,GR2 LD GR3,='0' ST GR3,0,GR1 XOR GR3,GR3 RET J040 PUSH 0,GR1 PUSH 0,GR2 PUSH 0,GR3 PUSH 0,GR4 PUSH 0,GR5 JPL J041 LD GR4,='-' ST GR4,0,GR1 LAD GR1,1,GR1 XOR GR3,=#FFFF LAD GR3,1,GR3 J041 LAD GR4,V001 LD GR5,GR1 LD GR2,GR3 LAD GR3,10 J042 CALL C009 ADDL GR1,='0' ST GR1,0,GR4 LAD GR4,1,GR4 LD GR2,GR0 JPL J042 LAD GR2,V001 LAD GR4,-1,GR4 J043 LD GR1,0,GR4 ST GR1,0,GR5 LAD GR5,1,GR5 LAD GR4,-1,GR4 CPL GR4,GR2 JPL J043 JZE J043 LD GR0,GR5 POP GR5 POP GR4 POP GR3 POP GR2 POP GR1 SUBL GR0,GR1 ST GR0,0,GR2 RET V001 DS 6 ; UtilCompareStr C004 PUSH 0,GR1 PUSH 0,GR2 PUSH 0,GR3 PUSH 0,GR4 PUSH 0,GR5 XOR GR0,GR0 J005 AND GR2,GR2 JPL J006 CPL GR2,GR4 JNZ J007 JUMP J009 J006 AND GR4,GR4 JZE J008 LD GR5,0,GR1 CPL GR5,0,GR3 JMI J007 JPL J008 LAD GR1,1,GR1 LAD GR2,-1,GR2 LAD GR3,1,GR3 LAD GR4,-1,GR4 JUMP J005 J007 LAD GR0,-1 J008 OR GR0,=1 J009 POP GR5 POP GR4 POP GR3 POP GR2 POP GR1 RET ; UtilCopyStr C007 PUSH 0,GR1 PUSH 0,GR2 PUSH 0,GR3 PUSH 0,GR4 ST GR4,0,GR2 AND GR4,GR4 JZE J036 J035 LD GR2,0,GR3 ST GR2,0,GR1 LAD GR3,1,GR3 LAD GR1,1,GR1 SUBL GR4,=1 JPL J035 J036 POP GR4 POP GR3 POP GR2 POP GR1 RET ; UtilDivMod C009 AND GR3,GR3 JNZ J021 XOR GR0,GR0 LAD GR1,-1 RET J021 PUSH 0,GR2 PUSH 0,GR3 PUSH 0,GR4 PUSH 0,GR5 LD GR4,GR2 LD GR5,GR2 JPL J019 XOR GR5,GR5 SUBA GR5,GR2 J019 LD GR1,GR3 JPL J020 XOR GR1,GR1 SUBA GR1,GR3 J020 LAD GR0,1 J022 ADDL GR1,GR1 JOV J023 ADDL GR0,GR0 JUMP J022 J023 SRL GR1,1 LAD GR1,#8000,GR1 XOR GR2,GR2 J024 CPL GR5,GR1 JMI J025 SUBL GR5,GR1 ADDL GR2,GR0 J025 SRL GR0,1 JZE J026 SRL GR1,1 JUMP J024 J026 LD GR5,GR4 XOR GR5,GR3 SRA GR5,15 XOR GR2,GR5 SUBA GR2,GR5 CALL C012 LD GR1,GR4 SUBA GR1,GR0 LD GR0,GR2 POP GR5 POP GR4 POP GR3 POP GR2 RET ; UtilFill C010 PUSH 0,GR1 PUSH 0,GR2 PUSH 0,GR3 ADDL GR3,GR1 J044 CPL GR1,GR3 JZE J045 ST GR2,0,GR1 LAD GR1,1,GR1 JUMP J044 J045 POP GR3 POP GR2 POP GR1 RET ; UtilMul C012 PUSH 0,GR2 PUSH 0,GR3 PUSH 0,GR4 PUSH 0,GR5 XOR GR0,GR0 XOR GR1,GR1 LD GR4,GR2 LD GR5,GR3 J027 SRL GR2,1 JOV J028 JNZ J030 JUMP J031 J028 ADDL GR0,GR3 JOV J029 JUMP J030 J029 LAD GR1,1,GR1 J030 SLL GR3,1 JUMP J027 J031 SRL GR5,1 SLL GR4,1 JOV J032 JNZ J031 JUMP J033 J032 ADDL GR1,GR5 JUMP J031 J033 POP GR5 POP GR4 POP GR3 POP GR2 RET END