@R2
M=0
@R0
D=M
@END
D, JEQ
@store
M=D
(LOOP)
@R1
D=D-M
@REMAINDER
D, JLT
@EVENLY
D, JEQ
@LOOP
0, JMP
(REMAINDER)
@R1
D=D+M
@R2
M=D
(EVENLY)
@store
D=M
@R0
M=D
(END)
@END
0, JMP
mod(x,y) works for unsigned integers, but not for signed integers in nand2tetris. What changes should I make?
164 Views Asked by comp sci At
1
There are 1 best solutions below
Related Questions in ASSEMBLY
- (x64 Nasm) Writeline function on Linux
- Is the compiler Xcode uses to produce Assembly code a bad compiler?
- Why do we need AX instead of MOV DS, data directly with a segment?
- Bootloader in Assembly with Linux kernel
- How should the byte sequence 0x40 0x55 be interpreted by an x86-64 emulator?
- C++ code into assembly
- Drawing circles of increasing radius
- Assembly print on screen using pop ecx
- Equivalent to asm volatile in Gfortran?
- Show 640x480 BMP image with inline ASM c++
- Keep track of numbers entered in by a user in assembly
- 8086 Assembly Arrays with I/O
- DB ASM variable in Inline ASM C++
- What does Jump to means in callgrind?
- How to convert binary into decimal in assembly x8086?
Related Questions in UNSIGNED-INTEGER
- U suffix in the variable declaration
- How does in assembly does assigning negative number to an unsigned int work?
- What are integer literal types? And how are they stored?
- Why Do We have unsigned and signed int type in C?
- Changed c++ unsigned int from 0 to -2, but prints 4294967294
- wcstombs_s "Cannot convert argument" DirectX-11
- Parsing unsigned integer from JSON dictionary in Swift
- C - Seemingly unsigned int being sign extended when right shift?
- How to shift int64 value to unsigned int64 space without changing the order?
- Printing a byte from an unsigned integer in C
- Depiction of binary digit changes during promotion from signed to unsigned integers/what happens?
- SQL Mode Is NO_UNSIGNED_SUBTRACTION But Still Getting Out of Range Error
- Unsigned Integer Multiple Syntax
- Correct way to use Java Prepared Statement with Unsigned Integer
- Reinterpreting the bitstring of a unsigned int range [uint(a1) uint(a2)] to floating point range [float(a1) float(a2)] is this possible?
Related Questions in MODULO
- How to compute relative difference in a circular domain (weekday) in R
- Find nCr mod M where M is not prime
- C++: Quickest way to get integer within a range
- Modulo operator
- Trouble finding differential between two items in C++
- Finding modulo inverse if gcd is not 1
- Calculating the modulo of two intervals
- Visual Basic Random Number/Mod
- Newbie: Using $mod method during insert in mongodb
- Want to know how to find Modulo of a decimal number with 10^9 + 7?
- Universal hashing performs worse than modulo hashing, what is wrong?
- Modulo operation difference between Swift and Python
- how to restore number after modulo
- Modulo of high powers without using Math.BigInteger
- having trouble creating a modulo calculator with javascript
Related Questions in NAND2TETRIS
- Dealing with arrays in HDL
- Matching similar terms in ANTLR without capturing difference
- Nand To Tetris (Jack): Simple if conditional with equality testing giving this error - "Expected - or ~ or ( in term"
- Nand to Tetris: string equality test isn't working
- Nand2tetris Project4- Test failed - of Fill.asm: Comparison failure at line 3
- HDL - PC.hdl but starting off with x2 8 bit registers
- I am trying to build a PC CHIP, but am getting the error message, Line 19, out(8) and out(16) have different bus widths
- How to build a 8 bit wide hdl ALU
- nand2Tetris use of chips as blocks
- Nand2Tetris Weird screen behavior
- Creating new string somehow changing value of old string? | C
- How to create a Bitwise Nand of memory cell 0 and 1, result recorded in memory cell 2
- Problem with an infinite loop in Memory Chip implementation (Nand2Tetris)
- Subtracting 16-bit 2's compliment numbers in assembly language
- Confusion related to virtual machine in nand2tetris
Related Questions in SIGNED-INTEGER
- SDL_Keycodes are too big for storage
- Displaying numbers with DOS
- Convert binary to signed int/decimal
- Unsigned Multiplication using Signed Multiplier
- Is comparing an underflowed, unsigned integer to -1 well-defined?
- mod(x,y) works for unsigned integers, but not for signed integers in nand2tetris. What changes should I make?
- About int and unsigned int
- how to print negative integer using SWORD PTR(assembly lang)
- How to printf a sint32 in C using gcc compiler tricore v3.4.6?
- Why is the "sign bit" included in the calculation of negative numbers?
- subtraction of 2 sign and magnitude binary numbers in assembly (ex : 11110110 and 10101011)
- C usual arithmetic conversions rules
- Unreasonable behavior on mixing signed and unsigned integers
- Why, in some C++ compilers, does `int x = 2147483647+1;` give only a warning but stores a negative value, while some compilers give a runtime error?
- Signed Memory Arithmetic vulnerability iOS
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You should identify the conditions under which your current code works, and fails. Does it require both operands to be positive, or just have the same sign?
Once you have done that, you also know the conditions under which it fails. You can then check for those, and either execute different code under those conditions, or modify the operands so that the current code works and generates the proper result.
To get you started, here's some examples of what modulo should return. Good luck!