Code Examples - PS8 Computing

Go to content

Code Examples

Relay Computers > SBRC
;
; Continually prints 'Hello World!'
; Uses included serial library
;
; Starts @ 10
;
0010 0000_0000 org 0x10
0010 8408_3024 begin jsr _wsr, _ws
0011 0000_0016 prm hello
0012 8408_3024 jsr _wsr, _ws
0013 0000_001D prm world
0014 8408_3735 jsr _wsnlr, _wsnl
0015 4018_FF10 jmp begin
             ;
             ; define strings
0016 0000_0048 hello str "Hello "
0017 0000_0065 e
0018 0000_006C l
0019 0000_006C l
001A 0000_006F o
001B 0000_0020
001C 0000_0000 0 (term)
001D 0000_0057 world str "World!"
001E 0000_006F o
001F 0000_0072 r
0020 0000_006C l
0021 0000_0064 d
0022 0000_0021 !
0023 0000_0000 0 (term)
             ;
             ; include serial library
             ;----------------------------------------------------------
             ; Write zero terminated string to serial
             ;
             ; Save P1 address
0024 0800_342A _ws st _ws_p1, _ws_p
0025 0800_3027 st _wsr, _ws_a
0026 4800_0031 clr _ws_t1
             ; Save [P1] value to _ws_t1
0027 8080_3100 _ws_a add _ws_t1, 0
             ;
0028 8080_2A31 add _ws_p, _ws_t1
0029 4800_0032 _ws_l clr _ws_tmp
002A 8080_3200 _ws_p add _ws_tmp, 0
             ; If the character is zero, then return
002B 0062_322F jeq _ws_tmp, _ws_d
002C 9800_3200 outc _ws_tmp
002D 4880_012A inc _ws_p
002E 4018_FF29 jmp _ws_l
             ; Increment 'back address' to skip over P1, the jump back to calling routine
002F 4880_0130 _ws_d inc _wsr
0030 4018_FF00 _wsr jmp 0
             ;
0031 C810_FF00 _ws_t1 data 0
0032 C810_FF00 _ws_tmp data 0
0033 8080_3100 _ws_a1 add _ws_t1, 0
0034 8080_3200 _ws_p1 add _ws_tmp, 0
             ;----------------------------------------------------------
             ;
             ; Write newline to serial
0035 D800_0A00 _wsnl outc #10
0036 D800_0D00 outc #13
0037 4018_FF00 _wsnlr jmp 0
             ;----------------------------------------------------------





Symbol table:

[serial] = 0x24
_ws = 0x24
_ws_a = 0x27
_ws_a1 = 0x33
_ws_d = 0x2F
_ws_l = 0x29
_ws_p = 0x2A
_ws_p1 = 0x34
_ws_t1 = 0x31
_ws_tmp = 0x32
_wsnl = 0x35
_wsnlr = 0x37
_wsr = 0x30
begin = 0x10
hello = 0x16
world = 0x1D

memory image:

0010: 84083024 00000016 84083024 0000001D 84083735 4018FF10 00000048
0017: 00000065 0000006C 0000006C 0000006F 00000020
001D: 00000057 0000006F 00000072
0020: 0000006C 00000064 00000021
0024: 0800342A 08003027 48000031 80803100 80802A31
0029: 48000032 80803200 0062322F 98003200 4880012A 4018FF29 48800130 4018FF00
0031: C810FF00 C810FF00 80803100 80803200 D8000A00 D8000D00 4018FF00

Back to content