Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use toString(16) for num2hex and addr2hex instead of own implementation #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -2474,14 +2474,13 @@ function SimulatorWidget(node) {


function addr2hex(addr) {
return num2hex((addr >> 8) & 0xff) + num2hex(addr & 0xff);
var addrHex = (addr & 0xffff).toString(16);
return "0".repeat(4 - addrHex.length) + addrHex;
}

function num2hex(nr) {
var str = "0123456789abcdef";
var hi = ((nr & 0xf0) >> 4);
var lo = (nr & 15);
return str.substring(hi, hi + 1) + str.substring(lo, lo + 1);
var nrHex = (nr & 0xff).toString(16);
return ((nrHex.length == 2) ? "" : "0") + nrHex;
}

// message() - Prints text in the message window
Expand Down