将二进制原码转换为补码的图灵机

实现将二进制原码转换为补码的图灵机

InstructionCurrent StateCurrent Value of MNew Value of MOperation on MNew State
1Begin**NOPStart
2Start**RIsNegative
3IsNegative00LHalt
4IsNegative11RFlip
5Flip10RFlip
6Flip01RFlip
7Flip**LAddition
8Addition01LReturn
9Addition10LCarry
10Carry01LReturn
11Carry10LCarry
12Carry*1LOverflow
13Overflowblank*NOPHalt
14Return00LReturn
15Return11LReturn
16Return**NOPHalt

输入的二进制数据按从左到右类似于大端法读取,第一位为符号位

样例:

  • *00101110* 经过 (1 2 3) 变为 *00101110*

  • *11001001* 经过 (1 2 4 5 6 6 5 6 6 5 7 8 15 15 14 15 15 14 15 16) 变为 *10110111*

corelab运行以下程序,initial state值为IsNegative

IsNegative 0 0 L Halt
IsNegative 1 1 R Flip
Flip 1 0 R Flip
Flip 0 1 R Flip
Flip * * L Addition
Addition 0 1 L Return
Addition 1 0 L Carry
Carry 0 1 L Return
Carry 1 0 L Carry
Carry * 1 L Overflow
Overflow _ * * Halt
Return 0 0 L Return
Return 1 1 L Return
Return * * * Halt
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值