C:\SISC> cat -l samp1.mc 1 ;samp1.mc 2 ;this is a sample Machine Code for the SISC 3 ; that will print out the code of myself 4 ; in decimal form 5 2 1,01 ; R1=1 (00) 6 2200 ; R2=0 (02) 7 233A ; R3 = length of this program 8 3209 ; store r2 into 9 (:AGAIN = 06) 9 16 00 ; LOAD r6 from ?? (:08 :09 ) 10 20 4d ; r0="M" 11 d1 00 ; print "M" 12 20 28 ; "(" 13 14 d100 ; print "(" (:10h) 15 40 2,0 ; move r2 to r0 (:12h) 16 d300 ; print r0 as integer 17 20 29 ; ")" 18 d100 19 203d;"=" 20 d100 21 4060; move r6 to r0 22 23 d300 ; out content of mem[r2] (:20h) 24 200d; CR 25 d100 26 20 0A ;LF 27 28 d100 ; print Line Feed (:28h) 29 40 30 ; move r3 to r0 (program length) 30 5221 ; r2 := r2+1 (r1 contains 1) 31 B232 ; jump to done if R2=R0=R3 32 33 b006 ; goto :AGAIN=06 (this line :30) 34 2007 ; bell (:done = 32) 35 d100 ; beep the speaker 36 c000 ; halt 37 ffff ; for man check only C:\SISC> sisc (進入全螢幕模式, 按 h 看 help ) Your running LOG is in SISC.LOG <------ 此即執行後之 LOG file C:\SISC> type sisc.log ****** SISC LOG at 00:06:00 on Friday, 12/22/1995 ****** Yes> H Command can be either Upper case or lower case: Q Quit this system H/I Help message/Instructions A Assemble assembly program B set Break pointer E show/Enter memory data L Load the Machine Code P set Program counter R? modify content of Register ? G Go (RUN) start from PC T Trace the program one step U Unassemble (4 instructions) M Memory size toggle =+- show/change RUNNING speed other cmd: C K F Only CMP affects LT/EQ/GT status Yes> I In addition to instructions on our text book page 455-456, ("?" means don't care) FADD=NOP D0??/D1?? Get/Out Char to/from R0 D2??/D3?? Get/Out int to/from R0 EZXY (zzzz xxxx yyyy in binary): Ezz00 xxxx yyyy: LOAD F,zzxxxxyyyy Ezz01 xxxx yyyy:STORE F,zzxxxxyyyy Ezz10 xxxx yyyy: CALL zzxxxxyyyy E??11 ???? ????: RETurn FZXY depends on right 2 bits of ZZ zzzz in binary: ??00 xxxx yyyy: CMP RX to RY zz01 xxxx yyyy: JLT zzxxxxyyyy zz10 xxxx yyyy: JEQ zzxxxxyyyy zz11 xxxx yyyy: JGT zzxxxxyyyy Only CMP affects LT/EQ/GT status Yes> L Filename: samp1.MC === Loading file samp1.MC === ;sample1.mc ;this is a sample Machine Co ; that will print out the co ; in decimal form 0000: 2 1,01 ; R1=1 (00) 0002: 2200 ; R2=0 (02) 0004: 233A ; R3 = length of this 0006: 3209 ; store r2 into 9 (:A 0008: 16 00 ; LOAD r6 from ?? (:0 000A: 20 4d ; r0="M" 000C: d1 00 ; print "M" 000E: 20 28 ; "(" 0010: d100 ; print "(" (:10h) 0012: 40 2,0 ; move r2 to r0 (: 0014: d300 ; print r0 as integer 0016: 20 29 ; ")" 0018: d100 001A: 203d;"=" 001C: d100 001E: 4060; move r6 to r0 0020: d300 ; out content of mem[r2 0022: 200d; CR 0024: d100 0026: 20 0A ;LF 0028: d100 ; print Line Feed (: 002A: 40 30 ; move r3 to r0 (progr 002C: 5221 ; r2 := r2+1 (r1 conta 002E: B232 ; jump to done if R2=R 0030: b006 ; goto :AGAIN=06 (thi 0032: 2007 ; bell (:done = 32) 0034: d100 ; beep the speaker 0036: c000 ; halt 0038: ffff ; for man check only Yes> U 000: 2101 !. LDI 1,01 002: 2200 ". LDI 2,00 004: 233A #: LDI 3,3A 006: 3209 2. STORE 2,09 008: 1600 .. LOAD 6,00 00A: 204D M LDI 0,4D 00C: D100 Q. PUTC 00E: 2028 ( LDI 0,28 010: D100 Q. PUTC 012: 4020 @ MOVE 2,0 Yes> U ( 連續 U 會接下去 ) 014: D300 S. PUTi 016: 2029 ) LDI 0,29 018: D100 Q. PUTC 01A: 203D = LDI 0,3D 01C: D100 Q. PUTC 01E: 4060 @` MOVE 6,0 020: D300 S. PUTi 022: 200D . LDI 0,0D 024: D100 Q. PUTC 026: 200A . LDI 0,0A Yes> U 028: D100 Q. PUTC 02A: 4030 @0 MOVE 3,0 02C: 5221 R! ADD 2,2,1 02E: B232 22 JUMP 2,32 030: B006 0. JUMP 0,06 032: 2007 . LDI 0,07 034: D100 Q. PUTC 036: C000 @. Halt 038: FFFF .. JGT 3FF 03A: 0000 .. NOP Yes> P Enter new Program Counter:1a Yes> U 01A: 203D = LDI 0,3D 01C: D100 Q. PUTC 01E: 4060 @` MOVE 6,0 020: D300 S. PUTi 022: 200D . LDI 0,0D 024: D100 Q. PUTC 026: 200A . LDI 0,0A 028: D100 Q. PUTC 02A: 4030 @0 MOVE 3,0 02C: 5221 R! ADD 2,2,1 Yes> P Enter new Program Counter:0 Yes> G ( G 指令會從 current PC 開始執行 ) M( 0)= 33 M( 1)= 1 M( 2)= 34 M( 3)= 0 M( 4)= 35 M( 5)= 58 M( 6)= 50 M( 7)= 9 M( 8)= 22 M( 9)= 9 M( 10)= 32 M( 11)= 77 M( 12)= 209 M( 13)= 0 M( 14)= 32 M( 15)= 40 M( 16)= 209 M( 17)= 0 M( 18)= 64 M( 19)= 32 M( 20)= 211 M( 21)= 0 M( 22)= 32 M( 23)= 41 M( 24)= 209 M( 25)= 0 M( 26)= 32 M( 27)= 61 M( 28)= 209 M( 29)= 0 M( 30)= 64 M( 31)= 96 M( 32)= 211 M( 33)= 0 M( 34)= 32 M( 35)= 13 M( 36)= 209 M( 37)= 0 M( 38)= 32 M( 39)= 10 M( 40)= 209 M( 41)= 0 M( 42)= 64 M( 43)= 48 M( 44)= 82 M( 45)= 33 M( 46)= 178 M( 47)= 50 M( 48)= 176 M( 49)= 6 M( 50)= 32 M( 51)= 7 M( 52)= 209 M( 53)= 0 M( 54)= 192 M( 55)= 0 M( 56)= 255 M( 57)= 255 ^GYes> Rx (Rx 表示 Clear all registers) all Registers cleared Yes> R1 R1= 00: 08 Yes> R2 R2= 00: 08 Yes> R0 R0= 00: 89 Yes> E (表示要 Examine/Enter Memory data) Location(hex)?40 MEM[040h] = dec 0 = 00h : 60 MEM[041h] = dec 0 = 00h : 12 MEM[042h] = dec 0 = 00h : Yes> P Enter new Program Counter:40 (輸入40將PC 改為 40h) Yes> U 040: 6012 `. FADD 0,1,2 042: 0000 .. NOP 044: 0000 .. NOP 046: 0000 .. NOP 048: 0000 .. NOP 04A: 0000 .. NOP 04C: 0000 .. NOP 04E: 0000 .. NOP 050: 0000 .. NOP 052: 0000 .. NOP Yes> T (會從 40h 開始, 因PC 已被改為 40h) Yes> R= (R= 表示print all registers) R0= 18 R1= 08 R2= 08 R3= 00 ( 注意我們做了 FADD R0, R1, R2 ) R4= 00 R5= 00 R6= 00 R7= 00 ( 也就是說 R0 := R1 + R2 ) R8= 00 R9= 00 RA= 00 RB= 00 RC= 00 RD= 00 RE= 00 RF= 00 Yes> Q Thank you for using SISC! C:\SISC> cat -l samp2.mc 1 ;samp2.mc 2 ;this machine program read N 3 ; and calculate 1+2+...+N 4 2101 ; R1=1 5 d624 ; print string "N=" 6 d200 ; read integer into R0 7 29 01 ; R9 = 1 8 2500 ; R5 = 0, used to store sum 9 5 5 5,9 ; R5 = R5 +R9 :again 10 B9 12 ; if done goto :ok 11 5991 ; R9 = R9 + 1 12 B0 0a ; goto :again 13 d6 28 ; print "Sum from 1 to " :ok 14 d300 ; out int from R0 15 d625 ; print "=" 16 4050 ; move r5 to r0 , the sum 17 d300 ; out int from R0 18 d620 ; out cr/lf 19 c000 ; halt 20 0d0a ; CR/LF (:20h) 21 2424 ; $ 22 4e3d ; "N=" (:24h) 23 2424 ; $$ 24 5375 ; Su (:28h) 25 6d20 ; m 26 6672 ; fr 27 6f6d ; om 28 2031 ; 1 29 2074 ; t 30 6f20 ; o 31 2424 ; $$ 32 c000 33 ;end of this program