mras0 / sasm Goto Github PK
View Code? Open in Web Editor NEWSelf-hosting Real Mode x86 Assembler
License: MIT License
Self-hosting Real Mode x86 Assembler
License: MIT License
A lot of my existing nasm code is using hex numbers in the format with the trailing 'h' (e.g. "0100h" instead of "0x100").
I don't know if this project is actively maintained, but it would be nice to have support for that alternate number format. I don't want to go through the whole forking process to be able to submit a pull request, but I did put together this little mod to add that in which seems to work fine as a potential starting place (I only bothered with SASM.COM, I'm sure doing this in the C version is fairly trivial):
diff --git a/sasm.asm b/sasm.asm
index 1e57006..9766700 100644
--- a/sasm.asm
+++ b/sasm.asm
@@ -833,11 +833,32 @@ Expect:
; Get number from Token to AX
GetTokenNumber:
+ xor dl, dl ; assume no "h" suffix
cmp word [UToken], '0X'
je .Hex
- ; Decimal number
+
+ ; check if it has h suffix though (e.g. "0100h")
xor ax, ax
mov bx, UToken
+
+ mov al, [TokenLen] ; read length of token
+ add bx, ax ; move past end of token
+ dec bx ; back to point at last char
+ mov al, [bx] ; fetch last char of token
+
+ cmp al, 'H' ; has "h" suffix?
+ jne .decimal ; if not, treat as decimal
+
+ ; hex number with 'h' suffix
+ inc dl ; don't skip 2 chars for "0x" below
+ mov cl, [TokenLen] ; decrement len to process
+ dec cl ; take off the 'h'
+ jmp short .Hex2
+
+.decimal:
+ ; Decimal number
+ mov bx, UToken
+ xor al, al
xor ch, ch
.Dec:
mov cl, [bx]
@@ -858,11 +879,17 @@ GetTokenNumber:
.Hex:
mov cl, [TokenLen]
sub cl, 2
+.Hex2:
cmp cl, 4
ja .Error
- xor ax, ax
+
mov bx, UToken
+ test dl, dl
+ jnz .noskip0x
add bx, 2
+.noskip0x:
+
+ xor ax, ax
.HexCvt:
shl ax, 1
shl ax, 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.