看板 Grad-ProbAsk 關於我們 聯絡資訊
問題入下: A hypothetical single instruction computer SIC has only one instruction; subtract and branch if negative, or sbn for short. The sbn instruction has three operands, each consisting of the address of a word in memory: sbn a,b,c # Mem[a]=Mem[a]-Mem[b]; if(Mem[a]<0) go to c This instruction will subtract the number in memory location b from the number in memory location a and place the result back in a, overwriting the previous value. If the result is greater than or equal to 0, the computer will take its next instruction from memory location just after the current instruction. If the result is less than 0, the next instruction is taken from memory location c. SIC has no registers and no instructions other than sbn. Although it has only one instruction, SIC can imitate many of the operations of more complex instruction sets by using clever sequences of sbn instruction. For example, here is a program to copy a number from location a to location b: Start Sbn temp, temp,. +1 # sets temp to zero Sbn temp, a,. +1 # sets temp to -a Sbn b, b,. +1 # sets b to zero Sbn b, temp,. +1 # sets b to temp which is a In the program above, the notation "+1" means "the address after this one," so that each instruction in this program goes on to the next in sequence whether or not the result is negative. We assume temp to be the address of a apare memory word that can be used for temporary result. Please write SIC program to multiply a by b, putting the result in c. 請問大大們,這題要如何創造出乘法指令?? 感謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 223.141.74.71